admin.min.js 505 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055
  1. var Grav;
  2. /******/ (() => { // webpackBootstrap
  3. /******/ var __webpack_modules__ = ({
  4. /***/ 40535:
  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__(73609);
  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.esm.js + 1 modules
  591. var simplebar_esm = __webpack_require__(56884);
  592. // EXTERNAL MODULE: ./node_modules/toastr/toastr.js
  593. var toastr = __webpack_require__(8901);
  594. var toastr_default = /*#__PURE__*/__webpack_require__.n(toastr);
  595. ;// CONCATENATED MODULE: ./app/utils/toastr.js
  596. (toastr_default()).options.positionClass = 'toast-top-right';
  597. (toastr_default()).options.preventDuplicates = true;
  598. /* harmony default export */ const utils_toastr = ((toastr_default()));
  599. ;// CONCATENATED MODULE: ./app/utils/offline.js
  600. var offlineElement = external_jQuery_default()('#offline-status');
  601. external_jQuery_default()(window).on('offline', function () {
  602. offlineElement.slideDown();
  603. });
  604. external_jQuery_default()(window).on('online', function () {
  605. offlineElement.slideUp();
  606. });
  607. external_jQuery_default()(document).ready(function () {
  608. if (!offline) {
  609. offlineElement.slideDown();
  610. }
  611. }); // assume online if can't check
  612. /* harmony default export */ const offline = (typeof __webpack_require__.g.navigator.onLine !== 'undefined' ? __webpack_require__.g.navigator.onLine : true);
  613. ;// CONCATENATED MODULE: external "GravAdmin"
  614. const external_GravAdmin_namespaceObject = GravAdmin;
  615. // EXTERNAL MODULE: ./node_modules/mout/string/trim.js
  616. var trim = __webpack_require__(78579);
  617. var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
  618. ;// CONCATENATED MODULE: ./app/utils/response.js
  619. var UNLOADING = false;
  620. var error = function error(response) {
  621. var error = new Error(response.statusText || response || '');
  622. error.response = response;
  623. return error;
  624. };
  625. function parseStatus(response) {
  626. return response;
  627. /* Whoops can handle JSON responses so we don't need this for now.
  628. if (response.status >= 200 && response.status < 300) {
  629. return response;
  630. } else {
  631. throw error(response);
  632. }
  633. */
  634. }
  635. function parseJSON(response) {
  636. return response.text().then(function (text) {
  637. var parsed = text;
  638. try {
  639. parsed = JSON.parse(text);
  640. } catch (error) {
  641. var content = document.createElement('div');
  642. content.innerHTML = text;
  643. var the_error = new Error();
  644. the_error.stack = trim_default()(content.innerText);
  645. throw the_error;
  646. }
  647. return parsed;
  648. });
  649. }
  650. function userFeedback(response) {
  651. if (UNLOADING) {
  652. return true;
  653. }
  654. var status = response.status || (response.error ? 'error' : '');
  655. var message = response.message || (response.error ? response.error.message : null);
  656. var settings = response.toastr || null;
  657. var backup;
  658. switch (status) {
  659. case 'unauthenticated':
  660. document.location.href = external_GravAdmin_namespaceObject.config.base_url_relative;
  661. throw error('Logged out');
  662. case 'unauthorized':
  663. status = 'error';
  664. message = message || 'Unauthorized.';
  665. break;
  666. case 'error':
  667. status = 'error';
  668. message = message || 'Unknown error.';
  669. break;
  670. case 'success':
  671. status = 'success';
  672. message = message || '';
  673. break;
  674. default:
  675. status = 'error';
  676. message = message || 'Invalid AJAX response.';
  677. break;
  678. }
  679. if (settings) {
  680. backup = Object.assign({}, utils_toastr.options);
  681. Object.keys(settings).forEach(function (key) {
  682. utils_toastr.options[key] = settings[key];
  683. });
  684. }
  685. if (message && (offline || !offline && status !== 'error')) {
  686. utils_toastr[status === 'success' ? 'success' : 'error'](message);
  687. }
  688. if (settings) {
  689. utils_toastr.options = backup;
  690. }
  691. return response;
  692. }
  693. function userFeedbackError(error) {
  694. if (UNLOADING) {
  695. return true;
  696. }
  697. var stack = error.stack ? "<pre><code>".concat(error.stack, "</code></pre>") : '';
  698. utils_toastr.error("Fetch Failed: <br /> ".concat(error.message, " ").concat(stack));
  699. console.error("".concat(error.message, " at ").concat(error.stack));
  700. }
  701. external_jQuery_default()(__webpack_require__.g).on('beforeunload._ajax', function () {
  702. UNLOADING = true;
  703. });
  704. // EXTERNAL MODULE: ./node_modules/events/events.js
  705. var events = __webpack_require__(17187);
  706. var events_default = /*#__PURE__*/__webpack_require__.n(events);
  707. ;// CONCATENATED MODULE: ./app/utils/gpm.js
  708. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  709. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  710. 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); } }
  711. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  712. 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  713. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  714. 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); }; }
  715. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  716. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  717. 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; } }
  718. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  719. var GPM = /*#__PURE__*/function (_EventEmitter) {
  720. _inherits(GPM, _EventEmitter);
  721. var _super = _createSuper(GPM);
  722. function GPM() {
  723. var _this;
  724. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'getUpdates';
  725. _classCallCheck(this, GPM);
  726. _this = _super.call(this);
  727. _this.payload = {};
  728. _this.raw = {};
  729. _this.action = action;
  730. return _this;
  731. }
  732. _createClass(GPM, [{
  733. key: "setPayload",
  734. value: function setPayload() {
  735. var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  736. this.payload = payload;
  737. this.emit('payload', payload);
  738. return this;
  739. }
  740. }, {
  741. key: "setAction",
  742. value: function setAction() {
  743. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'getUpdates';
  744. this.action = action;
  745. this.emit('action', action);
  746. return this;
  747. }
  748. }, {
  749. key: "fetch",
  750. value: function (_fetch) {
  751. function fetch() {
  752. return _fetch.apply(this, arguments);
  753. }
  754. fetch.toString = function () {
  755. return _fetch.toString();
  756. };
  757. return fetch;
  758. }(function () {
  759. var _this2 = this;
  760. var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
  761. return true;
  762. };
  763. var flush = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  764. var data = new FormData();
  765. data.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
  766. if (flush) {
  767. data.append('flush', true);
  768. }
  769. this.emit('fetching', this);
  770. fetch("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/update.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getUpdates"), {
  771. credentials: 'same-origin',
  772. method: 'post',
  773. body: data
  774. }).then(function (response) {
  775. _this2.raw = response;
  776. return response;
  777. }).then(parseStatus).then(parseJSON).then(function (response) {
  778. return _this2.response(response);
  779. }).then(function (response) {
  780. return callback(response, _this2.raw);
  781. }).then(function (response) {
  782. return _this2.emit('fetched', _this2.payload, _this2.raw, _this2);
  783. })["catch"](userFeedbackError);
  784. })
  785. }, {
  786. key: "response",
  787. value: function response(_response) {
  788. this.payload = _response;
  789. return _response;
  790. }
  791. }]);
  792. return GPM;
  793. }((events_default()));
  794. var Instance = new GPM();
  795. ;// CONCATENATED MODULE: ./app/utils/keepalive.js
  796. function keepalive_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  797. 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); } }
  798. function keepalive_createClass(Constructor, protoProps, staticProps) { if (protoProps) keepalive_defineProperties(Constructor.prototype, protoProps); if (staticProps) keepalive_defineProperties(Constructor, staticProps); return Constructor; }
  799. var MAX_SAFE_DELAY = 2147483647;
  800. var KeepAlive = /*#__PURE__*/function () {
  801. function KeepAlive() {
  802. keepalive_classCallCheck(this, KeepAlive);
  803. this.active = false;
  804. }
  805. keepalive_createClass(KeepAlive, [{
  806. key: "start",
  807. value: function start() {
  808. var _this = this;
  809. var timeout = external_GravAdmin_namespaceObject.config.admin_timeout / 1.5 * 1000;
  810. this.timer = setInterval(function () {
  811. return _this.fetch();
  812. }, Math.min(timeout, MAX_SAFE_DELAY));
  813. this.active = true;
  814. }
  815. }, {
  816. key: "stop",
  817. value: function stop() {
  818. clearInterval(this.timer);
  819. this.active = false;
  820. }
  821. }, {
  822. key: "fetch",
  823. value: function (_fetch) {
  824. function fetch() {
  825. return _fetch.apply(this, arguments);
  826. }
  827. fetch.toString = function () {
  828. return _fetch.toString();
  829. };
  830. return fetch;
  831. }(function () {
  832. var data = new FormData();
  833. data.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
  834. fetch("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "keepAlive"), {
  835. credentials: 'same-origin',
  836. method: 'post',
  837. body: data
  838. })["catch"](userFeedbackError);
  839. })
  840. }]);
  841. return KeepAlive;
  842. }();
  843. /* harmony default export */ const keepalive = (new KeepAlive());
  844. // EXTERNAL MODULE: ./node_modules/mout/array/unique.js
  845. var unique = __webpack_require__(79863);
  846. var unique_default = /*#__PURE__*/__webpack_require__.n(unique);
  847. ;// CONCATENATED MODULE: ./app/utils/request.js
  848. var raw;
  849. var request = function request(url) {
  850. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  851. var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
  852. return true;
  853. };
  854. if (typeof options === 'function') {
  855. callback = options;
  856. options = {};
  857. }
  858. if (options.method && options.method === 'post') {
  859. var data = new FormData();
  860. options.body = Object.assign({
  861. 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce
  862. }, options.body || {});
  863. Object.keys(options.body).map(function (key) {
  864. return data.append(key, options.body[key]);
  865. });
  866. options.body = data;
  867. }
  868. options = Object.assign({
  869. credentials: 'same-origin',
  870. headers: {
  871. 'Accept': 'application/json'
  872. }
  873. }, options);
  874. return fetch(url, options).then(function (response) {
  875. raw = response;
  876. return response;
  877. }).then(parseStatus).then(parseJSON).then(userFeedback).then(function (response) {
  878. return callback(response, raw);
  879. })["catch"](userFeedbackError);
  880. };
  881. /* harmony default export */ const utils_request = (request);
  882. ;// CONCATENATED MODULE: ./app/updates/notifications.js
  883. function notifications_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  884. 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); } }
  885. function notifications_createClass(Constructor, protoProps, staticProps) { if (protoProps) notifications_defineProperties(Constructor.prototype, protoProps); if (staticProps) notifications_defineProperties(Constructor, staticProps); return Constructor; }
  886. var canFetchNotifications = function canFetchNotifications() {
  887. return external_GravAdmin_namespaceObject.config.notifications.enabled;
  888. };
  889. var notificationsFilters = function notificationsFilters() {
  890. return external_GravAdmin_namespaceObject.config.notifications.filters;
  891. };
  892. var Notifications = /*#__PURE__*/function () {
  893. function Notifications() {
  894. notifications_classCallCheck(this, Notifications);
  895. }
  896. notifications_createClass(Notifications, [{
  897. key: "fetch",
  898. value: // Grav.default.Notifications.fetch()
  899. function fetch() {
  900. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  901. _ref$filter = _ref.filter,
  902. filter = _ref$filter === void 0 ? notificationsFilters() : _ref$filter,
  903. _ref$refresh = _ref.refresh,
  904. refresh = _ref$refresh === void 0 ? false : _ref$refresh;
  905. if (!canFetchNotifications()) {
  906. return false;
  907. }
  908. var feed = external_jQuery_default()('#notifications');
  909. var loader = feed.find('.widget-loader');
  910. var content = feed.find('.widget-content > ul');
  911. loader.find('div').remove();
  912. loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
  913. loader.show();
  914. content.hide();
  915. var processNotifications = function processNotifications(response) {
  916. var notifications = response.notifications;
  917. external_jQuery_default()('#notifications').find('.widget-content > ul').empty();
  918. if (notifications) {
  919. Object.keys(notifications).forEach(function (location) {
  920. return Notifications.processLocation(location, notifications[location]);
  921. });
  922. }
  923. };
  924. utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getNotifications"), {
  925. method: 'post',
  926. body: {
  927. refresh: refresh,
  928. filter: filter
  929. }
  930. }, function (response) {
  931. processNotifications(response);
  932. })["catch"](function () {
  933. var widget = external_jQuery_default()('#notifications .widget-content');
  934. widget.find('.widget-loader').find('div').remove();
  935. widget.find('.widget-loader').append('<div>Failed to retrieve notifications</div>').find('.fa-spin').removeClass('fa-spin fa-refresh').addClass('fa-warning');
  936. });
  937. }
  938. }], [{
  939. key: "addShowAllInFeed",
  940. value: function addShowAllInFeed() {
  941. external_jQuery_default()('#notifications ul').append('<li class="show-all" data-notification-action="show-all-notifications">Show all</li>');
  942. }
  943. }, {
  944. key: "showNotificationInFeed",
  945. value: function showNotificationInFeed(notification) {
  946. var notifications = external_jQuery_default()('#notifications').removeClass('hidden');
  947. var loader = notifications.find('.widget-loader').hide();
  948. var content = notifications.find('.widget-content > ul').show();
  949. loader.find('div').remove();
  950. loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
  951. content.append(notification).find('li:nth-child(n+11)').addClass('hidden'); // hide all items > 10
  952. if (content.find('li.hidden').length) {
  953. Notifications.addShowAllInFeed();
  954. }
  955. }
  956. }, {
  957. key: "showNotificationInTop",
  958. value: function showNotificationInTop(notification) {
  959. var container = external_jQuery_default()('.top-notifications-container');
  960. var dummy = external_jQuery_default()('<div />').html(notification);
  961. container.removeClass('hidden').append(dummy.children());
  962. dummy.children().slideDown(150);
  963. }
  964. }, {
  965. key: "showNotificationInDashboard",
  966. value: function showNotificationInDashboard(notification) {
  967. var container = external_jQuery_default()('.dashboard-notifications-container');
  968. var dummy = external_jQuery_default()('<div />').html(notification);
  969. container.removeClass('hidden').append(dummy.children());
  970. dummy.children().slideDown(150);
  971. }
  972. }, {
  973. key: "showNotificationInPlugins",
  974. value: function showNotificationInPlugins(notification) {
  975. var container = external_jQuery_default()('.plugins-notifications-container');
  976. var dummy = external_jQuery_default()('<div />').html(notification);
  977. container.removeClass('hidden').append(dummy.children());
  978. dummy.children().slideDown(150);
  979. }
  980. }, {
  981. key: "showNotificationInThemes",
  982. value: function showNotificationInThemes(notification) {
  983. var container = external_jQuery_default()('.themes-notifications-container');
  984. var dummy = external_jQuery_default()('<div />').html(notification);
  985. container.removeClass('hidden').append(dummy.children());
  986. dummy.children().slideDown(150);
  987. }
  988. }, {
  989. key: "processLocation",
  990. value: function processLocation(location, notification) {
  991. switch (location) {
  992. case 'feed':
  993. Notifications.showNotificationInFeed(notification);
  994. break;
  995. case 'top':
  996. if (!notification.read) {
  997. Notifications.showNotificationInTop(notification);
  998. }
  999. break;
  1000. case 'dashboard':
  1001. if (!notification.read) {
  1002. Notifications.showNotificationInDashboard(notification);
  1003. }
  1004. break;
  1005. case 'plugins':
  1006. if (!notification.read) {
  1007. Notifications.showNotificationInPlugins(notification);
  1008. }
  1009. break;
  1010. case 'themes':
  1011. if (!notification.read) {
  1012. Notifications.showNotificationInThemes(notification);
  1013. }
  1014. break;
  1015. }
  1016. }
  1017. }]);
  1018. return Notifications;
  1019. }();
  1020. var notifications = new Notifications();
  1021. /* harmony default export */ const updates_notifications = (notifications);
  1022. if (canFetchNotifications()) {
  1023. notifications.fetch();
  1024. /* Hide a notification and store it hidden */
  1025. // <a href="#" data-notification-action="hide-notification" data-notification-id="${notification.id}" class="close hide-notification"><i class="fa fa-close"></i></a>
  1026. external_jQuery_default()(document).on('click', '[data-notification-action="hide-notification"]', function (event) {
  1027. var notification_id = external_jQuery_default()(event.target).parents('.hide-notification').data('notification-id');
  1028. 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);
  1029. utils_request(url, {
  1030. method: 'post'
  1031. }, function () {});
  1032. external_jQuery_default()(event.target).parents('.single-notification').hide();
  1033. });
  1034. external_jQuery_default()(document).on('click', '[data-notification-action="hide-notification"]', function (event) {
  1035. var target = external_jQuery_default()(event.currentTarget);
  1036. var notification = target.parent();
  1037. notification.slideUp(function () {
  1038. return notification.remove();
  1039. });
  1040. });
  1041. external_jQuery_default()(document).on('click', '[data-notification-action="show-all-notifications"]', function (event) {
  1042. external_jQuery_default()('#notifications .show-all').hide();
  1043. external_jQuery_default()('#notifications .hidden').removeClass('hidden');
  1044. });
  1045. external_jQuery_default()(document).on('click', '[data-refresh="notifications"]', function (event) {
  1046. event.preventDefault();
  1047. notifications.fetch({
  1048. filter: ['feed'],
  1049. refresh: true
  1050. });
  1051. });
  1052. }
  1053. ;// CONCATENATED MODULE: ./app/updates/feed.js
  1054. function feed_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1055. 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); } }
  1056. function feed_createClass(Constructor, protoProps, staticProps) { if (protoProps) feed_defineProperties(Constructor.prototype, protoProps); if (staticProps) feed_defineProperties(Constructor, staticProps); return Constructor; }
  1057. var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getNewsFeed");
  1058. var Feed = /*#__PURE__*/function () {
  1059. function Feed() {
  1060. feed_classCallCheck(this, Feed);
  1061. this.data = null;
  1062. }
  1063. feed_createClass(Feed, [{
  1064. key: "fetch",
  1065. value: function fetch() {
  1066. var _this = this;
  1067. var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1068. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
  1069. utils_request(URI, {
  1070. method: 'post',
  1071. body: {
  1072. refresh: refresh
  1073. }
  1074. }, function (response) {
  1075. _this.data = response;
  1076. callback(response);
  1077. });
  1078. }
  1079. }, {
  1080. key: "refresh",
  1081. value: function refresh() {
  1082. var _refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1083. var feed = external_jQuery_default()('#news-feed .widget-content');
  1084. if (!feed.length) {
  1085. return;
  1086. }
  1087. var loader = feed.find('.widget-loader');
  1088. loader.find('div').remove();
  1089. loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
  1090. loader.show();
  1091. feed.find('> ul').hide();
  1092. if (!this.data || this.data.error || _refresh) {
  1093. this.fetch(_refresh, this.updateContent.bind(this));
  1094. } else {
  1095. this.updateContent();
  1096. }
  1097. }
  1098. }, {
  1099. key: "updateContent",
  1100. value: function updateContent() {
  1101. var feed = external_jQuery_default()('#news-feed .widget-content');
  1102. if (!feed.length) {
  1103. return;
  1104. }
  1105. var loader = feed.find('.widget-loader').hide();
  1106. var content = feed.find('> ul').empty().show();
  1107. if (this.data.error || this.data.status === 'error') {
  1108. loader.show().find('div').remove();
  1109. loader.find('.fa-refresh').removeClass('fa-refresh fa-spin').addClass('fa-warning');
  1110. loader.append("<div>".concat(this.data.error ? this.data.error.message : this.data.message || 'Unable to download news feed', "</div>"));
  1111. return;
  1112. }
  1113. if (this.data && this.data.feed_data) {
  1114. content.append(this.data.feed_data);
  1115. }
  1116. }
  1117. }]);
  1118. return Feed;
  1119. }();
  1120. var feed = new Feed();
  1121. external_jQuery_default()(document).ready(function () {
  1122. return feed.refresh();
  1123. });
  1124. external_jQuery_default()(document).on('click', '[data-refresh="feed"]', function (event) {
  1125. event.preventDefault();
  1126. feed.refresh(true);
  1127. });
  1128. /* harmony default export */ const updates_feed = (feed);
  1129. ;// CONCATENATED MODULE: ./app/updates/check.js
  1130. // Check for updates trigger
  1131. external_jQuery_default()('[data-gpm-checkupdates]').on('click', function () {
  1132. var element = external_jQuery_default()(this);
  1133. element.find('i').addClass('fa-spin');
  1134. Instance.fetch(function (response) {
  1135. element.find('i').removeClass('fa-spin');
  1136. var payload = response.payload;
  1137. if (!payload) {
  1138. return;
  1139. }
  1140. if (!payload.grav.isUpdatable && !payload.resources.total) {
  1141. utils_toastr.success(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.EVERYTHING_UP_TO_DATE);
  1142. } else {
  1143. var grav = payload.grav.isUpdatable ? 'Grav v' + payload.grav.available : '';
  1144. var resources = payload.resources.total ? payload.resources.total + ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATES_ARE_AVAILABLE : '';
  1145. if (!resources) {
  1146. grav += ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IS_AVAILABLE_FOR_UPDATE;
  1147. }
  1148. utils_toastr.info(grav + (grav && resources ? ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.AND + ' ' : '') + resources);
  1149. }
  1150. }, true);
  1151. });
  1152. ;// CONCATENATED MODULE: ./app/utils/formatbytes.js
  1153. var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
  1154. function formatBytes(bytes, decimals) {
  1155. if (bytes === 0) return '0 Byte';
  1156. var k = 1000;
  1157. var value = Math.floor(Math.log(bytes) / Math.log(k));
  1158. var decimal = decimals + 1 || 3;
  1159. return (bytes / Math.pow(k, value)).toPrecision(decimal) + ' ' + sizes[value];
  1160. }
  1161. ;// CONCATENATED MODULE: ./app/updates/update.js
  1162. // Dashboard update and Grav update
  1163. external_jQuery_default()(document).on('click.remodal', '[data-remodal-id="update-grav"] [data-remodal-action="confirm"]', function () {
  1164. var element = external_jQuery_default()('#grav-update-button');
  1165. element.html("".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATING_PLEASE_WAIT, " ").concat(formatBytes(updates_Instance.payload.grav.assets["grav-update"].size), ".."));
  1166. element.attr('disabled', 'disabled').find('> .fa').removeClass('fa-cloud-download').addClass('fa-refresh fa-spin');
  1167. utils_request(updates_Instance.updateURL, function (response) {
  1168. if (response.type === 'updategrav') {
  1169. external_jQuery_default()('[data-gpm-grav]').remove();
  1170. external_jQuery_default()('#footer .grav-version').html(response.version);
  1171. }
  1172. element.removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin').addClass('fa-cloud-download');
  1173. });
  1174. });
  1175. ;// CONCATENATED MODULE: ./app/updates/channel-switcher.js
  1176. var switcher = external_jQuery_default()('input[type="radio"][name="channel-switch"]');
  1177. if (switcher) {
  1178. switcher.on('change', function (event) {
  1179. var radio = external_jQuery_default()(event.target);
  1180. var url = "".concat(radio.parent('[data-url]').data('url'));
  1181. utils_request(url, {
  1182. method: 'post',
  1183. body: {
  1184. task: 'gpmRelease',
  1185. release: radio.val()
  1186. }
  1187. }, function (response) {
  1188. if (response.reload) {
  1189. __webpack_require__.g.location.reload();
  1190. }
  1191. });
  1192. });
  1193. }
  1194. ;// CONCATENATED MODULE: ./app/updates/index.js
  1195. function updates_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1196. 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); } }
  1197. function updates_createClass(Constructor, protoProps, staticProps) { if (protoProps) updates_defineProperties(Constructor.prototype, protoProps); if (staticProps) updates_defineProperties(Constructor, staticProps); return Constructor; }
  1198. var Updates = /*#__PURE__*/function () {
  1199. function Updates() {
  1200. var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1201. updates_classCallCheck(this, Updates);
  1202. this.setPayload(payload);
  1203. this.task = "task".concat(external_GravAdmin_namespaceObject.config.param_sep);
  1204. this.updateURL = '';
  1205. }
  1206. updates_createClass(Updates, [{
  1207. key: "setPayload",
  1208. value: function setPayload() {
  1209. var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1210. this.payload = payload;
  1211. return this;
  1212. }
  1213. }, {
  1214. key: "fetch",
  1215. value: function fetch() {
  1216. var _this = this;
  1217. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1218. Instance.fetch(function (response) {
  1219. return _this.setPayload(response);
  1220. }, force);
  1221. return this;
  1222. }
  1223. }, {
  1224. key: "maintenance",
  1225. value: function maintenance() {
  1226. var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'hide';
  1227. var element = external_jQuery_default()('#updates [data-update-packages]');
  1228. element[mode === 'show' ? 'fadeIn' : 'fadeOut']();
  1229. if (mode === 'hide') {
  1230. external_jQuery_default()('.badges.with-updates').removeClass('with-updates').find('.badge.updates').remove();
  1231. }
  1232. return this;
  1233. }
  1234. }, {
  1235. key: "grav",
  1236. value: function grav() {
  1237. var payload = this.payload.grav;
  1238. if (payload && payload.isUpdatable) {
  1239. var task = this.task;
  1240. var bar = '';
  1241. if (!payload.isSymlink) {
  1242. 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);
  1243. 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>");
  1244. } else {
  1245. 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>");
  1246. }
  1247. 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 ");
  1248. var element = external_jQuery_default()('[data-gpm-grav]').removeClass('hidden');
  1249. if (element.is(':empty')) {
  1250. element.hide();
  1251. }
  1252. element.addClass('grav').html("".concat(bar)).slideDown(150, function () {
  1253. var c = 5;
  1254. var x = setInterval(function () {
  1255. c -= 1;
  1256. element.find('.pointer-events-none .cnt-down').text('(' + c + 's)');
  1257. }, 1000);
  1258. setTimeout(function () {
  1259. clearInterval(x);
  1260. element.find('.pointer-events-none .cnt-down').remove();
  1261. element.find('.pointer-events-none').removeClass('pointer-events-none');
  1262. }, 5000);
  1263. }).parent('#messages').addClass('default-box-shadow');
  1264. }
  1265. return this;
  1266. }
  1267. }, {
  1268. key: "resources",
  1269. value: function resources() {
  1270. if (!this.payload || !this.payload.resources || !this.payload.resources.total) {
  1271. return this.maintenance('hide');
  1272. }
  1273. var is_current_package_latest = true;
  1274. var map = ['plugins', 'themes'];
  1275. var singles = ['plugin', 'theme'];
  1276. var _this$payload$resourc = this.payload.resources,
  1277. plugins = _this$payload$resourc.plugins,
  1278. themes = _this$payload$resourc.themes;
  1279. if (!this.payload.resources.total) {
  1280. return this;
  1281. }
  1282. [plugins, themes].forEach(function (resources, index) {
  1283. if (!resources || Array.isArray(resources)) {
  1284. return;
  1285. }
  1286. var length = Object.keys(resources).length;
  1287. var type = map[index]; // sidebar
  1288. external_jQuery_default()("#admin-menu a[href$=\"/".concat(map[index], "\"]")).find('.badges').addClass('with-updates').find('.badge.updates').text(length);
  1289. var type_translation = ''; // update all
  1290. if (type === 'plugins') {
  1291. type_translation = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PLUGINS;
  1292. } else {
  1293. type_translation = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.THEMES;
  1294. }
  1295. var updateAll = external_jQuery_default()(".grav-update.".concat(type));
  1296. 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 "));
  1297. var existing_slugs = external_jQuery_default()('[data-update-packages]').attr('data-packages-slugs') || '';
  1298. if (existing_slugs) {
  1299. existing_slugs = existing_slugs.split(',');
  1300. } else {
  1301. existing_slugs = [];
  1302. }
  1303. var slugs = unique_default()(existing_slugs.concat(Object.keys(resources))).join();
  1304. external_jQuery_default()('[data-update-packages]').attr('data-packages-slugs', "".concat(slugs));
  1305. Object.keys(resources).forEach(function (item) {
  1306. // listing page
  1307. var container = external_jQuery_default()("[data-gpm-".concat(singles[index], "=\"").concat(item, "\"]"));
  1308. var element = container.find('.gpm-name');
  1309. var url = element.find('a');
  1310. var content_wrapper = container.parents('.content-wrapper');
  1311. if (type === 'plugins' && !element.find('.badge.update').length) {
  1312. 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>"));
  1313. content_wrapper.addClass('has-updates');
  1314. } else if (type === 'themes') {
  1315. element.append("<div class=\"gpm-ribbon\"><a href=\"".concat(url.attr('href'), "\">").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE.toUpperCase(), "</a></div>"));
  1316. content_wrapper.addClass('has-updates');
  1317. } // details page
  1318. if (container.length) {
  1319. var details = external_jQuery_default()(".grav-update.".concat(singles[index]));
  1320. if (details.length) {
  1321. var releaseType = resources[item].type === 'testing' ? '<span class="gpm-testing">test release</span>' : '';
  1322. 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');
  1323. is_current_package_latest = false;
  1324. }
  1325. }
  1326. });
  1327. external_jQuery_default()('[data-update-packages]').removeClass('hidden');
  1328. });
  1329. external_jQuery_default()('.content-wrapper').addClass('updates-checked');
  1330. if (!is_current_package_latest) {
  1331. external_jQuery_default()('.warning-reinstall-not-latest-release').removeClass('hidden');
  1332. }
  1333. }
  1334. }]);
  1335. return Updates;
  1336. }();
  1337. var updates_Instance = new Updates();
  1338. // automatically refresh UI for updates (graph, sidebar, plugin/themes pages) after every fetch
  1339. Instance.on('fetched', function (response, raw) {
  1340. updates_Instance.setPayload(response.payload || {});
  1341. updates_Instance.grav().resources();
  1342. });
  1343. if (external_GravAdmin_namespaceObject.config.enable_auto_updates_check === '1') {
  1344. Instance.fetch();
  1345. }
  1346. // EXTERNAL MODULE: ./node_modules/chartist/dist/chartist.js
  1347. var chartist = __webpack_require__(69259);
  1348. var chartist_default = /*#__PURE__*/__webpack_require__.n(chartist);
  1349. ;// CONCATENATED MODULE: ./app/dashboard/chart.js
  1350. function chart_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { chart_typeof = function _typeof(obj) { return typeof obj; }; } else { chart_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return chart_typeof(obj); }
  1351. function _get(target, property, receiver) { 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(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  1352. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = chart_getPrototypeOf(object); if (object === null) break; } return object; }
  1353. 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 } }); if (superClass) chart_setPrototypeOf(subClass, superClass); }
  1354. function chart_setPrototypeOf(o, p) { chart_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return chart_setPrototypeOf(o, p); }
  1355. 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); }; }
  1356. function chart_possibleConstructorReturn(self, call) { if (call && (chart_typeof(call) === "object" || typeof call === "function")) { return call; } return chart_assertThisInitialized(self); }
  1357. function chart_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  1358. 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; } }
  1359. function chart_getPrototypeOf(o) { chart_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return chart_getPrototypeOf(o); }
  1360. function chart_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1361. 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); } }
  1362. function chart_createClass(Constructor, protoProps, staticProps) { if (protoProps) chart_defineProperties(Constructor.prototype, protoProps); if (staticProps) chart_defineProperties(Constructor, staticProps); return Constructor; }
  1363. // let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  1364. var defaults = {
  1365. data: {
  1366. series: [100, 0]
  1367. },
  1368. options: {
  1369. Pie: {
  1370. donut: true,
  1371. donutWidth: 10,
  1372. startAngle: 0,
  1373. total: 100,
  1374. showLabel: false,
  1375. height: 150,
  1376. // chartPadding: !isFirefox ? 10 : 25 // workaround for older versions of firefox
  1377. chartPadding: 5
  1378. },
  1379. Bar: {
  1380. height: 164,
  1381. chartPadding: 20,
  1382. // workaround for older versions of firefox
  1383. axisX: {
  1384. showGrid: false,
  1385. labelOffset: {
  1386. x: 0,
  1387. y: 0
  1388. }
  1389. },
  1390. axisY: {
  1391. offset: 15,
  1392. showLabel: true,
  1393. showGrid: true,
  1394. labelOffset: {
  1395. x: 5,
  1396. y: 5
  1397. },
  1398. scaleMinSpace: 25
  1399. }
  1400. }
  1401. }
  1402. };
  1403. var Chart = /*#__PURE__*/function () {
  1404. function Chart(element) {
  1405. var _this = this;
  1406. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1407. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1408. chart_classCallCheck(this, Chart);
  1409. this.element = external_jQuery_default()(element) || [];
  1410. if (!this.element[0]) {
  1411. return;
  1412. }
  1413. var type = (this.element.data('chart-type') || 'pie').toLowerCase();
  1414. this.type = type.charAt(0).toUpperCase() + type.substr(1).toLowerCase();
  1415. options = Object.assign({}, defaults.options[this.type], options);
  1416. data = Object.assign({}, defaults.data, data);
  1417. Object.assign(this, {
  1418. options: options,
  1419. data: data
  1420. });
  1421. this.chart = (chartist_default())[this.type](this.element.find('.ct-chart').empty()[0], this.data, this.options);
  1422. this.chart.on('created', function () {
  1423. _this.element.find('.hidden').removeClass('hidden'); // FIX: workaround for chartist issue not allowing HTML in labels anymore
  1424. // https://github.com/gionkunz/chartist-js/issues/937
  1425. _this.element.find('.ct-label').each(function (index, label) {
  1426. label = external_jQuery_default()(label);
  1427. var text = label.html().replace('&lt;', '<').replace('&gt;', '>');
  1428. label.html(text);
  1429. });
  1430. });
  1431. }
  1432. chart_createClass(Chart, [{
  1433. key: "updateData",
  1434. value: function updateData(data) {
  1435. Object.assign(this.data, data);
  1436. this.chart.update(this.data);
  1437. }
  1438. }]);
  1439. return Chart;
  1440. }();
  1441. ;
  1442. var UpdatesChart = /*#__PURE__*/function (_Chart) {
  1443. chart_inherits(UpdatesChart, _Chart);
  1444. var _super = chart_createSuper(UpdatesChart);
  1445. function UpdatesChart(element) {
  1446. var _this2;
  1447. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1448. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  1449. chart_classCallCheck(this, UpdatesChart);
  1450. _this2 = _super.call(this, element, options, data);
  1451. _this2.chart.on('draw', function (data) {
  1452. return _this2.draw(data);
  1453. });
  1454. Instance.on('fetched', function (response) {
  1455. if (!response.payload) {
  1456. return;
  1457. }
  1458. var payload = response.payload.grav;
  1459. var missing = (response.payload.resources.total + (payload.isUpdatable ? 1 : 0)) * 100 / (response.payload.installed + (payload.isUpdatable ? 1 : 0));
  1460. var updated = 100 - missing;
  1461. _this2.updateData({
  1462. series: [updated, missing]
  1463. });
  1464. if (response.payload.resources.total) {
  1465. updates_Instance.maintenance('show');
  1466. }
  1467. });
  1468. return _this2;
  1469. }
  1470. chart_createClass(UpdatesChart, [{
  1471. key: "draw",
  1472. value: function draw(data) {
  1473. if (data.index) {
  1474. return;
  1475. }
  1476. var notice = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN[data.value === 100 ? 'FULLY_UPDATED' : 'UPDATES_AVAILABLE'];
  1477. this.element.find('.numeric span').text("".concat(Math.round(data.value), "%"));
  1478. this.element.find('.js__updates-available-description').html(notice);
  1479. this.element.find('.hidden').removeClass('hidden');
  1480. }
  1481. }, {
  1482. key: "updateData",
  1483. value: function updateData(data) {
  1484. _get(chart_getPrototypeOf(UpdatesChart.prototype), "updateData", this).call(this, data); // missing updates
  1485. if (this.data.series[0] < 100) {
  1486. this.element.closest('#updates').find('[data-update-packages]').fadeIn();
  1487. }
  1488. }
  1489. }]);
  1490. return UpdatesChart;
  1491. }(Chart);
  1492. var charts = {};
  1493. external_jQuery_default()('[data-chart-name]').each(function () {
  1494. var element = external_jQuery_default()(this);
  1495. var name = element.data('chart-name') || '';
  1496. var options = element.data('chart-options') || {};
  1497. var data = element.data('chart-data') || {};
  1498. if (name === 'updates') {
  1499. charts[name] = new UpdatesChart(element, options, data);
  1500. } else {
  1501. charts[name] = new Chart(element, options, data);
  1502. }
  1503. });
  1504. var Instances = charts;
  1505. ;// CONCATENATED MODULE: ./app/dashboard/cache.js
  1506. function cache_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1507. 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); } }
  1508. function cache_createClass(Constructor, protoProps, staticProps) { if (protoProps) cache_defineProperties(Constructor.prototype, protoProps); if (staticProps) cache_defineProperties(Constructor, staticProps); return Constructor; }
  1509. var getUrl = function getUrl() {
  1510. var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  1511. if (type) {
  1512. type = "cleartype:".concat(type, "/");
  1513. }
  1514. 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);
  1515. };
  1516. var Cache = /*#__PURE__*/function () {
  1517. function Cache() {
  1518. var _this = this;
  1519. cache_classCallCheck(this, Cache);
  1520. this.element = external_jQuery_default()('[data-clear-cache]');
  1521. external_jQuery_default()('body').on('click', '[data-clear-cache]', function (event) {
  1522. return _this.clear(event, event.target);
  1523. });
  1524. }
  1525. cache_createClass(Cache, [{
  1526. key: "clear",
  1527. value: function clear(event, element) {
  1528. var _this2 = this;
  1529. var type = '';
  1530. if (event && event.preventDefault) {
  1531. event.preventDefault();
  1532. }
  1533. if (typeof event === 'string') {
  1534. type = event;
  1535. }
  1536. element = element ? external_jQuery_default()(element) : external_jQuery_default()("[data-clear-cache-type=\"".concat(type, "\"]"));
  1537. type = type || external_jQuery_default()(element).data('clear-cache-type') || '';
  1538. var url = element.data('clearCache') || getUrl(type);
  1539. this.disable();
  1540. utils_request(url, function () {
  1541. return _this2.enable();
  1542. });
  1543. }
  1544. }, {
  1545. key: "enable",
  1546. value: function enable() {
  1547. this.element.removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin fa-retweet').addClass('fa-retweet');
  1548. }
  1549. }, {
  1550. key: "disable",
  1551. value: function disable() {
  1552. this.element.attr('disabled', 'disabled').find('> .fa').removeClass('fa-retweet').addClass('fa-refresh fa-spin');
  1553. }
  1554. }]);
  1555. return Cache;
  1556. }();
  1557. var cache_Instance = new Cache();
  1558. ;// CONCATENATED MODULE: ./app/dashboard/backup.js
  1559. external_jQuery_default()('[data-backup][data-ajax*="backup/"]').on('click', function () {
  1560. var element = external_jQuery_default()(this);
  1561. var url = element.data('ajax');
  1562. var inDropdown = element.closest('.dropdown-menu');
  1563. (inDropdown.length ? inDropdown : element).closest('.button-group').find('> button:first').attr('disabled', 'disabled').find('> .fa').removeClass('fa-life-ring').addClass('fa-spin fa-refresh');
  1564. utils_request(url, function ()
  1565. /* response */
  1566. {
  1567. if (Instances && Instances.backups) {
  1568. Instances.backups.updateData({
  1569. series: [0, 100]
  1570. });
  1571. Instances.backups.element.find('.numeric').html("0 <em>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DAYS.toLowerCase(), "</em>"));
  1572. }
  1573. (inDropdown.length ? inDropdown : element).closest('.button-group').find('> button:first').removeAttr('disabled').find('> .fa').removeClass('fa-spin fa-refresh').addClass('fa-life-ring');
  1574. });
  1575. });
  1576. external_jQuery_default()('[data-backup][data-ajax*="backupDelete"]').on('click', function () {
  1577. var element = external_jQuery_default()(this);
  1578. var url = element.data('ajax');
  1579. var tr = element.closest('tr');
  1580. tr.addClass('deleting');
  1581. utils_request(url, function (response) {
  1582. if (response.status === 'success') {
  1583. tr.remove();
  1584. } else {
  1585. tr.removeClass('deleting');
  1586. }
  1587. });
  1588. });
  1589. ;// CONCATENATED MODULE: ./app/dashboard/index.js
  1590. /* harmony default export */ const dashboard = ({
  1591. Chart: {
  1592. Chart: Chart,
  1593. UpdatesChart: UpdatesChart,
  1594. Instances: Instances
  1595. },
  1596. Cache: cache_Instance
  1597. });
  1598. // EXTERNAL MODULE: ./node_modules/sortablejs/modular/sortable.esm.js
  1599. var sortable_esm = __webpack_require__(51474);
  1600. // EXTERNAL MODULE: ./node_modules/debounce/index.js
  1601. var debounce = __webpack_require__(20296);
  1602. var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce);
  1603. // EXTERNAL MODULE: ./app/utils/storage.js
  1604. var storage = __webpack_require__(92511);
  1605. ;// CONCATENATED MODULE: ./app/pages/tree.js
  1606. function tree_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1607. 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); } }
  1608. function tree_createClass(Constructor, protoProps, staticProps) { if (protoProps) tree_defineProperties(Constructor.prototype, protoProps); if (staticProps) tree_defineProperties(Constructor, staticProps); return Constructor; }
  1609. var sessionKey = 'grav:admin:pages';
  1610. if (!sessionStorage.getItem(sessionKey)) {
  1611. sessionStorage.setItem(sessionKey, '{}');
  1612. }
  1613. var PagesTree = /*#__PURE__*/function () {
  1614. function PagesTree(query) {
  1615. var _this = this;
  1616. var elements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
  1617. tree_classCallCheck(this, PagesTree);
  1618. this.query = query;
  1619. this.elements = external_jQuery_default()(elements !== undefined ? elements : this.query);
  1620. this.session = JSON.parse(sessionStorage.getItem(sessionKey) || '{}');
  1621. if (!this.elements.length) {
  1622. return;
  1623. }
  1624. this.restore();
  1625. this.elements.find('.page-icon').on('click', function (event) {
  1626. return _this.toggle(event.target);
  1627. });
  1628. this.elements.data('tree_init', 1);
  1629. external_jQuery_default()('[data-page-toggleall]').on('click', function (event) {
  1630. var element = external_jQuery_default()(event.target).closest('[data-page-toggleall]');
  1631. var action = element.data('page-toggleall');
  1632. _this[action]();
  1633. });
  1634. }
  1635. tree_createClass(PagesTree, [{
  1636. key: "reload",
  1637. value: function reload() {
  1638. var elements = external_jQuery_default()(this.query).filter(function (index, element) {
  1639. return !external_jQuery_default()(element).data('tree_init');
  1640. });
  1641. if (!elements.length) {
  1642. return;
  1643. }
  1644. this.constructor(this.query, elements);
  1645. }
  1646. }, {
  1647. key: "toggle",
  1648. value: function toggle(elements) {
  1649. var _this2 = this;
  1650. var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1651. if (typeof elements === 'string') {
  1652. elements = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")).find('[data-toggle="children"]');
  1653. }
  1654. elements = external_jQuery_default()(elements || this.elements);
  1655. elements.each(function (index, element) {
  1656. element = external_jQuery_default()(element);
  1657. var state = _this2.getState(element.closest('[data-toggle="children"]'));
  1658. _this2[state.isOpen ? 'collapse' : 'expand'](state.id, dontStore);
  1659. });
  1660. }
  1661. }, {
  1662. key: "collapse",
  1663. value: function collapse(elements) {
  1664. var _this3 = this;
  1665. var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1666. if (typeof elements === 'string') {
  1667. elements = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")).find('[data-toggle="children"]');
  1668. }
  1669. elements = external_jQuery_default()(elements || this.elements);
  1670. elements.each(function (index, element) {
  1671. element = external_jQuery_default()(element);
  1672. var state = _this3.getState(element);
  1673. if (state.isOpen) {
  1674. state.children.hide();
  1675. state.icon.removeClass('children-open').addClass('children-closed');
  1676. if (!dontStore) {
  1677. delete _this3.session[state.id];
  1678. }
  1679. }
  1680. });
  1681. if (!dontStore) {
  1682. this.save();
  1683. }
  1684. }
  1685. }, {
  1686. key: "expand",
  1687. value: function expand(elements) {
  1688. var _this4 = this;
  1689. var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1690. if (typeof elements === 'string') {
  1691. var element = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]"));
  1692. var parents = element.parents('[data-nav-id]'); // loop back through parents, we don't want to expand an hidden child
  1693. if (parents.length) {
  1694. parents = parents.find('[data-toggle="children"]:first');
  1695. parents = parents.add(element.find('[data-toggle="children"]:first'));
  1696. return this.expand(parents, dontStore);
  1697. }
  1698. elements = element.find('[data-toggle="children"]:first');
  1699. }
  1700. elements = external_jQuery_default()(elements || this.elements);
  1701. elements.each(function (index, element) {
  1702. element = external_jQuery_default()(element);
  1703. var state = _this4.getState(element);
  1704. if (!state.isOpen) {
  1705. state.children.show();
  1706. state.icon.removeClass('children-closed').addClass('children-open');
  1707. if (!dontStore) {
  1708. _this4.session[state.id] = 1;
  1709. }
  1710. }
  1711. });
  1712. if (!dontStore) {
  1713. this.save();
  1714. }
  1715. }
  1716. }, {
  1717. key: "restore",
  1718. value: function restore() {
  1719. var _this5 = this;
  1720. this.collapse(null, true);
  1721. Object.keys(this.session).forEach(function (key) {
  1722. _this5.expand(key, 'no-store');
  1723. });
  1724. }
  1725. }, {
  1726. key: "save",
  1727. value: function save() {
  1728. return sessionStorage.setItem(sessionKey, JSON.stringify(this.session));
  1729. }
  1730. }, {
  1731. key: "getState",
  1732. value: function getState(element) {
  1733. element = external_jQuery_default()(element);
  1734. return {
  1735. id: element.closest('[data-nav-id]').data('nav-id'),
  1736. children: element.closest('li.page-item').find('ul:first'),
  1737. icon: element.find('.page-icon'),
  1738. get isOpen() {
  1739. return this.icon.hasClass('children-open');
  1740. }
  1741. };
  1742. }
  1743. }]);
  1744. return PagesTree;
  1745. }();
  1746. var tree_Instance = new PagesTree('[data-toggle="children"]');
  1747. // EXTERNAL MODULE: ./node_modules/selectize/dist/js/selectize.js
  1748. var selectize = __webpack_require__(25703);
  1749. var selectize_default = /*#__PURE__*/__webpack_require__.n(selectize);
  1750. ;// CONCATENATED MODULE: ./app/utils/selectize-required-fix.js
  1751. /**
  1752. * This is a plugin to override the `.refreshValidityState` method of
  1753. * the Selectize library (https://selectize.github.io/selectize.js/).
  1754. * The library is not maintained anymore (as of 2017-09-13) and contains
  1755. * a bug which causes Microsoft Edge to not work with selectized [required]
  1756. * form fields. This plugin should be removed if
  1757. * https://github.com/selectize/selectize.js/pull/1320 is ever merged
  1758. * and a new version of Selectize gets released.
  1759. */
  1760. selectize_default().define('required-fix', function (options) {
  1761. var _this = this;
  1762. this.refreshValidityState = function () {
  1763. if (!_this.isRequired) return false;
  1764. var invalid = !_this.items.length;
  1765. _this.isInvalid = invalid;
  1766. if (invalid) {
  1767. _this.$control_input.attr('required', '');
  1768. _this.$input.removeAttr('required');
  1769. } else {
  1770. _this.$control_input.removeAttr('required');
  1771. _this.$input.attr('required');
  1772. }
  1773. };
  1774. });
  1775. ;// CONCATENATED MODULE: ./app/pages/filter.js
  1776. function filter_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { filter_typeof = function _typeof(obj) { return typeof obj; }; } else { filter_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return filter_typeof(obj); }
  1777. function filter_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1778. 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); } }
  1779. function filter_createClass(Constructor, protoProps, staticProps) { if (protoProps) filter_defineProperties(Constructor.prototype, protoProps); if (staticProps) filter_defineProperties(Constructor, staticProps); return Constructor; }
  1780. /* @formatter:off */
  1781. /* eslint-disable */
  1782. var options = [{
  1783. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.MODULE,
  1784. key: 'Module',
  1785. cat: 'mode'
  1786. }, {
  1787. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.VISIBLE,
  1788. key: 'Visible',
  1789. cat: 'mode'
  1790. }, {
  1791. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ROUTABLE,
  1792. key: 'Routable',
  1793. cat: 'mode'
  1794. }, {
  1795. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PUBLISHED,
  1796. key: 'Published',
  1797. cat: 'mode'
  1798. }, {
  1799. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_MODULE,
  1800. key: 'NonModule',
  1801. cat: 'mode'
  1802. }, {
  1803. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_VISIBLE,
  1804. key: 'NonVisible',
  1805. cat: 'mode'
  1806. }, {
  1807. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_ROUTABLE,
  1808. key: 'NonRoutable',
  1809. cat: 'mode'
  1810. }, {
  1811. flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_PUBLISHED,
  1812. key: 'NonPublished',
  1813. cat: 'mode'
  1814. }];
  1815. /* @formatter:on */
  1816. /* eslint-enable */
  1817. var PagesFilter = /*#__PURE__*/function () {
  1818. function PagesFilter(filters, search) {
  1819. var _this = this;
  1820. filter_classCallCheck(this, PagesFilter);
  1821. this.filters = external_jQuery_default()(filters);
  1822. this.search = external_jQuery_default()(search);
  1823. this.options = options;
  1824. this.tree = tree_Instance;
  1825. var storage = JSON.parse(localStorage.getItem('grav:admin:pages:filter') || '{}');
  1826. if (!this.filters.length || !this.search.length) {
  1827. return;
  1828. }
  1829. this.labels = this.filters.data('filter-labels');
  1830. this.search.on('input', debounce_default()(function () {
  1831. return _this.filter();
  1832. }, 250));
  1833. this.filters.on('change', function () {
  1834. return _this.filter();
  1835. }); // restore state
  1836. if (storage.flags || storage.query) {
  1837. this.setValues(storage);
  1838. this.filter();
  1839. }
  1840. this._initSelectize();
  1841. }
  1842. filter_createClass(PagesFilter, [{
  1843. key: "filter",
  1844. value: function filter(value) {
  1845. var _this2 = this;
  1846. var data = {
  1847. flags: '',
  1848. query: ''
  1849. };
  1850. if (filter_typeof(value) === 'object') {
  1851. Object.assign(data, value);
  1852. }
  1853. if (typeof value === 'string') {
  1854. data.query = value;
  1855. }
  1856. if (typeof value === 'undefined') {
  1857. data.flags = this.filters.val();
  1858. data.query = this.search.val();
  1859. }
  1860. if (!Object.keys(data).filter(function (key) {
  1861. return data[key] !== '';
  1862. }).length) {
  1863. this.resetValues();
  1864. return;
  1865. }
  1866. data.flags = data.flags.replace(/(\s{1,})?,(\s{1,})?/g, ',');
  1867. this.setValues({
  1868. flags: data.flags,
  1869. query: data.query
  1870. }, 'silent');
  1871. utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/pages-filter.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "filterPages"), {
  1872. method: 'post',
  1873. body: data
  1874. }, function (response) {
  1875. _this2.refreshDOM(response);
  1876. });
  1877. }
  1878. }, {
  1879. key: "refreshDOM",
  1880. value: function refreshDOM(response) {
  1881. var _this3 = this;
  1882. var items = external_jQuery_default()('[data-nav-id]');
  1883. if (!response) {
  1884. items.removeClass('search-match').show();
  1885. this.tree.restore();
  1886. return;
  1887. }
  1888. items.removeClass('search-match').hide();
  1889. response.results.forEach(function (page) {
  1890. var match = items.filter("[data-nav-id=\"".concat(page, "\"]")).addClass('search-match').show();
  1891. match.parents('[data-nav-id]').addClass('search-match').show();
  1892. _this3.tree.expand(page, 'no-store');
  1893. });
  1894. }
  1895. }, {
  1896. key: "setValues",
  1897. value: function setValues(_ref, silent) {
  1898. var _ref$flags = _ref.flags,
  1899. flags = _ref$flags === void 0 ? '' : _ref$flags,
  1900. _ref$query = _ref.query,
  1901. query = _ref$query === void 0 ? '' : _ref$query;
  1902. var flagsArray = flags.replace(/(\s{1,})?,(\s{1,})?/g, ',').split(',');
  1903. if (this.filters.val() !== flags) {
  1904. var selectize = this.filters.data('selectize');
  1905. this.filters[selectize ? 'setValue' : 'val'](flagsArray, silent);
  1906. }
  1907. if (this.search.val() !== query) {
  1908. this.search.val(query);
  1909. }
  1910. localStorage.setItem('grav:admin:pages:filter', JSON.stringify({
  1911. flags: flags,
  1912. query: query
  1913. }));
  1914. }
  1915. }, {
  1916. key: "resetValues",
  1917. value: function resetValues() {
  1918. this.setValues('', 'silent');
  1919. this.refreshDOM();
  1920. }
  1921. }, {
  1922. key: "_initSelectize",
  1923. value: function _initSelectize() {
  1924. var _this4 = this;
  1925. var extras = {
  1926. type: this.filters.data('filter-types') || {},
  1927. access: this.filters.data('filter-access-levels') || {}
  1928. };
  1929. Object.keys(extras).forEach(function (cat) {
  1930. Object.keys(extras[cat]).forEach(function (key) {
  1931. _this4.options.push({
  1932. cat: cat,
  1933. key: key,
  1934. flag: extras[cat][key]
  1935. });
  1936. });
  1937. });
  1938. this.filters.selectize({
  1939. maxItems: null,
  1940. valueField: 'key',
  1941. labelField: 'flag',
  1942. searchField: ['flag', 'key'],
  1943. options: this.options,
  1944. optgroups: this.labels,
  1945. optgroupField: 'cat',
  1946. optgroupLabelField: 'name',
  1947. optgroupValueField: 'id',
  1948. optgroupOrder: this.labels.map(function (item) {
  1949. return item.id;
  1950. }),
  1951. plugins: ['optgroup_columns', 'required-fix']
  1952. });
  1953. }
  1954. }]);
  1955. return PagesFilter;
  1956. }();
  1957. var filter_Instance = new PagesFilter('input[name="page-filter"]', 'input[name="page-search"]');
  1958. // EXTERNAL MODULE: ./node_modules/speakingurl/index.js
  1959. var speakingurl = __webpack_require__(989);
  1960. var speakingurl_default = /*#__PURE__*/__webpack_require__.n(speakingurl);
  1961. ;// CONCATENATED MODULE: ./app/utils/jquery-utils.js
  1962. var _this = undefined;
  1963. // jQuery no parents filter
  1964. (external_jQuery_default()).expr[":"].noparents = external_jQuery_default().expr.createPseudo(function (text) {
  1965. return function (element) {
  1966. return external_jQuery_default()(element).parents(text).length < 1;
  1967. };
  1968. }); // Slugify
  1969. // CommonJS and ES6 version of https://github.com/madflow/jquery-slugify
  1970. (external_jQuery_default()).fn.slugify = function (source, options) {
  1971. return _this.each(function (element) {
  1972. var target = external_jQuery_default()(element);
  1973. var source = external_jQuery_default()(source);
  1974. target.on('keyup change', function () {
  1975. target.data('locked', target.val() !== '' && target.val() !== undefined);
  1976. });
  1977. source.on('keyup change', function () {
  1978. if (target.data('locked') === true) {
  1979. return true;
  1980. }
  1981. var isInput = target.is('input') || target.is('textarea');
  1982. target[isInput ? 'val' : 'text'](external_jQuery_default().slugify(source.val(), options));
  1983. });
  1984. });
  1985. }; // Static method.
  1986. (external_jQuery_default()).slugify = function (sourceString, options) {
  1987. options = external_jQuery_default().extend({}, (external_jQuery_default()).slugify.options, options);
  1988. options.lang = options.lang || external_jQuery_default()('html').prop('lang');
  1989. if (typeof options.preSlug === 'function') {
  1990. sourceString = options.preSlug(sourceString);
  1991. }
  1992. sourceString = options.slugFunc(sourceString, options);
  1993. if (typeof options.postSlug === 'function') {
  1994. sourceString = options.postSlug(sourceString);
  1995. }
  1996. return sourceString;
  1997. }; // Default plugin options
  1998. (external_jQuery_default()).slugify.options = {
  1999. preSlug: null,
  2000. postSlug: null,
  2001. slugFunc: function slugFunc(input, opts) {
  2002. return speakingurl_default()(input, opts);
  2003. }
  2004. };
  2005. ;// CONCATENATED MODULE: ./app/pages/page/add.js
  2006. var custom = false;
  2007. 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]"]');
  2008. 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]"]');
  2009. var getFields = function getFields(type, target) {
  2010. target = external_jQuery_default()(target);
  2011. var query = "[data-remodal-id=\"".concat(target.closest('[data-remodal-id]').data('remodal-id'), "\"]");
  2012. return {
  2013. title: type === 'title' ? external_jQuery_default()(target) : external_jQuery_default()("".concat(query, " input[name=\"data[title]\"]")),
  2014. folder: type === 'folder' ? external_jQuery_default()(target) : external_jQuery_default()("".concat(query, " input[name=\"data[folder]\"]"))
  2015. };
  2016. };
  2017. title.on('input focus blur', function (event) {
  2018. if (custom) {
  2019. return true;
  2020. }
  2021. var elements = getFields('title', event.currentTarget);
  2022. var slug = external_jQuery_default().slugify(elements.title.val(), {
  2023. custom: {
  2024. "'": '',
  2025. '‘': '',
  2026. '’': ''
  2027. }
  2028. });
  2029. elements.folder.val(slug);
  2030. });
  2031. folder.on('input', function (event) {
  2032. var elements = getFields('folder', event.currentTarget);
  2033. var input = elements.folder.get(0);
  2034. var value = elements.folder.val();
  2035. var selection = {
  2036. start: input.selectionStart,
  2037. end: input.selectionEnd
  2038. };
  2039. value = value.toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, '');
  2040. elements.folder.val(value);
  2041. custom = !!value; // restore cursor position
  2042. input.setSelectionRange(selection.start, selection.end);
  2043. });
  2044. folder.on('focus blur', function (event) {
  2045. return getFields('title', event.currentTarget).title.trigger('input');
  2046. });
  2047. external_jQuery_default()(document).on('change', '[name="data[route]"]', function (event) {
  2048. var rawroute = external_jQuery_default()(event.currentTarget).val();
  2049. var pageTemplate = external_jQuery_default()('[name="data[name]"]');
  2050. var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getChildTypes");
  2051. if (pageTemplate.length === 0) {
  2052. return;
  2053. }
  2054. utils_request(URI, {
  2055. method: 'post',
  2056. body: {
  2057. rawroute: rawroute
  2058. }
  2059. }, function (response) {
  2060. var type = response.child_type;
  2061. if (type !== '' && type !== 'default') {
  2062. pageTemplate.val(type);
  2063. pageTemplate.data('selectize').setValue(type);
  2064. }
  2065. });
  2066. });
  2067. ;// CONCATENATED MODULE: ./app/pages/page/move.js
  2068. external_jQuery_default()(document).on('click', '[data-page-move] button[name="task"][value="save"]', function (event) {
  2069. /* let route = $('form#blueprints:first select[name="data[route]"]');
  2070. let moveTo = $('[data-page-move] select').val();
  2071. if (route.length && route.val() !== moveTo) {
  2072. let selectize = route.data('selectize');
  2073. route.val(moveTo);
  2074. if (selectize) selectize.setValue(moveTo);
  2075. }*/
  2076. var modal = external_jQuery_default()(event.currentTarget).closest('[data-remodal-id]');
  2077. var parents = modal.data('parents') || {};
  2078. var finder = parents.finder;
  2079. if (!parents || !finder) {
  2080. return true;
  2081. }
  2082. var field = parents.field;
  2083. var parentLabel = parents.parentLabel;
  2084. var parentName = parents.parentName;
  2085. var selection = finder.findLastActive().item[0];
  2086. var value = selection._item[finder.config.valueKey];
  2087. var name = selection._item[finder.config.labelKey];
  2088. field.val(value);
  2089. parentLabel.text(value);
  2090. parentName.text(name);
  2091. finder.config.defaultPath = value;
  2092. external_jQuery_default()('<div />').css({
  2093. backgroundColor: 'rgba(255, 255, 255, 0.1)',
  2094. position: 'fixed',
  2095. top: 0,
  2096. left: 0,
  2097. width: '100vw',
  2098. height: '100vh',
  2099. zIndex: 15000
  2100. }).appendTo(external_jQuery_default()('body'));
  2101. });
  2102. /*
  2103. $(document).on('click', '[data-remodal-id="parents"] [data-parents-select]', (event) => {
  2104. const modal = $(event.currentTarget).closest('[data-remodal-id]');
  2105. const parents = modal.data('parents');
  2106. const finder = parents.finder;
  2107. const field = parents.field;
  2108. const parentLabel = parents.parentLabel;
  2109. const parentName = parents.parentName;
  2110. const selection = finder.findLastActive().item[0];
  2111. const value = selection._item[finder.config.valueKey];
  2112. const name = selection._item[finder.config.labelKey];
  2113. field.val(value);
  2114. parentLabel.text(value);
  2115. parentName.text(name);
  2116. finder.config.defaultPath = value;
  2117. const remodal = $.remodal.lookup[$(`[data-remodal-id="${modal.data('remodalId')}"]`).data('remodal')];
  2118. remodal.close();
  2119. });
  2120. */
  2121. ;// CONCATENATED MODULE: ./app/pages/page/delete.js
  2122. external_jQuery_default()(document).on('click', '[data-remodal-target="delete"]', function () {
  2123. var confirm = external_jQuery_default()('[data-remodal-id="delete"] [data-delete-action]');
  2124. var link = external_jQuery_default()(this).data('delete-url');
  2125. confirm.data('delete-action', link);
  2126. });
  2127. external_jQuery_default()(document).on('click', '[data-delete-action]', function () {
  2128. var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id="delete"]').data('remodal')];
  2129. __webpack_require__.g.location.href = external_jQuery_default()(this).data('delete-action');
  2130. remodal.close();
  2131. });
  2132. ;// CONCATENATED MODULE: ./app/pages/page/unset.js
  2133. external_jQuery_default()(document).on('click', '.dz-unset', function () {
  2134. var file_upload = external_jQuery_default()(this).closest('.files-upload');
  2135. external_jQuery_default()(this).closest('.dz-image-preview').remove();
  2136. var unset_image = external_jQuery_default()(this).closest('.dz-image-preview').find('[data-dz-name]').text().trim();
  2137. var images = JSON.parse(file_upload.find('input[data-grav-field="hidden"]').val()) || {};
  2138. var image_array = {};
  2139. external_jQuery_default().each(images, function (ind, obj) {
  2140. if (!ind.endsWith(unset_image)) {
  2141. image_array[ind] = obj;
  2142. }
  2143. });
  2144. file_upload.find('input[data-grav-field="hidden"]').val(JSON.stringify(image_array));
  2145. });
  2146. ;// CONCATENATED MODULE: ./app/pages/page/disable-buttons.js
  2147. external_jQuery_default()('.disable-after-click').on('click', function () {
  2148. external_jQuery_default()(this).addClass('pointer-events-disabled');
  2149. });
  2150. // EXTERNAL MODULE: ./node_modules/dropzone/dist/dropzone.js
  2151. var dist_dropzone = __webpack_require__(32025);
  2152. var dropzone_default = /*#__PURE__*/__webpack_require__.n(dist_dropzone);
  2153. ;// CONCATENATED MODULE: ./app/forms/fields/files.js
  2154. function files_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2155. function files_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); } }
  2156. function files_createClass(Constructor, protoProps, staticProps) { if (protoProps) files_defineProperties(Constructor.prototype, protoProps); if (staticProps) files_defineProperties(Constructor, staticProps); return Constructor; }
  2157. // import EXIF from 'exif-js';
  2158. // translations
  2159. var Dictionary = {
  2160. dictCancelUpload: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_CANCEL_UPLOAD,
  2161. dictCancelUploadConfirmation: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_CANCEL_UPLOAD_CONFIRMATION,
  2162. dictDefaultMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_DEFAULT_MESSAGE,
  2163. dictFallbackMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FALLBACK_MESSAGE,
  2164. dictFallbackText: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FALLBACK_TEXT,
  2165. dictFileTooBig: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FILE_TOO_BIG,
  2166. dictInvalidFileType: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_INVALID_FILE_TYPE,
  2167. dictMaxFilesExceeded: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_MAX_FILES_EXCEEDED,
  2168. dictRemoveFile: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_REMOVE_FILE,
  2169. dictResponseError: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_RESPONSE_ERROR
  2170. };
  2171. (dropzone_default()).autoDiscover = false;
  2172. (dropzone_default()).options.gravPageDropzone = {};
  2173. (dropzone_default()).confirm = function (question, accepted, rejected) {
  2174. var doc = external_jQuery_default()(document);
  2175. var modalSelector = '[data-remodal-id="delete-media"]';
  2176. var removeEvents = function removeEvents() {
  2177. doc.off('confirmation', modalSelector, accept);
  2178. doc.off('cancellation', modalSelector, reject);
  2179. external_jQuery_default()(modalSelector).find('.remodal-confirm').removeClass('pointer-events-disabled');
  2180. };
  2181. var accept = function accept() {
  2182. accepted && accepted();
  2183. removeEvents();
  2184. };
  2185. var reject = function reject() {
  2186. rejected && rejected();
  2187. removeEvents();
  2188. };
  2189. (external_jQuery_default()).remodal.lookup[external_jQuery_default()(modalSelector).data('remodal')].open();
  2190. doc.on('confirmation', modalSelector, accept);
  2191. doc.on('cancellation', modalSelector, reject);
  2192. };
  2193. var DropzoneMediaConfig = {
  2194. timeout: 0,
  2195. thumbnailWidth: 200,
  2196. thumbnailHeight: 150,
  2197. addRemoveLinks: false,
  2198. dictDefaultMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROP_FILES_HERE_TO_UPLOAD.replace(/&lt;/g, '<').replace(/&gt;/g, '>'),
  2199. dictRemoveFileConfirmation: '[placeholder]',
  2200. 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()
  2201. }; // global.EXIF = EXIF;
  2202. var ACCEPT_FUNC = function ACCEPT_FUNC(file, done, settings) {
  2203. var resolution = settings.resolution;
  2204. if (!resolution) return done();
  2205. var reader = new FileReader();
  2206. var error = '';
  2207. var hasMin = resolution.min && (resolution.min.width || resolution.min.height);
  2208. var hasMax = resolution.max && (resolution.max.width || resolution.max.height);
  2209. if (hasMin || !(settings.resizeWidth || settings.resizeHeight) && hasMax) {
  2210. reader.onload = function (event) {
  2211. var image = new Image();
  2212. image.src = event.target.result;
  2213. image.onerror = function () {
  2214. done(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_UPLOAD);
  2215. };
  2216. image.onload = function () {
  2217. var _this = this;
  2218. if (resolution.min) {
  2219. Object.keys(resolution.min).forEach(function (attr) {
  2220. if (resolution.min[attr] && _this[attr] < resolution.min[attr]) {
  2221. error += external_GravAdmin_namespaceObject.translations.PLUGIN_FORM.RESOLUTION_MIN.replace(/{{attr}}/g, attr).replace(/{{min}}/g, resolution.min[attr]);
  2222. }
  2223. });
  2224. }
  2225. if (!(settings.resizeWidth || settings.resizeHeight)) {
  2226. if (resolution.max) {
  2227. Object.keys(resolution.max).forEach(function (attr) {
  2228. if (resolution.max[attr] && _this[attr] > resolution.max[attr]) {
  2229. error += external_GravAdmin_namespaceObject.translations.PLUGIN_FORM.RESOLUTION_MAX.replace(/{{attr}}/g, attr).replace(/{{max}}/g, resolution.max[attr]);
  2230. }
  2231. });
  2232. }
  2233. }
  2234. URL.revokeObjectURL(image.src); // release memory
  2235. return error ? done(error) : done();
  2236. };
  2237. };
  2238. reader.readAsDataURL(file);
  2239. } else {
  2240. return error ? done(error) : done();
  2241. }
  2242. };
  2243. var FilesField = /*#__PURE__*/function () {
  2244. function FilesField() {
  2245. var _this2 = this;
  2246. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  2247. _ref$container = _ref.container,
  2248. container = _ref$container === void 0 ? '.dropzone.files-upload' : _ref$container,
  2249. _ref$options = _ref.options,
  2250. options = _ref$options === void 0 ? {} : _ref$options;
  2251. files_classCallCheck(this, FilesField);
  2252. this.container = external_jQuery_default()(container);
  2253. if (!this.container.length) {
  2254. return;
  2255. }
  2256. this.urls = {};
  2257. this.customPost = this.container.data('filePostAdd') || {};
  2258. this.options = Object.assign({}, Dictionary, DropzoneMediaConfig, {
  2259. klass: this,
  2260. url: this.container.data('file-url-add') || external_GravAdmin_namespaceObject.config.current_url,
  2261. acceptedFiles: this.container.data('media-types'),
  2262. init: this.initDropzone
  2263. }, this.container.data('dropzone-options'), options);
  2264. this.options = Object.assign({}, this.options, {
  2265. accept: function accept(file, done) {
  2266. ACCEPT_FUNC(file, done, this.options);
  2267. }
  2268. });
  2269. this.dropzone = new (dropzone_default())(container, this.options);
  2270. this.dropzone.on('complete', this.onDropzoneComplete.bind(this));
  2271. this.dropzone.on('success', this.onDropzoneSuccess.bind(this));
  2272. this.dropzone.on('removedfile', this.onDropzoneRemovedFile.bind(this));
  2273. this.dropzone.on('sending', this.onDropzoneSending.bind(this));
  2274. this.dropzone.on('error', this.onDropzoneError.bind(this));
  2275. this.container.on('mouseenter', '[data-dz-view]', function (e) {
  2276. var value = JSON.parse(_this2.container.find('[name][type="hidden"]').val() || '{}');
  2277. var target = external_jQuery_default()(e.currentTarget);
  2278. var file = target.parent('.dz-preview').find('.dz-filename');
  2279. var filename = encodeURI(file.text());
  2280. var URL = Object.keys(value).filter(function (key) {
  2281. return value[key].name === filename;
  2282. }).shift();
  2283. target.attr('href', "".concat(external_GravAdmin_namespaceObject.config.base_url_simple, "/").concat(URL));
  2284. });
  2285. }
  2286. files_createClass(FilesField, [{
  2287. key: "initDropzone",
  2288. value: function initDropzone() {
  2289. var _this3 = this;
  2290. var files = this.options.klass.container.find('[data-file]');
  2291. var dropzone = this;
  2292. if (!files.length) {
  2293. return;
  2294. }
  2295. files.each(function (index, file) {
  2296. file = external_jQuery_default()(file);
  2297. var data = file.data('file');
  2298. var mock = {
  2299. name: data.name,
  2300. size: data.size,
  2301. type: data.type,
  2302. status: (dropzone_default()).ADDED,
  2303. accepted: true,
  2304. url: _this3.options.url,
  2305. removeUrl: data.remove
  2306. };
  2307. dropzone.files.push(mock);
  2308. dropzone.options.addedfile.call(dropzone, mock);
  2309. if (mock.type.match(/^image\//)) {
  2310. dropzone.options.thumbnail.call(dropzone, mock, data.path);
  2311. dropzone.createThumbnailFromUrl(mock, data.path);
  2312. }
  2313. file.remove();
  2314. });
  2315. }
  2316. }, {
  2317. key: "getURI",
  2318. value: function getURI() {
  2319. return this.container.data('mediaUri') || '';
  2320. }
  2321. }, {
  2322. key: "onDropzoneSending",
  2323. value: function onDropzoneSending(file, xhr, formData) {
  2324. var _this4 = this;
  2325. if (Object.keys(this.customPost).length) {
  2326. Object.keys(this.customPost).forEach(function (key) {
  2327. formData.append(key, _this4.customPost[key]);
  2328. });
  2329. } else {
  2330. formData.append('name', this.options.dotNotation);
  2331. formData.append('task', 'filesupload');
  2332. formData.append('uri', this.getURI());
  2333. }
  2334. formData.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
  2335. }
  2336. }, {
  2337. key: "onDropzoneSuccess",
  2338. value: function onDropzoneSuccess(file, response, xhr) {
  2339. response = typeof response === 'string' ? JSON.parse(response) : response;
  2340. if (this.options.reloadPage) {
  2341. __webpack_require__.g.location.reload();
  2342. } // store params for removing file from session before it gets saved
  2343. if (response.session) {
  2344. file.sessionParams = response.session;
  2345. file.removeUrl = this.options.url; // Touch field value to force a mutation detection
  2346. var input = this.container.find('[name][type="hidden"]');
  2347. var value = input.val();
  2348. input.val(value + ' ');
  2349. }
  2350. return this.handleError({
  2351. file: file,
  2352. data: response,
  2353. mode: 'removeFile',
  2354. msg: "<p>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_UPLOAD, " <strong>").concat(file.name, "</strong></p>\n <pre>").concat(response.message, "</pre>")
  2355. });
  2356. }
  2357. }, {
  2358. key: "onDropzoneComplete",
  2359. value: function onDropzoneComplete(file) {
  2360. if (!file.accepted && !file.rejected) {
  2361. var data = {
  2362. status: 'error',
  2363. message: "".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_UNSUPPORTED, ": ").concat(file.name.match(/\..+/).join(''))
  2364. };
  2365. return this.handleError({
  2366. file: file,
  2367. data: data,
  2368. mode: 'removeFile',
  2369. msg: "<p>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_ADD, " <strong>").concat(file.name, "</strong></p>\n <pre>").concat(data.message, "</pre>")
  2370. });
  2371. }
  2372. if (this.options.reloadPage) {
  2373. __webpack_require__.g.location.reload();
  2374. }
  2375. }
  2376. }, {
  2377. key: "b64_to_utf8",
  2378. value: function b64_to_utf8(str) {
  2379. str = str.replace(/\s/g, '');
  2380. return decodeURIComponent(escape(window.atob(str)));
  2381. }
  2382. }, {
  2383. key: "onDropzoneRemovedFile",
  2384. value: function onDropzoneRemovedFile(file) {
  2385. var _this5 = this;
  2386. if (!file.accepted || file.rejected) {
  2387. return;
  2388. }
  2389. var url = file.removeUrl || this.urls["delete"] || this.options.url;
  2390. var path = (url || '').match(/path:(.*)\//);
  2391. var body = {
  2392. filename: file.name,
  2393. uri: this.getURI()
  2394. };
  2395. if (file.sessionParams) {
  2396. body.task = 'filessessionremove';
  2397. body.session = file.sessionParams;
  2398. }
  2399. var customPost = this.container.data('filePostRemove') || {};
  2400. if (Object.keys(customPost).length) {
  2401. body = {};
  2402. Object.keys(customPost).forEach(function (key) {
  2403. body[key] = customPost[key];
  2404. });
  2405. }
  2406. body['filename'] = file.name;
  2407. body['admin-nonce'] = external_GravAdmin_namespaceObject.config.admin_nonce;
  2408. utils_request(url, {
  2409. method: 'post',
  2410. body: body
  2411. }, function () {
  2412. if (!path) {
  2413. return;
  2414. }
  2415. path = _this5.b64_to_utf8(path[1]);
  2416. var input = _this5.container.find('[name][type="hidden"]');
  2417. var data = JSON.parse(input.val() || '{}');
  2418. delete data[path];
  2419. input.val(JSON.stringify(data));
  2420. });
  2421. }
  2422. }, {
  2423. key: "onDropzoneError",
  2424. value: function onDropzoneError(file, response, xhr) {
  2425. var message = xhr ? response.error.message : response;
  2426. external_jQuery_default()(file.previewElement).find('[data-dz-errormessage]').html(message);
  2427. return this.handleError({
  2428. file: file,
  2429. data: {
  2430. status: 'error'
  2431. },
  2432. msg: "<pre>".concat(message, "</pre>")
  2433. });
  2434. }
  2435. }, {
  2436. key: "handleError",
  2437. value: function handleError(options) {
  2438. var file = options.file,
  2439. data = options.data,
  2440. mode = options.mode,
  2441. msg = options.msg;
  2442. if (data.status !== 'error' && data.status !== 'unauthorized') {
  2443. return;
  2444. }
  2445. switch (mode) {
  2446. case 'addBack':
  2447. if (file instanceof File) {
  2448. this.dropzone.addFile.call(this.dropzone, file);
  2449. } else {
  2450. this.dropzone.files.push(file);
  2451. this.dropzone.options.addedfile.call(this.dropzone, file);
  2452. this.dropzone.options.thumbnail.call(this.dropzone, file, file.extras.url);
  2453. }
  2454. break;
  2455. case 'removeFile':
  2456. default:
  2457. if (~this.dropzone.files.indexOf(file)) {
  2458. file.rejected = true;
  2459. this.dropzone.removeFile.call(this.dropzone, file, {
  2460. silent: true
  2461. });
  2462. }
  2463. break;
  2464. }
  2465. var modal = external_jQuery_default()('[data-remodal-id="generic"]');
  2466. modal.find('.error-content').html(msg);
  2467. (external_jQuery_default()).remodal.lookup[modal.data('remodal')].open();
  2468. }
  2469. }]);
  2470. return FilesField;
  2471. }();
  2472. function UriToMarkdown(uri) {
  2473. uri = uri.replace(/@3x|@2x|@1x/, '');
  2474. uri = uri.replace(/\(/g, '%28');
  2475. uri = uri.replace(/\)/g, '%29');
  2476. var title = uri.split('.').slice(0, -1).join('.');
  2477. 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, ")");
  2478. }
  2479. var instances = [];
  2480. var cache = external_jQuery_default()();
  2481. var onAddedNodes = function onAddedNodes(event, target
  2482. /* , record, instance */
  2483. ) {
  2484. var files = external_jQuery_default()(target).find('.dropzone.files-upload');
  2485. if (!files.length) {
  2486. return;
  2487. }
  2488. files.each(function (index, file) {
  2489. file = external_jQuery_default()(file);
  2490. if (!~cache.index(file)) {
  2491. addNode(file);
  2492. }
  2493. });
  2494. };
  2495. var addNode = function addNode(container) {
  2496. container = external_jQuery_default()(container);
  2497. var input = container.find('input[type="file"]');
  2498. var settings = container.data('grav-file-settings') || {};
  2499. if (settings.accept && ~settings.accept.indexOf('*')) {
  2500. settings.accept = [''];
  2501. }
  2502. var options = {
  2503. url: container.data('file-url-add') || (container.closest('form').attr('action') || external_GravAdmin_namespaceObject.config.current_url) + '.json',
  2504. paramName: settings.paramName || 'file',
  2505. dotNotation: settings.name || 'file',
  2506. acceptedFiles: settings.accept ? settings.accept.join(',') : input.attr('accept') || container.data('media-types'),
  2507. maxFilesize: typeof settings.filesize !== 'undefined' ? settings.filesize : 256,
  2508. maxFiles: settings.limit || null,
  2509. resizeWidth: settings.resizeWidth || null,
  2510. resizeHeight: settings.resizeHeight || null,
  2511. resizeQuality: settings.resizeQuality || null,
  2512. resolution: settings.resolution || null,
  2513. accept: function accept(file, done) {
  2514. ACCEPT_FUNC(file, done, settings);
  2515. }
  2516. };
  2517. cache = cache.add(container);
  2518. container = container[0];
  2519. instances.push(new FilesField({
  2520. container: container,
  2521. options: options
  2522. }));
  2523. };
  2524. var files_Instance = function () {
  2525. external_jQuery_default()('.dropzone.files-upload').each(function (i, container) {
  2526. return addNode(container);
  2527. });
  2528. external_jQuery_default()('body').on('mutation._grav', onAddedNodes);
  2529. return instances;
  2530. }();
  2531. ;// CONCATENATED MODULE: ./app/forms/fields/editor/buttons.js
  2532. var replacer = function replacer(_ref) {
  2533. var name = _ref.name,
  2534. replace = _ref.replace,
  2535. codemirror = _ref.codemirror,
  2536. button = _ref.button,
  2537. _ref$mode = _ref.mode,
  2538. mode = _ref$mode === void 0 ? 'replaceSelections' : _ref$mode,
  2539. runner = _ref.runner;
  2540. button.on("click.editor.".concat(name), function () {
  2541. strategies[mode]({
  2542. token: '$1',
  2543. template: replace,
  2544. codemirror: codemirror,
  2545. runner: runner
  2546. });
  2547. });
  2548. };
  2549. var strategies = {
  2550. replaceSelections: function replaceSelections(_ref2) {
  2551. var template = _ref2.template,
  2552. token = _ref2.token,
  2553. codemirror = _ref2.codemirror,
  2554. runner = _ref2.runner;
  2555. var replacements = [];
  2556. var ranges = [];
  2557. var selections = codemirror.getSelections();
  2558. var list = codemirror.listSelections();
  2559. var accumulator = {};
  2560. selections.forEach(function (selection, index) {
  2561. var markup = template.replace(token, selection);
  2562. var cursor = markup.indexOf('$cur');
  2563. var _list$index$anchor = list[index].anchor,
  2564. line = _list$index$anchor.line,
  2565. ch = _list$index$anchor.ch;
  2566. markup = markup.replace('$cur', '');
  2567. markup = runner ? runner(selection, markup, list) : markup;
  2568. replacements.push(markup);
  2569. if (!accumulator[line]) {
  2570. accumulator[line] = 0;
  2571. }
  2572. ch += accumulator[line] + (cursor === -1 ? markup.length : cursor);
  2573. var range = {
  2574. ch: ch,
  2575. line: line
  2576. };
  2577. ranges.push({
  2578. anchor: range,
  2579. head: range
  2580. });
  2581. accumulator[line] += markup.length - selection.length;
  2582. });
  2583. codemirror.replaceSelections(replacements);
  2584. codemirror.setSelections(ranges);
  2585. codemirror.focus();
  2586. },
  2587. replaceLine: function replaceLine(_ref3) {
  2588. var template = _ref3.template,
  2589. token = _ref3.token,
  2590. codemirror = _ref3.codemirror,
  2591. runner = _ref3.runner;
  2592. var list = codemirror.listSelections();
  2593. var range;
  2594. list.forEach(function (selection) {
  2595. var lines = {
  2596. min: Math.min(selection.anchor.line, selection.head.line),
  2597. max: Math.max(selection.anchor.line, selection.head.line)
  2598. };
  2599. codemirror.eachLine(lines.min, lines.max + 1, function (handler) {
  2600. var markup = template.replace(token, handler.text);
  2601. var line = codemirror.getLineNumber(handler);
  2602. markup = runner ? runner(handler, markup) : markup;
  2603. codemirror.replaceRange(markup, {
  2604. line: line,
  2605. ch: 0
  2606. }, {
  2607. line: line,
  2608. ch: markup.length
  2609. });
  2610. range = {
  2611. line: line,
  2612. ch: markup.length
  2613. };
  2614. });
  2615. });
  2616. codemirror.setSelection(range, range, 'end');
  2617. codemirror.focus();
  2618. },
  2619. replaceRange: function replaceRange() {}
  2620. };
  2621. var flipDisabled = function flipDisabled(codemirror, button, type) {
  2622. var hasHistory = codemirror.historySize()[type];
  2623. var element = button.find('a');
  2624. button[hasHistory ? 'removeClass' : 'addClass']('button-disabled');
  2625. if (!hasHistory) {
  2626. element.attr('title-disabled', element.attr('title'));
  2627. element.attr('data-hint-disabled', element.attr('data-hint'));
  2628. element.removeAttr('title').removeAttr('data-hint');
  2629. } else {
  2630. element.attr('title', element.attr('title-disabled'));
  2631. element.attr('data-hint', element.attr('data-hint-disabled'));
  2632. element.removeAttr('title-disabled').removeAttr('data-hint-disabled');
  2633. }
  2634. };
  2635. /* harmony default export */ const buttons = ({
  2636. navigation: [{
  2637. undo: {
  2638. identifier: 'undo',
  2639. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNDO,
  2640. label: '<i class="fa fa-fw fa-undo"></i>',
  2641. modes: [],
  2642. action: function action(_ref4) {
  2643. var codemirror = _ref4.codemirror,
  2644. button = _ref4.button,
  2645. textarea = _ref4.textarea;
  2646. button.addClass('button-disabled');
  2647. codemirror.on('change', function () {
  2648. return flipDisabled(codemirror, button, 'undo');
  2649. });
  2650. button.on('click.editor.undo', function () {
  2651. codemirror.undo();
  2652. });
  2653. }
  2654. }
  2655. }, {
  2656. redo: {
  2657. identifier: 'redo',
  2658. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.REDO,
  2659. label: '<i class="fa fa-fw fa-repeat"></i>',
  2660. modes: [],
  2661. action: function action(_ref5) {
  2662. var codemirror = _ref5.codemirror,
  2663. button = _ref5.button,
  2664. textarea = _ref5.textarea;
  2665. button.addClass('button-disabled');
  2666. codemirror.on('change', function () {
  2667. return flipDisabled(codemirror, button, 'redo');
  2668. });
  2669. button.on('click.editor.redo', function () {
  2670. codemirror.redo();
  2671. });
  2672. }
  2673. }
  2674. }, {
  2675. headers: {
  2676. identifier: 'headers',
  2677. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.HEADERS,
  2678. label: '<i class="fa fa-fw fa-header"></i>',
  2679. modes: ['gfm', 'markdown'],
  2680. children: [{
  2681. h1: {
  2682. identifier: 'h1',
  2683. label: '<i class="fa fa-fw fa-header"></i>1',
  2684. modes: ['gfm', 'markdown'],
  2685. action: function action(_ref6) {
  2686. var codemirror = _ref6.codemirror,
  2687. button = _ref6.button,
  2688. textarea = _ref6.textarea;
  2689. replacer({
  2690. name: 'h1',
  2691. replace: '# $1',
  2692. codemirror: codemirror,
  2693. button: button,
  2694. mode: 'replaceLine'
  2695. });
  2696. }
  2697. }
  2698. }, {
  2699. h2: {
  2700. identifier: 'h2',
  2701. label: '<i class="fa fa-fw fa-header"></i>2',
  2702. modes: ['gfm', 'markdown'],
  2703. action: function action(_ref7) {
  2704. var codemirror = _ref7.codemirror,
  2705. button = _ref7.button,
  2706. textarea = _ref7.textarea;
  2707. replacer({
  2708. name: 'h2',
  2709. replace: '## $1',
  2710. codemirror: codemirror,
  2711. button: button,
  2712. mode: 'replaceLine'
  2713. });
  2714. }
  2715. }
  2716. }, {
  2717. h3: {
  2718. identifier: 'h3',
  2719. label: '<i class="fa fa-fw fa-header"></i>3',
  2720. modes: ['gfm', 'markdown'],
  2721. action: function action(_ref8) {
  2722. var codemirror = _ref8.codemirror,
  2723. button = _ref8.button,
  2724. textarea = _ref8.textarea;
  2725. replacer({
  2726. name: 'h3',
  2727. replace: '### $1',
  2728. codemirror: codemirror,
  2729. button: button,
  2730. mode: 'replaceLine'
  2731. });
  2732. }
  2733. }
  2734. }, {
  2735. h4: {
  2736. identifier: 'h4',
  2737. label: '<i class="fa fa-fw fa-header"></i>4',
  2738. modes: ['gfm', 'markdown'],
  2739. action: function action(_ref9) {
  2740. var codemirror = _ref9.codemirror,
  2741. button = _ref9.button,
  2742. textarea = _ref9.textarea;
  2743. replacer({
  2744. name: 'h4',
  2745. replace: '#### $1',
  2746. codemirror: codemirror,
  2747. button: button,
  2748. mode: 'replaceLine'
  2749. });
  2750. }
  2751. }
  2752. }, {
  2753. h5: {
  2754. identifier: 'h5',
  2755. label: '<i class="fa fa-fw fa-header"></i>5',
  2756. modes: ['gfm', 'markdown'],
  2757. action: function action(_ref10) {
  2758. var codemirror = _ref10.codemirror,
  2759. button = _ref10.button,
  2760. textarea = _ref10.textarea;
  2761. replacer({
  2762. name: 'h5',
  2763. replace: '##### $1',
  2764. codemirror: codemirror,
  2765. button: button,
  2766. mode: 'replaceLine'
  2767. });
  2768. }
  2769. }
  2770. }, {
  2771. h6: {
  2772. identifier: 'h6',
  2773. label: '<i class="fa fa-fw fa-header"></i>6',
  2774. modes: ['gfm', 'markdown'],
  2775. action: function action(_ref11) {
  2776. var codemirror = _ref11.codemirror,
  2777. button = _ref11.button,
  2778. textarea = _ref11.textarea;
  2779. replacer({
  2780. name: 'h6',
  2781. replace: '###### $1',
  2782. codemirror: codemirror,
  2783. button: button,
  2784. mode: 'replaceLine'
  2785. });
  2786. }
  2787. }
  2788. }]
  2789. }
  2790. }, {
  2791. bold: {
  2792. identifier: 'bold',
  2793. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.BOLD,
  2794. label: '<i class="fa fa-fw fa-bold"></i>',
  2795. modes: ['gfm', 'markdown'],
  2796. shortcut: ['Ctrl-B', 'Cmd-B'],
  2797. action: function action(_ref12) {
  2798. var codemirror = _ref12.codemirror,
  2799. button = _ref12.button,
  2800. textarea = _ref12.textarea;
  2801. replacer({
  2802. name: 'bold',
  2803. replace: '**$1$cur**',
  2804. codemirror: codemirror,
  2805. button: button
  2806. });
  2807. }
  2808. }
  2809. }, {
  2810. italic: {
  2811. identifier: 'italic',
  2812. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ITALIC,
  2813. label: '<i class="fa fa-fw fa-italic"></i>',
  2814. modes: ['gfm', 'markdown'],
  2815. shortcut: ['Ctrl-I', 'Cmd-I'],
  2816. action: function action(_ref13) {
  2817. var codemirror = _ref13.codemirror,
  2818. button = _ref13.button,
  2819. textarea = _ref13.textarea;
  2820. replacer({
  2821. name: 'italic',
  2822. replace: '_$1$cur_',
  2823. codemirror: codemirror,
  2824. button: button
  2825. });
  2826. }
  2827. }
  2828. }, {
  2829. strike: {
  2830. identifier: 'strike',
  2831. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.STRIKETHROUGH,
  2832. label: '<i class="fa fa-fw fa-strikethrough"></i>',
  2833. modes: ['gfm', 'markdown'],
  2834. action: function action(_ref14) {
  2835. var codemirror = _ref14.codemirror,
  2836. button = _ref14.button,
  2837. textarea = _ref14.textarea;
  2838. replacer({
  2839. name: 'strike',
  2840. replace: '~~$1$cur~~',
  2841. codemirror: codemirror,
  2842. button: button
  2843. });
  2844. }
  2845. }
  2846. }, {
  2847. delimiter: {
  2848. identifier: 'delimiter',
  2849. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.SUMMARY_DELIMITER,
  2850. label: '<i class="fa fa-fw fa-minus"></i>',
  2851. modes: ['gfm', 'markdown'],
  2852. action: function action(_ref15) {
  2853. var codemirror = _ref15.codemirror,
  2854. button = _ref15.button,
  2855. textarea = _ref15.textarea;
  2856. replacer({
  2857. name: 'delimiter',
  2858. replace: "".concat(external_GravAdmin_namespaceObject.config.site.delimiter, "$1"),
  2859. codemirror: codemirror,
  2860. button: button,
  2861. mode: 'replaceLine'
  2862. });
  2863. }
  2864. }
  2865. }, {
  2866. link: {
  2867. identifier: 'link',
  2868. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.LINK,
  2869. label: '<i class="fa fa-fw fa-link"></i>',
  2870. modes: ['gfm', 'markdown'],
  2871. shortcut: ['Ctrl-K', 'Cmd-K'],
  2872. action: function action(_ref16) {
  2873. var codemirror = _ref16.codemirror,
  2874. button = _ref16.button,
  2875. textarea = _ref16.textarea;
  2876. replacer({
  2877. name: 'link',
  2878. replace: '[$1]($cur)',
  2879. codemirror: codemirror,
  2880. button: button
  2881. });
  2882. }
  2883. }
  2884. }, {
  2885. image: {
  2886. identifier: 'image',
  2887. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IMAGE,
  2888. label: '<i class="fa fa-fw fa-picture-o"></i>',
  2889. modes: ['gfm', 'markdown'],
  2890. action: function action(_ref17) {
  2891. var codemirror = _ref17.codemirror,
  2892. button = _ref17.button,
  2893. textarea = _ref17.textarea;
  2894. replacer({
  2895. name: 'image',
  2896. replace: '![$1]($cur)',
  2897. codemirror: codemirror,
  2898. button: button
  2899. });
  2900. }
  2901. }
  2902. }, {
  2903. blockquote: {
  2904. identifier: 'blockquote',
  2905. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.BLOCKQUOTE,
  2906. label: '<i class="fa fa-fw fa-quote-right"></i>',
  2907. modes: ['gfm', 'markdown'],
  2908. action: function action(_ref18) {
  2909. var codemirror = _ref18.codemirror,
  2910. button = _ref18.button,
  2911. textarea = _ref18.textarea;
  2912. replacer({
  2913. name: 'blockquote',
  2914. replace: '> $1',
  2915. codemirror: codemirror,
  2916. button: button,
  2917. mode: 'replaceLine'
  2918. });
  2919. }
  2920. }
  2921. }, {
  2922. listUl: {
  2923. identifier: 'listUl',
  2924. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNORDERED_LIST,
  2925. label: '<i class="fa fa-fw fa-list-ul"></i>',
  2926. modes: ['gfm', 'markdown'],
  2927. action: function action(_ref19) {
  2928. var codemirror = _ref19.codemirror,
  2929. button = _ref19.button,
  2930. textarea = _ref19.textarea;
  2931. replacer({
  2932. name: 'listUl',
  2933. replace: '* $1',
  2934. codemirror: codemirror,
  2935. button: button,
  2936. mode: 'replaceLine'
  2937. });
  2938. }
  2939. }
  2940. }, {
  2941. listOl: {
  2942. identifier: 'listOl',
  2943. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ORDERED_LIST,
  2944. label: '<i class="fa fa-fw fa-list-ol"></i>',
  2945. modes: ['gfm', 'markdown'],
  2946. action: function action(_ref20) {
  2947. var codemirror = _ref20.codemirror,
  2948. button = _ref20.button,
  2949. textarea = _ref20.textarea;
  2950. replacer({
  2951. name: 'listOl',
  2952. replace: '. $1',
  2953. codemirror: codemirror,
  2954. button: button,
  2955. mode: 'replaceLine',
  2956. runner: function runner(line, markup) {
  2957. var lineNo = codemirror.getLineNumber(line);
  2958. var previousLine = codemirror.getLine(lineNo - 1) || '';
  2959. var match = previousLine.match(/^(\d+)\./);
  2960. var prefix = 1 + (match ? Number(match[1]) : 0);
  2961. return "".concat(prefix).concat(markup);
  2962. }
  2963. });
  2964. }
  2965. }
  2966. }],
  2967. states: [{
  2968. code: {
  2969. identifier: 'editor',
  2970. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.EDITOR,
  2971. label: '<i class="fa fa-fw fa-code"></i>',
  2972. action: function action(_ref21) {
  2973. var codemirror = _ref21.codemirror,
  2974. button = _ref21.button,
  2975. textarea = _ref21.textarea,
  2976. ui = _ref21.ui;
  2977. if (textarea.data('grav-editor-mode') === 'editor') {
  2978. button.addClass('editor-active');
  2979. }
  2980. button.on('click.states.editor', function () {
  2981. button.siblings().removeClass('editor-active');
  2982. button.addClass('editor-active');
  2983. textarea.data('grav-editor-mode', 'editor');
  2984. var previewContainer = textarea.data('grav-editor-preview-container');
  2985. var content = textarea.parent('.grav-editor-content');
  2986. content.addClass('is-active');
  2987. ui.navigation.find('.grav-editor-actions').css('visibility', 'visible');
  2988. if (previewContainer) {
  2989. previewContainer.removeClass('is-active');
  2990. }
  2991. });
  2992. }
  2993. }
  2994. }, {
  2995. preview: {
  2996. identifier: 'preview',
  2997. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PREVIEW,
  2998. label: '<i class="fa fa-fw fa-eye"></i>',
  2999. modes: ['gfm', 'markdown'],
  3000. action: function action(_ref22) {
  3001. var codemirror = _ref22.codemirror,
  3002. button = _ref22.button,
  3003. textarea = _ref22.textarea,
  3004. ui = _ref22.ui;
  3005. if (textarea.data('grav-editor-mode') === 'preview') {
  3006. button.addClass('editor-active');
  3007. }
  3008. button.on('click.states.preview', function () {
  3009. var previewContainer = textarea.data('grav-editor-preview-container');
  3010. var content = textarea.parent('.grav-editor-content');
  3011. button.siblings().removeClass('editor-active');
  3012. button.addClass('editor-active');
  3013. textarea.data('grav-editor-mode', 'preview');
  3014. if (!previewContainer) {
  3015. previewContainer = external_jQuery_default()('<div class="grav-editor-preview" />');
  3016. content.after(previewContainer);
  3017. textarea.data('grav-editor-preview-container', previewContainer);
  3018. }
  3019. previewContainer.css({
  3020. height: content.height()
  3021. });
  3022. previewContainer.addClass('is-active');
  3023. content.removeClass('is-active');
  3024. ui.navigation.find('.grav-editor-actions').css('visibility', 'hidden');
  3025. var url = "".concat(textarea.data('grav-urlpreview'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "processmarkdown");
  3026. var params = textarea.closest('form').serializeArray();
  3027. var body = {};
  3028. params.map(function (obj) {
  3029. body[obj.name] = obj.value;
  3030. });
  3031. utils_request(url, {
  3032. method: 'post',
  3033. body: body
  3034. }, function (response) {
  3035. return previewContainer.html(response.preview);
  3036. });
  3037. });
  3038. }
  3039. }
  3040. }, {
  3041. fullscreen: {
  3042. identifier: 'fullscreen',
  3043. title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FULLSCREEN,
  3044. label: '<i class="fa fa-fw fa-expand"></i>',
  3045. action: function action(_ref23) {
  3046. var codemirror = _ref23.codemirror,
  3047. button = _ref23.button,
  3048. textarea = _ref23.textarea;
  3049. button.on('click.editor.fullscreen', function () {
  3050. var container = textarea.closest('.grav-editor');
  3051. var wrapper = codemirror.getWrapperElement();
  3052. var contentWrapper = external_jQuery_default()('.content-wrapper');
  3053. if (!container.hasClass('grav-editor-fullscreen')) {
  3054. textarea.data('fullScreenRestore', {
  3055. scrollTop: __webpack_require__.g.pageYOffset,
  3056. scrollLeft: __webpack_require__.g.pageXOffset,
  3057. width: wrapper.style.width,
  3058. height: wrapper.style.height
  3059. });
  3060. wrapper.style.width = '';
  3061. wrapper.style.height = textarea.parent('.grav-editor-content').height() + 'px';
  3062. __webpack_require__.g.document.documentElement.style.overflow = 'hidden';
  3063. var hints = container.find('.grav-editor-toolbar .hint--top');
  3064. if (hints) {
  3065. hints.removeClass('hint--top').addClass('hint--bottom');
  3066. external_jQuery_default()(hints[hints.length - 1]).addClass('hint--bottom-left');
  3067. }
  3068. if (contentWrapper) {
  3069. contentWrapper.css('overflow', 'visible');
  3070. }
  3071. } else {
  3072. __webpack_require__.g.document.documentElement.style.overflow = '';
  3073. var state = textarea.data('fullScreenRestore');
  3074. wrapper.style.width = state.width;
  3075. wrapper.style.height = state.height;
  3076. __webpack_require__.g.scrollTo(state.scrollLeft, state.scrollTop);
  3077. var _hints = container.find('.grav-editor-toolbar .hint--bottom');
  3078. if (_hints) {
  3079. _hints.removeClass('hint--bottom').addClass('hint--top');
  3080. external_jQuery_default()(_hints[_hints.length - 1]).removeClass('hint--bottom-left');
  3081. }
  3082. if (contentWrapper) {
  3083. contentWrapper.css('overflow', 'auto');
  3084. }
  3085. }
  3086. container.toggleClass('grav-editor-fullscreen');
  3087. setTimeout(function () {
  3088. codemirror.refresh(); // this.preview.parent().css('height', this.code.height());
  3089. external_jQuery_default()(__webpack_require__.g).trigger('resize');
  3090. }, 5);
  3091. });
  3092. }
  3093. }
  3094. }]
  3095. });
  3096. // EXTERNAL MODULE: ./node_modules/codemirror/lib/codemirror.js
  3097. var codemirror = __webpack_require__(4631);
  3098. var codemirror_default = /*#__PURE__*/__webpack_require__.n(codemirror);
  3099. // EXTERNAL MODULE: ./node_modules/watchjs/src/watch.js
  3100. var watch = __webpack_require__(29950);
  3101. // EXTERNAL MODULE: ./node_modules/js-yaml/dist/js-yaml.mjs
  3102. var js_yaml = __webpack_require__(47180);
  3103. // EXTERNAL MODULE: ./node_modules/codemirror/mode/css/css.js
  3104. var css = __webpack_require__(36629);
  3105. // EXTERNAL MODULE: ./node_modules/codemirror/mode/gfm/gfm.js
  3106. var gfm = __webpack_require__(42425);
  3107. // EXTERNAL MODULE: ./node_modules/codemirror/mode/htmlmixed/htmlmixed.js
  3108. var htmlmixed = __webpack_require__(16531);
  3109. // EXTERNAL MODULE: ./node_modules/codemirror/mode/javascript/javascript.js
  3110. var javascript = __webpack_require__(96876);
  3111. // EXTERNAL MODULE: ./node_modules/codemirror/mode/markdown/markdown.js
  3112. var markdown = __webpack_require__(49047);
  3113. // EXTERNAL MODULE: ./node_modules/codemirror/mode/php/php.js
  3114. var php = __webpack_require__(36702);
  3115. // EXTERNAL MODULE: ./node_modules/codemirror/mode/sass/sass.js
  3116. var sass = __webpack_require__(81201);
  3117. // EXTERNAL MODULE: ./node_modules/codemirror/mode/twig/twig.js
  3118. var twig = __webpack_require__(54702);
  3119. // EXTERNAL MODULE: ./node_modules/codemirror/mode/xml/xml.js
  3120. var xml = __webpack_require__(29589);
  3121. // EXTERNAL MODULE: ./node_modules/codemirror/mode/yaml/yaml.js
  3122. var yaml = __webpack_require__(53631);
  3123. // EXTERNAL MODULE: ./node_modules/codemirror/addon/edit/continuelist.js
  3124. var continuelist = __webpack_require__(23350);
  3125. // EXTERNAL MODULE: ./node_modules/codemirror/addon/mode/overlay.js
  3126. var overlay = __webpack_require__(14146);
  3127. // EXTERNAL MODULE: ./node_modules/codemirror/addon/selection/active-line.js
  3128. var active_line = __webpack_require__(20017);
  3129. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/lint.js
  3130. var lint = __webpack_require__(3256);
  3131. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/lint.css
  3132. var lint_lint = __webpack_require__(46226);
  3133. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/css-lint.js
  3134. var css_lint = __webpack_require__(41423);
  3135. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/javascript-lint.js
  3136. var javascript_lint = __webpack_require__(96477);
  3137. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/json-lint.js
  3138. var json_lint = __webpack_require__(62193);
  3139. // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/yaml-lint.js
  3140. var yaml_lint = __webpack_require__(82783);
  3141. ;// CONCATENATED MODULE: ./app/forms/fields/editor.js
  3142. function editor_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3143. 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); } }
  3144. function editor_createClass(Constructor, protoProps, staticProps) { if (protoProps) editor_defineProperties(Constructor.prototype, protoProps); if (staticProps) editor_defineProperties(Constructor, staticProps); return Constructor; }
  3145. __webpack_require__.g.jsyaml = js_yaml/* default */.ZP; // Modes
  3146. // Add-ons
  3147. var IS_MOUSEDOWN = false;
  3148. var ThemesMap = ['paper'];
  3149. var Defaults = {
  3150. codemirror: {
  3151. mode: 'htmlmixed',
  3152. theme: 'paper',
  3153. lineWrapping: true,
  3154. dragDrop: true,
  3155. autoCloseTags: true,
  3156. matchTags: true,
  3157. autoCloseBrackets: true,
  3158. matchBrackets: true,
  3159. indentUnit: 4,
  3160. indentWithTabs: false,
  3161. tabSize: 4,
  3162. hintOptions: {
  3163. completionSingle: false
  3164. },
  3165. extraKeys: {
  3166. 'Enter': 'newlineAndIndentContinueMarkdownList'
  3167. }
  3168. }
  3169. };
  3170. var EditorField = /*#__PURE__*/function () {
  3171. function EditorField(options) {
  3172. var _this = this;
  3173. editor_classCallCheck(this, EditorField);
  3174. var body = external_jQuery_default()('body');
  3175. this.editors = external_jQuery_default()();
  3176. this.options = Object.assign({}, Defaults, options);
  3177. this.buttons = buttons;
  3178. this.buttonStrategies = strategies;
  3179. (0,watch.watch)(buttons, function ()
  3180. /* key, modifier, prev, next */
  3181. {
  3182. _this.editors.each(function (index, editor) {
  3183. return external_jQuery_default()(editor).data('toolbar').renderButtons();
  3184. });
  3185. });
  3186. external_jQuery_default()('[data-grav-editor]').each(function (index, editor) {
  3187. return _this.addEditor(editor);
  3188. });
  3189. external_jQuery_default()(function () {
  3190. body.trigger('grav-editor-ready');
  3191. });
  3192. body.on('mutation._grav', this._onAddedNodes.bind(this));
  3193. body.on('mouseup._grav', function () {
  3194. if (!IS_MOUSEDOWN) {
  3195. return true;
  3196. }
  3197. body.unbind('mousemove._grav');
  3198. IS_MOUSEDOWN = false;
  3199. });
  3200. body.on('mousedown._grav', '.grav-editor-resizer', function (event) {
  3201. event && event.preventDefault();
  3202. IS_MOUSEDOWN = true;
  3203. var target = external_jQuery_default()(event.currentTarget);
  3204. var container = target.siblings('.grav-editor-content');
  3205. var editor = container.find('.CodeMirror');
  3206. var codemirror = container.find('textarea').data('codemirror');
  3207. body.on('mousemove._grav', function (event) {
  3208. editor.css('height', Math.max(100, event.pageY - container.offset().top));
  3209. codemirror.refresh();
  3210. });
  3211. });
  3212. }
  3213. editor_createClass(EditorField, [{
  3214. key: "addButton",
  3215. value: function addButton(button, options) {
  3216. if (options && (options.before || options.after)) {
  3217. var index = this.buttons.navigation.findIndex(function (obj) {
  3218. var key = Object.keys(obj).shift();
  3219. return obj[key].identifier === (options.before || options.after);
  3220. });
  3221. if (!~index) {
  3222. options = 'end';
  3223. } else {
  3224. this.buttons.navigation.splice(options.before ? index : index + 1, 0, button);
  3225. }
  3226. }
  3227. if (options === 'start') {
  3228. this.buttons.navigation.splice(0, 0, button);
  3229. }
  3230. if (!options || options === 'end') {
  3231. this.buttons.navigation.push(button);
  3232. }
  3233. }
  3234. }, {
  3235. key: "addEditor",
  3236. value: function addEditor(textarea) {
  3237. textarea = external_jQuery_default()(textarea);
  3238. var options = Object.assign({}, this.options.codemirror, textarea.data('grav-editor').codemirror);
  3239. var theme = options.theme || 'paper';
  3240. this.editors = this.editors.add(textarea);
  3241. if (theme && !~ThemesMap.indexOf(theme)) {
  3242. ThemesMap.push(theme); // let themeCSS = `https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.12.0/theme/${theme}.min.css`;
  3243. // $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', themeCSS));
  3244. }
  3245. if (options.mode === 'yaml') {
  3246. Object.assign(options.extraKeys, {
  3247. Tab: function Tab(cm) {
  3248. cm.replaceSelection(' ', 'end');
  3249. }
  3250. });
  3251. }
  3252. var editor = codemirror_default().fromTextArea(textarea.get(0), options);
  3253. textarea.data('codemirror', editor);
  3254. textarea.data('toolbar', new Toolbar(textarea));
  3255. textarea.addClass('code-mirrored');
  3256. if (options.toolbar === false) {
  3257. textarea.data('toolbar').ui.navigation.addClass('grav-editor-hide-toolbar');
  3258. }
  3259. editor.on('change', function () {
  3260. return editor.save();
  3261. });
  3262. }
  3263. }, {
  3264. key: "_onAddedNodes",
  3265. value: function _onAddedNodes(event, target
  3266. /* , record, instance */
  3267. ) {
  3268. var _this2 = this;
  3269. var editors = external_jQuery_default()(target).find('[data-grav-editor]');
  3270. if (!editors.length) {
  3271. return;
  3272. }
  3273. editors.each(function (index, editor) {
  3274. editor = external_jQuery_default()(editor);
  3275. if (!~_this2.editors.index(editor)) {
  3276. _this2.addEditor(editor);
  3277. }
  3278. });
  3279. }
  3280. }]);
  3281. return EditorField;
  3282. }();
  3283. var Toolbar = /*#__PURE__*/function () {
  3284. function Toolbar(editor) {
  3285. editor_classCallCheck(this, Toolbar);
  3286. this.editor = external_jQuery_default()(editor);
  3287. this.codemirror = this.editor.data('codemirror');
  3288. this.buttons = buttons.navigation;
  3289. this.ui = {
  3290. navigation: external_jQuery_default()(Toolbar.templates().navigation)
  3291. };
  3292. this.editor.parent('.grav-editor-content').before(this.ui.navigation).after(this.ui.states);
  3293. this.renderButtons();
  3294. }
  3295. editor_createClass(Toolbar, [{
  3296. key: "renderButtons",
  3297. value: function renderButtons() {
  3298. var _this3 = this;
  3299. var map = {
  3300. 'actions': 'navigation',
  3301. 'modes': 'states'
  3302. };
  3303. ['actions', 'modes'].forEach(function (type) {
  3304. _this3.ui.navigation.find(".grav-editor-".concat(type)).empty().append('<ul />');
  3305. buttons[map[type]].forEach(function (button) {
  3306. return _this3.renderButton(button, type);
  3307. });
  3308. });
  3309. }
  3310. }, {
  3311. key: "renderButton",
  3312. value: function renderButton(button, type) {
  3313. var _this4 = this;
  3314. var location = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3315. Object.keys(button).forEach(function (key) {
  3316. var obj = button[key];
  3317. if (!obj.modes) {
  3318. obj.modes = [];
  3319. }
  3320. if (!~_this4.codemirror.options.ignore.indexOf(key) && (!obj.modes.length || obj.modes.indexOf(_this4.codemirror.options.mode) > -1)) {
  3321. var hint = obj.title ? "data-hint=\"".concat(obj.title, "\"") : '';
  3322. var element = external_jQuery_default()("<li class=\"grav-editor-button-".concat(key, "\"><a class=\"hint--top\" ").concat(hint, ">").concat(obj.label, "</a></li>"));
  3323. (location || _this4.ui.navigation.find(".grav-editor-".concat(type, " ul:not(.dropdown-menu)"))).append(element);
  3324. if (obj.shortcut) {
  3325. _this4.addShortcut(obj.identifier, obj.shortcut, element);
  3326. }
  3327. obj.action && obj.action.call(obj.action, {
  3328. codemirror: _this4.codemirror,
  3329. button: element,
  3330. textarea: _this4.editor,
  3331. ui: _this4.ui
  3332. });
  3333. if (obj.children) {
  3334. var childrenContainer = external_jQuery_default()('<ul class="dropdown-menu" />');
  3335. element.addClass('button-group').find('a').wrap('<div class="dropdown-toggle" data-toggle="dropdown"></div>');
  3336. element.find('a').append(' <i class="fa fa-caret-down"></i>');
  3337. element.append(childrenContainer);
  3338. obj.children.forEach(function (child) {
  3339. return _this4.renderButton(child, type, childrenContainer);
  3340. });
  3341. }
  3342. }
  3343. });
  3344. }
  3345. }, {
  3346. key: "addShortcut",
  3347. value: function addShortcut(identifier, shortcut, element) {
  3348. var _this5 = this;
  3349. var map = {};
  3350. if (!Array.isArray(shortcut)) {
  3351. shortcut = [shortcut];
  3352. }
  3353. shortcut.forEach(function (key) {
  3354. map[key] = function () {
  3355. element.trigger("click.editor.".concat(identifier), [_this5.codemirror]);
  3356. };
  3357. });
  3358. this.codemirror.addKeyMap(map);
  3359. }
  3360. }], [{
  3361. key: "templates",
  3362. value: function templates() {
  3363. return {
  3364. navigation: "\n <div class=\"grav-editor-toolbar\">\n <div class=\"grav-editor-actions\"></div>\n <div class=\"grav-editor-modes\"></div>\n </div>\n "
  3365. };
  3366. }
  3367. }]);
  3368. return Toolbar;
  3369. }();
  3370. var editor_Instance = new EditorField();
  3371. ;// CONCATENATED MODULE: ./app/pages/page/media.js
  3372. function media_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { media_typeof = function _typeof(obj) { return typeof obj; }; } else { media_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return media_typeof(obj); }
  3373. function media_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3374. 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); } }
  3375. function media_createClass(Constructor, protoProps, staticProps) { if (protoProps) media_defineProperties(Constructor.prototype, protoProps); if (staticProps) media_defineProperties(Constructor, staticProps); return Constructor; }
  3376. function media_get(target, property, receiver) { 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(receiver); } return desc.value; }; } return media_get(target, property, receiver || target); }
  3377. function media_superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = media_getPrototypeOf(object); if (object === null) break; } return object; }
  3378. 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 } }); if (superClass) media_setPrototypeOf(subClass, superClass); }
  3379. function media_setPrototypeOf(o, p) { media_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return media_setPrototypeOf(o, p); }
  3380. 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); }; }
  3381. function media_possibleConstructorReturn(self, call) { if (call && (media_typeof(call) === "object" || typeof call === "function")) { return call; } return media_assertThisInitialized(self); }
  3382. function media_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  3383. 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; } }
  3384. function media_getPrototypeOf(o) { media_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return media_getPrototypeOf(o); }
  3385. 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();
  3386. var PageMedia = /*#__PURE__*/function (_FilesField) {
  3387. media_inherits(PageMedia, _FilesField);
  3388. var _super = media_createSuper(PageMedia);
  3389. function PageMedia() {
  3390. var _this;
  3391. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3392. _ref$container = _ref.container,
  3393. container = _ref$container === void 0 ? '#grav-dropzone' : _ref$container,
  3394. _ref$options = _ref.options,
  3395. options = _ref$options === void 0 ? {} : _ref$options;
  3396. media_classCallCheck(this, PageMedia);
  3397. options = Object.assign(options, {
  3398. previewTemplate: previewTemplate
  3399. });
  3400. _this = _super.call(this, {
  3401. container: container,
  3402. options: options
  3403. });
  3404. if (!_this.container.length) {
  3405. return media_possibleConstructorReturn(_this);
  3406. }
  3407. _this.urls = {
  3408. fetch: "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "listmedia"),
  3409. add: "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "addmedia"),
  3410. "delete": "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "delmedia")
  3411. };
  3412. _this.dropzone.options.url = _this.urls.add;
  3413. if (typeof _this.options.fetchMedia === 'undefined' || _this.options.fetchMedia) {
  3414. _this.fetchMedia();
  3415. }
  3416. if (typeof _this.options.attachDragDrop === 'undefined' || _this.options.attachDragDrop) {
  3417. _this.attachDragDrop();
  3418. }
  3419. var field = external_jQuery_default()("[name=\"".concat(_this.container.data('dropzone-field'), "\"]"));
  3420. if (field.length) {
  3421. _this.sortable = new sortable_esm/* default */.ZP(_this.container.get(0), {
  3422. animation: 150,
  3423. // forceFallback: true,
  3424. setData: function setData(dataTransfer, target) {
  3425. target = external_jQuery_default()(target);
  3426. var uri = encodeURI(target.find('.dz-filename').text());
  3427. var shortcode = UriToMarkdown(uri);
  3428. _this.dropzone.disable();
  3429. target.addClass('hide-backface');
  3430. dataTransfer.effectAllowed = 'copy';
  3431. dataTransfer.setData('text', shortcode);
  3432. },
  3433. onSort: function onSort() {
  3434. var names = [];
  3435. _this.container.find('[data-dz-name]').each(function (index, file) {
  3436. file = external_jQuery_default()(file);
  3437. var name = file.text().trim();
  3438. names.push(name);
  3439. });
  3440. field.val(names.join(','));
  3441. }
  3442. });
  3443. }
  3444. return _this;
  3445. }
  3446. media_createClass(PageMedia, [{
  3447. key: "fetchMedia",
  3448. value: function fetchMedia() {
  3449. var _this2 = this;
  3450. var order = this.container.closest('.form-field').find('[name="data[header][media_order]"]').val();
  3451. var body = {
  3452. uri: this.getURI(),
  3453. order: order
  3454. };
  3455. var url = this.urls.fetch;
  3456. utils_request(url, {
  3457. method: 'post',
  3458. body: body
  3459. }, function (response) {
  3460. var results = response.results;
  3461. Object.keys(results).forEach(function (name) {
  3462. var data = results[name];
  3463. var mock = {
  3464. name: name,
  3465. size: data.size,
  3466. accepted: true,
  3467. extras: data
  3468. };
  3469. _this2.dropzone.files.push(mock);
  3470. _this2.dropzone.options.addedfile.call(_this2.dropzone, mock);
  3471. _this2.dropzone.options.thumbnail.call(_this2.dropzone, mock, data.url);
  3472. });
  3473. _this2.container.find('.dz-preview').prop('draggable', 'true');
  3474. });
  3475. }
  3476. }, {
  3477. key: "onDropzoneSending",
  3478. value: function onDropzoneSending(file, xhr, formData) {
  3479. /*
  3480. // Cannot call super because Safari and IE API don't implement `delete`
  3481. super.onDropzoneSending(file, xhr, formData);
  3482. formData.delete('task');
  3483. */
  3484. formData.append('name', this.options.dotNotation || file.name);
  3485. formData.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
  3486. formData.append('uri', this.getURI());
  3487. }
  3488. }, {
  3489. key: "onDropzoneComplete",
  3490. value: function onDropzoneComplete(file) {
  3491. media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneComplete", this).call(this, file);
  3492. if (this.sortable) {
  3493. this.sortable.options.onSort();
  3494. } // accepted
  3495. external_jQuery_default()('.dz-preview').prop('draggable', 'true');
  3496. }
  3497. }, {
  3498. key: "onDropzoneRemovedFile",
  3499. value: function onDropzoneRemovedFile(file) {
  3500. var _get2;
  3501. for (var _len = arguments.length, extra = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3502. extra[_key - 1] = arguments[_key];
  3503. }
  3504. (_get2 = media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneRemovedFile", this)).call.apply(_get2, [this, file].concat(extra));
  3505. if (this.sortable) {
  3506. this.sortable.options.onSort();
  3507. }
  3508. }
  3509. }, {
  3510. key: "attachDragDrop",
  3511. value: function attachDragDrop() {
  3512. var _this3 = this;
  3513. this.container.delegate('[data-dz-insert]', 'click', function (e) {
  3514. var target = external_jQuery_default()(e.currentTarget).parent('.dz-preview').find('.dz-filename');
  3515. var editor = editor_Instance.editors.filter(function (index, editor) {
  3516. return external_jQuery_default()(editor).attr('name') === 'data[content]';
  3517. });
  3518. if (editor.length) {
  3519. editor = editor.data('codemirror');
  3520. editor.focus();
  3521. var filename = encodeURI(target.text());
  3522. var shortcode = UriToMarkdown(filename);
  3523. editor.doc.replaceSelection(shortcode);
  3524. }
  3525. });
  3526. this.container.delegate('[data-dz-view]', 'mouseenter', function (e) {
  3527. var target = external_jQuery_default()(e.currentTarget);
  3528. var file = target.parent('.dz-preview').find('.dz-filename');
  3529. var filename = encodeURI(file.text());
  3530. var URL = target.closest('[data-media-path]').data('media-path');
  3531. var original = _this3.dropzone.files.filter(function (file) {
  3532. return encodeURI(file.name) === filename;
  3533. }).shift();
  3534. original = original && (original.extras && original.extras.original || encodeURI(original.name));
  3535. target.attr('href', "".concat(URL, "/").concat(original));
  3536. });
  3537. this.container.delegate('[data-dz-metadata]', 'click', function (e) {
  3538. e.preventDefault();
  3539. var target = external_jQuery_default()(e.currentTarget);
  3540. var file = target.parent('.dz-preview').find('.dz-filename');
  3541. var filename = encodeURI(file.text());
  3542. var fileObj = _this3.dropzone.files.filter(function (file) {
  3543. return file.name === __webpack_require__.g.decodeURI(filename);
  3544. }).shift() || {};
  3545. if (!fileObj.extras) {
  3546. fileObj.extras = {
  3547. metadata: []
  3548. };
  3549. }
  3550. if (Array.isArray(fileObj.extras.metadata) && !fileObj.extras.metadata.length) {
  3551. fileObj.extras.metadata = {
  3552. '': "".concat(__webpack_require__.g.decodeURI(filename), ".meta.yaml doesn't exist")
  3553. };
  3554. }
  3555. fileObj = fileObj.extras;
  3556. var modal_element = external_jQuery_default()('body').find('[data-remodal-id="metadata"]');
  3557. var modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
  3558. modal_element.find('h1 strong').html(filename);
  3559. if (fileObj.url) {
  3560. modal_element.find('.meta-preview').html("<img src=\"".concat(fileObj.url, "\" />"));
  3561. }
  3562. var container = modal_element.find('.meta-content').html('<ul />').find('ul');
  3563. Object.keys(fileObj.metadata).forEach(function (meta) {
  3564. container.append("<li><strong>".concat(meta ? meta + ':' : '', "</strong> ").concat(fileObj.metadata[meta], "</li>"));
  3565. });
  3566. modal.open();
  3567. });
  3568. this.container.delegate('.dz-preview', 'dragstart', function (e) {
  3569. var target = external_jQuery_default()(e.currentTarget);
  3570. var uri = encodeURI(target.find('.dz-filename').text());
  3571. var shortcode = UriToMarkdown(uri);
  3572. _this3.dropzone.disable();
  3573. target.addClass('hide-backface');
  3574. e.originalEvent.dataTransfer.effectAllowed = 'copy';
  3575. e.originalEvent.dataTransfer.setData('text', shortcode);
  3576. });
  3577. this.container.delegate('.dz-preview', 'dragend', function (e) {
  3578. var target = external_jQuery_default()(e.currentTarget);
  3579. _this3.dropzone.enable();
  3580. target.removeClass('hide-backface');
  3581. });
  3582. }
  3583. }]);
  3584. return PageMedia;
  3585. }(FilesField);
  3586. var media_Instance = new PageMedia();
  3587. ;// CONCATENATED MODULE: ./app/pages/page/multilang.js
  3588. external_jQuery_default()('[name="task"][value="saveas"], [name="task"][value="switchlanguage"]').on('mousedown touchstart', function (event) {
  3589. var fields = ['lang', 'redirect'];
  3590. var element = external_jQuery_default()(event.currentTarget);
  3591. var form = external_jQuery_default()("#".concat(element.attr('form')));
  3592. if (!form.length) {
  3593. return;
  3594. }
  3595. fields.forEach(function (field) {
  3596. var value = element.attr(field);
  3597. if (!value) {
  3598. return;
  3599. }
  3600. var input = form.find("[name=\"data[".concat(field, "]\"]"));
  3601. if (!input.length) {
  3602. input = external_jQuery_default()("<input type=\"hidden\" name=\"data[".concat(field, "]\" value=\"\" />"));
  3603. form.append(input);
  3604. }
  3605. input.val(value);
  3606. });
  3607. return true;
  3608. });
  3609. ;// CONCATENATED MODULE: ./app/pages/page/index.js
  3610. var page_switcher = external_jQuery_default()('input[type="radio"][name="mode-switch"]');
  3611. if (page_switcher) {
  3612. var page_link = page_switcher.closest(':checked').data('leave-url');
  3613. var fakeLink = external_jQuery_default()("<a href=\"".concat(page_link, "\" />"));
  3614. page_switcher.parent().append(fakeLink);
  3615. page_switcher.siblings('label').on('mousedown touchdown', function (event) {
  3616. event.preventDefault(); // let remodal = $.remodal.lookup[$('[data-remodal-id="changes"]').data('remodal')];
  3617. var confirm = external_jQuery_default()('[data-remodal-id="changes"] [data-leave-action="continue"]');
  3618. confirm.one('click', function () {
  3619. external_jQuery_default()(__webpack_require__.g).on('beforeunload._grav');
  3620. fakeLink.off('click._grav');
  3621. external_jQuery_default()(event.target).trigger('click');
  3622. });
  3623. fakeLink.trigger('click._grav');
  3624. });
  3625. page_switcher.on('change', function (event) {
  3626. var radio = external_jQuery_default()(event.target);
  3627. page_link = radio.data('leave-url');
  3628. setTimeout(function () {
  3629. return fakeLink.attr('href', page_link).get(0).click();
  3630. }, 5);
  3631. });
  3632. }
  3633. /* harmony default export */ const page = ({
  3634. Media: {
  3635. PageMedia: PageMedia,
  3636. PageMediaInstances: media_Instance
  3637. }
  3638. });
  3639. ;// CONCATENATED MODULE: ./app/pages/index.js
  3640. var pad = function pad(n, s) {
  3641. return "000".concat(n).substr(-s);
  3642. }; // Pages Ordering
  3643. var Ordering = null;
  3644. var orderingElement = external_jQuery_default()('#ordering');
  3645. if (orderingElement.length) {
  3646. Ordering = new sortable_esm/* default */.ZP(orderingElement.get(0), {
  3647. filter: '.ignore',
  3648. onUpdate: function onUpdate() {
  3649. /* Old single page index behavior
  3650. let item = $(event.item);
  3651. let index = orderingElement.children().index(item) + 1;
  3652. $('[data-order]').val(index);
  3653. */
  3654. var indexes = [];
  3655. var children = orderingElement.children();
  3656. var padZero = (children.length + '').split('').length;
  3657. children.each(function (index, item) {
  3658. item = external_jQuery_default()(item);
  3659. indexes.push(item.data('id'));
  3660. item.find('.page-order').text("".concat(pad(index + 1, padZero), "."));
  3661. });
  3662. external_jQuery_default()('[data-order]').val(indexes.join(','));
  3663. }
  3664. });
  3665. external_jQuery_default()(document).on('input', '[name="data[folder]"]', function (event) {
  3666. var target = external_jQuery_default()(event.currentTarget);
  3667. var activeOrder = external_jQuery_default()('[data-id][data-active-id]');
  3668. activeOrder.data('id', target.val());
  3669. Ordering.options.onUpdate();
  3670. });
  3671. }
  3672. /* harmony default export */ const pages = ({
  3673. Ordering: Ordering,
  3674. Page: page,
  3675. PageFilters: {
  3676. PageFilters: PagesFilter,
  3677. Instance: filter_Instance
  3678. }
  3679. });
  3680. // EXTERNAL MODULE: ./node_modules/immutable/dist/immutable.js
  3681. var immutable = __webpack_require__(43393);
  3682. var immutable_default = /*#__PURE__*/__webpack_require__.n(immutable);
  3683. // EXTERNAL MODULE: ./node_modules/immutablediff/src/diff.js
  3684. var src_diff = __webpack_require__(64847);
  3685. var diff_default = /*#__PURE__*/__webpack_require__.n(src_diff);
  3686. ;// CONCATENATED MODULE: ./app/forms/state.js
  3687. function state_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3688. 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); } }
  3689. function state_createClass(Constructor, protoProps, staticProps) { if (protoProps) state_defineProperties(Constructor.prototype, protoProps); if (staticProps) state_defineProperties(Constructor, staticProps); return Constructor; }
  3690. var FormLoadState = {};
  3691. var DOMBehaviors = {
  3692. attach: function attach() {
  3693. this.preventUnload();
  3694. this.preventClickAway();
  3695. },
  3696. preventUnload: function preventUnload() {
  3697. var selector = '[name="task"][value^="save"], [data-delete-action], [data-flex-safe-action]';
  3698. if (external_jQuery_default()._data(window, 'events') && (external_jQuery_default()._data(window, 'events').beforeunload || []).filter(function (event) {
  3699. return event.namespace === '_grav';
  3700. }).length) {
  3701. return;
  3702. } // Allow some elements to leave the page without native confirmation
  3703. external_jQuery_default()(selector).on('click._grav', function (event) {
  3704. external_jQuery_default()(__webpack_require__.g).off('beforeunload');
  3705. }); // Catch browser uri change / refresh attempt and stop it if the form state is dirty
  3706. external_jQuery_default()(__webpack_require__.g).on('beforeunload._grav', function () {
  3707. if (state_Instance.equals() === false) {
  3708. 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.';
  3709. }
  3710. });
  3711. },
  3712. preventClickAway: function preventClickAway() {
  3713. var selector = 'a[href]:not([href^="#"]):not([target="_blank"]):not([href^="javascript:"])';
  3714. 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) {
  3715. return event.namespace === '_grav';
  3716. })) {
  3717. return;
  3718. } // Prevent clicking away if the form state is dirty
  3719. // instead, display a confirmation before continuing
  3720. external_jQuery_default()(selector).on('click._grav', function (event) {
  3721. var isClean = state_Instance.equals();
  3722. if (isClean === null || isClean) {
  3723. return true;
  3724. }
  3725. event.preventDefault();
  3726. var destination = external_jQuery_default()(this).attr('href');
  3727. var modal = external_jQuery_default()('[data-remodal-id="changes"]');
  3728. var lookup = (external_jQuery_default()).remodal.lookup[modal.data('remodal')];
  3729. var buttons = external_jQuery_default()('a.button', modal);
  3730. var handler = function handler(event) {
  3731. event.preventDefault();
  3732. var action = external_jQuery_default()(this).data('leave-action');
  3733. buttons.off('click', handler);
  3734. lookup.close();
  3735. if (action === 'continue') {
  3736. external_jQuery_default()(__webpack_require__.g).off('beforeunload');
  3737. __webpack_require__.g.location.href = destination;
  3738. }
  3739. };
  3740. buttons.on('click', handler);
  3741. lookup.open();
  3742. });
  3743. }
  3744. };
  3745. var FormState = /*#__PURE__*/function () {
  3746. function FormState() {
  3747. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  3748. ignore: [],
  3749. form_id: 'blueprints'
  3750. };
  3751. state_classCallCheck(this, FormState);
  3752. this.options = options;
  3753. this.refresh();
  3754. if (!this.form || !this.fields.length) {
  3755. return;
  3756. }
  3757. FormLoadState = this.collect();
  3758. this.loadState = FormLoadState;
  3759. DOMBehaviors.attach();
  3760. }
  3761. state_createClass(FormState, [{
  3762. key: "refresh",
  3763. value: function refresh() {
  3764. this.form = external_jQuery_default()("form#".concat(this.options.form_id)).filter(':noparents(.remodal)');
  3765. 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)');
  3766. return this;
  3767. }
  3768. }, {
  3769. key: "collect",
  3770. value: function collect() {
  3771. var _this = this;
  3772. if (!this.form || !this.fields.length) {
  3773. return;
  3774. }
  3775. var values = {};
  3776. this.refresh().fields.each(function (index, field) {
  3777. field = external_jQuery_default()(field);
  3778. var name = field.prop('name');
  3779. var type = field.prop('type');
  3780. var tag = field.prop('tagName').toLowerCase();
  3781. var value;
  3782. if (name.startsWith('toggleable_') || name === 'data[lang]' || name === 'data[redirect]') {
  3783. return;
  3784. }
  3785. switch (type) {
  3786. case 'checkbox':
  3787. value = field.is(':checked');
  3788. break;
  3789. case 'radio':
  3790. if (!field.is(':checked')) {
  3791. return;
  3792. }
  3793. value = field.val();
  3794. break;
  3795. default:
  3796. value = field.val();
  3797. }
  3798. if (tag === 'select' && value === null) {
  3799. value = '';
  3800. }
  3801. if (Array.isArray(value)) {
  3802. value = value.join('|');
  3803. }
  3804. if (name && !~_this.options.ignore.indexOf(name)) {
  3805. values[name] = value;
  3806. }
  3807. });
  3808. return immutable_default().OrderedMap(values);
  3809. }
  3810. }, {
  3811. key: "diff",
  3812. value: function diff() {
  3813. return diff_default()(FormLoadState, this.collect());
  3814. } // When the form doesn't exist or there are no fields, `equals` returns `null`
  3815. // for this reason, _NEVER_ check with !Instance.equals(), use Instance.equals() === false
  3816. }, {
  3817. key: "equals",
  3818. value: function equals() {
  3819. if (!this.form || !this.fields.length) {
  3820. return null;
  3821. }
  3822. return immutable_default().is(FormLoadState, this.collect());
  3823. }
  3824. }]);
  3825. return FormState;
  3826. }();
  3827. ;
  3828. var state_Instance = new FormState();
  3829. ;// CONCATENATED MODULE: ./app/forms/form.js
  3830. function form_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3831. 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); } }
  3832. function form_createClass(Constructor, protoProps, staticProps) { if (protoProps) form_defineProperties(Constructor.prototype, protoProps); if (staticProps) form_defineProperties(Constructor, staticProps); return Constructor; }
  3833. /* Dependencies for checking if changes happened since load on a form
  3834. import toastr from '../utils/toastr';
  3835. import { translations } from 'grav-config';
  3836. import { Instance as FormState } from './state';
  3837. */
  3838. var Form = /*#__PURE__*/function () {
  3839. function Form(form) {
  3840. var _this = this;
  3841. form_classCallCheck(this, Form);
  3842. this.form = external_jQuery_default()(form);
  3843. if (!this.form.length || this.form.prop('tagName').toLowerCase() !== 'form') {
  3844. return;
  3845. }
  3846. /* Option for not saving while nothing in a form has changed
  3847. this.form.on('submit', (event) => {
  3848. if (FormState.equals()) {
  3849. event.preventDefault();
  3850. toastr.info(translations.PLUGIN_ADMIN.NOTHING_TO_SAVE);
  3851. }
  3852. }); */
  3853. this._attachShortcuts();
  3854. this._attachToggleables();
  3855. this._attachDisabledFields();
  3856. this._submitUncheckedFields();
  3857. this.observer = new MutationObserver(this.addedNodes);
  3858. this.form.each(function (index, form) {
  3859. return _this.observer.observe(form, {
  3860. subtree: true,
  3861. childList: true
  3862. });
  3863. });
  3864. }
  3865. form_createClass(Form, [{
  3866. key: "_attachShortcuts",
  3867. value: function _attachShortcuts() {
  3868. // CTRL + S / CMD + S - shortcut for [Save] when available
  3869. var saveTask = external_jQuery_default()('#titlebar [name="task"][value="save"][form="blueprints"]');
  3870. if (saveTask.length) {
  3871. external_jQuery_default()(__webpack_require__.g).on('keydown', function (event) {
  3872. var key = String.fromCharCode(event.which).toLowerCase();
  3873. if (!event.shiftKey && (event.ctrlKey && !event.altKey || event.metaKey) && key === 's') {
  3874. event.preventDefault();
  3875. saveTask.click();
  3876. }
  3877. });
  3878. }
  3879. }
  3880. }, {
  3881. key: "_attachToggleables",
  3882. value: function _attachToggleables() {
  3883. var query = '[data-grav-field="toggleable"] input[type="checkbox"]';
  3884. this.form.on('change', query, function (event) {
  3885. var toggle = external_jQuery_default()(event.target);
  3886. var enabled = toggle.is(':checked');
  3887. var parent = toggle.closest('.form-field');
  3888. var label = parent.find('label.toggleable');
  3889. var fields = parent.find('.form-data');
  3890. var inputs = fields.find('input, select, textarea, button');
  3891. label.add(fields).css('opacity', enabled ? '' : 0.7);
  3892. inputs.map(function (index, input) {
  3893. var isSelectize = input.selectize;
  3894. input = external_jQuery_default()(input);
  3895. if (isSelectize) {
  3896. isSelectize[enabled ? 'enable' : 'disable']();
  3897. } else {
  3898. input.prop('disabled', !enabled);
  3899. }
  3900. });
  3901. });
  3902. this.form.find(query).trigger('change');
  3903. }
  3904. }, {
  3905. key: "_attachDisabledFields",
  3906. value: function _attachDisabledFields() {
  3907. var prefix = '.form-field-toggleable .form-data';
  3908. var query = [];
  3909. ['input', 'select', 'label[for]', 'textarea', '.selectize-control'].forEach(function (item) {
  3910. query.push("".concat(prefix, " ").concat(item));
  3911. });
  3912. this.form.on('mousedown', query.join(', '), function (event) {
  3913. var input = external_jQuery_default()(event.target);
  3914. var isFor = input.prop('for');
  3915. var isSelectize = (input.hasClass('selectize-control') || input.parents('.selectize-control')).length;
  3916. if (isFor) {
  3917. input = external_jQuery_default()("[id=\"".concat(isFor, "\"]"));
  3918. }
  3919. if (isSelectize) {
  3920. input = input.closest('.selectize-control').siblings('select[name]');
  3921. }
  3922. if (!input.prop('disabled')) {
  3923. return true;
  3924. }
  3925. var toggle = input.closest('.form-field').find('[data-grav-field="toggleable"] input[type="checkbox"]');
  3926. toggle.trigger('click');
  3927. });
  3928. }
  3929. }, {
  3930. key: "_submitUncheckedFields",
  3931. value: function _submitUncheckedFields() {
  3932. var submitted = false;
  3933. this.form.each(function (index, form) {
  3934. form = external_jQuery_default()(form);
  3935. form.on('submit', function () {
  3936. // workaround for MS Edge, submitting multiple forms at the same time
  3937. if (submitted) {
  3938. return false;
  3939. }
  3940. var formId = form.attr('id');
  3941. var unchecked = form.find('input[type="checkbox"]:not(:checked):not(:disabled)');
  3942. var submit = form.find('[type="submit"]').add("[form=\"".concat(formId, "\"][type=\"submit\"]"));
  3943. if (!unchecked.length) {
  3944. return true;
  3945. }
  3946. submit.addClass('pointer-events-disabled');
  3947. unchecked.each(function (index, element) {
  3948. element = external_jQuery_default()(element);
  3949. var name = element.prop('name');
  3950. var fake = external_jQuery_default()("<input type=\"hidden\" name=\"".concat(name, "\" value=\"0\" />"));
  3951. form.append(fake);
  3952. });
  3953. submitted = true;
  3954. return true;
  3955. });
  3956. });
  3957. }
  3958. }, {
  3959. key: "addedNodes",
  3960. value: function addedNodes(mutations) {
  3961. var _this2 = this;
  3962. mutations.forEach(function (mutation) {
  3963. if (mutation.type !== 'childList') {
  3964. return;
  3965. }
  3966. if (mutation.addedNodes) {
  3967. external_jQuery_default()('body').trigger('mutation._grav', mutation.target, mutation, _this2);
  3968. }
  3969. if (mutation.removedNodes) {
  3970. external_jQuery_default()('body').trigger('mutation_removed._grav', {
  3971. target: mutation.target,
  3972. mutation: mutation
  3973. }, _this2);
  3974. }
  3975. });
  3976. }
  3977. }]);
  3978. return Form;
  3979. }();
  3980. var form_Instance = new Form('form#blueprints');
  3981. ;// CONCATENATED MODULE: ./app/forms/fields/filepicker.js
  3982. function filepicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3983. 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); } }
  3984. function filepicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) filepicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) filepicker_defineProperties(Constructor, staticProps); return Constructor; }
  3985. // const insertTextAt = (string, index, text) => [string.slice(0, index), text, string.slice(index)].join('');
  3986. var FilePickerField = /*#__PURE__*/function () {
  3987. function FilePickerField(options) {
  3988. var _this = this;
  3989. filepicker_classCallCheck(this, FilePickerField);
  3990. this.items = external_jQuery_default()();
  3991. this.options = Object.assign({}, this.defaults, options);
  3992. external_jQuery_default()('[data-grav-filepicker]').each(function (index, element) {
  3993. return _this.addItem(element);
  3994. });
  3995. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  3996. }
  3997. filepicker_createClass(FilePickerField, [{
  3998. key: "_onAddedNodes",
  3999. value: function _onAddedNodes(event, target
  4000. /* , record, instance */
  4001. ) {
  4002. var _this2 = this;
  4003. var fields = external_jQuery_default()(target).find('[data-grav-filepicker]');
  4004. if (!fields.length) {
  4005. return;
  4006. }
  4007. fields.each(function (index, field) {
  4008. field = external_jQuery_default()(field);
  4009. if (!~_this2.items.index(field)) {
  4010. _this2.addItem(field);
  4011. }
  4012. });
  4013. }
  4014. }, {
  4015. key: "addItem",
  4016. value: function addItem(element) {
  4017. element = external_jQuery_default()(element);
  4018. this.items = this.items.add(element);
  4019. var tag = element.prop('tagName').toLowerCase();
  4020. var isInput = tag === 'input' || tag === 'select';
  4021. var field = isInput ? element : element.find('input, select');
  4022. var folder = '';
  4023. var thumbs = {};
  4024. var onDemand = field.closest('[data-ondemand]').length > 0;
  4025. if (!field.length || field.get(0).selectize) {
  4026. return;
  4027. }
  4028. var getData = function getData(field, callback) {
  4029. var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
  4030. var url = external_GravAdmin_namespaceObject.config.current_url + ".json/task".concat(external_GravAdmin_namespaceObject.config.param_sep, "getFilesInFolder");
  4031. var parent = field.closest('[data-grav-filepicker]');
  4032. var name = parent.data('name');
  4033. var value = parent.data('value');
  4034. var params = JSON.stringify(external_GravAdmin_namespaceObject.uri_params || '{}');
  4035. utils_request(url, {
  4036. method: 'post',
  4037. body: {
  4038. name: name,
  4039. params: params
  4040. }
  4041. }, function (response) {
  4042. if (typeof response.files === 'undefined') {
  4043. return;
  4044. }
  4045. var data = [];
  4046. thumbs = response.thumbs || {};
  4047. for (var i = 0; i < response.files.length; i++) {
  4048. if (mode === 'selected' && response.files[i] !== value) {
  4049. continue;
  4050. }
  4051. data.push({
  4052. 'name': response.files[i],
  4053. 'status': 'available',
  4054. thumb: thumbs[response.files[i]] || ''
  4055. });
  4056. }
  4057. for (var _i = 0; _i < response.pending.length; _i++) {
  4058. if (mode === 'selected' && response.pending[_i] !== value) {
  4059. continue;
  4060. }
  4061. data.push({
  4062. 'name': response.pending[_i],
  4063. 'status': 'pending',
  4064. thumb: thumbs[response.pending[_i]] || ''
  4065. });
  4066. }
  4067. folder = response.folder;
  4068. callback(data, value);
  4069. });
  4070. };
  4071. var imagesPreview = field.closest('[data-preview-images]').length > 0;
  4072. var selectedIsRendered = false;
  4073. var renderOption = function renderOption(item, escape) {
  4074. var image = '';
  4075. if (imagesPreview && folder && (!item.status || item.status === 'available') && item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i)) {
  4076. // const fallback2x = insertTextAt(`${config.base_url_relative}/../${folder}/${item.name}`, -4, '@2x');
  4077. // const fallback3x = insertTextAt(`${config.base_url_relative}/../${folder}/${item.name}`, -4, '@3x');
  4078. 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}'}"
  4079. image = "<img class=\"filepicker-field-image\" src=\"".concat(source, "\" />");
  4080. }
  4081. return "<div>\n <span class=\"title\">\n ".concat(image, " <span class=\"name filepicker-field-name\">").concat(escape(item.name), "</span>\n </span>\n </div>");
  4082. };
  4083. field.selectize({
  4084. plugins: ['required-fix'],
  4085. valueField: 'name',
  4086. labelField: 'name',
  4087. searchField: 'name',
  4088. optgroups: [{
  4089. $order: 1,
  4090. value: 'pending',
  4091. label: 'Pending'
  4092. }, {
  4093. $order: 2,
  4094. value: 'available',
  4095. label: 'Available'
  4096. }],
  4097. optgroupField: 'status',
  4098. // lockOptgroupOrder: true,
  4099. create: false,
  4100. preload: false,
  4101. // 'focus',
  4102. render: {
  4103. option: function option(item, escape) {
  4104. return renderOption(item, escape);
  4105. },
  4106. item: function item(_item, escape) {
  4107. return renderOption(_item, escape);
  4108. }
  4109. },
  4110. onInitialize: function onInitialize() {
  4111. if (!onDemand) {
  4112. this.load(function (callback) {
  4113. return getData(field, function (data) {
  4114. return callback(data);
  4115. }, 'selected');
  4116. });
  4117. }
  4118. },
  4119. onLoad: function onLoad()
  4120. /* data */
  4121. {
  4122. if (!selectedIsRendered) {
  4123. var name = this.getValue();
  4124. this.updateOption(name, {
  4125. name: name
  4126. });
  4127. selectedIsRendered = true;
  4128. }
  4129. },
  4130. onFocus: function onFocus() {
  4131. this.load(function (callback) {
  4132. return getData(field, function (data) {
  4133. return callback(data);
  4134. });
  4135. });
  4136. }
  4137. });
  4138. }
  4139. }]);
  4140. return FilePickerField;
  4141. }();
  4142. var filepicker_Instance = new FilePickerField();
  4143. ;// CONCATENATED MODULE: ./app/utils/selectize-option-click.js
  4144. selectize_default().define('option_click', function (options) {
  4145. var self = this;
  4146. var setup = self.setup;
  4147. this.setup = function () {
  4148. setup.apply(self, arguments);
  4149. var clicking = false; // Detect click on a .clickable
  4150. self.$dropdown_content.on('mousedown click', function (e) {
  4151. var target = external_jQuery_default()(e.target);
  4152. if (target.hasClass('clickable') || target.closest('.clickable').length) {
  4153. if (e.type === 'mousedown') {
  4154. clicking = true;
  4155. self.isFocused = false; // awful hack to defuse the document mousedown listener
  4156. } else {
  4157. self.isFocused = true;
  4158. setTimeout(function () {
  4159. clicking = false; // wait until blur has been preempted
  4160. });
  4161. }
  4162. } else {
  4163. // cleanup in case user right-clicked or dragged off the element
  4164. clicking = false;
  4165. self.isFocused = true;
  4166. }
  4167. }); // Intercept default handlers
  4168. self.$dropdown.off('mousedown click', '[data-selectable]').on('mousedown click', '[data-selectable]', function () {
  4169. if (!clicking) {
  4170. return self.onOptionSelect.apply(self, arguments);
  4171. }
  4172. });
  4173. self.$control_input.off('blur').on('blur', function () {
  4174. if (!clicking) {
  4175. return self.onBlur.apply(self, arguments);
  4176. }
  4177. });
  4178. };
  4179. });
  4180. ;// CONCATENATED MODULE: ./app/forms/fields/selectize.js
  4181. function selectize_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4182. 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); } }
  4183. function selectize_createClass(Constructor, protoProps, staticProps) { if (protoProps) selectize_defineProperties(Constructor.prototype, protoProps); if (staticProps) selectize_defineProperties(Constructor, staticProps); return Constructor; }
  4184. var PagesRoute = {
  4185. option: function option(item, escape) {
  4186. var label = escape(item.text).split(' ');
  4187. var arrows = label.shift();
  4188. var slug = label.shift();
  4189. 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>");
  4190. }
  4191. };
  4192. var SelectizeField = /*#__PURE__*/function () {
  4193. function SelectizeField() {
  4194. var _this = this;
  4195. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4196. selectize_classCallCheck(this, SelectizeField);
  4197. this.options = Object.assign({}, options);
  4198. this.elements = [];
  4199. external_jQuery_default()('[data-grav-selectize]').each(function (index, element) {
  4200. return _this.add(element);
  4201. });
  4202. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  4203. }
  4204. selectize_createClass(SelectizeField, [{
  4205. key: "add",
  4206. value: function add(element) {
  4207. element = external_jQuery_default()(element);
  4208. if (element.closest('template').length) {
  4209. return false;
  4210. }
  4211. var tag = element.prop('tagName').toLowerCase();
  4212. var isInput = tag === 'input' || tag === 'select';
  4213. var data = (isInput ? element.closest('[data-grav-selectize]') : element).data('grav-selectize') || {};
  4214. var field = isInput ? element : element.find('input, select');
  4215. if (field.attr('name') === 'data[route]') {
  4216. data = external_jQuery_default().extend({}, data, {
  4217. render: PagesRoute
  4218. });
  4219. }
  4220. if (!field.length || field.get(0).selectize) {
  4221. return;
  4222. }
  4223. var plugins = external_jQuery_default().merge(data.plugins ? data.plugins : [], ['required-fix']);
  4224. field.selectize(external_jQuery_default().extend({}, data, {
  4225. plugins: plugins
  4226. }));
  4227. this.elements.push(field.data('selectize'));
  4228. }
  4229. }, {
  4230. key: "_onAddedNodes",
  4231. value: function _onAddedNodes(event, target
  4232. /* , record, instance */
  4233. ) {
  4234. var _this2 = this;
  4235. var fields = external_jQuery_default()(target).find('select.fancy, input.fancy, [data-grav-selectize]').filter(function (index, element) {
  4236. return !external_jQuery_default()(element).closest('template').length;
  4237. });
  4238. if (!fields.length) {
  4239. return;
  4240. }
  4241. fields.each(function (index, field) {
  4242. return _this2.add(field);
  4243. });
  4244. }
  4245. }]);
  4246. return SelectizeField;
  4247. }();
  4248. var selectize_Instance = new SelectizeField();
  4249. ;// CONCATENATED MODULE: ./app/forms/fields/array.js
  4250. function array_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4251. 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); } }
  4252. function array_createClass(Constructor, protoProps, staticProps) { if (protoProps) array_defineProperties(Constructor.prototype, protoProps); if (staticProps) array_defineProperties(Constructor, staticProps); return Constructor; }
  4253. var body = external_jQuery_default()('body');
  4254. var Template = /*#__PURE__*/function () {
  4255. function Template(container) {
  4256. array_classCallCheck(this, Template);
  4257. this.container = external_jQuery_default()(container);
  4258. if (this.getName() === undefined) {
  4259. this.container = this.container.closest('[data-grav-array-name]');
  4260. }
  4261. }
  4262. array_createClass(Template, [{
  4263. key: "getName",
  4264. value: function getName() {
  4265. return this.container.data('grav-array-name') || '';
  4266. }
  4267. }, {
  4268. key: "getKeyPlaceholder",
  4269. value: function getKeyPlaceholder() {
  4270. return this.container.data('grav-array-keyname') || 'Key';
  4271. }
  4272. }, {
  4273. key: "getValuePlaceholder",
  4274. value: function getValuePlaceholder() {
  4275. return this.container.data('grav-array-valuename') || 'Value';
  4276. }
  4277. }, {
  4278. key: "isValueOnly",
  4279. value: function isValueOnly() {
  4280. return this.container.find('[data-grav-array-mode="value_only"]:first').length || false;
  4281. }
  4282. }, {
  4283. key: "isTextArea",
  4284. value: function isTextArea() {
  4285. return this.container.data('grav-array-textarea') || false;
  4286. }
  4287. }, {
  4288. key: "shouldBeDisabled",
  4289. value: function shouldBeDisabled() {
  4290. // check for toggleables, if field is toggleable and it's not enabled, render disabled
  4291. var toggle = this.container.closest('.form-field').find('[data-grav-field="toggleable"] input[type="checkbox"]');
  4292. return toggle.length && toggle.is(':not(:checked)');
  4293. }
  4294. }, {
  4295. key: "getNewRow",
  4296. value: function getNewRow() {
  4297. var tpl = '';
  4298. 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(), "\" />");
  4299. if (this.isValueOnly()) {
  4300. 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 ");
  4301. } else {
  4302. 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 ");
  4303. }
  4304. 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>";
  4305. return tpl;
  4306. }
  4307. }]);
  4308. return Template;
  4309. }();
  4310. var ArrayField = /*#__PURE__*/function () {
  4311. function ArrayField() {
  4312. var _this = this;
  4313. array_classCallCheck(this, ArrayField);
  4314. body.on('input', '[data-grav-array-type="key"], [data-grav-array-type="value"]', function (event) {
  4315. return _this.actionInput(event);
  4316. });
  4317. body.on('click touch', '[data-grav-array-action]:not([data-grav-array-action="sort"])', function (event) {
  4318. return _this.actionEvent(event);
  4319. });
  4320. this.arrays = external_jQuery_default()();
  4321. external_jQuery_default()('[data-grav-field="array"]').each(function (index, list) {
  4322. return _this.addArray(list);
  4323. });
  4324. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  4325. }
  4326. array_createClass(ArrayField, [{
  4327. key: "addArray",
  4328. value: function addArray(list) {
  4329. var _this2 = this;
  4330. list = external_jQuery_default()(list);
  4331. list.find('[data-grav-array-type="container"]').each(function (index, container) {
  4332. container = external_jQuery_default()(container);
  4333. if (container.data('array-sort') || container[0].hasAttribute('data-array-nosort')) {
  4334. return;
  4335. }
  4336. container.data('array-sort', new sortable_esm/* default */.ZP(container.get(0), {
  4337. handle: '.fa-bars',
  4338. animation: 150,
  4339. onUpdate: function onUpdate() {
  4340. var item = container.find('[data-grav-array-type="row"]:first');
  4341. _this2._setTemplate(item);
  4342. var template = item.data('array-template');
  4343. _this2.refreshNames(template);
  4344. }
  4345. }));
  4346. });
  4347. }
  4348. }, {
  4349. key: "actionInput",
  4350. value: function actionInput(event) {
  4351. var element = external_jQuery_default()(event.target);
  4352. var type = element.data('grav-array-type');
  4353. this._setTemplate(element);
  4354. var template = element.data('array-template');
  4355. var keyElement = type === 'key' ? element : element.siblings('[data-grav-array-type="key"]:first');
  4356. var valueElement = type === 'value' ? element : element.siblings('[data-grav-array-type="value"]:first');
  4357. var escaped_name = !template.isValueOnly() ? keyElement.val() : this.getIndexFor(element);
  4358. escaped_name = escaped_name.toString().replace(/\[/g, '%5B').replace(/]/g, '%5D');
  4359. var name = "".concat(template.getName(), "[").concat(escaped_name, "]");
  4360. if (!template.isValueOnly() && !keyElement.val() && !valueElement.val()) {
  4361. valueElement.attr('name', '');
  4362. } else {
  4363. // valueElement.attr('name', !valueElement.val() ? template.getName() : name);
  4364. valueElement.attr('name', name);
  4365. }
  4366. this.refreshNames(template);
  4367. }
  4368. }, {
  4369. key: "actionEvent",
  4370. value: function actionEvent(event) {
  4371. event && event.preventDefault();
  4372. var element = external_jQuery_default()(event.target);
  4373. var action = element.data('grav-array-action');
  4374. var container = element.parents('[data-grav-array-type="container"]');
  4375. this._setTemplate(element);
  4376. this["".concat(action, "Action")](element);
  4377. var siblings = container.find('> div');
  4378. container[siblings.length > 1 ? 'removeClass' : 'addClass']('one-child');
  4379. }
  4380. }, {
  4381. key: "addAction",
  4382. value: function addAction(element) {
  4383. var template = element.data('array-template');
  4384. var row = element.closest('[data-grav-array-type="row"]');
  4385. row.after(template.getNewRow());
  4386. }
  4387. }, {
  4388. key: "remAction",
  4389. value: function remAction(element) {
  4390. var template = element.data('array-template');
  4391. var row = element.closest('[data-grav-array-type="row"]');
  4392. var isLast = !row.siblings().length;
  4393. if (isLast) {
  4394. var newRow = external_jQuery_default()(template.getNewRow());
  4395. row.after(newRow);
  4396. newRow.find('[data-grav-array-type="value"]:last').attr('name', template.getName());
  4397. }
  4398. row.remove();
  4399. this.refreshNames(template);
  4400. }
  4401. }, {
  4402. key: "refreshNames",
  4403. value: function refreshNames(template) {
  4404. if (!template.isValueOnly()) {
  4405. return;
  4406. }
  4407. var row = template.container.find('> div > [data-grav-array-type="row"]');
  4408. var inputs = row.find('[name]:not([name=""])');
  4409. inputs.each(function (index, input) {
  4410. input = external_jQuery_default()(input);
  4411. var preserved_name = input.closest('[data-grav-array-name]');
  4412. var name = "".concat(preserved_name.attr('data-grav-array-name'), "[").concat(index, "]");
  4413. input.attr('name', name);
  4414. });
  4415. if (!inputs.length) {
  4416. row.find('[data-grav-array-type="value"]').attr('name', template.getName());
  4417. }
  4418. }
  4419. }, {
  4420. key: "getIndexFor",
  4421. value: function getIndexFor(element) {
  4422. var template = element.data('array-template');
  4423. var row = element.closest('[data-grav-array-type="row"]');
  4424. return template.container.find("".concat(template.isValueOnly() ? '> div ' : '', " > [data-grav-array-type=\"row\"]")).index(row);
  4425. }
  4426. }, {
  4427. key: "_setTemplate",
  4428. value: function _setTemplate(element) {
  4429. if (!element.data('array-template')) {
  4430. element.data('array-template', new Template(element.closest('[data-grav-array-name]')));
  4431. }
  4432. }
  4433. }, {
  4434. key: "_onAddedNodes",
  4435. value: function _onAddedNodes(event, target
  4436. /* , record, instance */
  4437. ) {
  4438. var _this3 = this;
  4439. var arrays = external_jQuery_default()(target).find('[data-grav-field="array"]');
  4440. if (!arrays.length) {
  4441. return;
  4442. }
  4443. arrays.each(function (index, list) {
  4444. list = external_jQuery_default()(list);
  4445. if (!~_this3.arrays.index(list)) {
  4446. _this3.addArray(list);
  4447. }
  4448. });
  4449. }
  4450. }]);
  4451. return ArrayField;
  4452. }();
  4453. var array_Instance = new ArrayField();
  4454. ;// CONCATENATED MODULE: ./app/forms/fields/collections.js
  4455. function collections_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4456. 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); } }
  4457. function collections_createClass(Constructor, protoProps, staticProps) { if (protoProps) collections_defineProperties(Constructor.prototype, protoProps); if (staticProps) collections_defineProperties(Constructor, staticProps); return Constructor; }
  4458. var CollectionsField = /*#__PURE__*/function () {
  4459. function CollectionsField() {
  4460. var _this = this;
  4461. collections_classCallCheck(this, CollectionsField);
  4462. this.lists = external_jQuery_default()();
  4463. external_jQuery_default()('[data-type="collection"]').each(function (index, list) {
  4464. return _this.addList(list);
  4465. });
  4466. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  4467. }
  4468. collections_createClass(CollectionsField, [{
  4469. key: "addList",
  4470. value: function addList(list) {
  4471. var _this2 = this;
  4472. list = external_jQuery_default()(list);
  4473. this.lists = this.lists.add(list);
  4474. list.on('click', '> .collection-actions [data-action="add"]', function (event) {
  4475. return _this2.addItem(event);
  4476. });
  4477. list.on('click', '> ul > li > .item-actions [data-action="delete"]', function (event) {
  4478. return _this2.removeItem(event);
  4479. });
  4480. list.on('click', '> ul > li > .item-actions [data-action="collapse"]', function (event) {
  4481. return _this2.collapseItem(event);
  4482. });
  4483. list.on('click', '> ul > li > .item-actions [data-action="expand"]', function (event) {
  4484. return _this2.expandItem(event);
  4485. });
  4486. list.on('click', '> .collection-actions [data-action-sort="date"]', function (event) {
  4487. return _this2.sortItems(event);
  4488. });
  4489. list.on('click', '> .collection-actions [data-action="collapse_all"]', function (event) {
  4490. return _this2.collapseItems(event);
  4491. });
  4492. list.on('click', '> .collection-actions [data-action="expand_all"]', function (event) {
  4493. return _this2.expandItems(event);
  4494. });
  4495. list.on('input change', '[data-key-observe]', function (event) {
  4496. return _this2.observeKey(event);
  4497. });
  4498. list.find('[data-collection-holder]').each(function (index, container) {
  4499. container = external_jQuery_default()(container);
  4500. if (container.data('collection-sort') || container[0].hasAttribute('data-collection-nosort')) {
  4501. return;
  4502. }
  4503. container.data('collection-sort', new sortable_esm/* default */.ZP(container.get(0), {
  4504. forceFallback: false,
  4505. handle: '.collection-sort',
  4506. animation: 150,
  4507. onUpdate: function onUpdate() {
  4508. return _this2.reindex(container);
  4509. }
  4510. }));
  4511. });
  4512. this._updateActionsStateBasedOnMinMax(list);
  4513. }
  4514. }, {
  4515. key: "addItem",
  4516. value: function addItem(event) {
  4517. var button = external_jQuery_default()(event.currentTarget);
  4518. var position = button.data('action-add') || 'bottom';
  4519. var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
  4520. var template = external_jQuery_default()(list.find('> [data-collection-template="new"]').data('collection-template-html'));
  4521. this._updateActionsStateBasedOnMinMax(list);
  4522. var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4523. var maxItems = list.data('max');
  4524. if (typeof maxItems !== 'undefined' && items.length >= maxItems) {
  4525. return;
  4526. }
  4527. list.find('> [data-collection-holder]')[position === 'top' ? 'prepend' : 'append'](template);
  4528. this.reindex(list);
  4529. items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4530. var topAction = list.closest('[data-type="collection"]').find('[data-action-add="top"]');
  4531. var sortAction = list.closest('[data-type="collection"]').find('[data-action="sort"]');
  4532. if (items.length) {
  4533. if (topAction.length) {
  4534. topAction.parent().removeClass('hidden');
  4535. }
  4536. if (sortAction.length && items.length > 1) {
  4537. sortAction.removeClass('hidden');
  4538. }
  4539. } // refresh toggleables in a list
  4540. external_jQuery_default()('[data-grav-field="toggleable"] input[type="checkbox"]').trigger('change');
  4541. }
  4542. }, {
  4543. key: "removeItem",
  4544. value: function removeItem(event) {
  4545. var button = external_jQuery_default()(event.currentTarget);
  4546. var item = button.closest('[data-collection-item]');
  4547. var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
  4548. var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4549. var minItems = list.data('min');
  4550. if (typeof minItems !== 'undefined' && items.length <= minItems) {
  4551. return;
  4552. }
  4553. item.remove();
  4554. this.reindex(list);
  4555. items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4556. var topAction = list.closest('[data-type="collection"]').find('[data-action-add="top"]');
  4557. var sortAction = list.closest('[data-type="collection"]').find('[data-action="sort"]');
  4558. if (!items.length) {
  4559. if (topAction.length) {
  4560. topAction.parent().addClass('hidden');
  4561. }
  4562. }
  4563. if (sortAction.length && items.length <= 1) {
  4564. sortAction.addClass('hidden');
  4565. }
  4566. this._updateActionsStateBasedOnMinMax(list);
  4567. }
  4568. }, {
  4569. key: "collapseItems",
  4570. value: function collapseItems(event) {
  4571. var button = external_jQuery_default()(event.currentTarget);
  4572. var items = external_jQuery_default()(button.closest('[data-type="collection"]')).find('> ul > [data-collection-item] > .item-actions [data-action="collapse"]');
  4573. items.click();
  4574. }
  4575. }, {
  4576. key: "collapseItem",
  4577. value: function collapseItem(event) {
  4578. var button = external_jQuery_default()(event.currentTarget);
  4579. var item = button.closest('[data-collection-item]');
  4580. button.attr('data-action', 'expand').removeClass('fa-chevron-circle-down').addClass('fa-chevron-circle-right');
  4581. item.addClass('collection-collapsed');
  4582. }
  4583. }, {
  4584. key: "expandItems",
  4585. value: function expandItems(event) {
  4586. var button = external_jQuery_default()(event.currentTarget);
  4587. var items = external_jQuery_default()(button.closest('[data-type="collection"]')).find('> ul > [data-collection-item] > .item-actions [data-action="expand"]');
  4588. items.click();
  4589. }
  4590. }, {
  4591. key: "expandItem",
  4592. value: function expandItem(event) {
  4593. var button = external_jQuery_default()(event.currentTarget);
  4594. var item = button.closest('[data-collection-item]');
  4595. button.attr('data-action', 'collapse').removeClass('fa-chevron-circle-right').addClass('fa-chevron-circle-down');
  4596. item.removeClass('collection-collapsed');
  4597. }
  4598. }, {
  4599. key: "sortItems",
  4600. value: function sortItems(event) {
  4601. var button = external_jQuery_default()(event.currentTarget);
  4602. var sortby = button.data('action-sort');
  4603. var sortby_dir = button.data('action-sort-dir') || 'asc';
  4604. var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
  4605. var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4606. items.sort(function (a, b) {
  4607. var A = external_jQuery_default()(a).find('[name$="[' + sortby + ']"]');
  4608. var B = external_jQuery_default()(b).find('[name$="[' + sortby + ']"]');
  4609. var sort;
  4610. if (sortby_dir === 'asc') {
  4611. sort = A.val() < B.val() ? -1 : A.val() > B.val() ? 1 : 0;
  4612. } else {
  4613. sort = A.val() > B.val() ? -1 : A.val() < B.val() ? 1 : 0;
  4614. }
  4615. return sort;
  4616. }).each(function (_, container) {
  4617. external_jQuery_default()(container).parent().append(container);
  4618. });
  4619. this.reindex(list);
  4620. }
  4621. }, {
  4622. key: "observeKey",
  4623. value: function observeKey(event) {
  4624. var input = external_jQuery_default()(event.target);
  4625. var value = input.val();
  4626. var item = input.closest('[data-collection-key]');
  4627. item.data('collection-key-backup', item.data('collection-key')).data('collection-key', value);
  4628. this.reindex(null, item);
  4629. }
  4630. }, {
  4631. key: "reindex",
  4632. value: function reindex(list, items) {
  4633. items = items || external_jQuery_default()(list).closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4634. items.each(function (index, item) {
  4635. item = external_jQuery_default()(item);
  4636. var observed = item.find('[data-key-observe]');
  4637. var observedValue = observed.val();
  4638. var hasCustomKey = observed.length;
  4639. var currentKey = item.data('collection-key-backup');
  4640. item.attr('data-collection-key', hasCustomKey ? observedValue : index);
  4641. ['name', 'data-grav-field-name', 'for', 'id', 'data-grav-file-settings', 'data-file-post-add', 'data-file-post-remove', 'data-grav-array-name'].forEach(function (prop) {
  4642. item.find('[' + prop + '], [_' + prop + ']').each(function () {
  4643. var element = external_jQuery_default()(this);
  4644. var indexes = [];
  4645. var array_index = null;
  4646. var regexps = [new RegExp('\\[(\\d+|\\*|' + currentKey + ')\\]', 'g'), new RegExp('\\.(\\d+|\\*|' + currentKey + ')\\.', 'g')]; // special case to preserve array field index keys
  4647. if (prop === 'name' && element.data('gravArrayType')) {
  4648. var match_index = element.attr(prop).match(/\[[0-9]{1,}\]$/);
  4649. var pattern = element[0].closest('[data-grav-array-name]').dataset.gravArrayName;
  4650. if (match_index && pattern) {
  4651. array_index = match_index[0];
  4652. element.attr(prop, "".concat(pattern).concat(match_index[0]));
  4653. return;
  4654. }
  4655. }
  4656. if (hasCustomKey && !observedValue) {
  4657. element.attr("_".concat(prop), element.attr(prop));
  4658. element.attr(prop, null);
  4659. return;
  4660. }
  4661. if (element.attr("_".concat(prop))) {
  4662. element.attr(prop, element.attr("_".concat(prop)));
  4663. element.attr("_".concat(prop), null);
  4664. }
  4665. element.parents('[data-collection-key]').map(function (idx, parent) {
  4666. return indexes.push(external_jQuery_default()(parent).attr('data-collection-key'));
  4667. });
  4668. indexes.reverse();
  4669. var matchedKey = currentKey;
  4670. var replaced = element.attr(prop).replace(regexps[0], function ()
  4671. /* str, p1, offset */
  4672. {
  4673. var extras = '';
  4674. if (array_index) {
  4675. extras = array_index;
  4676. console.log(indexes, extras);
  4677. }
  4678. matchedKey = indexes.shift() || matchedKey;
  4679. return "[".concat(matchedKey, "]").concat(extras);
  4680. });
  4681. replaced = replaced.replace(regexps[1], function ()
  4682. /* str, p1, offset */
  4683. {
  4684. matchedKey = indexes.shift() || matchedKey;
  4685. return ".".concat(matchedKey, ".");
  4686. });
  4687. element.attr(prop, replaced);
  4688. });
  4689. });
  4690. });
  4691. }
  4692. }, {
  4693. key: "_onAddedNodes",
  4694. value: function _onAddedNodes(event, target
  4695. /* , record, instance */
  4696. ) {
  4697. var _this3 = this;
  4698. var collections = external_jQuery_default()(target).find('[data-type="collection"]');
  4699. if (!collections.length) {
  4700. return;
  4701. }
  4702. collections.each(function (index, collection) {
  4703. collection = external_jQuery_default()(collection);
  4704. if (!~_this3.lists.index(collection)) {
  4705. _this3.addList(collection);
  4706. }
  4707. });
  4708. }
  4709. }, {
  4710. key: "_updateActionsStateBasedOnMinMax",
  4711. value: function _updateActionsStateBasedOnMinMax(list) {
  4712. var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
  4713. var minItems = list.data('min');
  4714. var maxItems = list.data('max');
  4715. list.find('> .collection-actions [data-action="add"]').attr('disabled', false);
  4716. list.find('> ul > li > .item-actions [data-action="delete"]').attr('disabled', false);
  4717. if (typeof minItems !== 'undefined' && items.length <= minItems) {
  4718. list.find('> ul > li > .item-actions [data-action="delete"]').attr('disabled', true);
  4719. }
  4720. if (typeof maxItems !== 'undefined' && items.length >= maxItems) {
  4721. list.find('> .collection-actions [data-action="add"]').attr('disabled', true);
  4722. }
  4723. }
  4724. }]);
  4725. return CollectionsField;
  4726. }();
  4727. var collections_Instance = new CollectionsField();
  4728. // EXTERNAL MODULE: ./app/utils/bootstrap-datetimepicker.js
  4729. var bootstrap_datetimepicker = __webpack_require__(36531);
  4730. ;// CONCATENATED MODULE: ./app/forms/fields/datetime.js
  4731. function datetime_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4732. 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); } }
  4733. function datetime_createClass(Constructor, protoProps, staticProps) { if (protoProps) datetime_defineProperties(Constructor.prototype, protoProps); if (staticProps) datetime_defineProperties(Constructor, staticProps); return Constructor; }
  4734. var DateTimeField = /*#__PURE__*/function () {
  4735. function DateTimeField(options) {
  4736. var _this = this;
  4737. datetime_classCallCheck(this, DateTimeField);
  4738. this.items = external_jQuery_default()();
  4739. this.options = Object.assign({}, this.defaults, options);
  4740. external_jQuery_default()('[data-grav-datetime]').each(function (index, field) {
  4741. return _this.addItem(field);
  4742. });
  4743. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  4744. }
  4745. datetime_createClass(DateTimeField, [{
  4746. key: "defaults",
  4747. get: function get() {
  4748. return {
  4749. showTodayButton: true,
  4750. showClear: true,
  4751. locale: external_GravAdmin_namespaceObject.config.language || 'en',
  4752. icons: {
  4753. time: 'fa fa-clock-o',
  4754. date: 'fa fa-calendar-o',
  4755. up: 'fa fa-chevron-up',
  4756. down: 'fa fa-chevron-down',
  4757. previous: 'fa fa-chevron-left',
  4758. next: 'fa fa-chevron-right',
  4759. today: 'fa fa-bullseye',
  4760. clear: 'fa fa-trash-o',
  4761. close: 'fa fa-remove'
  4762. }
  4763. };
  4764. }
  4765. }, {
  4766. key: "addItem",
  4767. value: function addItem(list) {
  4768. list = external_jQuery_default()(list);
  4769. this.items = this.items.add(list);
  4770. if (list.data('DateTimePicker')) {
  4771. return;
  4772. }
  4773. var options = Object.assign({}, this.options, list.data('grav-datetime') || {});
  4774. list.datetimepicker(options).on('dp.show dp.update', this._disableDecades);
  4775. list.siblings('.field-icons').on('click', function () {
  4776. return list.mousedown().focus();
  4777. });
  4778. }
  4779. }, {
  4780. key: "_onAddedNodes",
  4781. value: function _onAddedNodes(event, target
  4782. /* , record, instance */
  4783. ) {
  4784. var _this2 = this;
  4785. var fields = external_jQuery_default()(target).find('[data-grav-datetime]');
  4786. if (!fields.length) {
  4787. return;
  4788. }
  4789. fields.each(function (index, field) {
  4790. field = external_jQuery_default()(field);
  4791. if (!~_this2.items.index(field)) {
  4792. _this2.addItem(field);
  4793. }
  4794. });
  4795. }
  4796. }, {
  4797. key: "_disableDecades",
  4798. value: function _disableDecades() {
  4799. external_jQuery_default()('.datepicker-years .picker-switch').removeAttr('title').on('click', function (e) {
  4800. return e.stopPropagation();
  4801. });
  4802. }
  4803. }]);
  4804. return DateTimeField;
  4805. }();
  4806. var datetime_Instance = new DateTimeField();
  4807. // EXTERNAL MODULE: ./node_modules/mout/math/clamp.js
  4808. var clamp = __webpack_require__(19188);
  4809. var clamp_default = /*#__PURE__*/__webpack_require__.n(clamp);
  4810. // EXTERNAL MODULE: ./node_modules/mout/function/bind.js
  4811. var bind = __webpack_require__(84596);
  4812. var bind_default = /*#__PURE__*/__webpack_require__.n(bind);
  4813. ;// CONCATENATED MODULE: ./app/utils/colors.js
  4814. // Parses a string and returns a valid hex string when possible
  4815. // parseHex('#fff') => '#ffffff'
  4816. var parseHex = function parseHex(string) {
  4817. string = string.replace(/[^A-F0-9]/ig, '');
  4818. if (string.length !== 3 && string.length !== 6) return '';
  4819. if (string.length === 3) {
  4820. string = string[0] + string[0] + string[1] + string[1] + string[2] + string[2];
  4821. }
  4822. return '#' + string.toLowerCase();
  4823. }; // Converts an HSB object to an RGB object
  4824. // hsb2rgb({h: 0, s: 0, b: 100}) => {r: 255, g: 255, b: 255}
  4825. var hsb2rgb = function hsb2rgb(hsb) {
  4826. var rgb = {};
  4827. var h = Math.round(hsb.h);
  4828. var s = Math.round(hsb.s * 255 / 100);
  4829. var v = Math.round(hsb.b * 255 / 100);
  4830. if (s === 0) {
  4831. rgb.r = rgb.g = rgb.b = v;
  4832. } else {
  4833. var t1 = v;
  4834. var t2 = (255 - s) * v / 255;
  4835. var t3 = (t1 - t2) * (h % 60) / 60;
  4836. if (h === 360) h = 0;
  4837. if (h < 60) {
  4838. rgb.r = t1;
  4839. rgb.b = t2;
  4840. rgb.g = t2 + t3;
  4841. } else if (h < 120) {
  4842. rgb.g = t1;
  4843. rgb.b = t2;
  4844. rgb.r = t1 - t3;
  4845. } else if (h < 180) {
  4846. rgb.g = t1;
  4847. rgb.r = t2;
  4848. rgb.b = t2 + t3;
  4849. } else if (h < 240) {
  4850. rgb.b = t1;
  4851. rgb.r = t2;
  4852. rgb.g = t1 - t3;
  4853. } else if (h < 300) {
  4854. rgb.b = t1;
  4855. rgb.g = t2;
  4856. rgb.r = t2 + t3;
  4857. } else if (h < 360) {
  4858. rgb.r = t1;
  4859. rgb.g = t2;
  4860. rgb.b = t1 - t3;
  4861. } else {
  4862. rgb.r = 0;
  4863. rgb.g = 0;
  4864. rgb.b = 0;
  4865. }
  4866. }
  4867. return {
  4868. r: Math.round(rgb.r),
  4869. g: Math.round(rgb.g),
  4870. b: Math.round(rgb.b)
  4871. };
  4872. }; // Converts an RGB object to a HEX string
  4873. // rgb2hex({r: 255, g: 255, b: 255}) => #ffffff
  4874. var rgb2hex = function rgb2hex(rgb) {
  4875. var hex = [rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)];
  4876. hex.forEach(function (val, nr) {
  4877. if (val.length === 1) hex[nr] = '0' + val;
  4878. });
  4879. return '#' + hex.join('');
  4880. }; // Converts and RGB(a) string to a HEX string
  4881. // rgbstr2hex('rgba(255, 255, 255, 0.5)') => #ffffff
  4882. var rgbstr2hex = function rgbstr2hex(rgb) {
  4883. rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  4884. 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) : '';
  4885. }; // Converts an HSB object to a HEX string
  4886. // hsb2hex({h: 0, s: 0, b: 100}) => #ffffff
  4887. var hsb2hex = function hsb2hex(hsb) {
  4888. return rgb2hex(hsb2rgb(hsb));
  4889. }; // Converts a HEX string to an HSB object
  4890. // hex2hsb('#ffffff') => {h: 0, s: 0, b: 100}
  4891. var hex2hsb = function hex2hsb(hex) {
  4892. var hsb = rgb2hsb(hex2rgb(hex));
  4893. if (hsb.s === 0) hsb.h = 360;
  4894. return hsb;
  4895. }; // Converts an RGB object to an HSB object
  4896. // rgb2hsb({r: 255, g: 255, b: 255}) => {h: 0, s: 0, b: 100}
  4897. var rgb2hsb = function rgb2hsb(rgb) {
  4898. var hsb = {
  4899. h: 0,
  4900. s: 0,
  4901. b: 0
  4902. };
  4903. var min = Math.min(rgb.r, rgb.g, rgb.b);
  4904. var max = Math.max(rgb.r, rgb.g, rgb.b);
  4905. var delta = max - min;
  4906. hsb.b = max;
  4907. hsb.s = max !== 0 ? 255 * delta / max : 0;
  4908. if (hsb.s !== 0) {
  4909. if (rgb.r === max) {
  4910. hsb.h = (rgb.g - rgb.b) / delta;
  4911. } else if (rgb.g === max) {
  4912. hsb.h = 2 + (rgb.b - rgb.r) / delta;
  4913. } else {
  4914. hsb.h = 4 + (rgb.r - rgb.g) / delta;
  4915. }
  4916. } else {
  4917. hsb.h = -1;
  4918. }
  4919. hsb.h *= 60;
  4920. if (hsb.h < 0) {
  4921. hsb.h += 360;
  4922. }
  4923. hsb.s *= 100 / 255;
  4924. hsb.b *= 100 / 255;
  4925. return hsb;
  4926. }; // Converts a HEX string to an RGB object
  4927. // hex2rgb('#ffffff') => {r: 255, g: 255, b: 255}
  4928. var hex2rgb = function hex2rgb(hex) {
  4929. hex = parseInt(hex.indexOf('#') > -1 ? hex.substring(1) : hex, 16);
  4930. return {
  4931. /* jshint ignore:start */
  4932. r: hex >> 16,
  4933. g: (hex & 0x00FF00) >> 8,
  4934. b: hex & 0x0000FF
  4935. /* jshint ignore:end */
  4936. };
  4937. };
  4938. ;// CONCATENATED MODULE: ./app/forms/fields/colorpicker.js
  4939. function colorpicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4940. 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); } }
  4941. function colorpicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) colorpicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) colorpicker_defineProperties(Constructor, staticProps); return Constructor; }
  4942. var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  4943. var colorpicker_body = external_jQuery_default()('body');
  4944. var MOUSEDOWN = 'mousedown touchstart MSPointerDown pointerdown';
  4945. var MOUSEMOVE = 'mousemove touchmove MSPointerMove pointermove';
  4946. var MOUSEUP = 'mouseup touchend MSPointerUp pointerup';
  4947. var FOCUSIN = isFirefox ? 'focus' : 'focusin';
  4948. var ColorpickerField = /*#__PURE__*/function () {
  4949. function ColorpickerField(selector) {
  4950. var _this = this;
  4951. colorpicker_classCallCheck(this, ColorpickerField);
  4952. this.selector = selector;
  4953. this.field = external_jQuery_default()(this.selector);
  4954. this.options = Object.assign({}, this.field.data('grav-colorpicker'));
  4955. this.built = false;
  4956. this.attach();
  4957. if (this.options.update) {
  4958. this.field.on('change._grav_colorpicker', function (event, field, hex, opacity) {
  4959. var backgroundColor = hex;
  4960. var rgb = hex2rgb(hex);
  4961. if (opacity < 1) {
  4962. backgroundColor = 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + opacity + ')';
  4963. }
  4964. var target = field.closest(_this.options.update);
  4965. if (!target.length) {
  4966. target = field.siblings(_this.options.update);
  4967. }
  4968. if (!target.length) {
  4969. target = field.parent('.g-colorpicker').find(_this.options.update);
  4970. }
  4971. target.css({
  4972. backgroundColor: backgroundColor
  4973. });
  4974. });
  4975. }
  4976. }
  4977. colorpicker_createClass(ColorpickerField, [{
  4978. key: "attach",
  4979. value: function attach() {
  4980. var _this2 = this;
  4981. colorpicker_body.on(FOCUSIN, this.selector, function (event) {
  4982. return _this2.show(event, event.currentTarget);
  4983. });
  4984. colorpicker_body.on(MOUSEDOWN, this.selector + ' .g-colorpicker, ' + this.selector + ' .g-colorpicker i', this.bound('iconClick'));
  4985. colorpicker_body.on('keydown', this.selector, function (event) {
  4986. switch (event.keyCode) {
  4987. case 9:
  4988. // tab
  4989. _this2.hide();
  4990. break;
  4991. case 13: // enter
  4992. case 27:
  4993. // esc
  4994. _this2.hide();
  4995. event.currentTarget.blur();
  4996. break;
  4997. }
  4998. return true;
  4999. }); // Update on keyup
  5000. colorpicker_body.on('keyup', this.selector, function (event) {
  5001. _this2.updateFromInput(true, event.currentTarget);
  5002. return true;
  5003. }); // Update on paste
  5004. colorpicker_body.on('paste', this.selector, function (event) {
  5005. setTimeout(function () {
  5006. return _this2.updateFromInput(true, event.currentTarget);
  5007. }, 1);
  5008. });
  5009. }
  5010. }, {
  5011. key: "show",
  5012. value: function show(event, target) {
  5013. target = external_jQuery_default()(target);
  5014. if (!this.built) {
  5015. this.build();
  5016. }
  5017. this.element = target;
  5018. this.reposition();
  5019. this.wrapper.addClass('cp-visible');
  5020. this.updateFromInput();
  5021. this.wrapper.on(MOUSEDOWN, '.cp-grid, .cp-slider, .cp-opacity-slider', this.bound('bodyDown'));
  5022. colorpicker_body.on(MOUSEMOVE, this.bound('bodyMove'));
  5023. colorpicker_body.on(MOUSEDOWN, this.bound('bodyClick'));
  5024. colorpicker_body.on(MOUSEUP, this.bound('targetReset'));
  5025. external_jQuery_default()('#admin-main > .content-wrapper').on('scroll', this.bound('reposition'));
  5026. }
  5027. }, {
  5028. key: "hide",
  5029. value: function hide() {
  5030. if (!this.built) {
  5031. return;
  5032. }
  5033. this.wrapper.removeClass('cp-visible');
  5034. this.wrapper.undelegate(MOUSEDOWN, '.cp-grid, .cp-slider, .cp-opacity-slider', this.bound('bodyDown'));
  5035. colorpicker_body.off(MOUSEMOVE, this.bound('bodyMove'));
  5036. colorpicker_body.off(MOUSEDOWN, this.bound('bodyClick'));
  5037. colorpicker_body.off(MOUSEUP, this.bound('targetReset'));
  5038. external_jQuery_default()('#admin-main > .content-wrapper').on('scroll', this.bound('reposition'));
  5039. }
  5040. }, {
  5041. key: "build",
  5042. value: function build() {
  5043. var _this3 = this;
  5044. this.wrapper = external_jQuery_default()('<div class="cp-wrapper cp-with-opacity cp-mode-hue" />');
  5045. this.slider = external_jQuery_default()('<div class="cp-slider cp-sprite" />').appendTo(this.wrapper).append(external_jQuery_default()('<div class="cp-picker" />'));
  5046. this.opacitySlider = external_jQuery_default()('<div class="cp-opacity-slider cp-sprite" />').appendTo(this.wrapper).append(external_jQuery_default()('<div class="cp-picker" />'));
  5047. 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" />'));
  5048. external_jQuery_default()('<div />').appendTo(this.grid.find('.cp-picker'));
  5049. var tabs = external_jQuery_default()('<div class="cp-tabs" />').appendTo(this.wrapper);
  5050. this.tabs = {
  5051. hue: external_jQuery_default()('<div class="cp-tab-hue active" />').text('HUE').appendTo(tabs),
  5052. brightness: external_jQuery_default()('<div class="cp-tab-brightness" />').text('BRI').appendTo(tabs),
  5053. saturation: external_jQuery_default()('<div class="cp-tab-saturation" />').text('SAT').appendTo(tabs),
  5054. wheel: external_jQuery_default()('<div class="cp-tab-wheel" />').text('WHEEL').appendTo(tabs),
  5055. transparent: external_jQuery_default()('<div class="cp-tab-transp" />').text('TRANSPARENT').appendTo(tabs)
  5056. };
  5057. tabs.on(MOUSEDOWN, '> div', function (event) {
  5058. var element = external_jQuery_default()(event.currentTarget);
  5059. if (element.is(_this3.tabs.transparent)) {
  5060. var sliderHeight = _this3.opacitySlider.height();
  5061. _this3.opacity = 0;
  5062. _this3.opacitySlider.find('.cp-picker').css({
  5063. 'top': clamp_default()(sliderHeight - sliderHeight * _this3.opacity, 0, sliderHeight)
  5064. });
  5065. _this3.move(_this3.opacitySlider, {
  5066. manualOpacity: true
  5067. });
  5068. return;
  5069. }
  5070. var active = tabs.find('.active');
  5071. var mode = active.attr('class').replace(/\s|active|cp-tab-/g, '');
  5072. var newMode = element.attr('class').replace(/\s|active|cp-tab-/g, '');
  5073. _this3.wrapper.removeClass('cp-mode-' + mode).addClass('cp-mode-' + newMode);
  5074. active.removeClass('active');
  5075. element.addClass('active');
  5076. _this3.mode = newMode;
  5077. _this3.updateFromInput();
  5078. });
  5079. this.wrapper.appendTo('.content-wrapper');
  5080. this.built = true;
  5081. this.mode = 'hue';
  5082. }
  5083. }, {
  5084. key: "reposition",
  5085. value: function reposition() {
  5086. var ct = external_jQuery_default()('.content-wrapper')[0];
  5087. var offset = this.element[0].getBoundingClientRect();
  5088. var ctOffset = ct.getBoundingClientRect();
  5089. var delta = {
  5090. x: 0,
  5091. y: 0
  5092. };
  5093. if (this.options.offset) {
  5094. delta.x = this.options.offset.x || 0;
  5095. delta.y = this.options.offset.y || 0;
  5096. }
  5097. this.wrapper.css({
  5098. top: offset.top + offset.height + ct.scrollTop - ctOffset.top + delta.y,
  5099. left: offset.left + ct.scrollLeft - ctOffset.left + delta.x
  5100. });
  5101. }
  5102. }, {
  5103. key: "iconClick",
  5104. value: function iconClick(event) {
  5105. if (this.wrapper && this.wrapper.hasClass('cp-visible')) {
  5106. return true;
  5107. }
  5108. event && event.preventDefault();
  5109. var input = external_jQuery_default()(event.currentTarget).find('input');
  5110. setTimeout(function () {
  5111. return input.focus();
  5112. }, 50);
  5113. }
  5114. }, {
  5115. key: "bodyMove",
  5116. value: function bodyMove(event) {
  5117. event && event.preventDefault();
  5118. if (this.target) {
  5119. this.move(this.target, event);
  5120. }
  5121. }
  5122. }, {
  5123. key: "bodyClick",
  5124. value: function bodyClick(event) {
  5125. var target = external_jQuery_default()(event.target);
  5126. if (!target.closest('.cp-wrapper').length && !target.is(this.selector)) {
  5127. this.hide();
  5128. }
  5129. }
  5130. }, {
  5131. key: "bodyDown",
  5132. value: function bodyDown(event) {
  5133. event && event.preventDefault();
  5134. this.target = external_jQuery_default()(event.currentTarget);
  5135. this.move(this.target, event, true);
  5136. }
  5137. }, {
  5138. key: "targetReset",
  5139. value: function targetReset(event) {
  5140. event && event.preventDefault();
  5141. this.target = null;
  5142. }
  5143. }, {
  5144. key: "move",
  5145. value: function move(target, event) {
  5146. var input = this.element;
  5147. var picker = target.find('.cp-picker');
  5148. var clientRect = target[0].getBoundingClientRect();
  5149. var offsetX = clientRect.left + window.scrollX;
  5150. var offsetY = clientRect.top + window.scrollY;
  5151. var x = Math.round((event ? event.pageX : 0) - offsetX);
  5152. var y = Math.round((event ? event.pageY : 0) - offsetY);
  5153. var wx;
  5154. var wy;
  5155. var r;
  5156. var phi; // Touch support
  5157. var touchEvents = event.changedTouches || event.originalEvent && event.originalEvent.changedTouches;
  5158. if (event && touchEvents) {
  5159. x = (touchEvents ? touchEvents[0].pageX : 0) - offsetX;
  5160. y = (touchEvents ? touchEvents[0].pageY : 0) - offsetY;
  5161. }
  5162. if (event && event.manualOpacity) {
  5163. y = clientRect.height;
  5164. } // Constrain picker to its container
  5165. if (x < 0) x = 0;
  5166. if (y < 0) y = 0;
  5167. if (x > clientRect.width) x = clientRect.width;
  5168. if (y > clientRect.height) y = clientRect.height; // Constrain color wheel values to the wheel
  5169. if (target.parent('.cp-mode-wheel').length && picker.parent('.cp-grid').length) {
  5170. wx = 75 - x;
  5171. wy = 75 - y;
  5172. r = Math.sqrt(wx * wx + wy * wy);
  5173. phi = Math.atan2(wy, wx);
  5174. if (phi < 0) phi += Math.PI * 2;
  5175. if (r > 75) {
  5176. x = 75 - 75 * Math.cos(phi);
  5177. y = 75 - 75 * Math.sin(phi);
  5178. }
  5179. x = Math.round(x);
  5180. y = Math.round(y);
  5181. } // Move the picker
  5182. if (target.hasClass('cp-grid')) {
  5183. picker.css({
  5184. top: y,
  5185. left: x
  5186. });
  5187. this.updateFromPicker(input, target);
  5188. } else {
  5189. picker.css({
  5190. top: y
  5191. });
  5192. this.updateFromPicker(input, target);
  5193. }
  5194. }
  5195. }, {
  5196. key: "updateFromInput",
  5197. value: function updateFromInput(dontFireEvent, element) {
  5198. element = element ? external_jQuery_default()(element) : this.element;
  5199. var value = element.val();
  5200. var opacity = value.replace(/\s/g, '').match(/^rgba?\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},(.+)\)/);
  5201. var hex;
  5202. var hsb;
  5203. value = rgbstr2hex(value) || value;
  5204. opacity = opacity ? clamp_default()(opacity[1], 0, 1) : 1;
  5205. if (!(hex = parseHex(value))) {
  5206. hex = '#ffffff';
  5207. }
  5208. hsb = hex2hsb(hex);
  5209. if (this.built) {
  5210. // opacity
  5211. this.opacity = opacity;
  5212. var sliderHeight = this.opacitySlider.height();
  5213. this.opacitySlider.find('.cp-picker').css({
  5214. 'top': clamp_default()(sliderHeight - sliderHeight * this.opacity, 0, sliderHeight)
  5215. }); // bg color
  5216. var gridHeight = this.grid.height();
  5217. var gridWidth = this.grid.width();
  5218. var r;
  5219. var phi;
  5220. var x;
  5221. var y;
  5222. sliderHeight = this.slider.height();
  5223. switch (this.mode) {
  5224. case 'wheel':
  5225. // Set grid position
  5226. r = clamp_default()(Math.ceil(hsb.s * 0.75), 0, gridHeight / 2);
  5227. phi = hsb.h * Math.PI / 180;
  5228. x = clamp_default()(75 - Math.cos(phi) * r, 0, gridWidth);
  5229. y = clamp_default()(75 - Math.sin(phi) * r, 0, gridHeight);
  5230. this.grid.css({
  5231. backgroundColor: 'transparent'
  5232. }).find('.cp-picker').css({
  5233. top: y,
  5234. left: x
  5235. }); // Set slider position
  5236. y = 150 - hsb.b / (100 / gridHeight);
  5237. if (hex === '') y = 0;
  5238. this.slider.find('.cp-picker').css({
  5239. top: y
  5240. }); // Update panel color
  5241. this.slider.css({
  5242. backgroundColor: hsb2hex({
  5243. h: hsb.h,
  5244. s: hsb.s,
  5245. b: 100
  5246. })
  5247. });
  5248. break;
  5249. case 'saturation':
  5250. // Set grid position
  5251. x = clamp_default()(5 * hsb.h / 12, 0, 150);
  5252. y = clamp_default()(gridHeight - Math.ceil(hsb.b / (100 / gridHeight)), 0, gridHeight);
  5253. this.grid.find('.cp-picker').css({
  5254. top: y,
  5255. left: x
  5256. }); // Set slider position
  5257. y = clamp_default()(sliderHeight - hsb.s * (sliderHeight / 100), 0, sliderHeight);
  5258. this.slider.find('.cp-picker').css({
  5259. top: y
  5260. }); // Update UI
  5261. this.slider.css({
  5262. backgroundColor: hsb2hex({
  5263. h: hsb.h,
  5264. s: 100,
  5265. b: hsb.b
  5266. })
  5267. });
  5268. this.grid.find('.cp-grid-inner').css({
  5269. opacity: hsb.s / 100
  5270. });
  5271. break;
  5272. case 'brightness':
  5273. // Set grid position
  5274. x = clamp_default()(5 * hsb.h / 12, 0, 150);
  5275. y = clamp_default()(gridHeight - Math.ceil(hsb.s / (100 / gridHeight)), 0, gridHeight);
  5276. this.grid.find('.cp-picker').css({
  5277. top: y,
  5278. left: x
  5279. }); // Set slider position
  5280. y = clamp_default()(sliderHeight - hsb.b * (sliderHeight / 100), 0, sliderHeight);
  5281. this.slider.find('.cp-picker').css({
  5282. top: y
  5283. }); // Update UI
  5284. this.slider.css({
  5285. backgroundColor: hsb2hex({
  5286. h: hsb.h,
  5287. s: hsb.s,
  5288. b: 100
  5289. })
  5290. });
  5291. this.grid.find('.cp-grid-inner').css({
  5292. opacity: 1 - hsb.b / 100
  5293. });
  5294. break;
  5295. case 'hue':
  5296. default:
  5297. // Set grid position
  5298. x = clamp_default()(Math.ceil(hsb.s / (100 / gridWidth)), 0, gridWidth);
  5299. y = clamp_default()(gridHeight - Math.ceil(hsb.b / (100 / gridHeight)), 0, gridHeight);
  5300. this.grid.find('.cp-picker').css({
  5301. top: y,
  5302. left: x
  5303. }); // Set slider position
  5304. y = clamp_default()(sliderHeight - hsb.h / (360 / sliderHeight), 0, sliderHeight);
  5305. this.slider.find('.cp-picker').css({
  5306. top: y
  5307. }); // Update panel color
  5308. this.grid.css({
  5309. backgroundColor: hsb2hex({
  5310. h: hsb.h,
  5311. s: 100,
  5312. b: 100
  5313. })
  5314. });
  5315. break;
  5316. }
  5317. }
  5318. if (!dontFireEvent) {
  5319. element.val(this.getValue(hex));
  5320. }
  5321. (this.element || element).trigger('change._grav_colorpicker', [element, hex, opacity]);
  5322. }
  5323. }, {
  5324. key: "updateFromPicker",
  5325. value: function updateFromPicker(input, target) {
  5326. var getCoords = function getCoords(picker, container) {
  5327. var left, top;
  5328. if (!picker.length || !container) return null;
  5329. left = picker[0].getBoundingClientRect().left;
  5330. top = picker[0].getBoundingClientRect().top;
  5331. return {
  5332. x: left - container[0].getBoundingClientRect().left + picker[0].offsetWidth / 2,
  5333. y: top - container[0].getBoundingClientRect().top + picker[0].offsetHeight / 2
  5334. };
  5335. };
  5336. var hex;
  5337. var hue;
  5338. var saturation;
  5339. var brightness;
  5340. var x;
  5341. var y;
  5342. var r;
  5343. var phi; // Panel objects
  5344. var grid = this.wrapper.find('.cp-grid');
  5345. var slider = this.wrapper.find('.cp-slider');
  5346. var opacitySlider = this.wrapper.find('.cp-opacity-slider'); // Picker objects
  5347. var gridPicker = grid.find('.cp-picker');
  5348. var sliderPicker = slider.find('.cp-picker');
  5349. var opacityPicker = opacitySlider.find('.cp-picker'); // Picker positions
  5350. var gridPos = getCoords(gridPicker, grid);
  5351. var sliderPos = getCoords(sliderPicker, slider);
  5352. var opacityPos = getCoords(opacityPicker, opacitySlider); // Sizes
  5353. var gridWidth = grid[0].getBoundingClientRect().width;
  5354. var gridHeight = grid[0].getBoundingClientRect().height;
  5355. var sliderHeight = slider[0].getBoundingClientRect().height;
  5356. var opacitySliderHeight = opacitySlider[0].getBoundingClientRect().height;
  5357. var value = this.element.val();
  5358. value = rgbstr2hex(value) || value;
  5359. if (!(hex = parseHex(value))) {
  5360. hex = '#ffffff';
  5361. } // Handle colors
  5362. if (target.hasClass('cp-grid') || target.hasClass('cp-slider')) {
  5363. // Determine HSB values
  5364. switch (this.mode) {
  5365. case 'wheel':
  5366. // Calculate hue, saturation, and brightness
  5367. x = gridWidth / 2 - gridPos.x;
  5368. y = gridHeight / 2 - gridPos.y;
  5369. r = Math.sqrt(x * x + y * y);
  5370. phi = Math.atan2(y, x);
  5371. if (phi < 0) phi += Math.PI * 2;
  5372. if (r > 75) {
  5373. r = 75;
  5374. gridPos.x = 69 - 75 * Math.cos(phi);
  5375. gridPos.y = 69 - 75 * Math.sin(phi);
  5376. }
  5377. saturation = clamp_default()(r / 0.75, 0, 100);
  5378. hue = clamp_default()(phi * 180 / Math.PI, 0, 360);
  5379. brightness = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
  5380. hex = hsb2hex({
  5381. h: hue,
  5382. s: saturation,
  5383. b: brightness
  5384. }); // Update UI
  5385. slider.css({
  5386. backgroundColor: hsb2hex({
  5387. h: hue,
  5388. s: saturation,
  5389. b: 100
  5390. })
  5391. });
  5392. break;
  5393. case 'saturation':
  5394. // Calculate hue, saturation, and brightness
  5395. hue = clamp_default()(parseInt(gridPos.x * (360 / gridWidth), 10), 0, 360);
  5396. saturation = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
  5397. brightness = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
  5398. hex = hsb2hex({
  5399. h: hue,
  5400. s: saturation,
  5401. b: brightness
  5402. }); // Update UI
  5403. slider.css({
  5404. backgroundColor: hsb2hex({
  5405. h: hue,
  5406. s: 100,
  5407. b: brightness
  5408. })
  5409. });
  5410. grid.find('.cp-grid-inner').css({
  5411. opacity: saturation / 100
  5412. });
  5413. break;
  5414. case 'brightness':
  5415. // Calculate hue, saturation, and brightness
  5416. hue = clamp_default()(parseInt(gridPos.x * (360 / gridWidth), 10), 0, 360);
  5417. saturation = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
  5418. brightness = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
  5419. hex = hsb2hex({
  5420. h: hue,
  5421. s: saturation,
  5422. b: brightness
  5423. }); // Update UI
  5424. slider.css({
  5425. backgroundColor: hsb2hex({
  5426. h: hue,
  5427. s: saturation,
  5428. b: 100
  5429. })
  5430. });
  5431. grid.find('.cp-grid-inner').css({
  5432. opacity: 1 - brightness / 100
  5433. });
  5434. break;
  5435. default:
  5436. // Calculate hue, saturation, and brightness
  5437. hue = clamp_default()(360 - parseInt(sliderPos.y * (360 / sliderHeight), 10), 0, 360);
  5438. saturation = clamp_default()(Math.floor(gridPos.x * (100 / gridWidth)), 0, 100);
  5439. brightness = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
  5440. hex = hsb2hex({
  5441. h: hue,
  5442. s: saturation,
  5443. b: brightness
  5444. }); // Update UI
  5445. grid.css({
  5446. backgroundColor: hsb2hex({
  5447. h: hue,
  5448. s: 100,
  5449. b: 100
  5450. })
  5451. });
  5452. break;
  5453. }
  5454. } // Handle opacity
  5455. if (target.hasClass('cp-opacity-slider')) {
  5456. this.opacity = parseFloat(1 - opacityPos.y / opacitySliderHeight).toFixed(2);
  5457. } // Adjust case
  5458. input.val(this.getValue(hex)); // Handle change event
  5459. this.element.trigger('change._grav_colorpicker', [this.element, hex, this.opacity]);
  5460. }
  5461. }, {
  5462. key: "getValue",
  5463. value: function getValue(hex) {
  5464. if (this.opacity === 1) {
  5465. return hex;
  5466. }
  5467. var rgb = hex2rgb(hex);
  5468. return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + this.opacity + ')';
  5469. }
  5470. }, {
  5471. key: "bound",
  5472. value: function bound(name) {
  5473. var bound = this._bound || (this._bound = {});
  5474. return bound[name] || (bound[name] = bind_default()(this[name], this));
  5475. }
  5476. }]);
  5477. return ColorpickerField;
  5478. }();
  5479. var colorpicker_Instance = new ColorpickerField('[data-grav-colorpicker]');
  5480. ;// CONCATENATED MODULE: ./app/forms/fields/folder.js
  5481. var Regenerate = function Regenerate() {
  5482. var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '[name="data[folder]"]';
  5483. var element = external_jQuery_default()(field);
  5484. var title = external_jQuery_default()('[name="data[header][title]"]');
  5485. var slug = external_jQuery_default().slugify(title.val(), {
  5486. custom: {
  5487. "'": ''
  5488. }
  5489. });
  5490. element.addClass('highlight').val(slug);
  5491. setTimeout(function () {
  5492. return element.removeClass('highlight');
  5493. }, 500);
  5494. };
  5495. external_jQuery_default()(document).on('click', '[data-regenerate]', function (event) {
  5496. var target = external_jQuery_default()(event.currentTarget);
  5497. var field = external_jQuery_default()(target.data('regenerate'));
  5498. Regenerate(field);
  5499. });
  5500. /* harmony default export */ const fields_folder = (Regenerate);
  5501. // EXTERNAL MODULE: ./node_modules/mout/object/forIn.js
  5502. var forIn = __webpack_require__(15473);
  5503. var forIn_default = /*#__PURE__*/__webpack_require__.n(forIn);
  5504. ;// CONCATENATED MODULE: ./app/forms/fields/selectunique.js
  5505. function selectunique_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5506. 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); } }
  5507. function selectunique_createClass(Constructor, protoProps, staticProps) { if (protoProps) selectunique_defineProperties(Constructor.prototype, protoProps); if (staticProps) selectunique_defineProperties(Constructor, staticProps); return Constructor; }
  5508. // import { config } from 'grav-config';
  5509. var Data = {};
  5510. var SelectUniqueField = /*#__PURE__*/function () {
  5511. function SelectUniqueField(options) {
  5512. var _this = this;
  5513. selectunique_classCallCheck(this, SelectUniqueField);
  5514. var body = external_jQuery_default()('body');
  5515. this.items = external_jQuery_default()();
  5516. this.options = Object.assign({}, this.defaults, options);
  5517. external_jQuery_default()('[data-select-observe]').each(function (index, element) {
  5518. return _this.addSelect(element);
  5519. }).last().trigger('change', {
  5520. load: true
  5521. });
  5522. body.on('mutation._grav', this._onAddedNodes.bind(this));
  5523. body.on('mutation_removed._grav', this._onRemovedNodes.bind(this));
  5524. }
  5525. selectunique_createClass(SelectUniqueField, [{
  5526. key: "_onAddedNodes",
  5527. value: function _onAddedNodes(event, target, record, instance) {
  5528. var _this2 = this;
  5529. var fields = external_jQuery_default()(target).find('[data-select-observe]');
  5530. if (!fields.length) {
  5531. return;
  5532. }
  5533. fields.each(function (index, field) {
  5534. field = external_jQuery_default()(field);
  5535. if (!~_this2.items.index(field)) {
  5536. _this2.addSelect(field);
  5537. }
  5538. });
  5539. }
  5540. }, {
  5541. key: "_onRemovedNodes",
  5542. value: function _onRemovedNodes(event, data
  5543. /* , instance */
  5544. ) {
  5545. var _this3 = this;
  5546. var target = external_jQuery_default()(data.target);
  5547. var holder = target.data('collectionHolder');
  5548. if (!holder) {
  5549. return false;
  5550. }
  5551. var node = external_jQuery_default()(data.mutation.removedNodes);
  5552. var value = node.find('[data-select-observe]').val();
  5553. if (value) {
  5554. Data[holder].state[value] = value;
  5555. }
  5556. target.find('[data-select-observe]').each(function (index, field) {
  5557. field = external_jQuery_default()(field);
  5558. if (field.val() !== value) {
  5559. _this3.updateOptions(field);
  5560. }
  5561. });
  5562. }
  5563. }, {
  5564. key: "addSelect",
  5565. value: function addSelect(element) {
  5566. var _this4 = this;
  5567. this.items = this.items.add(element);
  5568. element = external_jQuery_default()(element);
  5569. var value = element.attr('value');
  5570. var holder = element.closest('[data-collection-holder]').data('collectionHolder');
  5571. var options = element.closest('[data-select-unique]').data('selectUnique');
  5572. if (!Data[holder]) {
  5573. var data = {};
  5574. if (Array.isArray(options)) {
  5575. options.slice(0).map(function (item) {
  5576. data[item] = item;
  5577. });
  5578. } else {
  5579. data = Object.assign({}, options);
  5580. }
  5581. Data[holder] = {
  5582. original: null,
  5583. state: null
  5584. };
  5585. Data[holder].original = Object.assign({}, data);
  5586. Data[holder].state = Object.assign({}, data);
  5587. }
  5588. this.updateOptions(element);
  5589. element.data('originalValue', value);
  5590. element.on('change', function (event, extras) {
  5591. var target = external_jQuery_default()(event.currentTarget);
  5592. if (target.data('dummyChange')) {
  5593. target.data('dummyChange', false);
  5594. return false;
  5595. }
  5596. _this4.refreshOptions(target, extras && extras.load ? null : element.data('originalValue'));
  5597. element.data('originalValue', target.val());
  5598. });
  5599. }
  5600. }, {
  5601. key: "updateOptions",
  5602. value: function updateOptions(element) {
  5603. element = external_jQuery_default()(element);
  5604. var value = element.attr('value');
  5605. var holder = element.closest('[data-collection-holder]').data('collectionHolder');
  5606. forIn_default()(Data[holder].state, function (v, k) {
  5607. var selected = k === value ? 'selected="selected"' : '';
  5608. if (element.get(0).selectize) {
  5609. var selectize = element.data('selectize');
  5610. selectize.removeOption(k);
  5611. selectize.addOption({
  5612. value: k,
  5613. text: v
  5614. });
  5615. } else {
  5616. element.append("<option value=\"".concat(k, "\" ").concat(selected, ">").concat(v, "</option>"));
  5617. }
  5618. if (selected) {
  5619. if (element.get(0).selectize) {
  5620. var _selectize = element.data('selectize');
  5621. _selectize.setValue(k);
  5622. }
  5623. delete Data[holder].state[value];
  5624. }
  5625. });
  5626. }
  5627. }, {
  5628. key: "refreshOptions",
  5629. value: function refreshOptions(element, originalValue) {
  5630. var value = element.val();
  5631. var holder = element.closest('[data-collection-holder]').data('collectionHolder');
  5632. delete Data[holder].state[value];
  5633. if (originalValue && Data[holder].original[originalValue]) {
  5634. Data[holder].state[originalValue] = Data[holder].original[originalValue];
  5635. }
  5636. this.items.each(function (index, select) {
  5637. select = external_jQuery_default()(select);
  5638. if (select[0] === element[0]) {
  5639. return;
  5640. }
  5641. var selectedValue = select.val();
  5642. select.data('dummyChange', true);
  5643. if (select.get(0).selectize) {
  5644. var selectize = select.data('selectize');
  5645. if (selectize) {
  5646. selectize.clearOptions();
  5647. if (selectedValue) {
  5648. selectize.addOption({
  5649. value: selectedValue,
  5650. text: Data[holder].original[selectedValue] || selectedValue
  5651. });
  5652. }
  5653. forIn_default()(Data[holder].state, function (v, k) {
  5654. selectize.addOption({
  5655. value: k,
  5656. text: v
  5657. });
  5658. });
  5659. selectize.setValue(selectedValue, true);
  5660. }
  5661. } else {
  5662. select.empty();
  5663. forIn_default()(Data[holder].state, function (v, k) {
  5664. var selected = k === selectedValue ? 'selected="selected"' : '';
  5665. select.append("<option value=\"".concat(k, "\" ").concat(selected, ">").concat(v, "</option>"));
  5666. });
  5667. }
  5668. select.data('dummyChange', false);
  5669. });
  5670. }
  5671. }]);
  5672. return SelectUniqueField;
  5673. }();
  5674. var selectunique_Instance = new SelectUniqueField();
  5675. ;// CONCATENATED MODULE: ./app/forms/fields/iconpicker.js
  5676. function iconpicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5677. 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); } }
  5678. function iconpicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) iconpicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) iconpicker_defineProperties(Constructor, staticProps); return Constructor; }
  5679. /* Icon Picker by QueryLoop
  5680. * Author: @eliorivero
  5681. * URL: http://queryloop.com/
  5682. * License: GPLv2
  5683. */
  5684. var iconpicker_defaults = {
  5685. 'mode': 'dialog',
  5686. // show overlay 'dialog' panel or slide down 'inline' panel
  5687. 'closeOnPick': true,
  5688. // whether to close panel after picking or 'no'
  5689. 'save': 'class',
  5690. // save icon 'class' or 'code'
  5691. 'size': '',
  5692. 'classes': {
  5693. 'launcher': '',
  5694. // extra classes for launcher buttons
  5695. 'clear': 'remove-times',
  5696. // extra classes for button that removes preview and clears field
  5697. 'highlight': '',
  5698. // extra classes when highlighting an icon
  5699. 'close': '' // extra classes for close button
  5700. },
  5701. 'iconSets': {
  5702. // example data structure. Used to specify which launchers will be created
  5703. 'genericon': 'Genericon',
  5704. // create a launcher to pick genericon icons
  5705. 'fa': 'FontAwesome' // create a launcher to pick fontawesome icons
  5706. }
  5707. };
  5708. var QL_Icon_Picker = /*#__PURE__*/function () {
  5709. function QL_Icon_Picker(element, options) {
  5710. iconpicker_classCallCheck(this, QL_Icon_Picker);
  5711. this.iconSet = '';
  5712. this.iconSetName = '';
  5713. this.$field = '';
  5714. this.element = element;
  5715. this.settings = external_jQuery_default().extend({}, iconpicker_defaults, options);
  5716. this._defaults = iconpicker_defaults;
  5717. this.init();
  5718. }
  5719. iconpicker_createClass(QL_Icon_Picker, [{
  5720. key: "init",
  5721. value: function init() {
  5722. var $brick = external_jQuery_default()(this.element);
  5723. var pickerId = $brick.data('pickerid');
  5724. var $preview = external_jQuery_default()('<div class="icon-preview icon-preview-' + pickerId + '" />');
  5725. this.$field = $brick.find('input'); // Add preview area
  5726. this.makePreview($brick, pickerId, $preview); // Make button to clear field and remove preview
  5727. this.makeClear(pickerId, $preview); // Make buttons that open the panel of icons
  5728. this.makeLaunchers($brick, pickerId); // Prepare display styles, inline and dialog
  5729. this.makeDisplay($brick);
  5730. }
  5731. }, {
  5732. key: "makePreview",
  5733. value: function makePreview($brick, pickerId, $preview) {
  5734. var $icon = external_jQuery_default()('<i />');
  5735. var iconValue = this.$field.val();
  5736. $preview.prependTo($brick);
  5737. $icon.prependTo($preview);
  5738. if (iconValue !== '') {
  5739. $preview.addClass('icon-preview-on');
  5740. $icon.addClass(iconValue);
  5741. }
  5742. }
  5743. }, {
  5744. key: "makeClear",
  5745. value: function makeClear(pickerId, $preview) {
  5746. var base = this;
  5747. 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
  5748. $clear.hide().prependTo($preview); // If there's a icon saved in the field, show remove icon button
  5749. if (base.$field.val() !== '') {
  5750. $clear.show();
  5751. }
  5752. $preview.on('click', '.remove-icon', function (e) {
  5753. e.preventDefault();
  5754. base.$field.val('');
  5755. $preview.removeClass('icon-preview-on').find('i').removeClass();
  5756. external_jQuery_default()(this).hide();
  5757. });
  5758. }
  5759. }, {
  5760. key: "makeDisplay",
  5761. value: function makeDisplay($brick) {
  5762. var base = this;
  5763. var close = base.settings.classes.close;
  5764. var $body = external_jQuery_default()('body');
  5765. var $close = external_jQuery_default()('<a href="#" class="icon-picker-close"/>');
  5766. if (base.settings.mode === 'inline') {
  5767. $brick.find('.icon-set').append($close).removeClass('dialog').addClass('ip-inline ' + base.settings.size).parent().addClass('icon-set-wrap');
  5768. } else if (base.settings.mode === 'dialog') {
  5769. external_jQuery_default()('.icon-set').addClass('dialog ' + base.settings.size);
  5770. if (external_jQuery_default()('.icon-picker-overlay').length <= 0) {
  5771. $body.append('<div class="icon-picker-overlay"/>').append($close);
  5772. }
  5773. }
  5774. $body.on('click', '.icon-picker-close, .icon-picker-overlay', function (e) {
  5775. e.preventDefault();
  5776. base.closePicker($brick, external_jQuery_default()(base.iconSet), base.settings.mode);
  5777. }).on('mouseenter mouseleave', '.icon-picker-close', function (e) {
  5778. if (e.type === 'mouseenter') {
  5779. external_jQuery_default()(this).addClass(close);
  5780. } else {
  5781. external_jQuery_default()(this).removeClass(close);
  5782. }
  5783. });
  5784. }
  5785. }, {
  5786. key: "makeLaunchers",
  5787. value: function makeLaunchers($brick) {
  5788. var base = this;
  5789. var dataIconSets = $brick.data('iconsets');
  5790. var iconSet;
  5791. if (typeof dataIconSets === 'undefined') {
  5792. dataIconSets = base.settings.iconSets;
  5793. }
  5794. for (iconSet in dataIconSets) {
  5795. if (dataIconSets.hasOwnProperty(iconSet)) {
  5796. $brick.append('<a class="launch-icons button ' + base.settings.classes.launcher + '" data-icons="' + iconSet + '">' + dataIconSets[iconSet] + '</a>');
  5797. }
  5798. }
  5799. $brick.find('.launch-icons').on('click', function (e) {
  5800. e.preventDefault();
  5801. var $self = external_jQuery_default()(this);
  5802. var theseIcons = $self.data('icons');
  5803. base.iconSetName = theseIcons;
  5804. base.iconSet = '.' + theseIcons + '-set'; // Initialize picker
  5805. base.iconPick($brick); // Show icon picker
  5806. base.showPicker($brick, external_jQuery_default()(base.iconSet), base.settings.mode);
  5807. });
  5808. }
  5809. }, {
  5810. key: "iconPick",
  5811. value: function iconPick($brick) {
  5812. var base = this;
  5813. var highlight = 'icon-highlight ' + base.settings.classes.highlight;
  5814. external_jQuery_default()(base.iconSet).on('click', 'li', function (e) {
  5815. e.preventDefault();
  5816. var $icon = external_jQuery_default()(this);
  5817. var icon = $icon.data(base.settings.save); // Mark as selected
  5818. external_jQuery_default()('.icon-selected').removeClass('icon-selected');
  5819. $icon.addClass('icon-selected');
  5820. if (base.$field.data('format') === 'short') {
  5821. icon = icon.slice(6);
  5822. } // Save icon value to field
  5823. base.$field.val(icon); // Close icon picker
  5824. if (base.settings.closeOnPick) {
  5825. base.closePicker($brick, $icon.closest(base.iconSet), base.settings.mode);
  5826. } // Set preview
  5827. base.setPreview($icon.data('class')); // Broadcast event passing the selected icon.
  5828. external_jQuery_default()('body').trigger('iconselected.queryloop', icon);
  5829. });
  5830. external_jQuery_default()(base.iconSet).on('mouseenter mouseleave', 'li', function (e) {
  5831. if (e.type === 'mouseenter') {
  5832. external_jQuery_default()(this).addClass(highlight);
  5833. } else {
  5834. external_jQuery_default()(this).removeClass(highlight);
  5835. }
  5836. });
  5837. }
  5838. }, {
  5839. key: "showPicker",
  5840. value: function showPicker($brick, $icons, mode) {
  5841. if (mode === 'inline') {
  5842. external_jQuery_default()('.icon-set').removeClass('ip-inline-open');
  5843. $brick.find($icons).toggleClass('ip-inline-open');
  5844. } else if (mode === 'dialog') {
  5845. $brick.find('.icon-picker-close').addClass('make-visible');
  5846. $brick.find('.icon-picker-overlay').addClass('make-visible');
  5847. $icons.addClass('dialog-open');
  5848. }
  5849. $icons.find('.icon-selected').removeClass('icon-selected');
  5850. var selectedIcon = this.$field.val().replace(' ', '.');
  5851. if (selectedIcon !== '') {
  5852. if (this.settings.save === 'class') {
  5853. $icons.find('.' + selectedIcon).addClass('icon-selected');
  5854. } else {
  5855. $icons.find('[data-code="' + selectedIcon + '"]').addClass('icon-selected');
  5856. }
  5857. } // Broadcast event when the picker is shown passing the picker mode.
  5858. external_jQuery_default()('body').trigger('iconpickershow.queryloop', mode);
  5859. }
  5860. }, {
  5861. key: "closePicker",
  5862. value: function closePicker($brick, $icons, mode) {
  5863. // Remove event so they don't fire from a different picker
  5864. external_jQuery_default()(this.iconSet).off('click', 'li');
  5865. if (mode === 'inline') {
  5866. $brick.find($icons).removeClass('ip-inline-open');
  5867. } else if (mode === 'dialog') {
  5868. external_jQuery_default()('.icon-picker-close, .icon-picker-overlay').removeClass('make-visible');
  5869. } // Broadcast event when the picker is closed passing the picker mode.
  5870. external_jQuery_default()('body').trigger('iconpickerclose.queryloop', mode);
  5871. external_jQuery_default()('.icon-set').removeClass('dialog-open');
  5872. }
  5873. }, {
  5874. key: "setPreview",
  5875. value: function setPreview(preview) {
  5876. var $preview = external_jQuery_default()(this.element).find('.icon-preview');
  5877. $preview.addClass('icon-preview-on').find('i').removeClass().addClass(this.iconSetName).addClass(preview);
  5878. $preview.find('a').show();
  5879. }
  5880. }]);
  5881. return QL_Icon_Picker;
  5882. }();
  5883. /* Grav */
  5884. // extend $ with 3rd party QL Icon Picker
  5885. (external_jQuery_default()).fn.qlIconPicker = function (options) {
  5886. this.each(function () {
  5887. if (!external_jQuery_default().data(this, 'plugin_qlIconPicker')) {
  5888. external_jQuery_default().data(this, 'plugin_qlIconPicker', new QL_Icon_Picker(this, options));
  5889. }
  5890. });
  5891. return this;
  5892. };
  5893. var IconpickerField = /*#__PURE__*/function () {
  5894. function IconpickerField(options) {
  5895. var _this = this;
  5896. iconpicker_classCallCheck(this, IconpickerField);
  5897. this.items = external_jQuery_default()();
  5898. this.options = Object.assign({}, this.defaults, options);
  5899. external_jQuery_default()('[data-grav-iconpicker]').each(function (index, element) {
  5900. return _this.addItem(element);
  5901. });
  5902. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  5903. }
  5904. iconpicker_createClass(IconpickerField, [{
  5905. key: "_onAddedNodes",
  5906. value: function _onAddedNodes(event, target
  5907. /* , record, instance */
  5908. ) {
  5909. var _this2 = this;
  5910. var fields = external_jQuery_default()(target).find('[data-grav-iconpicker]');
  5911. if (!fields.length) {
  5912. return;
  5913. }
  5914. fields.each(function (index, field) {
  5915. field = external_jQuery_default()(field);
  5916. if (!~_this2.items.index(field)) {
  5917. _this2.addItem(field);
  5918. }
  5919. });
  5920. }
  5921. }, {
  5922. key: "addItem",
  5923. value: function addItem(element) {
  5924. element = external_jQuery_default()(element);
  5925. this.items = this.items.add(element);
  5926. element.find('.icon-picker').qlIconPicker({
  5927. 'save': 'class'
  5928. }); // hack to remove extra icon sets that are just copies
  5929. external_jQuery_default()('.icon-set:not(:first)').remove();
  5930. }
  5931. }]);
  5932. return IconpickerField;
  5933. }();
  5934. var iconpicker_Instance = new IconpickerField(); // Fix to close the dialog when clicking outside
  5935. external_jQuery_default()(document).on('click', function (event) {
  5936. var target = external_jQuery_default()(event.target);
  5937. var match = '.icon-set.dialog-open, .launch-icons[data-icons]';
  5938. if (!target.is(match) && !target.closest(match).length) {
  5939. var dialogs = external_jQuery_default()('.icon-set.dialog-open'); // skip if there's no dialog open
  5940. if (dialogs.length) {
  5941. dialogs.each(function (index, dialog) {
  5942. var picker = external_jQuery_default()(dialog).siblings('.icon-picker');
  5943. var data = picker.data('plugin_qlIconPicker');
  5944. data.closePicker(picker, external_jQuery_default()(data.iconSet), data.settings.mode);
  5945. });
  5946. }
  5947. }
  5948. });
  5949. ;// CONCATENATED MODULE: ./app/utils/cron-ui.js
  5950. function cron_ui_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { cron_ui_typeof = function _typeof(obj) { return typeof obj; }; } else { cron_ui_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return cron_ui_typeof(obj); }
  5951. /* eslint-disable */
  5952. /*
  5953. * This file is part of the Arnapou jqCron package.
  5954. *
  5955. * (c) Arnaud Buathier <arnaud@arnapou.net>
  5956. *
  5957. * For the full copyright and license information, please view the LICENSE
  5958. * file that was distributed with this source code.
  5959. */
  5960. /**
  5961. * Default settings
  5962. */
  5963. var jqCronDefaultSettings = {
  5964. texts: {},
  5965. 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],
  5966. 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],
  5967. 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"],
  5968. 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],
  5969. lang: 'en',
  5970. enabled_minute: false,
  5971. enabled_hour: true,
  5972. enabled_day: true,
  5973. enabled_week: true,
  5974. enabled_month: true,
  5975. enabled_year: true,
  5976. multiple_dom: false,
  5977. multiple_month: false,
  5978. multiple_mins: false,
  5979. multiple_dow: false,
  5980. multiple_time_hours: false,
  5981. multiple_time_minutes: false,
  5982. numeric_zero_pad: false,
  5983. default_period: 'day',
  5984. default_value: '',
  5985. no_reset_button: true,
  5986. disabled: false,
  5987. bind_to: null,
  5988. bind_method: {
  5989. set: function set($element, value) {
  5990. $element.is(':input') ? $element.val(value) : $element.data('jqCronValue', value);
  5991. },
  5992. get: function get($element) {
  5993. return $element.is(':input') ? $element.val() : $element.data('jqCronValue');
  5994. }
  5995. }
  5996. };
  5997. /**
  5998. * Custom extend of json for jqCron settings.
  5999. * We don't use jQuery.extend because simple extend does not fit our needs, and deep extend has a bad
  6000. * feature for us : it replaces keys of "Arrays" instead of replacing the full array.
  6001. */
  6002. (function ($) {
  6003. var extend = function extend(dst, src) {
  6004. for (var i in src) {
  6005. if ($.isPlainObject(src[i])) {
  6006. dst[i] = extend(dst[i] && $.isPlainObject(dst[i]) ? dst[i] : {}, src[i]);
  6007. } else if ($.isArray(src[i])) {
  6008. dst[i] = src[i].slice(0);
  6009. } else if (src[i] !== undefined) {
  6010. dst[i] = src[i];
  6011. }
  6012. }
  6013. return dst;
  6014. };
  6015. this.jqCronMergeSettings = function (obj) {
  6016. return extend(extend({}, jqCronDefaultSettings), obj || {});
  6017. };
  6018. }).call(window, (external_jQuery_default()));
  6019. /**
  6020. * Shortcut to get the instance of jqCron instance from one jquery object
  6021. */
  6022. (function ($) {
  6023. $.fn.jqCronGetInstance = function () {
  6024. return this.data('jqCron');
  6025. };
  6026. }).call(window, (external_jQuery_default()));
  6027. /**
  6028. * Main plugin
  6029. */
  6030. (function ($) {
  6031. $.fn.jqCron = function (settings) {
  6032. var saved_settings = settings;
  6033. return this.each(function () {
  6034. var cron, saved;
  6035. var $this = $(this);
  6036. var settings = jqCronMergeSettings(saved_settings); // clone settings
  6037. var translations = settings.texts[settings.lang];
  6038. if (cron_ui_typeof(translations) !== 'object' || $.isEmptyObject(translations)) {
  6039. 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().');
  6040. return;
  6041. }
  6042. if (!settings.jquery_container) {
  6043. if ($this.is(':container')) {
  6044. settings.jquery_element = $this.uniqueId('jqCron');
  6045. } else if ($this.is(':autoclose')) {
  6046. // delete already generated dom if exists
  6047. if ($this.next('.jqCron').length == 1) {
  6048. $this.next('.jqCron').remove();
  6049. } // generate new
  6050. settings.jquery_element = $('<span class="jqCron"></span>').uniqueId('jqCron').insertAfter($this);
  6051. } else {
  6052. console && console.error(settings.texts[settings.lang].error1.replace('%s', this.tagName));
  6053. return;
  6054. }
  6055. } // autoset bind_to if it is an input
  6056. if ($this.is(':input')) {
  6057. settings.bind_to = settings.bind_to || $this;
  6058. } // init cron object
  6059. if (settings.bind_to) {
  6060. if (settings.bind_to.is(':input')) {
  6061. // auto bind from input to object if an input, textarea ...
  6062. settings.bind_to.blur(function () {
  6063. var value = settings.bind_method.get(settings.bind_to);
  6064. $this.jqCronGetInstance().setCron(value);
  6065. });
  6066. }
  6067. saved = settings.bind_method.get(settings.bind_to);
  6068. cron = new jqCron(settings);
  6069. cron.setCron(saved);
  6070. } else {
  6071. cron = new jqCron(settings);
  6072. }
  6073. $(this).data('jqCron', cron);
  6074. });
  6075. };
  6076. }).call(window, (external_jQuery_default()));
  6077. /**
  6078. * jqCron class
  6079. */
  6080. (function ($) {
  6081. var jqCronInstances = [];
  6082. function jqCron(settings) {
  6083. var _initialized = false;
  6084. var _self = this;
  6085. var _$elt = this;
  6086. var _$obj = $('<span class="jqCron-container"></span>');
  6087. var _$blocks = $('<span class="jqCron-blocks"></span>');
  6088. var _$blockPERIOD = $('<span class="jqCron-period"></span>');
  6089. var _$blockDOM = $('<span class="jqCron-dom"></span>');
  6090. var _$blockMONTH = $('<span class="jqCron-month"></span>');
  6091. var _$blockMINS = $('<span class="jqCron-mins"></span>');
  6092. var _$blockDOW = $('<span class="jqCron-dow"></span>');
  6093. var _$blockTIME = $('<span class="jqCron-time"></span>');
  6094. var _$cross = $('<span class="jqCron-cross">&#10008;</span>');
  6095. var _selectors = [];
  6096. var _selectorPeriod, _selectorMins, _selectorTimeH, _selectorTimeM, _selectorDow, _selectorDom, _selectorMonth; // instanciate a new selector
  6097. function newSelector($block, multiple, type) {
  6098. var selector = new jqCronSelector(_self, $block, multiple, type);
  6099. selector.$.bind('selector:open', function () {
  6100. // we close all opened selectors of all other jqCron
  6101. for (var n = jqCronInstances.length; n--;) {
  6102. if (jqCronInstances[n] != _self) {
  6103. jqCronInstances[n].closeSelectors();
  6104. } else {
  6105. // we close all other opened selectors of this jqCron
  6106. for (var o = _selectors.length; o--;) {
  6107. if (_selectors[o] != selector) {
  6108. _selectors[o].close();
  6109. }
  6110. }
  6111. }
  6112. }
  6113. });
  6114. selector.$.bind('selector:change', function () {
  6115. var boundChanged = false; // don't propagate if not initialized
  6116. if (!_initialized) return; // bind data between two minute selectors (only if they have the same multiple settings)
  6117. if (settings.multiple_mins == settings.multiple_time_minutes) {
  6118. if (selector == _selectorMins) {
  6119. boundChanged = _selectorTimeM.setValue(_selectorMins.getValue());
  6120. } else if (selector == _selectorTimeM) {
  6121. boundChanged = _selectorMins.setValue(_selectorTimeM.getValue());
  6122. }
  6123. } // we propagate the change event to the main object
  6124. boundChanged || _$obj.trigger('cron:change', _self.getCron());
  6125. });
  6126. _selectors.push(selector);
  6127. return selector;
  6128. } // disable the selector
  6129. this.disable = function () {
  6130. _$obj.addClass('disable');
  6131. settings.disable = true;
  6132. _self.closeSelectors();
  6133. }; // return if the selector is disabled
  6134. this.isDisabled = function () {
  6135. return settings.disable == true;
  6136. }; // enable the selector
  6137. this.enable = function () {
  6138. _$obj.removeClass('disable');
  6139. settings.disable = false;
  6140. }; // get cron value
  6141. this.getCron = function () {
  6142. var period = _selectorPeriod.getValue();
  6143. var items = ['*', '*', '*', '*', '*'];
  6144. if (period == 'hour') {
  6145. items[0] = _selectorMins.getCronValue();
  6146. }
  6147. if (period == 'day' || period == 'week' || period == 'month' || period == 'year') {
  6148. items[0] = _selectorTimeM.getCronValue();
  6149. items[1] = _selectorTimeH.getCronValue();
  6150. }
  6151. if (period == 'month' || period == 'year') {
  6152. items[2] = _selectorDom.getCronValue();
  6153. }
  6154. if (period == 'year') {
  6155. items[3] = _selectorMonth.getCronValue();
  6156. }
  6157. if (period == 'week') {
  6158. items[4] = _selectorDow.getCronValue();
  6159. }
  6160. return items.join(' ');
  6161. }; // set cron (string like * * * * *)
  6162. this.setCron = function (str) {
  6163. if (!str) return;
  6164. try {
  6165. str = str.replace(/\s+/g, ' ').replace(/^ +/, '').replace(/ +$/, ''); // sanitize
  6166. var mask = str.replace(/[^\* ]/g, '-').replace(/-+/g, '-').replace(/ +/g, '');
  6167. var items = str.split(' ');
  6168. if (items.length != 5) _self.error(_self.getText('error2'));
  6169. if (mask == '*****') {
  6170. // 1 possibility
  6171. _selectorPeriod.setValue('minute');
  6172. } else if (mask == '-****') {
  6173. // 1 possibility
  6174. _selectorPeriod.setValue('hour');
  6175. _selectorMins.setCronValue(items[0]);
  6176. _selectorTimeM.setCronValue(items[0]);
  6177. } else if (mask.substring(2, mask.length) == '***') {
  6178. // 4 possibilities
  6179. _selectorPeriod.setValue('day');
  6180. _selectorMins.setCronValue(items[0]);
  6181. _selectorTimeM.setCronValue(items[0]);
  6182. _selectorTimeH.setCronValue(items[1]);
  6183. } else if (mask.substring(2, mask.length) == '-**') {
  6184. // 4 possibilities
  6185. _selectorPeriod.setValue('month');
  6186. _selectorMins.setCronValue(items[0]);
  6187. _selectorTimeM.setCronValue(items[0]);
  6188. _selectorTimeH.setCronValue(items[1]);
  6189. _selectorDom.setCronValue(items[2]);
  6190. } else if (mask.substring(2, mask.length) == '**-') {
  6191. // 4 possibilities
  6192. _selectorPeriod.setValue('week');
  6193. _selectorMins.setCronValue(items[0]);
  6194. _selectorTimeM.setCronValue(items[0]);
  6195. _selectorTimeH.setCronValue(items[1]);
  6196. _selectorDow.setCronValue(items[4]);
  6197. } else if (mask.substring(3, mask.length) == '-*') {
  6198. // 8 possibilities
  6199. _selectorPeriod.setValue('year');
  6200. _selectorMins.setCronValue(items[0]);
  6201. _selectorTimeM.setCronValue(items[0]);
  6202. _selectorTimeH.setCronValue(items[1]);
  6203. _selectorDom.setCronValue(items[2]);
  6204. _selectorMonth.setCronValue(items[3]);
  6205. } else {
  6206. _self.error(_self.getText('error4'));
  6207. }
  6208. _self.clearError();
  6209. } catch (e) {}
  6210. }; // close all child selectors
  6211. this.closeSelectors = function () {
  6212. for (var n = _selectors.length; n--;) {
  6213. _selectors[n].close();
  6214. }
  6215. }; // get the main element id
  6216. this.getId = function () {
  6217. return _$elt.attr('id');
  6218. }; // get the translated text
  6219. this.getText = function (key) {
  6220. var text = settings.texts[settings.lang][key] || null;
  6221. if (typeof text == "string" && text.match('<b')) {
  6222. text = text.replace(/(<b *\/>)/gi, '</span><b /><span class="jqCron-text">');
  6223. text = '<span class="jqCron-text">' + text + '</span>';
  6224. }
  6225. return text;
  6226. }; // get the human readable text
  6227. this.getHumanText = function () {
  6228. var texts = [];
  6229. _$obj.find('> span > span:visible').find('.jqCron-text, .jqCron-selector > span').each(function () {
  6230. var text = $(this).text().replace(/\s+$/g, '').replace(/^\s+/g, '');
  6231. text && texts.push(text);
  6232. });
  6233. return texts.join(' ').replace(/\s:\s/g, ':');
  6234. }; // get settings
  6235. this.getSettings = function () {
  6236. return settings;
  6237. }; // display an error
  6238. this.error = function (msg) {
  6239. console && console.error('[jqCron Error] ' + msg);
  6240. _$obj.addClass('jqCron-error').attr('title', msg);
  6241. throw msg;
  6242. }; // clear error
  6243. this.clearError = function () {
  6244. _$obj.attr('title', '').removeClass('jqCron-error');
  6245. }; // clear
  6246. this.clear = function () {
  6247. _selectorDom.setValue([]);
  6248. _selectorDow.setValue([]);
  6249. _selectorMins.setValue([]);
  6250. _selectorMonth.setValue([]);
  6251. _selectorTimeH.setValue([]);
  6252. _selectorTimeM.setValue([]);
  6253. _self.triggerChange();
  6254. }; // init (called in constructor)
  6255. this.init = function () {
  6256. var n, i, labelsList, list;
  6257. if (_initialized) return;
  6258. settings = jqCronMergeSettings(settings);
  6259. settings.jquery_element || _self.error(_self.getText('error3'));
  6260. _$elt = settings.jquery_element;
  6261. _$elt.append(_$obj);
  6262. _$obj.data('id', settings.id);
  6263. _$obj.data('jqCron', _self);
  6264. _$obj.append(_$blocks);
  6265. settings.no_reset_button || _$obj.append(_$cross);
  6266. !settings.disable || _$obj.addClass('disable');
  6267. _$blocks.append(_$blockPERIOD);
  6268. if (/^(ko)$/i.test(settings.lang)) {
  6269. _$blocks.append(_$blockMONTH, _$blockDOM);
  6270. } else {
  6271. _$blocks.append(_$blockDOM, _$blockMONTH);
  6272. }
  6273. _$blocks.append(_$blockMINS);
  6274. _$blocks.append(_$blockDOW);
  6275. _$blocks.append(_$blockTIME); // various binding
  6276. _$cross.click(function () {
  6277. _self.isDisabled() || _self.clear();
  6278. }); // binding from cron to target
  6279. _$obj.bind('cron:change', function (evt, value) {
  6280. if (!settings.bind_to) return;
  6281. settings.bind_method.set && settings.bind_method.set(settings.bind_to, value);
  6282. _self.clearError();
  6283. }); // PERIOD
  6284. _$blockPERIOD.append(_self.getText('text_period'));
  6285. _selectorPeriod = newSelector(_$blockPERIOD, false, 'period');
  6286. settings.enabled_minute && _selectorPeriod.add('minute', _self.getText('name_minute'));
  6287. settings.enabled_hour && _selectorPeriod.add('hour', _self.getText('name_hour'));
  6288. settings.enabled_day && _selectorPeriod.add('day', _self.getText('name_day'));
  6289. settings.enabled_week && _selectorPeriod.add('week', _self.getText('name_week'));
  6290. settings.enabled_month && _selectorPeriod.add('month', _self.getText('name_month'));
  6291. settings.enabled_year && _selectorPeriod.add('year', _self.getText('name_year'));
  6292. _selectorPeriod.$.bind('selector:change', function (e, value) {
  6293. _$blockDOM.hide();
  6294. _$blockMONTH.hide();
  6295. _$blockMINS.hide();
  6296. _$blockDOW.hide();
  6297. _$blockTIME.hide();
  6298. if (value == 'hour') {
  6299. _$blockMINS.show();
  6300. } else if (value == 'day') {
  6301. _$blockTIME.show();
  6302. } else if (value == 'week') {
  6303. _$blockDOW.show();
  6304. _$blockTIME.show();
  6305. } else if (value == 'month') {
  6306. _$blockDOM.show();
  6307. _$blockTIME.show();
  6308. } else if (value == 'year') {
  6309. _$blockDOM.show();
  6310. _$blockMONTH.show();
  6311. _$blockTIME.show();
  6312. }
  6313. });
  6314. _selectorPeriod.setValue(settings.default_period); // MINS (minutes)
  6315. _$blockMINS.append(_self.getText('text_mins'));
  6316. _selectorMins = newSelector(_$blockMINS, settings.multiple_mins, 'minutes');
  6317. for (i = 0, list = settings.minutes; i < list.length; i++) {
  6318. _selectorMins.add(list[i], list[i]);
  6319. } // TIME (hour:min)
  6320. _$blockTIME.append(_self.getText('text_time'));
  6321. _selectorTimeH = newSelector(_$blockTIME, settings.multiple_time_hours, 'time_hours');
  6322. for (i = 0, list = settings.hours, labelsList = settings.hour_labels; i < list.length; i++) {
  6323. _selectorTimeH.add(list[i], labelsList[i]);
  6324. }
  6325. _selectorTimeM = newSelector(_$blockTIME, settings.multiple_time_minutes, 'time_minutes');
  6326. for (i = 0, list = settings.minutes; i < list.length; i++) {
  6327. _selectorTimeM.add(list[i], list[i]);
  6328. } // DOW (day of week)
  6329. _$blockDOW.append(_self.getText('text_dow'));
  6330. _selectorDow = newSelector(_$blockDOW, settings.multiple_dow, 'day_of_week');
  6331. for (i = 0, list = _self.getText('weekdays'); i < list.length; i++) {
  6332. _selectorDow.add(i + 1, list[i]);
  6333. } // DOM (day of month)
  6334. _$blockDOM.append(_self.getText('text_dom'));
  6335. _selectorDom = newSelector(_$blockDOM, settings.multiple_dom, 'day_of_month');
  6336. for (i = 0, list = settings.monthdays; i < list.length; i++) {
  6337. _selectorDom.add(list[i], list[i]);
  6338. } // MONTH (day of week)
  6339. _$blockMONTH.append(_self.getText('text_month'));
  6340. _selectorMonth = newSelector(_$blockMONTH, settings.multiple_month, 'month');
  6341. for (i = 0, list = _self.getText('months'); i < list.length; i++) {
  6342. _selectorMonth.add(i + 1, list[i]);
  6343. } // close all selectors when we click in body
  6344. $('body').click(function () {
  6345. var i,
  6346. n = _selectors.length;
  6347. for (i = 0; i < n; i++) {
  6348. _selectors[i].close();
  6349. }
  6350. });
  6351. _initialized = true; // default value
  6352. if (settings.default_value) {
  6353. _self.setCron(settings.default_value);
  6354. }
  6355. }; // trigger a change event
  6356. this.triggerChange = function () {
  6357. _$obj.trigger('cron:change', _self.getCron());
  6358. }; // store instance in array
  6359. jqCronInstances.push(this); // expose main jquery object
  6360. this.$ = _$obj; // init
  6361. try {
  6362. this.init();
  6363. _self.triggerChange();
  6364. } catch (e) {}
  6365. }
  6366. this.jqCron = jqCron;
  6367. }).call(window, (external_jQuery_default()));
  6368. /**
  6369. * jqCronSelector class
  6370. */
  6371. (function ($) {
  6372. function jqCronSelector(_cron, _$block, _multiple, _type) {
  6373. var _self = this;
  6374. var _$list = $('<ul class="jqCron-selector-list"></ul>');
  6375. var _$title = $('<span class="jqCron-selector-title"></span>');
  6376. var _$selector = $('<span class="jqCron-selector"></span>');
  6377. var _values = {};
  6378. var _value = [];
  6379. var _hasNumericTexts = true;
  6380. var _numeric_zero_pad = _cron.getSettings().numeric_zero_pad; // return an array without doublon
  6381. function array_unique(l) {
  6382. var i = 0,
  6383. n = l.length,
  6384. k = {},
  6385. a = [];
  6386. while (i < n) {
  6387. k[l[i]] || (k[l[i]] = true && a.push(l[i]));
  6388. i++;
  6389. }
  6390. return a;
  6391. } // get the value (an array if multiple, else a single value)
  6392. this.getValue = function () {
  6393. return _multiple ? _value : _value[0];
  6394. }; // get a correct string for cron
  6395. this.getCronValue = function () {
  6396. if (_value.length == 0) return '*';
  6397. var cron = [_value[0]],
  6398. i,
  6399. s = _value[0],
  6400. c = _value[0],
  6401. n = _value.length;
  6402. for (i = 1; i < n; i++) {
  6403. if (_value[i] == c + 1) {
  6404. c = _value[i];
  6405. cron[cron.length - 1] = s + '-' + c;
  6406. } else {
  6407. s = c = _value[i];
  6408. cron.push(c);
  6409. }
  6410. }
  6411. return cron.join(',');
  6412. }; // set the cron value
  6413. this.setCronValue = function (str) {
  6414. var values = [],
  6415. m,
  6416. i,
  6417. n;
  6418. if (str !== '*') {
  6419. while (str != '') {
  6420. // test "*/n" expression
  6421. m = str.match(/^\*\/([0-9]+),?/);
  6422. if (m && m.length == 2) {
  6423. for (i = 0; i <= 59; i += m[1] | 0) {
  6424. values.push(i);
  6425. }
  6426. str = str.replace(m[0], '');
  6427. continue;
  6428. } // test "a-b/n" expression
  6429. m = str.match(/^([0-9]+)-([0-9]+)\/([0-9]+),?/);
  6430. if (m && m.length == 4) {
  6431. for (i = m[1] | 0; i <= (m[2] | 0); i += m[3] | 0) {
  6432. values.push(i);
  6433. }
  6434. str = str.replace(m[0], '');
  6435. continue;
  6436. } // test "a-b" expression
  6437. m = str.match(/^([0-9]+)-([0-9]+),?/);
  6438. if (m && m.length == 3) {
  6439. for (i = m[1] | 0; i <= (m[2] | 0); i++) {
  6440. values.push(i);
  6441. }
  6442. str = str.replace(m[0], '');
  6443. continue;
  6444. } // test "c" expression
  6445. m = str.match(/^([0-9]+),?/);
  6446. if (m && m.length == 2) {
  6447. values.push(m[1] | 0);
  6448. str = str.replace(m[0], '');
  6449. continue;
  6450. } // something goes wrong in the expression
  6451. return;
  6452. }
  6453. }
  6454. _self.setValue(values);
  6455. }; // close the selector
  6456. this.close = function () {
  6457. _$selector.trigger('selector:close');
  6458. }; // open the selector
  6459. this.open = function () {
  6460. _$selector.trigger('selector:open');
  6461. }; // whether the selector is open
  6462. this.isOpened = function () {
  6463. return _$list.is(':visible');
  6464. }; // add a selected value to the list
  6465. this.addValue = function (key) {
  6466. var values = _multiple ? _value.slice(0) : []; // clone array
  6467. values.push(key);
  6468. _self.setValue(values);
  6469. }; // remove a selected value from the list
  6470. this.removeValue = function (key) {
  6471. if (_multiple) {
  6472. var i,
  6473. newValue = [];
  6474. for (i = 0; i < _value.length; i++) {
  6475. if (key != [_value[i]]) {
  6476. newValue.push(_value[i]);
  6477. }
  6478. }
  6479. _self.setValue(newValue);
  6480. } else {
  6481. _self.clear();
  6482. }
  6483. }; // set the selected value(s) of the list
  6484. this.setValue = function (keys) {
  6485. var i,
  6486. newKeys = [],
  6487. saved = _value.join(' ');
  6488. if (!$.isArray(keys)) keys = [keys];
  6489. _$list.find('li').removeClass('selected');
  6490. keys = array_unique(keys);
  6491. keys.sort(function (a, b) {
  6492. var ta = cron_ui_typeof(a);
  6493. var tb = cron_ui_typeof(b);
  6494. if (ta == tb && ta == "number") return a - b;else return String(a) == String(b) ? 0 : String(a) < String(b) ? -1 : 1;
  6495. });
  6496. if (_multiple) {
  6497. for (i = 0; i < keys.length; i++) {
  6498. if (keys[i] in _values) {
  6499. _values[keys[i]].addClass('selected');
  6500. newKeys.push(keys[i]);
  6501. }
  6502. }
  6503. } else {
  6504. if (keys[0] in _values) {
  6505. _values[keys[0]].addClass('selected');
  6506. newKeys.push(keys[0]);
  6507. }
  6508. } // remove unallowed values
  6509. _value = newKeys;
  6510. if (saved != _value.join(' ')) {
  6511. _$selector.trigger('selector:change', _multiple ? keys : keys[0]);
  6512. return true;
  6513. }
  6514. return false;
  6515. }; // get the title text
  6516. this.getTitleText = function () {
  6517. var getValueText = function getValueText(key) {
  6518. return key in _values ? _values[key].text() : key;
  6519. };
  6520. if (_value.length == 0) {
  6521. return _cron.getText('empty_' + _type) || _cron.getText('empty');
  6522. }
  6523. var cron = [getValueText(_value[0])],
  6524. i,
  6525. s = _value[0],
  6526. c = _value[0],
  6527. n = _value.length;
  6528. for (i = 1; i < n; i++) {
  6529. if (_value[i] == c + 1) {
  6530. c = _value[i];
  6531. cron[cron.length - 1] = getValueText(s) + '-' + getValueText(c);
  6532. } else {
  6533. s = c = _value[i];
  6534. cron.push(getValueText(c));
  6535. }
  6536. }
  6537. return cron.join(',');
  6538. }; // clear list
  6539. this.clear = function () {
  6540. _values = {};
  6541. _self.setValue([]);
  6542. _$list.empty();
  6543. }; // add a (key, value) pair
  6544. this.add = function (key, value) {
  6545. if (!(value + '').match(/^[0-9]+$/)) _hasNumericTexts = false;
  6546. if (_numeric_zero_pad && _hasNumericTexts && value < 10) {
  6547. value = '0' + value;
  6548. }
  6549. var $item = $('<li>' + value + '</li>');
  6550. _$list.append($item);
  6551. _values[key] = $item;
  6552. $item.click(function () {
  6553. if (_multiple && $(this).hasClass('selected')) {
  6554. _self.removeValue(key);
  6555. } else {
  6556. _self.addValue(key);
  6557. if (!_multiple) _self.close();
  6558. }
  6559. });
  6560. }; // expose main jquery object
  6561. this.$ = _$selector; // constructor
  6562. _$block.find('b:eq(0)').after(_$selector).remove();
  6563. _$selector.addClass('jqCron-selector-' + _$block.find('.jqCron-selector').length).append(_$title).append(_$list).bind('selector:open', function () {
  6564. if (_hasNumericTexts) {
  6565. var nbcols = 1,
  6566. n = _$list.find('li').length;
  6567. 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;
  6568. _$list.addClass('cols' + nbcols);
  6569. }
  6570. _$list.show();
  6571. }).bind('selector:close', function () {
  6572. _$list.hide();
  6573. }).bind('selector:change', function () {
  6574. _$title.html(_self.getTitleText());
  6575. }).click(function (e) {
  6576. e.stopPropagation();
  6577. }).trigger('selector:change');
  6578. $.fn.disableSelection && _$selector.disableSelection(); // only work with jQuery UI
  6579. _$title.click(function (e) {
  6580. _self.isOpened() || _cron.isDisabled() ? _self.close() : _self.open();
  6581. });
  6582. _self.close();
  6583. _self.clear();
  6584. }
  6585. this.jqCronSelector = jqCronSelector;
  6586. }).call(window, (external_jQuery_default()));
  6587. /**
  6588. * Generate unique id for each element.
  6589. * Skip elements which have already an id.
  6590. */
  6591. (function ($) {
  6592. var jqUID = 0;
  6593. var jqGetUID = function jqGetUID(prefix) {
  6594. var id;
  6595. while (1) {
  6596. jqUID++;
  6597. id = (prefix || 'JQUID') + '' + jqUID;
  6598. if (!document.getElementById(id)) return id;
  6599. }
  6600. };
  6601. $.fn.uniqueId = function (prefix) {
  6602. return this.each(function () {
  6603. if ($(this).attr('id')) return;
  6604. var id = jqGetUID(prefix);
  6605. $(this).attr('id', id);
  6606. });
  6607. };
  6608. }).call(window, (external_jQuery_default()));
  6609. /**
  6610. * Extends jQuery selectors with new block selector
  6611. */
  6612. (function ($) {
  6613. $.extend($.expr[':'], {
  6614. container: function container(a) {
  6615. return (a.tagName + '').toLowerCase() in {
  6616. a: 1,
  6617. abbr: 1,
  6618. acronym: 1,
  6619. address: 1,
  6620. b: 1,
  6621. big: 1,
  6622. blockquote: 1,
  6623. button: 1,
  6624. cite: 1,
  6625. code: 1,
  6626. dd: 1,
  6627. del: 1,
  6628. dfn: 1,
  6629. div: 1,
  6630. dt: 1,
  6631. em: 1,
  6632. fieldset: 1,
  6633. form: 1,
  6634. h1: 1,
  6635. h2: 1,
  6636. h3: 1,
  6637. h4: 1,
  6638. h5: 1,
  6639. h6: 1,
  6640. i: 1,
  6641. ins: 1,
  6642. kbd: 1,
  6643. label: 1,
  6644. li: 1,
  6645. p: 1,
  6646. pre: 1,
  6647. q: 1,
  6648. samp: 1,
  6649. small: 1,
  6650. span: 1,
  6651. strong: 1,
  6652. sub: 1,
  6653. sup: 1,
  6654. td: 1,
  6655. tt: 1
  6656. };
  6657. },
  6658. autoclose: function autoclose(a) {
  6659. return (a.tagName + '').toLowerCase() in {
  6660. area: 1,
  6661. base: 1,
  6662. basefont: 1,
  6663. br: 1,
  6664. col: 1,
  6665. frame: 1,
  6666. hr: 1,
  6667. img: 1,
  6668. input: 1,
  6669. link: 1,
  6670. meta: 1,
  6671. param: 1
  6672. };
  6673. }
  6674. });
  6675. }).call(window, (external_jQuery_default()));
  6676. ;// CONCATENATED MODULE: ./app/forms/fields/cron.js
  6677. function cron_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6678. 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); } }
  6679. function cron_createClass(Constructor, protoProps, staticProps) { if (protoProps) cron_defineProperties(Constructor.prototype, protoProps); if (staticProps) cron_defineProperties(Constructor, staticProps); return Constructor; }
  6680. var CronField = /*#__PURE__*/function () {
  6681. function CronField() {
  6682. var _this = this;
  6683. cron_classCallCheck(this, CronField);
  6684. this.items = external_jQuery_default()();
  6685. external_jQuery_default()('[data-grav-field="cron"]').each(function (index, cron) {
  6686. return _this.addCron(cron);
  6687. });
  6688. external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
  6689. }
  6690. cron_createClass(CronField, [{
  6691. key: "addCron",
  6692. value: function addCron(cron) {
  6693. cron = external_jQuery_default()(cron);
  6694. this.items = this.items.add(cron);
  6695. cron.find('.cron-selector').each(function (index, container) {
  6696. container = external_jQuery_default()(container);
  6697. var input = container.closest('[data-grav-field]').find('input');
  6698. container.jqCron({
  6699. numeric_zero_pad: true,
  6700. enabled_minute: true,
  6701. multiple_dom: true,
  6702. multiple_month: true,
  6703. multiple_mins: true,
  6704. multiple_dow: true,
  6705. multiple_time_hours: true,
  6706. multiple_time_minutes: true,
  6707. default_period: 'hour',
  6708. default_value: input.val() || '* * * * *',
  6709. no_reset_button: false,
  6710. bind_to: input,
  6711. bind_method: {
  6712. set: function set($element, value) {
  6713. $element.val(value);
  6714. }
  6715. },
  6716. texts: {
  6717. en: {
  6718. empty: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY"],
  6719. empty_minutes: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY"],
  6720. empty_time_hours: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_HOUR"],
  6721. empty_time_minutes: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_MINUTE"],
  6722. empty_day_of_week: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_DAY_OF_WEEK"],
  6723. empty_day_of_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_DAY_OF_MONTH"],
  6724. empty_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_MONTH"],
  6725. name_minute: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.MINUTE"],
  6726. name_hour: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.HOUR"],
  6727. name_day: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.DAY"],
  6728. name_week: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.WEEK"],
  6729. name_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.MONTH"],
  6730. name_year: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.YEAR"],
  6731. text_period: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_PERIOD"],
  6732. text_mins: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_MINS"],
  6733. text_time: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_TIME"],
  6734. text_dow: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_DOW"],
  6735. text_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_MONTH"],
  6736. text_dom: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_DOM"],
  6737. error1: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR1"],
  6738. error2: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR2"],
  6739. error3: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR3"],
  6740. error4: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR4"],
  6741. weekdays: external_GravAdmin_namespaceObject.translations.GRAV_CORE.DAYS_OF_THE_WEEK,
  6742. months: external_GravAdmin_namespaceObject.translations.GRAV_CORE.MONTHS_OF_THE_YEAR
  6743. }
  6744. }
  6745. });
  6746. });
  6747. }
  6748. }, {
  6749. key: "_onAddedNodes",
  6750. value: function _onAddedNodes(event, target
  6751. /* , record, instance */
  6752. ) {
  6753. var _this2 = this;
  6754. var crons = external_jQuery_default()(target).find('[data-grav-field="cron"]');
  6755. if (!crons.length) {
  6756. return;
  6757. }
  6758. crons.each(function (index, list) {
  6759. list = external_jQuery_default()(list);
  6760. if (!~_this2.items.index(list)) {
  6761. _this2.addCron(list);
  6762. }
  6763. });
  6764. }
  6765. }]);
  6766. return CronField;
  6767. }();
  6768. var cron_Instance = new CronField();
  6769. // EXTERNAL MODULE: ./node_modules/eventemitter3/index.js
  6770. var eventemitter3 = __webpack_require__(26729);
  6771. var eventemitter3_default = /*#__PURE__*/__webpack_require__.n(eventemitter3);
  6772. ;// CONCATENATED MODULE: ./app/utils/finderjs.js
  6773. function finderjs_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { finderjs_typeof = function _typeof(obj) { return typeof obj; }; } else { finderjs_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return finderjs_typeof(obj); }
  6774. function finderjs_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6775. 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); } }
  6776. function finderjs_createClass(Constructor, protoProps, staticProps) { if (protoProps) finderjs_defineProperties(Constructor.prototype, protoProps); if (staticProps) finderjs_defineProperties(Constructor, staticProps); return Constructor; }
  6777. /**
  6778. * (c) Trilby Media, LLC
  6779. * Author Djamil Legato
  6780. *
  6781. * Based on Mark Matyas's Finderjs
  6782. * MIT License
  6783. */
  6784. var DEFAULTS = {
  6785. labelKey: 'name',
  6786. valueKey: 'value',
  6787. // new
  6788. childKey: 'children',
  6789. iconKey: 'icon',
  6790. // new
  6791. itemKey: 'item-key',
  6792. // new
  6793. pathBar: true,
  6794. className: {
  6795. container: 'fjs-container',
  6796. pathBar: 'fjs-path-bar',
  6797. col: 'fjs-col',
  6798. list: 'fjs-list',
  6799. item: 'fjs-item',
  6800. active: 'fjs-active',
  6801. children: 'fjs-has-children',
  6802. url: 'fjs-url',
  6803. itemPrepend: 'fjs-item-prepend',
  6804. itemContent: 'fjs-item-content',
  6805. itemAppend: 'fjs-item-append'
  6806. }
  6807. };
  6808. var Finder = /*#__PURE__*/function () {
  6809. function Finder(container, data, options) {
  6810. var _this = this;
  6811. finderjs_classCallCheck(this, Finder);
  6812. this.$emitter = new (eventemitter3_default())();
  6813. this.container = external_jQuery_default()(container);
  6814. this.data = data;
  6815. this.config = external_jQuery_default().extend({}, DEFAULTS, options); // dom events
  6816. this.container.on('click', this.clickEvent.bind(this));
  6817. this.container.on('keydown', this.keydownEvent.bind(this)); // internal events
  6818. this.$emitter.on('item-selected', this.itemSelected.bind(this));
  6819. this.$emitter.on('create-column', this.addColumn.bind(this));
  6820. this.$emitter.on('navigate', this.navigate.bind(this));
  6821. this.$emitter.on('go-to', this.goTo.bind(this, this.data));
  6822. this.container.addClass(this.config.className.container).attr('tabindex', 0);
  6823. this.createColumn(this.data);
  6824. if (this.config.pathBar) {
  6825. this.pathBar = this.createPathBar();
  6826. this.pathBar.on('click', '[data-breadcrumb-node]', function (event) {
  6827. event.preventDefault();
  6828. var location = external_jQuery_default()(event.currentTarget).data('breadcrumbNode');
  6829. _this.goTo(_this.data, location);
  6830. });
  6831. } // '' is <Root>
  6832. if (this.config.defaultPath || this.config.defaultPath === '') {
  6833. this.goTo(this.data, this.config.defaultPath);
  6834. }
  6835. }
  6836. finderjs_createClass(Finder, [{
  6837. key: "reload",
  6838. value: function reload() {
  6839. var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.data;
  6840. this.createColumn(data); // '' is <Root>
  6841. if (this.config.defaultPath || this.config.defaultPath === '') {
  6842. this.goTo(data, this.config.defaultPath);
  6843. }
  6844. }
  6845. }, {
  6846. key: "createColumn",
  6847. value: function createColumn(data, parent) {
  6848. var _this2 = this;
  6849. var callback = function callback(data) {
  6850. return _this2.createColumn(data, parent);
  6851. };
  6852. if (typeof data === 'function') {
  6853. data.call(this, parent, callback);
  6854. } else if (Array.isArray(data) || finderjs_typeof(data) === 'object') {
  6855. if (finderjs_typeof(data) === 'object') {
  6856. data = Array.from(data);
  6857. }
  6858. var list = this.createList(data);
  6859. var div = external_jQuery_default()('<div />');
  6860. div.append(list).addClass(this.config.className.col);
  6861. this.$emitter.emit('create-column', div);
  6862. return div;
  6863. } else {
  6864. throw new Error('Unknown data type');
  6865. }
  6866. }
  6867. }, {
  6868. key: "createPathBar",
  6869. value: function createPathBar() {
  6870. this.container.siblings(".".concat(this.config.className.pathBar)).remove();
  6871. var pathBar = external_jQuery_default()("<div class=\"".concat(this.config.className.pathBar, "\" />"));
  6872. pathBar.insertAfter(this.container);
  6873. return pathBar;
  6874. }
  6875. }, {
  6876. key: "clickEvent",
  6877. value: function clickEvent(event) {
  6878. event.stopPropagation();
  6879. event.preventDefault();
  6880. var target = external_jQuery_default()(event.target);
  6881. var column = target.closest(".".concat(this.config.className.col));
  6882. var item = target.closest(".".concat(this.config.className.item));
  6883. if (item.length) {
  6884. this.$emitter.emit('item-selected', {
  6885. column: column,
  6886. item: item
  6887. });
  6888. }
  6889. }
  6890. }, {
  6891. key: "keydownEvent",
  6892. value: function keydownEvent(event) {
  6893. var codes = {
  6894. 37: 'left',
  6895. 38: 'up',
  6896. 39: 'right',
  6897. 40: 'down'
  6898. };
  6899. if (event.keyCode in codes) {
  6900. event.stopPropagation();
  6901. event.preventDefault();
  6902. this.$emitter.emit('navigate', {
  6903. direction: codes[event.keyCode]
  6904. });
  6905. }
  6906. }
  6907. }, {
  6908. key: "itemSelected",
  6909. value: function itemSelected(value) {
  6910. var element = value.item;
  6911. if (!element.length) {
  6912. return false;
  6913. }
  6914. var item = element[0]._item;
  6915. var column = value.column;
  6916. var data = item[this.config.childKey] || this.data;
  6917. var active = external_jQuery_default()(column).find(".".concat(this.config.className.active));
  6918. if (active.length) {
  6919. active.removeClass(this.config.className.active);
  6920. }
  6921. element.addClass(this.config.className.active);
  6922. column.nextAll().remove(); // ?!?!?
  6923. this.container[0].focus();
  6924. window.scrollTo(window.pageXOffset, window.pageYOffset);
  6925. this.updatePathBar();
  6926. var newColumn;
  6927. if (data) {
  6928. newColumn = this.createColumn(data, item);
  6929. this.$emitter.emit('interior-selected', item);
  6930. } else {
  6931. this.$emitter.emit('leaf-selected', item);
  6932. }
  6933. return newColumn;
  6934. }
  6935. }, {
  6936. key: "addColumn",
  6937. value: function addColumn(column) {
  6938. this.container.append(column);
  6939. this.$emitter.emit('column-created', column);
  6940. }
  6941. }, {
  6942. key: "navigate",
  6943. value: function navigate(value) {
  6944. var active = this.findLastActive();
  6945. var direction = value.direction;
  6946. var column;
  6947. var item;
  6948. var target;
  6949. if (active) {
  6950. item = active.item;
  6951. column = active.column;
  6952. if (direction === 'up' && item.prev().length) {
  6953. target = item.prev();
  6954. } else if (direction === 'down' && item.next().length) {
  6955. target = item.next();
  6956. } else if (direction === 'right' && column.next().length) {
  6957. column = column.next();
  6958. target = column.find(".".concat(this.config.className.item)).first();
  6959. } else if (direction === 'left' && column.prev().length) {
  6960. column = column.prev();
  6961. target = column.find(".".concat(this.config.className.active)).first() || column.find(".".concat(this.config.className.item));
  6962. }
  6963. } else {
  6964. column = this.container.find(".".concat(this.config.className.col)).first();
  6965. target = column.find(".".concat(this.config.className.item)).first();
  6966. }
  6967. if (target) {
  6968. this.$emitter.emit('item-selected', {
  6969. column: column,
  6970. item: target
  6971. });
  6972. }
  6973. }
  6974. }, {
  6975. key: "goTo",
  6976. value: function goTo(data, path) {
  6977. var _this3 = this;
  6978. path = Array.isArray(path) ? path : path.split('/').map(function (bit) {
  6979. return bit.trim();
  6980. }).filter(Boolean);
  6981. if (path.length) {
  6982. this.container.children().remove();
  6983. }
  6984. if (typeof data === 'function') {
  6985. data.call(this, null, function (data) {
  6986. return _this3.selectPath(path, data);
  6987. });
  6988. } else {
  6989. this.selectPath(path, data);
  6990. }
  6991. }
  6992. }, {
  6993. key: "selectPath",
  6994. value: function selectPath(path, data, column) {
  6995. var _this4 = this;
  6996. column = column || (path.length ? this.createColumn(data) : this.container.find("> .".concat(this.config.className.col)));
  6997. var current = path[0] || '';
  6998. var children = data.find(function (item) {
  6999. return item[_this4.config.itemKey] === current;
  7000. });
  7001. var newColumn = this.itemSelected({
  7002. column: column,
  7003. item: column.find("[data-fjs-item=\"".concat(current, "\"]")).first()
  7004. });
  7005. path.shift();
  7006. if (path.length && children) {
  7007. this.selectPath(path, children[this.config.childKey], newColumn);
  7008. }
  7009. }
  7010. }, {
  7011. key: "findLastActive",
  7012. value: function findLastActive() {
  7013. var active = this.container.find(".".concat(this.config.className.active));
  7014. if (!active.length) {
  7015. return null;
  7016. }
  7017. var item = active.last();
  7018. var column = item.closest(".".concat(this.config.className.col));
  7019. return {
  7020. item: item,
  7021. column: column
  7022. };
  7023. }
  7024. }, {
  7025. key: "createList",
  7026. value: function createList(data) {
  7027. var _this5 = this;
  7028. var list = external_jQuery_default()('<ul />');
  7029. var items = data.map(function (item) {
  7030. return _this5.createItem(item);
  7031. });
  7032. var fragments = items.reduce(function (fragment, current) {
  7033. fragment.appendChild(current[0] || current);
  7034. return fragment;
  7035. }, document.createDocumentFragment());
  7036. list.append(fragments).addClass(this.config.className.list);
  7037. return list;
  7038. }
  7039. }, {
  7040. key: "createItem",
  7041. value: function createItem(item) {
  7042. var listItem = external_jQuery_default()('<li />');
  7043. var listItemClasses = [this.config.className.item];
  7044. var link = external_jQuery_default()('<a />');
  7045. var createItemContent = this.config.createItemContent || this.createItemContent;
  7046. var fragment = createItemContent.call(this, item);
  7047. link.append(fragment).attr('href', '').attr('tabindex', -1);
  7048. if (item.url) {
  7049. link.attr('href', item.url);
  7050. listItemClasses.push(item.className);
  7051. }
  7052. if (item[this.config.childKey]) {
  7053. listItemClasses.push(this.config.className[this.config.childKey]);
  7054. }
  7055. listItemClasses.push("fjs-item-".concat(item.type));
  7056. listItem.addClass(listItemClasses.join(' '));
  7057. listItem.append(link).attr('data-fjs-item', item[this.config.itemKey]);
  7058. listItem[0]._item = item;
  7059. return listItem;
  7060. }
  7061. }, {
  7062. key: "updatePathBar",
  7063. value: function updatePathBar() {
  7064. var _this6 = this;
  7065. if (!this.config.pathBar) {
  7066. return false;
  7067. }
  7068. var activeItems = this.container.find(".".concat(this.config.className.active));
  7069. var itemKeys = '';
  7070. this.pathBar.children().empty();
  7071. activeItems.each(function (index, activeItem) {
  7072. var item = activeItem._item;
  7073. var isLast = index + 1 === activeItems.length;
  7074. itemKeys += "/".concat(item[_this6.config.itemKey]);
  7075. _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 "));
  7076. });
  7077. }
  7078. }, {
  7079. key: "getIcon",
  7080. value: function getIcon(type) {
  7081. switch (type) {
  7082. case 'root':
  7083. return 'fa-sitemap';
  7084. case 'file':
  7085. return 'fa-file-o';
  7086. case 'dir':
  7087. default:
  7088. return 'fa-folder';
  7089. }
  7090. }
  7091. }]);
  7092. return Finder;
  7093. }();
  7094. /* harmony default export */ const finderjs = (Finder);
  7095. ;// CONCATENATED MODULE: ./app/forms/fields/parents.js
  7096. function parents_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7097. 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); } }
  7098. function parents_createClass(Constructor, protoProps, staticProps) { if (protoProps) parents_defineProperties(Constructor.prototype, protoProps); if (staticProps) parents_defineProperties(Constructor, staticProps); return Constructor; }
  7099. var XHRUUID = 0;
  7100. var parents_Instances = {};
  7101. var Parents = /*#__PURE__*/function () {
  7102. function Parents(container, field, data) {
  7103. var _this = this;
  7104. parents_classCallCheck(this, Parents);
  7105. this.container = external_jQuery_default()(container);
  7106. this.fieldName = field.attr('name');
  7107. this.field = external_jQuery_default()("[name=\"".concat(this.fieldName, "\"]"));
  7108. this.data = data;
  7109. this.parentLabel = external_jQuery_default()("[data-parents-field-label=\"".concat(this.fieldName, "\"]"));
  7110. this.parentName = external_jQuery_default()("[data-parents-field-name=\"".concat(this.fieldName, "\"]"));
  7111. var dataLoad = this.dataLoad;
  7112. this.finder = new finderjs(this.container, function (parent, callback) {
  7113. return dataLoad.call(_this, parent, callback);
  7114. }, {
  7115. labelKey: 'name',
  7116. defaultPath: this.field.val(),
  7117. createItemContent: function createItemContent(item) {
  7118. return Parents.createItemContent(this.config, item);
  7119. }
  7120. });
  7121. /*
  7122. this.finder.$emitter.on('leaf-selected', (item) => {
  7123. console.log('selected', item);
  7124. this.finder.emit('create-column', () => this.createSimpleColumn(item));
  7125. });
  7126. this.finder.$emitter.on('item-selected', (selected) => {
  7127. console.log('selected', selected);
  7128. // for future use only - create column-card creation for file with details like in macOS finder
  7129. // this.finder.$emitter('create-column', () => this.createSimpleColumn(selected));
  7130. }); */
  7131. this.finder.$emitter.on('column-created', function () {
  7132. _this.container[0].scrollLeft = _this.container[0].scrollWidth - _this.container[0].clientWidth;
  7133. });
  7134. }
  7135. parents_createClass(Parents, [{
  7136. key: "createSimpleColumn",
  7137. value: function createSimpleColumn(item) {}
  7138. }, {
  7139. key: "dataLoad",
  7140. value: function dataLoad(parent, callback) {
  7141. var _this2 = this;
  7142. if (!parent) {
  7143. return callback(this.data);
  7144. }
  7145. if (parent.type !== 'dir' || !parent['has-children']) {
  7146. return false;
  7147. }
  7148. var UUID = ++XHRUUID;
  7149. this.startLoader();
  7150. external_jQuery_default().ajax({
  7151. url: "".concat(external_GravAdmin_namespaceObject.config.current_url),
  7152. method: 'post',
  7153. data: Object.assign({}, getExtraFormData(this.container), {
  7154. route: b64_encode_unicode(parent.value),
  7155. field: this.field.data('fieldName'),
  7156. action: 'getLevelListing',
  7157. 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce
  7158. }),
  7159. success: function success(response) {
  7160. _this2.stopLoader();
  7161. if (response.status === 'error') {
  7162. _this2.finder.$emitter.emit('create-column', Parents.createErrorColumn(response.message)[0]);
  7163. return false;
  7164. } // stale request
  7165. if (UUID !== XHRUUID) {
  7166. return false;
  7167. }
  7168. return callback(response.data);
  7169. }
  7170. });
  7171. }
  7172. }, {
  7173. key: "startLoader",
  7174. value: function startLoader() {
  7175. this.loadingIndicator = Parents.createLoadingColumn();
  7176. this.finder.$emitter.emit('create-column', this.loadingIndicator[0]);
  7177. return this.loadingIndicator;
  7178. }
  7179. }, {
  7180. key: "stopLoader",
  7181. value: function stopLoader() {
  7182. return this.loadingIndicator && this.loadingIndicator.remove();
  7183. }
  7184. }], [{
  7185. key: "createItemContent",
  7186. value: function createItemContent(config, item) {
  7187. var frag = document.createDocumentFragment();
  7188. var label = external_jQuery_default()("<span title=\"".concat(item[config.labelKey], "\" />"));
  7189. var infoContainer = external_jQuery_default()('<span class="info-container" />');
  7190. var iconPrepend = external_jQuery_default()('<i />');
  7191. var iconAppend = external_jQuery_default()('<i />');
  7192. var badge = external_jQuery_default()('<span class="badge" />');
  7193. var prependClasses = ['fa'];
  7194. var appendClasses = ['fa']; // prepend icon
  7195. if (item.children || item.type === 'dir') {
  7196. prependClasses.push('fa-folder');
  7197. } else if (item.type === 'root') {
  7198. prependClasses.push('fa-sitemap');
  7199. } else if (item.type === 'file') {
  7200. prependClasses.push('fa-file-o');
  7201. }
  7202. iconPrepend.addClass(prependClasses.join(' ')); // text label
  7203. label.text(item[config.labelKey]).prepend(iconPrepend);
  7204. label.appendTo(frag); // append icon
  7205. if (item.children || item['has-children']) {
  7206. appendClasses.push('fa-caret-right');
  7207. badge.text(item.size || item.count || 0);
  7208. badge.appendTo(infoContainer);
  7209. }
  7210. iconAppend.addClass(appendClasses.join(' '));
  7211. iconAppend.appendTo(infoContainer);
  7212. infoContainer.appendTo(frag);
  7213. return frag;
  7214. }
  7215. }, {
  7216. key: "createLoadingColumn",
  7217. value: function createLoadingColumn() {
  7218. 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 ");
  7219. }
  7220. }, {
  7221. key: "createErrorColumn",
  7222. value: function createErrorColumn(error) {
  7223. 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 "));
  7224. }
  7225. }]);
  7226. return Parents;
  7227. }();
  7228. var b64_encode_unicode = function b64_encode_unicode(str) {
  7229. return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
  7230. return String.fromCharCode('0x' + p1);
  7231. }));
  7232. };
  7233. var b64_decode_unicode = function b64_decode_unicode(str) {
  7234. return decodeURIComponent(atob(str).split('').map(function (c) {
  7235. return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  7236. }).join(''));
  7237. };
  7238. var getExtraFormData = function getExtraFormData(container) {
  7239. var form = container.closest('form');
  7240. if (container.closest('[data-remodal-id]').length) {
  7241. form = external_jQuery_default()('form#blueprints');
  7242. }
  7243. var data = {};
  7244. var unique_id = form.find('[name="__unique_form_id__"]');
  7245. data['__form-name__'] = form.find('[name="__form-name__"]').val();
  7246. data['form-nonce'] = form.find('[name="form-nonce"]').val();
  7247. if (unique_id.length) {
  7248. data['__unique_form_id__'] = unique_id.val();
  7249. }
  7250. return data;
  7251. };
  7252. external_jQuery_default()(document).on('click', '[data-parents]', function (event) {
  7253. event.preventDefault();
  7254. event.stopPropagation();
  7255. var target = external_jQuery_default()(event.currentTarget);
  7256. var field = target.closest('.parents-wrapper').find('input[name]');
  7257. var fieldName = field.attr('name');
  7258. if (!field.length) {
  7259. fieldName = target.data('parents');
  7260. field = external_jQuery_default()("[name=\"".concat(target.data('parents'), "\"]")).first();
  7261. }
  7262. var modal = external_jQuery_default()("[data-remodal-id=\"".concat(target.data('remodalTarget') || 'parents', "\"]"));
  7263. var loader = modal.find('.grav-loading');
  7264. var content = modal.find('.parents-content');
  7265. loader.css('display', 'block');
  7266. content.html('');
  7267. external_jQuery_default().ajax({
  7268. url: "".concat(external_GravAdmin_namespaceObject.config.current_url),
  7269. method: 'post',
  7270. data: Object.assign({}, getExtraFormData(target), {
  7271. route: b64_encode_unicode(field.val()),
  7272. field: field.data('fieldName'),
  7273. action: 'getLevelListing',
  7274. 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce,
  7275. initial: true
  7276. }),
  7277. success: function success(response) {
  7278. loader.css('display', 'none');
  7279. if (response.status === 'error') {
  7280. content.html(response.message);
  7281. return true;
  7282. }
  7283. if (!parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))]) {
  7284. parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))] = new Parents(content, field, response.data);
  7285. } else {
  7286. parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))].finder.reload(response.data);
  7287. }
  7288. modal.data('parents', parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))]);
  7289. modal.data('parents-selectedField', field);
  7290. }
  7291. });
  7292. }); // apply finder selection to field
  7293. external_jQuery_default()(document).on('click', '[data-remodal-id].parents-container [data-parents-select]', function (event) {
  7294. var modal = external_jQuery_default()(event.currentTarget).closest('[data-remodal-id]');
  7295. var parents = modal.data('parents');
  7296. var selectedField = modal.data('parentsSelectedField');
  7297. var finder = parents.finder;
  7298. var field = parents.field;
  7299. var parentLabel = parents.parentLabel;
  7300. var parentName = parents.parentName;
  7301. var selection = finder.findLastActive().item[0];
  7302. var value = selection._item[finder.config.valueKey];
  7303. var name = selection._item[finder.config.labelKey];
  7304. if (selectedField.closest('.remodal').length) {
  7305. var index = field.index(selectedField);
  7306. selectedField.val(value);
  7307. external_jQuery_default()(parentLabel[index]).text(value);
  7308. external_jQuery_default()(parentName[index]).text(name);
  7309. } else {
  7310. field.val(value);
  7311. parentLabel.text(value);
  7312. parentName.text(name);
  7313. finder.config.defaultPath = value;
  7314. }
  7315. var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()("[data-remodal-id=\"".concat(modal.data('remodalId'), "\"]")).data('remodal')];
  7316. remodal.close();
  7317. });
  7318. ;// CONCATENATED MODULE: ./app/forms/fields/acl-picker.js
  7319. var acl_picker_body = external_jQuery_default()('body');
  7320. acl_picker_body.on('change', '[data-acl_picker] select', function (event) {
  7321. var target = external_jQuery_default()(event.currentTarget);
  7322. var value = target.val();
  7323. var item = target.closest('.permissions-item');
  7324. var inputs = item.find('input[type="checkbox"], input[type="radio"]');
  7325. var hidden = item.find('input[type="hidden"][name]');
  7326. var wrapper = target.closest('[data-acl_picker_id]');
  7327. var type = item.data('fieldType');
  7328. if (type === 'access') {
  7329. inputs.each(function (index, input) {
  7330. input = external_jQuery_default()(input);
  7331. var name = input.prop('name');
  7332. input.prop('name', name.replace(/(.*)(\[[^\]]*\])/, "$1[".concat(value, "]")));
  7333. });
  7334. } else if (type === 'permissions') {
  7335. var crudpContainer = item.find('[data-field-name]');
  7336. inputs.each(function (index, input) {
  7337. input = external_jQuery_default()(input);
  7338. var rand = Math.round(Math.random() * 500);
  7339. var name = crudpContainer.data('fieldName');
  7340. var id = input.prop('id').split('_').slice(0, -1).join('_') + "_".concat(value, "+").concat(rand); // const key = input.data('crudpKey');
  7341. hidden.prop('name', name.replace(/(.*)(\[[^\]]*\])/, "$1[".concat(value, "]")));
  7342. input.prop('id', id);
  7343. input.next('label').prop('for', id);
  7344. });
  7345. }
  7346. wrapper.find('.permissions-item .button.add-item')[!value ? 'addClass' : 'removeClass']('disabled').prop('disabled', !value ? 'disabled' : null);
  7347. });
  7348. acl_picker_body.on('input', 'input[data-crudp-key]', function (event) {
  7349. var target = external_jQuery_default()(event.currentTarget);
  7350. var container = target.closest('.crudp-container');
  7351. var hidden = container.find('input[type="hidden"][name]');
  7352. var key = target.data('crudpKey');
  7353. var json = JSON.parse(hidden.val() || '{}');
  7354. json[key] = target.val();
  7355. hidden.val(JSON.stringify(json));
  7356. });
  7357. acl_picker_body.on('click', '[data-acl_picker] .remove-item', function (event) {
  7358. event.preventDefault();
  7359. var target = external_jQuery_default()(event.currentTarget);
  7360. var container = target.closest('.permissions-item');
  7361. var wrapper = target.closest('[data-acl_picker_id]');
  7362. container.remove();
  7363. var empty = wrapper.find('.permissions-item').length === 1; // show the initial + button
  7364. if (empty) {
  7365. wrapper.find('.permissions-item.empty-list').removeClass('hidden');
  7366. }
  7367. });
  7368. acl_picker_body.on('click', '[data-acl_picker] .add-item', function (event) {
  7369. event.preventDefault();
  7370. var target = external_jQuery_default()(event.currentTarget);
  7371. var item = target.closest('.permissions-item');
  7372. var wrapper = target.closest('[data-acl_picker_id]');
  7373. var ID = wrapper.data('acl_picker_id');
  7374. var template = document.querySelector("template[data-id=\"acl_picker-".concat(ID, "\"]"));
  7375. var clone = external_jQuery_default()(template.content.firstElementChild).clone();
  7376. clone.insertAfter(item); // randomize ids
  7377. clone.find('.switch-toggle input[type="radio"]').each(function (index, input) {
  7378. input = external_jQuery_default()(input);
  7379. var id = input.prop('id');
  7380. var label = input.next('label');
  7381. var rand = (Date.now().toString(36) + Math.random().toString(36).substr(2, 5)).toLowerCase();
  7382. input.prop('id', "".concat(id).concat(rand));
  7383. label.prop('for', "".concat(id).concat(rand));
  7384. }); // hide the initial + button
  7385. wrapper.find('.permissions-item.empty-list').addClass('hidden'); // disable all + buttons until one is selected
  7386. wrapper.find('.permissions-item .button.add-item').addClass('disabled').prop('disabled', 'disabled');
  7387. });
  7388. ;// CONCATENATED MODULE: ./app/forms/fields/permissions.js
  7389. var permissions_body = external_jQuery_default()('body');
  7390. var radioSelector = '.permission-container.parent-section input[type="radio"]';
  7391. var handleParent = function handleParent(event) {
  7392. var target = external_jQuery_default()(event.currentTarget);
  7393. var value = target.val();
  7394. var container = target.closest('.parent-section');
  7395. var fieldset = container.next('fieldset');
  7396. var radios = fieldset.find("input[type=\"radio\"][value=\"".concat(value, "\"]"));
  7397. if (container.data('isLocked') !== false) {
  7398. container.data('isUpdating', true);
  7399. radios.each(function (index, radio) {
  7400. var ID = radio.id;
  7401. external_jQuery_default()(radio).siblings("[for=\"".concat(ID, "\"]")).trigger('click');
  7402. });
  7403. container.data('isUpdating', false);
  7404. }
  7405. };
  7406. var boundHandleParent = handleParent.bind(handleParent);
  7407. permissions_body.on('click', '.permission-container.parent-section label', function (event) {
  7408. var target = external_jQuery_default()(event.currentTarget);
  7409. var container = target.closest('.parent-section');
  7410. container.data('isLocked', true);
  7411. });
  7412. permissions_body.on('input', radioSelector, boundHandleParent);
  7413. permissions_body.on('input', '.permissions-container input[type="radio"][data-parent-id]', function (event) {
  7414. var target = external_jQuery_default()(event.currentTarget);
  7415. var parent = external_jQuery_default()("[for=\"".concat(target.data('parentId'), "\"]"));
  7416. var container = target.closest('fieldset').prev('.permission-container.parent-section');
  7417. if (container.data('isUpdating') === true) {
  7418. return true;
  7419. }
  7420. permissions_body.off('input', radioSelector, boundHandleParent);
  7421. container.data('isLocked', false);
  7422. parent.trigger('click');
  7423. permissions_body.on('input', radioSelector, boundHandleParent);
  7424. });
  7425. ;// CONCATENATED MODULE: ./app/forms/fields/indeterminate.js
  7426. document.addEventListener('click', function (event) {
  7427. if (document.querySelector('#pages-filters')) {
  7428. return true;
  7429. }
  7430. var wrapper = event.target.closest('.checkboxes.indeterminate');
  7431. if (wrapper) {
  7432. event.preventDefault();
  7433. var checkbox = wrapper.querySelector('input[type="checkbox"]:not([disabled])');
  7434. var checkStatus = wrapper.dataset._checkStatus;
  7435. wrapper.classList.remove('status-checked', 'status-unchecked', 'status-indeterminate');
  7436. switch (checkStatus) {
  7437. // checked, going indeterminate
  7438. case '1':
  7439. wrapper.dataset._checkStatus = '2';
  7440. checkbox.indeterminate = true;
  7441. checkbox.checked = false;
  7442. checkbox.value = 0;
  7443. wrapper.classList.add('status-indeterminate');
  7444. break;
  7445. // indeterminate, going unchecked
  7446. case '2':
  7447. wrapper.dataset._checkStatus = '0';
  7448. checkbox.indeterminate = false;
  7449. checkbox.checked = false;
  7450. checkbox.value = '';
  7451. wrapper.classList.add('status-unchecked');
  7452. break;
  7453. // unchecked, going checked
  7454. case '0':
  7455. default:
  7456. wrapper.dataset._checkStatus = '1';
  7457. checkbox.indeterminate = false;
  7458. checkbox.checked = true;
  7459. checkbox.value = 1;
  7460. wrapper.classList.add('status-checked');
  7461. break;
  7462. } // const input = new CustomEvent('input', { detail: { target: checkbox }});
  7463. // document.dispatchEvent(input);
  7464. external_jQuery_default()(checkbox).trigger('input');
  7465. }
  7466. });
  7467. (document.querySelectorAll('input[type="checkbox"][indeterminate="true"]') || []).forEach(function (input) {
  7468. input.indeterminate = true;
  7469. });
  7470. ;// CONCATENATED MODULE: ./app/forms/fields/mediapicker.js
  7471. external_jQuery_default()(function () {
  7472. var modal = '';
  7473. var body = external_jQuery_default()('body'); // Thumb Resizer
  7474. external_jQuery_default()(document).on('input change', '.media-container .media-range', function (event) {
  7475. var target = external_jQuery_default()(event.currentTarget);
  7476. var container = target.closest('.remodal');
  7477. var cards = container.find('.media-container div.card-item');
  7478. var width = target.val() + 'px';
  7479. cards.each(function () {
  7480. external_jQuery_default()(this).css('width', width);
  7481. });
  7482. });
  7483. body.on('click', '[data-mediapicker-modal-trigger]', function (event) {
  7484. var element = external_jQuery_default()(event.currentTarget);
  7485. var modal_identifier = external_jQuery_default()(this).data('grav-mediapicker-unique-identifier');
  7486. var modal_element = body.find("[data-remodal-unique-identifier=\"".concat(modal_identifier, "\"]"));
  7487. modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
  7488. if (!modal) {
  7489. modal_element.remodal();
  7490. modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
  7491. }
  7492. modal.open();
  7493. modal.dataField = element.find('input'); // load all media
  7494. modal_element.find('.js__files').trigger('fillView');
  7495. setTimeout(function () {
  7496. return tree_Instance.reload();
  7497. }, 100);
  7498. });
  7499. /* handle media modal click actions */
  7500. body.on('click', '[data-remodal-mediapicker] .media-container.in-modal .admin-media-details a', function (event) {
  7501. event.preventDefault();
  7502. event.stopPropagation();
  7503. var val = external_jQuery_default()(event.target).parents('.js__media-element').data('file-url');
  7504. var string = val.replace(/ /g, '%20');
  7505. modal.dataField.val(string);
  7506. modal.close();
  7507. });
  7508. });
  7509. ;// CONCATENATED MODULE: ./app/forms/fields/multilevel.js
  7510. external_jQuery_default()(function () {
  7511. var getField = function getField(level, name) {
  7512. var levelMargin = level * 50;
  7513. var top = level === 0 ? 'top' : '';
  7514. var the_name = 'name="' + name + '"';
  7515. if (level === 0) {
  7516. // top
  7517. the_name = 'data-attr-name="' + name + '"';
  7518. }
  7519. var marginDir = window.getComputedStyle(document.body).direction === 'ltr' ? 'margin-left' : 'margin-right';
  7520. 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 ");
  7521. return field;
  7522. };
  7523. var hasChildInputs = function hasChildInputs($element) {
  7524. if ($element.attr('name')) {
  7525. return false;
  7526. }
  7527. return true;
  7528. };
  7529. var getTopItems = function getTopItems(element) {
  7530. return external_jQuery_default()(element + ' .js__multilevel-field.top');
  7531. };
  7532. var refreshControls = function refreshControls(unique_identifier) {
  7533. var element = '[data-grav-multilevel-field]';
  7534. if (unique_identifier) {
  7535. element = '[data-grav-multilevel-field][data-id="' + unique_identifier + '"]';
  7536. }
  7537. var hideButtons = function hideButtons() {
  7538. external_jQuery_default()(element + ' .js__add-sibling').addClass('hidden');
  7539. external_jQuery_default()(element + ' .js__add-children').addClass('hidden');
  7540. };
  7541. var restoreAddSiblingButtons = function restoreAddSiblingButtons() {
  7542. external_jQuery_default()(element + ' .children-wrapper').each(function () {
  7543. var elements = external_jQuery_default()(this).children();
  7544. elements.last().each(function () {
  7545. var field = external_jQuery_default()(this);
  7546. if (!external_jQuery_default()(this).hasClass('js__multilevel-field')) {
  7547. field = external_jQuery_default()(this).find('.js__multilevel-field').first();
  7548. }
  7549. field.find('.js__add-sibling').removeClass('hidden');
  7550. });
  7551. }); // add sibling to the last top element
  7552. external_jQuery_default()(element + ' .js__multilevel-field.top').last().find('.js__add-sibling').removeClass('hidden');
  7553. };
  7554. var restoreAddChildrenButtons = function restoreAddChildrenButtons() {
  7555. external_jQuery_default()(element + ' .js__multilevel-field').each(function () {
  7556. if (external_jQuery_default()(this).siblings('.children-wrapper').length === 0 || external_jQuery_default()(this).siblings('.children-wrapper').find('.js__multilevel-field').length === 0) {
  7557. external_jQuery_default()(this).find('.js__add-children').removeClass('hidden');
  7558. }
  7559. });
  7560. };
  7561. var preventRemovingLastTopItem = function preventRemovingLastTopItem() {
  7562. var top_items = getTopItems(element);
  7563. if (top_items.length === 1) {
  7564. top_items.first().find('.js__remove-item').addClass('hidden');
  7565. }
  7566. };
  7567. hideButtons();
  7568. restoreAddSiblingButtons();
  7569. restoreAddChildrenButtons();
  7570. preventRemovingLastTopItem();
  7571. };
  7572. var changeAllOccurrencesInTree = function changeAllOccurrencesInTree($el, current_name, new_name) {
  7573. $el.parents('[data-grav-multilevel-field]').find('input').each(function () {
  7574. var $input = external_jQuery_default()(this);
  7575. if ($input.attr('name')) {
  7576. $input.attr('name', $input.attr('name').replace(current_name, new_name));
  7577. }
  7578. if ($input.attr('data-attr-name')) {
  7579. $input.attr('data-attr-name', $input.attr('data-attr-name').replace(current_name, new_name));
  7580. }
  7581. });
  7582. };
  7583. external_jQuery_default()(document).ready(function () {
  7584. refreshControls();
  7585. });
  7586. external_jQuery_default()(document).on('mouseleave', '[data-grav-multilevel-field]', function (event) {
  7587. var top_items = getTopItems('[data-id="' + external_jQuery_default()(this).data('id') + '"]');
  7588. var has_top_items_without_children = false;
  7589. var element_content = '';
  7590. top_items.each(function () {
  7591. var item = external_jQuery_default()(this);
  7592. if (external_jQuery_default()(item).siblings('.children-wrapper').find('input').length === 0) {
  7593. has_top_items_without_children = true;
  7594. element_content = item.find('input').val();
  7595. }
  7596. });
  7597. if (has_top_items_without_children) {
  7598. if (element_content) {
  7599. alert('Warning: if you save now, the element ' + element_content + ', without children, will be removed, because it\'s invalid YAML');
  7600. } else {
  7601. alert('Warning: if you save now, the top elements without children will be removed, because it\'s invalid YAML');
  7602. }
  7603. }
  7604. });
  7605. external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__add-children', function (event) {
  7606. var element = external_jQuery_default()(this);
  7607. var unique_container_id = element.closest('.js__multilevel-field').data('id');
  7608. var level = element.data('level') + 1;
  7609. var getParentOfElement = function getParentOfElement(element) {
  7610. var parent = element.closest('.js__multilevel-field').parent().first();
  7611. if (parent.find('.children-wrapper').length === 0) {
  7612. external_jQuery_default()(parent).append('<div class="children-wrapper"></div>');
  7613. }
  7614. parent = parent.find('.children-wrapper').first();
  7615. return parent;
  7616. };
  7617. var getNameFromParentInput = function getNameFromParentInput(parentInput, attr) {
  7618. if (parentInput.hasClass('children-wrapper')) {
  7619. parentInput = parentInput.siblings('.js__multilevel-field').first().find('input');
  7620. }
  7621. return parentInput.attr(attr) + '[' + parentInput.val() + ']';
  7622. };
  7623. var getInputFromChildrenWrapper = function getInputFromChildrenWrapper(parentChildrenWrapper) {
  7624. return parentChildrenWrapper.siblings('.js__multilevel-field').first().find('input');
  7625. };
  7626. var parentChildrenWrapper = getParentOfElement(element);
  7627. var parentInput = getInputFromChildrenWrapper(parentChildrenWrapper);
  7628. var attr = 'name';
  7629. if (parentInput.closest('.js__multilevel-field').hasClass('top')) {
  7630. attr = 'data-attr-name';
  7631. }
  7632. parentInput.attr(attr, parentInput.attr(attr).replace('[]', ''));
  7633. var name = getNameFromParentInput(parentInput, attr);
  7634. var field = getField(level, name);
  7635. external_jQuery_default()(parentChildrenWrapper).append(field);
  7636. refreshControls(unique_container_id);
  7637. });
  7638. external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__add-sibling', function (event) {
  7639. var element = external_jQuery_default()(this);
  7640. var unique_container_id = element.closest('.js__multilevel-field').data('id');
  7641. var level = element.data('level');
  7642. element.closest('.children-wrapper').find('.js__add-sibling').addClass('hidden');
  7643. var sibling = null;
  7644. var is_top = false;
  7645. if (element.closest('.js__multilevel-field').hasClass('top')) {
  7646. is_top = true;
  7647. }
  7648. if (is_top) {
  7649. sibling = element.closest('.js__multilevel-field').first().find('input').last();
  7650. } else {
  7651. sibling = element.siblings('input').first();
  7652. if (!sibling) {
  7653. sibling = element.closest('.children-wrapper').first().find('input').last();
  7654. }
  7655. }
  7656. var getParentOfElement = function getParentOfElement(element) {
  7657. var parent = element.closest('.js__multilevel-field').parent().first();
  7658. if (!parent.hasClass('element-wrapper')) {
  7659. if (parent.find('.element-wrapper').length === 0) {
  7660. external_jQuery_default()(parent).append('<div class="element-wrapper"></div>');
  7661. }
  7662. parent = parent.find('.element-wrapper').first();
  7663. }
  7664. return parent;
  7665. };
  7666. var getNameFromSibling = function getNameFromSibling(parent, sibling) {
  7667. var is_top = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7668. var name = sibling.attr('name');
  7669. if (hasChildInputs(sibling)) {
  7670. var val = sibling.data('attr-name') + '[]';
  7671. sibling.removeAttr('name');
  7672. return val;
  7673. }
  7674. var last_index = name.lastIndexOf('[');
  7675. var almost_there = name.substr(last_index + 1);
  7676. var last_tag = almost_there.substr(0, almost_there.length - 1);
  7677. if (external_jQuery_default().isNumeric(last_tag)) {
  7678. name = name.replace('[' + last_tag + ']', '[' + (parseInt(last_tag, 10) + 1) + ']');
  7679. } else {
  7680. if (is_top) {
  7681. name = name.replace('[' + last_tag + ']', '');
  7682. } else {
  7683. name = name + '[1]'; // change sibling name attr if necessary
  7684. if (sibling.attr('name').slice('-2') !== '[0]') {
  7685. changeAllOccurrencesInTree(sibling, sibling.attr('name'), sibling.attr('name') + '[0]');
  7686. }
  7687. }
  7688. }
  7689. return name;
  7690. };
  7691. var parent = getParentOfElement(element);
  7692. var name = getNameFromSibling(parent, sibling, is_top);
  7693. var field = getField(level, name);
  7694. external_jQuery_default()(field).insertAfter(parent);
  7695. refreshControls(unique_container_id);
  7696. });
  7697. external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__remove-item', function (event) {
  7698. external_jQuery_default()(this).parents('.element-wrapper').first().remove();
  7699. var unique_container_id = external_jQuery_default()(this).closest('.js__multilevel-field').data('id');
  7700. refreshControls(unique_container_id);
  7701. }); // Store old value before editing a field
  7702. external_jQuery_default()(document).on('focusin', '[data-grav-multilevel-field] input', function (event) {
  7703. external_jQuery_default()(this).data('current-value', external_jQuery_default()(this).val());
  7704. }); // Handle field edited event
  7705. external_jQuery_default()(document).on('change', '[data-grav-multilevel-field] input', function (event) {
  7706. var $el = external_jQuery_default()(this);
  7707. var old_value = $el.data('current-value');
  7708. var new_value = $el.val();
  7709. var full_name = $el.attr('name') || $el.attr('data-attr-name'); // first-level items have `data-attr-name` instead of `name`
  7710. var old_name_attr = full_name + '[' + old_value + ']';
  7711. var new_name_attr = full_name + '[' + new_value + ']';
  7712. changeAllOccurrencesInTree($el, old_name_attr, new_name_attr);
  7713. });
  7714. });
  7715. ;// CONCATENATED MODULE: ./app/forms/fields/text.js
  7716. external_jQuery_default()(document).ready(function () {
  7717. external_jQuery_default()('.copy-to-clipboard').click(function (event) {
  7718. var $tempElement = external_jQuery_default()('<input>');
  7719. external_jQuery_default()('body').append($tempElement);
  7720. $tempElement.val(external_jQuery_default()(this).prev('input').val()).select();
  7721. document.execCommand('Copy');
  7722. $tempElement.remove();
  7723. external_jQuery_default()(this).attr('data-hint', 'Copied to clipboard!').addClass('hint--left');
  7724. });
  7725. });
  7726. ;// CONCATENATED MODULE: ./app/forms/fields/range.js
  7727. external_jQuery_default()(document).on('input', '[type="range"].rangefield, [type="number"].rangefield', function (event) {
  7728. var target = external_jQuery_default()(event.currentTarget);
  7729. var type = target.attr('type').toLowerCase();
  7730. var sibling = type === 'range' ? 'number' : 'range';
  7731. var feedback = target.siblings("[type=\"".concat(sibling, "\"].rangefield"));
  7732. feedback.val(target.val());
  7733. });
  7734. ;// CONCATENATED MODULE: ./app/forms/fields/index.js
  7735. /* harmony default export */ const fields = ({
  7736. FilepickerField: {
  7737. FilepickerField: FilePickerField,
  7738. Instance: filepicker_Instance
  7739. },
  7740. SelectizeField: {
  7741. SelectizeField: SelectizeField,
  7742. Instance: selectize_Instance
  7743. },
  7744. ArrayField: {
  7745. ArrayField: ArrayField,
  7746. Instance: array_Instance
  7747. },
  7748. CollectionsField: {
  7749. CollectionsField: CollectionsField,
  7750. Instance: collections_Instance
  7751. },
  7752. DateTimeField: {
  7753. DateTimeField: DateTimeField,
  7754. Instance: datetime_Instance
  7755. },
  7756. EditorField: {
  7757. EditorField: EditorField,
  7758. Instance: editor_Instance
  7759. },
  7760. ColorpickerField: {
  7761. ColorpickerField: ColorpickerField,
  7762. Instance: colorpicker_Instance
  7763. },
  7764. FilesField: {
  7765. FilesField: FilesField,
  7766. Instance: files_Instance
  7767. },
  7768. FolderField: {
  7769. Regenerate: fields_folder
  7770. },
  7771. SelectUniqueField: {
  7772. SelectUniqueField: SelectUniqueField,
  7773. Instance: selectunique_Instance
  7774. },
  7775. IconpickerField: {
  7776. IconpickerField: IconpickerField,
  7777. Instance: iconpicker_Instance
  7778. },
  7779. CronField: {
  7780. CronField: CronField,
  7781. Instance: cron_Instance
  7782. },
  7783. ParentsField: {
  7784. ParentsField: Parents,
  7785. Instance: parents_Instances
  7786. }
  7787. });
  7788. ;// CONCATENATED MODULE: ./app/forms/index.js
  7789. /* harmony default export */ const app_forms = ({
  7790. Form: {
  7791. Form: Form,
  7792. Instance: form_Instance
  7793. },
  7794. Fields: fields,
  7795. FormState: {
  7796. FormState: FormState,
  7797. Instance: state_Instance
  7798. }
  7799. });
  7800. ;// CONCATENATED MODULE: ./app/utils/cookies.js
  7801. function cookies_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { cookies_typeof = function _typeof(obj) { return typeof obj; }; } else { cookies_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return cookies_typeof(obj); }
  7802. /*
  7803. * Cookies.js - 1.2.3-grav
  7804. * https://github.com/ScottHamper/Cookies
  7805. *
  7806. * With SameSite support by Grav
  7807. *
  7808. * This is free and unencumbered software released into the public domain.
  7809. */
  7810. var factory = function factory(window) {
  7811. var _arguments = arguments;
  7812. if (cookies_typeof(window.document) !== 'object') {
  7813. throw new Error('Cookies.js requires a `window` with a `document` object');
  7814. }
  7815. var Cookies = function Cookies(key, value, options) {
  7816. alert('a');
  7817. return _arguments.length === 1 ? Cookies.get(key) : Cookies.set(key, value, options);
  7818. }; // Allows for setter injection in unit tests
  7819. Cookies._document = window.document; // Used to ensure cookie keys do not collide with
  7820. // built-in `Object` properties
  7821. Cookies._cacheKeyPrefix = 'cookey.'; // Hurr hurr, :)
  7822. Cookies._maxExpireDate = new Date('Fri, 31 Dec 9999 23:59:59 UTC');
  7823. Cookies.defaults = {
  7824. path: '/',
  7825. secure: false,
  7826. sameSite: 'Lax'
  7827. };
  7828. Cookies.get = function (key) {
  7829. if (Cookies._cachedDocumentCookie !== Cookies._document.cookie) {
  7830. Cookies._renewCache();
  7831. }
  7832. var value = Cookies._cache[Cookies._cacheKeyPrefix + key];
  7833. return value === undefined ? undefined : decodeURIComponent(value);
  7834. };
  7835. Cookies.set = function (key, value, options) {
  7836. options = Cookies._getExtendedOptions(options);
  7837. options.expires = Cookies._getExpiresDate(value === undefined ? -1 : options.expires);
  7838. Cookies._document.cookie = Cookies._generateCookieString(key, value, options);
  7839. return Cookies;
  7840. };
  7841. Cookies.expire = function (key, options) {
  7842. return Cookies.set(key, undefined, options);
  7843. };
  7844. Cookies._getExtendedOptions = function (options) {
  7845. return {
  7846. path: options && options.path || Cookies.defaults.path,
  7847. domain: options && options.domain || Cookies.defaults.domain,
  7848. expires: options && options.expires || Cookies.defaults.expires,
  7849. secure: options && options.secure !== undefined ? options.secure : Cookies.defaults.secure,
  7850. sameSite: options && options.sameSite || Cookies.defaults.sameSite
  7851. };
  7852. };
  7853. Cookies._isValidDate = function (date) {
  7854. return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
  7855. };
  7856. Cookies._getExpiresDate = function (expires, now) {
  7857. now = now || new Date();
  7858. if (typeof expires === 'number') {
  7859. expires = expires === Infinity ? Cookies._maxExpireDate : new Date(now.getTime() + expires * 1000);
  7860. } else if (typeof expires === 'string') {
  7861. expires = new Date(expires);
  7862. }
  7863. if (expires && !Cookies._isValidDate(expires)) {
  7864. throw new Error('`expires` parameter cannot be converted to a valid Date instance');
  7865. }
  7866. return expires;
  7867. };
  7868. Cookies._generateCookieString = function (key, value, options) {
  7869. key = key.replace(/[^#$&+\^`|]/g, encodeURIComponent);
  7870. key = key.replace(/\(/g, '%28').replace(/\)/g, '%29');
  7871. value = (value + '').replace(/[^!#$&-+\--:<-\[\]-~]/g, encodeURIComponent);
  7872. options = options || {};
  7873. var cookieString = key + '=' + value;
  7874. cookieString += options.path ? ';path=' + options.path : '';
  7875. cookieString += options.domain ? ';domain=' + options.domain : '';
  7876. cookieString += options.expires ? ';expires=' + options.expires.toUTCString() : '';
  7877. cookieString += options.secure ? ';secure' : '';
  7878. cookieString += options.sameSite ? ';SameSite=' + options.sameSite : '';
  7879. return cookieString;
  7880. };
  7881. Cookies._getCacheFromString = function (documentCookie) {
  7882. var cookieCache = {};
  7883. var cookiesArray = documentCookie ? documentCookie.split('; ') : [];
  7884. for (var i = 0; i < cookiesArray.length; i++) {
  7885. var cookieKvp = Cookies._getKeyValuePairFromCookieString(cookiesArray[i]);
  7886. if (cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] === undefined) {
  7887. cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] = cookieKvp.value;
  7888. }
  7889. }
  7890. return cookieCache;
  7891. };
  7892. Cookies._getKeyValuePairFromCookieString = function (cookieString) {
  7893. // "=" is a valid character in a cookie value according to RFC6265, so cannot `split('=')`
  7894. var separatorIndex = cookieString.indexOf('='); // IE omits the "=" when the cookie value is an empty string
  7895. separatorIndex = separatorIndex < 0 ? cookieString.length : separatorIndex;
  7896. var key = cookieString.substr(0, separatorIndex);
  7897. var decodedKey;
  7898. try {
  7899. decodedKey = decodeURIComponent(key);
  7900. } catch (e) {
  7901. if (console && typeof console.error === 'function') {
  7902. console.error('Could not decode cookie with key "' + key + '"', e);
  7903. }
  7904. }
  7905. return {
  7906. key: decodedKey,
  7907. value: cookieString.substr(separatorIndex + 1) // Defer decoding value until accessed
  7908. };
  7909. };
  7910. Cookies._renewCache = function () {
  7911. Cookies._cache = Cookies._getCacheFromString(Cookies._document.cookie);
  7912. Cookies._cachedDocumentCookie = Cookies._document.cookie;
  7913. };
  7914. Cookies._areEnabled = function () {
  7915. var testKey = 'cookies.js';
  7916. var areEnabled = Cookies.set(testKey, 1).get(testKey) === '1';
  7917. Cookies.expire(testKey);
  7918. return areEnabled;
  7919. };
  7920. Cookies.enabled = Cookies._areEnabled();
  7921. return Cookies;
  7922. };
  7923. __webpack_require__.g.Cookies = __webpack_require__.g && cookies_typeof(__webpack_require__.g.document) === 'object' ? factory(__webpack_require__.g) : factory;
  7924. /* harmony default export */ const cookies = (__webpack_require__.g.Cookies);
  7925. // EXTERNAL MODULE: ./node_modules/es6-promise/dist/es6-promise.js
  7926. var es6_promise = __webpack_require__(82702);
  7927. ;// CONCATENATED MODULE: ./app/utils/packages.js
  7928. function packages_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7929. 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); } }
  7930. function packages_createClass(Constructor, protoProps, staticProps) { if (protoProps) packages_defineProperties(Constructor.prototype, protoProps); if (staticProps) packages_defineProperties(Constructor, staticProps); return Constructor; }
  7931. var Sorter = /*#__PURE__*/function () {
  7932. function Sorter() {
  7933. packages_classCallCheck(this, Sorter);
  7934. }
  7935. packages_createClass(Sorter, [{
  7936. key: "getElements",
  7937. value: function getElements(elements, container) {
  7938. this.elements = elements || external_jQuery_default()('[data-gpm-plugin], [data-gpm-theme]');
  7939. this.container = container || external_jQuery_default()('.gpm-plugins > table > tbody, .gpm-themes > .themes.card-row');
  7940. return this.elements;
  7941. }
  7942. }, {
  7943. key: "byCommon",
  7944. value: function byCommon() {
  7945. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  7946. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  7947. var elements = this.getElements().sort(function (a, b) {
  7948. var A = external_jQuery_default()(a).data(data).toString().toLowerCase();
  7949. var B = external_jQuery_default()(b).data(data).toString().toLowerCase();
  7950. return Sorter.sort(A, B, direction);
  7951. });
  7952. return elements.appendTo(this.container);
  7953. }
  7954. }, {
  7955. key: "byName",
  7956. value: function byName() {
  7957. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  7958. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpm-name';
  7959. return this.byCommon(direction, data);
  7960. }
  7961. }, {
  7962. key: "byAuthor",
  7963. value: function byAuthor() {
  7964. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  7965. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpm-author';
  7966. return this.byCommon(direction, data);
  7967. }
  7968. }, {
  7969. key: "byOfficial",
  7970. value: function byOfficial() {
  7971. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  7972. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpm-official';
  7973. return this.byCommon(direction, data);
  7974. }
  7975. }, {
  7976. key: "byReleaseDate",
  7977. value: function byReleaseDate() {
  7978. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  7979. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpm-release-date';
  7980. var elements = this.getElements().sort(function (a, b) {
  7981. var A = new Date(external_jQuery_default()(a).data(data)).getTime();
  7982. var B = new Date(external_jQuery_default()(b).data(data)).getTime();
  7983. return Sorter.sort(A, B, direction === 'asc' ? 'desc' : 'asc');
  7984. });
  7985. elements.appendTo(this.container);
  7986. }
  7987. }, {
  7988. key: "byUpdatable",
  7989. value: function byUpdatable() {
  7990. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  7991. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpm-updatable';
  7992. return this.byCommon(direction, data);
  7993. }
  7994. }, {
  7995. key: "byEnabled",
  7996. value: function byEnabled() {
  7997. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  7998. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpm-enabled';
  7999. return this.byCommon(direction, data);
  8000. }
  8001. }, {
  8002. key: "byTesting",
  8003. value: function byTesting() {
  8004. var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
  8005. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpm-testing';
  8006. return this.byCommon(direction, data);
  8007. }
  8008. }], [{
  8009. key: "sort",
  8010. value: function sort(A, B) {
  8011. var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'asc';
  8012. if (A > B) {
  8013. return direction === 'asc' ? 1 : -1;
  8014. }
  8015. if (A < B) {
  8016. return direction === 'asc' ? -1 : 1;
  8017. }
  8018. return 0;
  8019. }
  8020. }]);
  8021. return Sorter;
  8022. }();
  8023. var Packages = /*#__PURE__*/function () {
  8024. function Packages() {
  8025. packages_classCallCheck(this, Packages);
  8026. this.Sort = new Sorter();
  8027. }
  8028. packages_createClass(Packages, [{
  8029. key: "addDependenciesToList",
  8030. value: function addDependenciesToList(dependencies) {
  8031. var slug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  8032. dependencies.forEach(function (dependency) {
  8033. Packages.addDependencyToList('plugin', dependency.name || dependency, slug);
  8034. });
  8035. }
  8036. }, {
  8037. key: "removePackage",
  8038. value: function removePackage(type, slug) {
  8039. var _this = this;
  8040. var url = Packages.getRemovePackageUrl(type);
  8041. utils_request(url, {
  8042. method: 'post',
  8043. body: {
  8044. "package": slug
  8045. }
  8046. }, function (response) {
  8047. if (response.status === 'success') {
  8048. external_jQuery_default()('.remove-package-confirm').addClass('hidden');
  8049. if (response.dependencies && response.dependencies.length > 0) {
  8050. _this.addDependenciesToList(response.dependencies);
  8051. external_jQuery_default()('.remove-package-dependencies').removeClass('hidden');
  8052. } else {
  8053. external_jQuery_default()('.remove-package-done').removeClass('hidden');
  8054. } // The package was removed. When the modal closes, move to the packages list
  8055. external_jQuery_default()(document).on('closing', '[data-remodal-id="remove-package"]', function () {
  8056. Packages.getBackToList(type);
  8057. });
  8058. } else {
  8059. external_jQuery_default()('.remove-package-confirm').addClass('hidden');
  8060. external_jQuery_default()('.remove-package-error').removeClass('hidden');
  8061. }
  8062. });
  8063. }
  8064. }, {
  8065. key: "reinstallPackage",
  8066. value: function reinstallPackage(type, slug, package_name, current_version) {
  8067. external_jQuery_default()('.button-bar button').addClass('hidden');
  8068. external_jQuery_default()('.button-bar .spinning-wheel').removeClass('hidden');
  8069. var url = Packages.getReinstallPackageUrl(type);
  8070. utils_request(url, {
  8071. method: 'post',
  8072. body: {
  8073. slug: slug,
  8074. type: type,
  8075. package_name: package_name,
  8076. current_version: current_version
  8077. }
  8078. }, function (response) {
  8079. if (response.status === 'success') {
  8080. external_jQuery_default()('.reinstall-package-confirm').addClass('hidden');
  8081. external_jQuery_default()('.reinstall-package-done').removeClass('hidden');
  8082. } else {
  8083. external_jQuery_default()('.reinstall-package-confirm').addClass('hidden');
  8084. external_jQuery_default()('.reinstall-package-error').removeClass('hidden');
  8085. }
  8086. window.location.reload();
  8087. });
  8088. }
  8089. }, {
  8090. key: "removeDependency",
  8091. value: function removeDependency(type, slug, button) {
  8092. var _this2 = this;
  8093. var url = Packages.getRemovePackageUrl(type);
  8094. utils_request(url, {
  8095. method: 'post',
  8096. body: {
  8097. "package": slug
  8098. }
  8099. }, function (response) {
  8100. if (response.status === 'success') {
  8101. button.removeClass('button');
  8102. button.replaceWith(external_jQuery_default()('<span>Removed successfully</span>'));
  8103. if (response.dependencies && response.dependencies.length > 0) {
  8104. _this2.addDependenciesToList(response.dependencies, slug);
  8105. }
  8106. }
  8107. });
  8108. }
  8109. }, {
  8110. key: "getPackagesDependencies",
  8111. value: function getPackagesDependencies(type, slugs, finishedLoadingCallback) {
  8112. var url = Packages.getGetPackagesDependenciesUrl(type);
  8113. utils_request(url, {
  8114. method: 'post',
  8115. body: {
  8116. packages: slugs
  8117. }
  8118. }, function (response) {
  8119. finishedLoadingCallback();
  8120. if (response.status === 'success') {
  8121. if (response.dependencies) {
  8122. var hasDependencies = false;
  8123. for (var dependency in response.dependencies) {
  8124. if (response.dependencies.hasOwnProperty(dependency)) {
  8125. if (dependency === 'grav') {
  8126. continue;
  8127. }
  8128. hasDependencies = true;
  8129. var dependencyName = dependency;
  8130. var action = response.dependencies[dependency];
  8131. Packages.addNeededDependencyToList(action, dependencyName);
  8132. }
  8133. }
  8134. if (hasDependencies) {
  8135. external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').removeClass('hidden');
  8136. } else {
  8137. external_jQuery_default()('[data-packages-modal] .install-package-container').removeClass('hidden');
  8138. }
  8139. } else {
  8140. external_jQuery_default()('[data-packages-modal] .install-package-container').removeClass('hidden');
  8141. }
  8142. } else {
  8143. external_jQuery_default()('[data-packages-modal] .install-package-error').removeClass('hidden');
  8144. }
  8145. });
  8146. }
  8147. }, {
  8148. key: "installDependenciesOfPackages",
  8149. value: function installDependenciesOfPackages(type, slugs, callbackSuccess, callbackError) {
  8150. var url = Packages.getInstallDependenciesOfPackagesUrl(type);
  8151. utils_request(url, {
  8152. method: 'post',
  8153. body: {
  8154. packages: slugs
  8155. }
  8156. }, callbackSuccess);
  8157. }
  8158. }, {
  8159. key: "installPackages",
  8160. value: function installPackages(type, slugs, callbackSuccess) {
  8161. var url = Packages.getInstallPackageUrl(type);
  8162. es6_promise.Promise.all(slugs.map(function (slug) {
  8163. return new es6_promise.Promise(function (resolve, reject) {
  8164. utils_request(url, {
  8165. method: 'post',
  8166. body: {
  8167. "package": slug,
  8168. type: type
  8169. }
  8170. }, function (response) {
  8171. resolve(response);
  8172. });
  8173. });
  8174. })).then(callbackSuccess);
  8175. }
  8176. }, {
  8177. key: "handleGettingPackageDependencies",
  8178. value: function handleGettingPackageDependencies(type, event) {
  8179. var action = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'update';
  8180. var slugs = Packages.getSlugsFromEvent(event);
  8181. if (!slugs) {
  8182. alert('No slug set');
  8183. return;
  8184. } // Cleanup
  8185. external_jQuery_default()('.packages-names-list').html('');
  8186. external_jQuery_default()('.install-dependencies-package-container li').remove();
  8187. slugs.forEach(function (slug) {
  8188. if (action === 'update') {
  8189. var current_version = '';
  8190. var available_version = '';
  8191. var _name = '';
  8192. var resources = Instance.payload.payload.resources;
  8193. if (resources.plugins[slug]) {
  8194. available_version = resources.plugins[slug].available;
  8195. current_version = resources.plugins[slug].version;
  8196. _name = resources.plugins[slug].name;
  8197. } else if (resources.themes[slug]) {
  8198. available_version = resources.themes[slug].available;
  8199. current_version = resources.themes[slug].version;
  8200. _name = resources.themes[slug].name;
  8201. }
  8202. 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>"));
  8203. } else {
  8204. external_jQuery_default()('.packages-names-list').append("<li>".concat(name ? name : slug, "</li>"));
  8205. }
  8206. });
  8207. event.preventDefault();
  8208. event.stopPropagation(); // fix mismatching types when sharing install modal between plugins/themes
  8209. var query = '[data-packages-modal] [data-theme-action], [data-packages-modal] [data-plugin-action]';
  8210. var data = external_jQuery_default()(query).data('themeAction') || external_jQuery_default()(query).data('pluginAction');
  8211. external_jQuery_default()(query).removeAttr('data-theme-action').removeAttr('data-plugin-action').attr("data-".concat(type, "-action"), data); // Restore original state
  8212. external_jQuery_default()('[data-packages-modal] .loading').removeClass('hidden');
  8213. external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').addClass('hidden');
  8214. external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
  8215. external_jQuery_default()('[data-packages-modal] .installing-dependencies').addClass('hidden');
  8216. external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
  8217. external_jQuery_default()('[data-packages-modal] .installation-complete').addClass('hidden');
  8218. external_jQuery_default()('[data-packages-modal] .install-package-error').addClass('hidden');
  8219. this.getPackagesDependencies(type, slugs, function () {
  8220. var slugs_string = slugs.join();
  8221. external_jQuery_default()("[data-packages-modal] [data-".concat(type, "-action=\"install-dependencies-and-package\"]")).attr('data-packages-slugs', slugs_string);
  8222. external_jQuery_default()("[data-packages-modal] [data-".concat(type, "-action=\"install-package\"]")).attr('data-packages-slugs', slugs_string);
  8223. external_jQuery_default()('[data-packages-modal] .loading').addClass('hidden');
  8224. });
  8225. }
  8226. }, {
  8227. key: "handleInstallingDependenciesAndPackage",
  8228. value: function handleInstallingDependenciesAndPackage(type, event) {
  8229. var _this3 = this;
  8230. var slugs = Packages.getSlugsFromEvent(event);
  8231. event.preventDefault();
  8232. event.stopPropagation();
  8233. external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').addClass('hidden');
  8234. external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
  8235. external_jQuery_default()('[data-packages-modal] .installing-dependencies').removeClass('hidden');
  8236. this.installDependenciesOfPackages(type, slugs, function (response) {
  8237. external_jQuery_default()('[data-packages-modal] .installing-dependencies').addClass('hidden');
  8238. external_jQuery_default()('[data-packages-modal] .installing-package').removeClass('hidden');
  8239. _this3.installPackages(type, slugs, function () {
  8240. external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
  8241. external_jQuery_default()('[data-packages-modal] .installation-complete').removeClass('hidden');
  8242. if (response.status === 'error') {
  8243. var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-packages-modal]').data('remodal')];
  8244. remodal.close();
  8245. return;
  8246. }
  8247. setTimeout(function () {
  8248. if (slugs.length === 1) {
  8249. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s/").concat(slugs[0]);
  8250. } else {
  8251. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
  8252. }
  8253. }, 1000);
  8254. });
  8255. });
  8256. }
  8257. }, {
  8258. key: "handleInstallingPackage",
  8259. value: function handleInstallingPackage(type, event) {
  8260. var slugs = Packages.getSlugsFromEvent(event);
  8261. event.preventDefault();
  8262. event.stopPropagation();
  8263. external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
  8264. external_jQuery_default()('[data-packages-modal] .installing-package').removeClass('hidden');
  8265. this.installPackages(type, slugs, function (response) {
  8266. external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
  8267. external_jQuery_default()('[data-packages-modal] .installation-complete').removeClass('hidden');
  8268. var errors = Array.from(response).filter(function (r) {
  8269. return r.status === 'error';
  8270. });
  8271. if (errors && errors.length) {
  8272. var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-packages-modal].remodal-is-opened').data('remodal')];
  8273. remodal.close();
  8274. return;
  8275. }
  8276. if (slugs.length === 1) {
  8277. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s/").concat(slugs[0]);
  8278. } else {
  8279. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
  8280. }
  8281. });
  8282. }
  8283. }, {
  8284. key: "handleRemovingPackage",
  8285. value: function handleRemovingPackage(type, event) {
  8286. var slug = external_jQuery_default()(event.target).attr('data-packages-slugs');
  8287. event.preventDefault();
  8288. event.stopPropagation();
  8289. this.removePackage(type, slug);
  8290. }
  8291. }, {
  8292. key: "handleReinstallPackage",
  8293. value: function handleReinstallPackage(type, event) {
  8294. var target = external_jQuery_default()(event.target);
  8295. var slug = target.attr('data-package-slug');
  8296. var package_name = target.attr('data-package-name');
  8297. var current_version = target.attr('data-package-current-version');
  8298. event.preventDefault();
  8299. event.stopPropagation();
  8300. this.reinstallPackage(type, slug, package_name, current_version);
  8301. }
  8302. }, {
  8303. key: "handleRemovingDependency",
  8304. value: function handleRemovingDependency(type, event) {
  8305. var slug = external_jQuery_default()(event.target).attr('data-dependency-slug');
  8306. var button = external_jQuery_default()(event.target);
  8307. event.preventDefault();
  8308. event.stopPropagation();
  8309. this.removeDependency(type, slug, button);
  8310. }
  8311. }], [{
  8312. key: "getBackToList",
  8313. value: function getBackToList(type) {
  8314. __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
  8315. }
  8316. }, {
  8317. key: "addDependencyToList",
  8318. value: function addDependencyToList(type, dependency) {
  8319. var slug = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  8320. if (['admin', 'form', 'login', 'email', 'grav'].indexOf(dependency) !== -1) {
  8321. return;
  8322. }
  8323. var container = external_jQuery_default()('.package-dependencies-container');
  8324. var text = "".concat(dependency, " <a href=\"#\" class=\"button\" data-dependency-slug=\"").concat(dependency, "\" data-").concat(type, "-action=\"remove-dependency-package\">Remove</a>");
  8325. if (slug) {
  8326. text += " (was needed by ".concat(slug, ")");
  8327. }
  8328. container.append("<li>".concat(text, "</li>"));
  8329. }
  8330. }, {
  8331. key: "getTaskUrl",
  8332. value: function getTaskUrl(type, task) {
  8333. var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative);
  8334. url += "/".concat(type, "s.json");
  8335. url += "/task".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(task);
  8336. return url;
  8337. }
  8338. }, {
  8339. key: "getRemovePackageUrl",
  8340. value: function getRemovePackageUrl(type) {
  8341. return "".concat(Packages.getTaskUrl(type, 'removePackage'));
  8342. }
  8343. }, {
  8344. key: "getReinstallPackageUrl",
  8345. value: function getReinstallPackageUrl(type) {
  8346. return "".concat(Packages.getTaskUrl(type, 'reinstallPackage'));
  8347. }
  8348. }, {
  8349. key: "getGetPackagesDependenciesUrl",
  8350. value: function getGetPackagesDependenciesUrl(type) {
  8351. return "".concat(Packages.getTaskUrl(type, 'getPackagesDependencies'));
  8352. }
  8353. }, {
  8354. key: "getInstallDependenciesOfPackagesUrl",
  8355. value: function getInstallDependenciesOfPackagesUrl(type) {
  8356. return "".concat(Packages.getTaskUrl(type, 'installDependenciesOfPackages'));
  8357. }
  8358. }, {
  8359. key: "getInstallPackageUrl",
  8360. value: function getInstallPackageUrl(type) {
  8361. return "".concat(Packages.getTaskUrl(type, 'installPackage'));
  8362. }
  8363. }, {
  8364. key: "addNeededDependencyToList",
  8365. value: function addNeededDependencyToList(action, slug) {
  8366. external_jQuery_default()('.install-dependencies-package-container .type-' + action).removeClass('hidden');
  8367. var list = external_jQuery_default()('.install-dependencies-package-container .type-' + action + ' ul');
  8368. if (action !== 'install') {
  8369. var current_version = '';
  8370. var available_version = '';
  8371. var _name2 = '';
  8372. var resources = Instance.payload.payload.resources;
  8373. if (resources.plugins[slug]) {
  8374. available_version = resources.plugins[slug].available;
  8375. current_version = resources.plugins[slug].version;
  8376. _name2 = resources.plugins[slug].name;
  8377. } else if (resources.themes[slug]) {
  8378. available_version = resources.themes[slug].available;
  8379. current_version = resources.themes[slug].version;
  8380. _name2 = resources.themes[slug].name;
  8381. }
  8382. 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>"));
  8383. } else {
  8384. list.append("<li>".concat(name ? name : slug, "</li>"));
  8385. }
  8386. }
  8387. }, {
  8388. key: "getSlugsFromEvent",
  8389. value: function getSlugsFromEvent(event) {
  8390. var slugs = '';
  8391. if (external_jQuery_default()(event.target).is('[data-packages-slugs]')) {
  8392. slugs = external_jQuery_default()(event.target).attr('data-packages-slugs');
  8393. } else {
  8394. slugs = external_jQuery_default()(event.target).parent('[data-packages-slugs]').attr('data-packages-slugs');
  8395. }
  8396. if (typeof slugs === 'undefined') {
  8397. return null;
  8398. }
  8399. slugs = slugs.split(',');
  8400. return typeof slugs === 'string' ? [slugs] : slugs;
  8401. }
  8402. }]);
  8403. return Packages;
  8404. }();
  8405. /* harmony default export */ const utils_packages = (new Packages());
  8406. // EXTERNAL MODULE: ./node_modules/mout/string/camelCase.js
  8407. var camelCase = __webpack_require__(71047);
  8408. var camelCase_default = /*#__PURE__*/__webpack_require__.n(camelCase);
  8409. // EXTERNAL MODULE: ./node_modules/mout/string/contains.js
  8410. var contains = __webpack_require__(85286);
  8411. var contains_default = /*#__PURE__*/__webpack_require__.n(contains);
  8412. ;// CONCATENATED MODULE: ./app/plugins/index.js
  8413. // Plugins sliders details
  8414. external_jQuery_default()('.gpm-name, .gpm-actions').on('click', function (e) {
  8415. var element = external_jQuery_default()(this);
  8416. var target = external_jQuery_default()(e.target);
  8417. var tag = target.prop('tagName').toLowerCase();
  8418. if (tag === 'a' || element.parent('a').length || target.parent('a').length) {
  8419. return true;
  8420. }
  8421. var wrapper = element.siblings('.gpm-details').find('.table-wrapper');
  8422. wrapper.slideToggle({
  8423. duration: 350,
  8424. complete: function complete() {
  8425. var visible = wrapper.is(':visible');
  8426. wrapper.closest('tr').find('.gpm-details-expand i').removeClass('fa-chevron-' + (visible ? 'down' : 'up')).addClass('fa-chevron-' + (visible ? 'up' : 'down'));
  8427. }
  8428. });
  8429. }); // Removing plugin
  8430. external_jQuery_default()(document).on('click', '[data-plugin-action="remove-package"]', function (event) {
  8431. utils_packages.handleRemovingPackage('plugin', event);
  8432. }); // Reinstall plugin
  8433. external_jQuery_default()(document).on('click', '[data-plugin-action="reinstall-package"]', function (event) {
  8434. utils_packages.handleReinstallPackage('plugin', event);
  8435. });
  8436. external_jQuery_default()(document).on('click', '[data-plugin-action="remove-dependency-package"]', function (event) {
  8437. utils_packages.handleRemovingDependency('plugin', event);
  8438. }); // Trigger the add new plugin / update plugin modal
  8439. external_jQuery_default()(document).on('click', '[data-plugin-action="start-package-installation"]', function (event) {
  8440. utils_packages.handleGettingPackageDependencies('plugin', event, 'install');
  8441. }); // Trigger the update all plugins modal
  8442. external_jQuery_default()(document).on('click', '[data-plugin-action="start-packages-update"]', function (event) {
  8443. utils_packages.handleGettingPackageDependencies('plugin', event);
  8444. }); // Install a plugin dependencies and the plugin
  8445. external_jQuery_default()(document).on('click', '[data-plugin-action="install-dependencies-and-package"]', function (event) {
  8446. utils_packages.handleInstallingDependenciesAndPackage('plugin', event);
  8447. }); // Install a plugin
  8448. external_jQuery_default()(document).on('click', '[data-plugin-action="install-package"]', function (event) {
  8449. utils_packages.handleInstallingPackage('plugin', event);
  8450. }); // Sort plugins/themes dropdown
  8451. external_jQuery_default()(document).on('change', '.sort-actions select', function (event) {
  8452. var direction = external_jQuery_default()('.sort-actions .sort-icon .fa').hasClass('fa-sort-amount-desc') ? 'desc' : 'asc';
  8453. var sorting = external_jQuery_default()(event.currentTarget).val();
  8454. utils_packages.Sort[camelCase_default()("by-".concat(sorting))](direction);
  8455. }); // Sort plugins/themes icon
  8456. external_jQuery_default()(document).on('click', '.sort-icon', function (event) {
  8457. var icon = external_jQuery_default()(event.currentTarget).find('.fa');
  8458. var current = icon.hasClass('fa-sort-amount-asc') ? 'asc' : 'desc';
  8459. var opposite = current === 'asc' ? 'desc' : 'asc';
  8460. icon.removeClass("fa-sort-amount-".concat(current)).addClass("fa-sort-amount-".concat(opposite));
  8461. external_jQuery_default()('.sort-actions select').trigger('change');
  8462. }); // Filter plugin/theme
  8463. external_jQuery_default()(document).on('input', '[data-gpm-filter]', debounce_default()(function (event) {
  8464. var value = external_jQuery_default()(external_jQuery_default()(event.currentTarget)).val();
  8465. var items = external_jQuery_default()('[data-gpm-plugin], [data-gpm-theme]');
  8466. items.hide().filter(function (index, item) {
  8467. item = external_jQuery_default()(item);
  8468. return contains_default()(item.data('gpm-plugin'), value) || contains_default()(item.data('gpm-theme'), value) || contains_default()(item.data('gpm-name').toLowerCase(), value.toLowerCase());
  8469. }).show();
  8470. }, 250));
  8471. ;// CONCATENATED MODULE: ./app/themes/index.js
  8472. // Themes Switcher Warning
  8473. external_jQuery_default()(document).on('mousedown', '[data-remodal-target="theme-switch-warn"]', function (event) {
  8474. var name = external_jQuery_default()(event.target).closest('[data-gpm-theme]').find('.gpm-name a:first').text();
  8475. var remodal = external_jQuery_default()('.remodal.theme-switcher');
  8476. remodal.find('strong').text(name);
  8477. remodal.find('.button.continue').attr('href', external_jQuery_default()(event.target).attr('href'));
  8478. }); // Removing theme
  8479. external_jQuery_default()(document).on('click', '[data-theme-action="remove-package"]', function (event) {
  8480. utils_packages.handleRemovingPackage('theme', event);
  8481. }); // Reinstall theme
  8482. external_jQuery_default()(document).on('click', '[data-theme-action="reinstall-package"]', function (event) {
  8483. utils_packages.handleReinstallPackage('theme', event);
  8484. });
  8485. external_jQuery_default()(document).on('click', '[data-theme-action="remove-dependency-package"]', function (event) {
  8486. utils_packages.handleRemovingDependency('theme', event);
  8487. }); // Opened the add new theme / update theme modal
  8488. external_jQuery_default()(document).on('click', '[data-theme-action="start-package-installation"]', function (event) {
  8489. utils_packages.handleGettingPackageDependencies('theme', event, 'install');
  8490. }); // Trigger the update all themes modal
  8491. external_jQuery_default()(document).on('click', '[data-theme-action="start-packages-update"]', function (event) {
  8492. utils_packages.handleGettingPackageDependencies('theme', event);
  8493. }); // Install a theme dependencies and the theme
  8494. external_jQuery_default()(document).on('click', '[data-theme-action="install-dependencies-and-package"]', function (event) {
  8495. utils_packages.handleInstallingDependenciesAndPackage('theme', event);
  8496. }); // Install a theme
  8497. external_jQuery_default()(document).on('click', '[data-theme-action="install-package"]', function (event) {
  8498. utils_packages.handleInstallingPackage('theme', event);
  8499. });
  8500. ;// CONCATENATED MODULE: ./app/media/index.js
  8501. function app_media_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8502. 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); } }
  8503. function app_media_createClass(Constructor, protoProps, staticProps) { if (protoProps) app_media_defineProperties(Constructor.prototype, protoProps); if (staticProps) app_media_defineProperties(Constructor, staticProps); return Constructor; }
  8504. var Filter = /*#__PURE__*/function () {
  8505. function Filter() {
  8506. app_media_classCallCheck(this, Filter);
  8507. this.URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/media-manager/");
  8508. }
  8509. app_media_createClass(Filter, [{
  8510. key: "filter",
  8511. value: function filter(name, value) {
  8512. var filtered = [];
  8513. var keys = Object.keys(external_GravAdmin_namespaceObject.uri_params);
  8514. if (!~keys.indexOf(name)) {
  8515. keys.push(name);
  8516. }
  8517. keys.forEach(function (key) {
  8518. var filter = Filter.cleanValue(key === name ? value : external_GravAdmin_namespaceObject.uri_params[key]);
  8519. if (filter !== '*') {
  8520. filtered.push("".concat(key).concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filter));
  8521. }
  8522. });
  8523. __webpack_require__.g.location = this.URI + filtered.join('/');
  8524. }
  8525. }], [{
  8526. key: "cleanValue",
  8527. value: function cleanValue(value) {
  8528. return encodeURIComponent(value.replace('/', '\\'));
  8529. }
  8530. }]);
  8531. return Filter;
  8532. }();
  8533. var app_media_Instance = new Filter();
  8534. var isLoading = false;
  8535. var filters = {};
  8536. var global_index = 1;
  8537. var files_ended = false;
  8538. var MEDIA_PAGINATION_INTERVAL = 20;
  8539. /* handle changing file type / date filter */
  8540. external_jQuery_default()('body').on('change', '.thumbs-list-container select.filter', function (event) {
  8541. var target = external_jQuery_default()(event.currentTarget);
  8542. var filterName = target.data('name');
  8543. var filterValue = target.val();
  8544. if (filterValue) {
  8545. filters[filterName] = filterValue;
  8546. } else {
  8547. delete filters[filterName];
  8548. }
  8549. filterFiles();
  8550. });
  8551. /* initialize media uploader */
  8552. if (external_jQuery_default()('.thumbs-list-container .dropzone')[0]) {
  8553. external_jQuery_default()('.thumbs-list-container .dropzone')[0].dropzone.on('queuecomplete', function () {
  8554. var body = {};
  8555. if (filters.page) {
  8556. body.page = filters.page;
  8557. }
  8558. if (filters.date) {
  8559. body.date = filters.date;
  8560. }
  8561. if (filters.type) {
  8562. body.type = filters.type;
  8563. }
  8564. external_jQuery_default()('.dropzone')[0].dropzone.files.forEach(function (file) {
  8565. file.previewElement.remove();
  8566. });
  8567. external_jQuery_default()('.dropzone').first().removeClass('dz-started');
  8568. utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/media-manager.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "clearMediaCache"), {
  8569. method: 'post',
  8570. body: body
  8571. }, function () {
  8572. filterFiles();
  8573. });
  8574. });
  8575. }
  8576. /* handle loading media */
  8577. var loadMedia = function loadMedia(filters, callback) {
  8578. 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);
  8579. if (filters.page) {
  8580. url += "/page".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.page.split('/').join('%5C'));
  8581. }
  8582. if (filters.type && filters.type !== '*') {
  8583. url += "/type".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.type);
  8584. }
  8585. if (filters.date && filters.date !== '*') {
  8586. url += "/date".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.date);
  8587. }
  8588. if (!isLoading) {
  8589. isLoading = true;
  8590. external_jQuery_default()('.spinning-wheel').show();
  8591. external_jQuery_default().get(url, function (content) {
  8592. external_jQuery_default()('.js__files').append(content);
  8593. external_jQuery_default()('.spinning-wheel').hide();
  8594. external_jQuery_default()('.media-container .media-range').trigger('change');
  8595. isLoading = false;
  8596. global_index++;
  8597. callback(content);
  8598. });
  8599. }
  8600. };
  8601. var cleanFilesList = function cleanFilesList() {
  8602. external_jQuery_default()('.js__files .card-item').remove();
  8603. };
  8604. var resetActiveStateInSidebar = function resetActiveStateInSidebar() {
  8605. external_jQuery_default()('.pages-list-container .row').removeClass('active'); // clear active state in sidebar
  8606. };
  8607. var showEmptyState = function showEmptyState() {
  8608. external_jQuery_default()('.thumbs-list-container').append('<p class="card-item empty-space">No media found</p>');
  8609. };
  8610. var filterFiles = function filterFiles() {
  8611. cleanFilesList();
  8612. global_index = 0;
  8613. files_ended = false;
  8614. external_jQuery_default()('.empty-space').remove();
  8615. loadMedia(filters, function (content) {
  8616. if (!content.trim().length) {
  8617. showEmptyState();
  8618. } else {
  8619. if (!filters.page && (!filters.date || filters.date === '*') && (!filters.type || filters.type === '*')) {
  8620. external_jQuery_default()('.js__files').trigger('fillView');
  8621. }
  8622. }
  8623. });
  8624. };
  8625. /* handle changing page */
  8626. external_jQuery_default()('body').on('click', '.pages-list-container .js__page-link', function (event) {
  8627. var page = external_jQuery_default()(event.target).data('page');
  8628. filters['page'] = page;
  8629. external_jQuery_default()('.media-list-title .page-indicator').html(page); // set indication
  8630. external_jQuery_default()('.js__reset-pages-filter').removeClass('hidden'); // activate reset pages icon
  8631. resetActiveStateInSidebar();
  8632. external_jQuery_default()(event.target).parents('.row').addClass('active'); // set active state in sidebar
  8633. external_jQuery_default()('.js__file-uploader').removeClass('hidden'); // customize processing URL, as the page changes dynamically
  8634. if (external_jQuery_default()('.dropzone')[0]) {
  8635. external_jQuery_default()('.dropzone')[0].dropzone.on('processing', function (file) {
  8636. 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");
  8637. });
  8638. }
  8639. external_jQuery_default()('.js__button-clear-media-cache').addClass('hidden');
  8640. filterFiles();
  8641. disableInfiniteScrolling(); // only infinite scroll on main list, not inside single pages
  8642. });
  8643. /* handle clearing page filter */
  8644. external_jQuery_default()('body').on('click', '.js__reset-pages-filter', function (event) {
  8645. external_jQuery_default()('.media-list-title .page-indicator').html('All Pages'); // set indication
  8646. cleanFilesList();
  8647. resetActiveStateInSidebar();
  8648. external_jQuery_default()('.js__reset-pages-filter').addClass('hidden'); // remove reset pages icon
  8649. external_jQuery_default()('.js__file-uploader').addClass('hidden');
  8650. external_jQuery_default()('.js__button-clear-media-cache').removeClass('hidden');
  8651. delete filters['page'];
  8652. filterFiles();
  8653. });
  8654. /* handle infinite loading */
  8655. var enableInfiniteScrolling = function enableInfiniteScrolling() {
  8656. external_jQuery_default()('.spinning-wheel').hide();
  8657. var view = external_jQuery_default()('.mediapicker-scroll').last();
  8658. if (!view.length) {
  8659. return;
  8660. }
  8661. external_jQuery_default()(view).on('scroll', function () {
  8662. if (external_jQuery_default()(this).scrollTop() + external_jQuery_default()(this).innerHeight() + 100 >= external_jQuery_default()(this)[0].scrollHeight) {
  8663. fillView();
  8664. }
  8665. });
  8666. };
  8667. var loadNextBatch = function loadNextBatch(callback) {
  8668. if (files_ended) {
  8669. return;
  8670. }
  8671. loadMedia({}, function (content) {
  8672. if (!external_jQuery_default()(content).length || content.split('card-item').length - 1 < MEDIA_PAGINATION_INTERVAL) {
  8673. files_ended = true;
  8674. } else {
  8675. if (callback) {
  8676. callback();
  8677. }
  8678. }
  8679. external_jQuery_default()('.media-container .media-range').trigger('input');
  8680. });
  8681. };
  8682. var fillView = function fillView() {
  8683. if (!external_jQuery_default()('.js__files').find('.card-item').last().offset()) {
  8684. setTimeout(function () {
  8685. // retry later
  8686. fillView();
  8687. }, 300);
  8688. return;
  8689. }
  8690. if (external_jQuery_default()('.js__files').find('.card-item').last().offset().top - 1 <= external_jQuery_default()('.media-container').height()) {
  8691. loadNextBatch(function () {
  8692. fillView();
  8693. });
  8694. }
  8695. };
  8696. /* disable infinite loading */
  8697. var disableInfiniteScrolling = function disableInfiniteScrolling() {
  8698. external_jQuery_default()('.spinning-wheel').hide();
  8699. external_jQuery_default()('.content-wrapper').unbind('scroll');
  8700. };
  8701. external_jQuery_default()('.js__files').on('fillView', function (event) {
  8702. // the first batch got the max number of media files, try loading more
  8703. if (external_jQuery_default()('.js__files')[0].innerHTML.split('card-item').length - 1 === MEDIA_PAGINATION_INTERVAL) {
  8704. fillView();
  8705. enableInfiniteScrolling();
  8706. }
  8707. });
  8708. ;// CONCATENATED MODULE: ./app/utils/2fa.js
  8709. var _2fa_body = external_jQuery_default()('body'); // Dashboard update and Grav update
  8710. _2fa_body.on('click', '[data-2fa-regenerate]', function (event) {
  8711. event.preventDefault();
  8712. var element = external_jQuery_default()(this);
  8713. var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "regenerate2FASecret");
  8714. element.attr('disabled', 'disabled').find('> .fa').addClass('fa-spin');
  8715. utils_request(url, {
  8716. method: 'post'
  8717. }, function (response) {
  8718. external_jQuery_default()('[data-2fa-image]').attr('src', response.image);
  8719. external_jQuery_default()('[data-2fa-secret]').text(response.secret);
  8720. external_jQuery_default()('[data-2fa-value]').val(response.secret.replace(' ', ''));
  8721. element.removeAttr('disabled').find('> .fa').removeClass('fa-spin');
  8722. });
  8723. });
  8724. var toggleSecret = function toggleSecret() {
  8725. var toggle = external_jQuery_default()('#toggle_twofa_enabled1');
  8726. var secret = external_jQuery_default()('.twofa-secret');
  8727. secret[toggle.is(':checked') ? 'addClass' : 'removeClass']('show');
  8728. };
  8729. _2fa_body.on('click', '.twofa-toggle input', toggleSecret);
  8730. toggleSecret();
  8731. // EXTERNAL MODULE: ./node_modules/mout/queryString.js
  8732. var queryString = __webpack_require__(85407);
  8733. ;// CONCATENATED MODULE: ./app/tools/logs.js
  8734. var prepareQuery = function prepareQuery(key, value) {
  8735. return (0,queryString.setParam)(__webpack_require__.g.location.href, key, value);
  8736. };
  8737. external_jQuery_default()(document).on('change', '.logs-content .block-select select[name]', function (event) {
  8738. var target = external_jQuery_default()(event.currentTarget);
  8739. var name = target.attr('name');
  8740. var value = target.val();
  8741. __webpack_require__.g.location.href = prepareQuery(name, value);
  8742. });
  8743. ;// CONCATENATED MODULE: ./app/tools/index.js
  8744. ;// CONCATENATED MODULE: ./app/whitelabel/compile.js
  8745. /* harmony default export */ const compile = (function () {
  8746. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8747. _ref$preview = _ref.preview,
  8748. preview = _ref$preview === void 0 ? false : _ref$preview,
  8749. _ref$exportScss = _ref.exportScss,
  8750. exportScss = _ref$exportScss === void 0 ? false : _ref$exportScss,
  8751. _ref$color_scheme = _ref.color_scheme,
  8752. color_scheme = _ref$color_scheme === void 0 ? {} : _ref$color_scheme,
  8753. _ref$fonts = _ref.fonts,
  8754. fonts = _ref$fonts === void 0 ? {} : _ref$fonts,
  8755. _ref$callback = _ref.callback,
  8756. callback = _ref$callback === void 0 ? function () {} : _ref$callback;
  8757. var task = exportScss ? 'exportScss' : 'compileScss'; // console.log(config);
  8758. var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, ".json/task:").concat(task);
  8759. utils_request(URI, {
  8760. method: 'post',
  8761. body: Object.assign({}, preview ? {
  8762. preview: preview
  8763. } : null, color_scheme)
  8764. }, callback);
  8765. });
  8766. var prepareElement = function prepareElement(element) {
  8767. element.data('busy_right_now', true);
  8768. if (!element.data('current_icon')) {
  8769. element.data('current_icon', element.find('.fa').attr('class'));
  8770. }
  8771. element.find('.fa').attr('class', 'fa fa-fw fa-spin fa-refresh');
  8772. };
  8773. var resetElement = function resetElement(element) {
  8774. element.data('busy_right_now', false);
  8775. element.find('.fa').attr('class', element.data('current_icon'));
  8776. };
  8777. ;// CONCATENATED MODULE: ./app/whitelabel/presets.js
  8778. var presets_body = external_jQuery_default()('body');
  8779. var presets_fields = [];
  8780. var presets_FormState = app_forms.FormState.Instance;
  8781. var setField = function setField(field, value) {
  8782. var name = field.prop('name');
  8783. var tag = field.prop('tagName').toLowerCase();
  8784. var type = field.prop('type');
  8785. presets_fields.push(name);
  8786. switch (tag) {
  8787. case 'select':
  8788. field.val(value);
  8789. field.data('selectize').setValue(value);
  8790. field.trigger('change');
  8791. break;
  8792. case 'input':
  8793. if (type === 'radio') {
  8794. var strValue = value ? '1' : '0';
  8795. field.filter(function (index, radio) {
  8796. return external_jQuery_default()(radio).val() === strValue;
  8797. }).prop('checked', true);
  8798. break;
  8799. }
  8800. if (type === 'checkbox') {
  8801. field.prop('checked', value);
  8802. break;
  8803. }
  8804. field.val(value);
  8805. field.trigger('keyup');
  8806. }
  8807. };
  8808. presets_body.on('click', '[data-preset-values]', function (event) {
  8809. var target = external_jQuery_default()(event.currentTarget);
  8810. var data = target.data('preset-values');
  8811. Object.keys(data).forEach(function (section) {
  8812. if (typeof data[section] === 'string') {
  8813. return;
  8814. }
  8815. Object.keys(data[section]).forEach(function (key) {
  8816. var field = external_jQuery_default()("[name=\"data[whitelabel][color_scheme][".concat(section, "][").concat(key, "]\"], [name=\"data[").concat(section, "][").concat(key, "]\"]"));
  8817. var value = data[section][key];
  8818. setField(field, value);
  8819. });
  8820. });
  8821. });
  8822. presets_body.on('click', '[data-reset-scss]', function (event) {
  8823. event && event.preventDefault();
  8824. var element = external_jQuery_default()(event.currentTarget);
  8825. var links = external_jQuery_default()('link[id^=admin-pro-preview-]');
  8826. element.remove();
  8827. links.remove();
  8828. presets_fields.forEach(function (field) {
  8829. var value = presets_FormState.loadState.get(field);
  8830. setField(external_jQuery_default()("[name=\"".concat(field, "\"]")), value);
  8831. });
  8832. presets_fields = [];
  8833. }); // Horizontal Scroll Functionality
  8834. (external_jQuery_default()).fn.hscrollarrows = function () {
  8835. return this.each(function () {
  8836. var navNext = external_jQuery_default()('<a class="nav-next hide"></a>');
  8837. var navPrev = external_jQuery_default()('<a class="nav-prev hide"></a>');
  8838. var scrollTime = null;
  8839. var resizeTime = null;
  8840. var scrolling = false;
  8841. var elm_w = 0;
  8842. var elem_data_w = 0;
  8843. var max_scroll = 0;
  8844. var inc_scroll = 0;
  8845. var calcData = function calcData() {
  8846. elm_w = elem.width();
  8847. elem_data_w = elem_data.get(0).scrollWidth;
  8848. max_scroll = elem_data_w - elm_w;
  8849. inc_scroll = elm_w * 0.3; // 20%
  8850. };
  8851. var revalidate = function revalidate() {
  8852. calcData();
  8853. stateNavs();
  8854. };
  8855. var run = function run() {
  8856. calcData();
  8857. setupNavs();
  8858. };
  8859. var setupNavs = function setupNavs() {
  8860. elem.parent().prepend(navNext);
  8861. elem.parent().prepend(navPrev);
  8862. navNext.on('click', next);
  8863. navPrev.on('click', prev);
  8864. stateNavs();
  8865. external_jQuery_default()(elem).scroll(function () {
  8866. if (!scrolling) {
  8867. clearTimeout(scrollTime);
  8868. scrollTime = setTimeout(function () {
  8869. stateNavs();
  8870. }, 250);
  8871. }
  8872. });
  8873. external_jQuery_default()(window).resize(function () {
  8874. clearTimeout(resizeTime);
  8875. resizeTime = setTimeout(function () {
  8876. revalidate();
  8877. }, 250);
  8878. });
  8879. };
  8880. var stateNavs = function stateNavs() {
  8881. var current_scroll = elem.scrollLeft();
  8882. if (current_scroll < max_scroll) {
  8883. navNext.removeClass('hide');
  8884. } else {
  8885. navNext.addClass('hide');
  8886. }
  8887. if (current_scroll > 0) {
  8888. navPrev.removeClass('hide');
  8889. } else {
  8890. navPrev.addClass('hide');
  8891. }
  8892. scrolling = false;
  8893. };
  8894. var next = function next() {
  8895. var current_scroll = elem.scrollLeft();
  8896. if (current_scroll < max_scroll) {
  8897. scrolling = true;
  8898. elem.stop().animate({
  8899. scrollLeft: current_scroll + inc_scroll
  8900. }, stateNavs);
  8901. }
  8902. };
  8903. var prev = function prev() {
  8904. var current_scroll = elem.scrollLeft();
  8905. if (current_scroll > 0) {
  8906. scrolling = true;
  8907. elem.stop().animate({
  8908. scrollLeft: current_scroll - inc_scroll
  8909. }, stateNavs);
  8910. }
  8911. };
  8912. var elem = external_jQuery_default()(this);
  8913. var elem_data = external_jQuery_default()(':first-child', elem);
  8914. run();
  8915. });
  8916. };
  8917. external_jQuery_default()(document).ready(function () {
  8918. external_jQuery_default()('.jquery-horizontal-scroll').hscrollarrows();
  8919. });
  8920. ;// CONCATENATED MODULE: ./app/whitelabel/index.js
  8921. var whitelabel_body = external_jQuery_default()('body');
  8922. var whitelabel_FormState = app_forms.FormState.Instance;
  8923. var compiler = function compiler(element) {
  8924. var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8925. var exportScss = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8926. var _callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {};
  8927. prepareElement(element);
  8928. var fields = whitelabel_FormState.collect();
  8929. compile({
  8930. preview: preview,
  8931. exportScss: exportScss,
  8932. color_scheme: !fields ? [] : fields.filter(function (value, key) {
  8933. return key.match(/^data\[whitelabel]\[color_scheme]/);
  8934. }).toJS(),
  8935. callback: function callback(response) {
  8936. _callback.call(_callback, response);
  8937. resetElement(element);
  8938. }
  8939. });
  8940. };
  8941. whitelabel_body.on('click', '[data-preview-scss]', function (event) {
  8942. event && event.preventDefault();
  8943. var element = external_jQuery_default()(event.currentTarget);
  8944. if (element.data('busy_right_now')) {
  8945. return false;
  8946. }
  8947. compiler(element, true, false, function (response) {
  8948. if (response.files) {
  8949. Object.keys(response.files).forEach(function (key) {
  8950. var file = external_jQuery_default()("#admin-pro-preview-".concat(key));
  8951. var timestamp = Date.now();
  8952. if (!file.length) {
  8953. file = external_jQuery_default()("<link id=\"admin-pro-preview-".concat(key, "\" type=\"text/css\" rel=\"stylesheet\" />"));
  8954. external_jQuery_default()('head').append(file);
  8955. if (!external_jQuery_default()('[data-reset-scss]').length) {
  8956. 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>');
  8957. reset.insertAfter(element);
  8958. }
  8959. }
  8960. file.attr('href', "".concat(response.files[key], "?").concat(timestamp));
  8961. });
  8962. }
  8963. });
  8964. });
  8965. whitelabel_body.on('click', '[data-recompile-scss]', function (event) {
  8966. event && event.preventDefault();
  8967. var element = external_jQuery_default()(event.currentTarget);
  8968. if (element.data('busy_right_now')) {
  8969. return false;
  8970. }
  8971. compiler(element, true, false);
  8972. });
  8973. whitelabel_body.on('click', '[data-export-scss]', function (event) {
  8974. event && event.preventDefault();
  8975. var element = external_jQuery_default()(event.currentTarget);
  8976. if (element.data('busy_right_now')) {
  8977. return false;
  8978. }
  8979. compiler(element, true, true, function (response) {
  8980. if (response.files) {
  8981. Object.keys(response.files).forEach(function (key) {
  8982. if (key === 'download') {
  8983. var _element = document.createElement('a');
  8984. _element.setAttribute('href', response.files[key]);
  8985. _element.setAttribute('download', '');
  8986. _element.style.display = 'none';
  8987. document.body.appendChild(_element);
  8988. _element.click();
  8989. document.body.removeChild(_element);
  8990. }
  8991. });
  8992. }
  8993. });
  8994. });
  8995. whitelabel_body.on('change._grav_colorpicker', '[data-grav-colorpicker]', function (event, input, hex, opacity) {
  8996. var RGB = hex2rgb(hex);
  8997. var YIQ = (RGB.r * 299 + RGB.g * 587 + RGB.b * 114) / 1000;
  8998. var contrast = YIQ >= 128 || opacity <= 0.50 ? 'dark' : 'light';
  8999. input.parent().removeClass('dark-text light-text').addClass("".concat(contrast, "-text"));
  9000. });
  9001. whitelabel_body.ready(function () {
  9002. external_jQuery_default()('[data-grav-colorpicker]').trigger('keyup');
  9003. });
  9004. ;// CONCATENATED MODULE: ./app/utils/bootstrap-transition.js
  9005. +function ($) {
  9006. 'use strict'; // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  9007. // ============================================================
  9008. function transitionEnd() {
  9009. var el = document.createElement('bootstrap');
  9010. var transEndEventNames = {
  9011. WebkitTransition: 'webkitTransitionEnd',
  9012. MozTransition: 'transitionend',
  9013. OTransition: 'oTransitionEnd otransitionend',
  9014. transition: 'transitionend'
  9015. };
  9016. for (var name in transEndEventNames) {
  9017. if (el.style[name] !== undefined) {
  9018. return {
  9019. end: transEndEventNames[name]
  9020. };
  9021. }
  9022. }
  9023. return false; // explicit for ie8 ( ._.)
  9024. } // http://blog.alexmaccaw.com/css-transitions
  9025. $.fn.emulateTransitionEnd = function (duration) {
  9026. var called = false;
  9027. var $el = this;
  9028. $(this).one('bsTransitionEnd', function () {
  9029. called = true;
  9030. });
  9031. var callback = function callback() {
  9032. if (!called) $($el).trigger($.support.transition.end);
  9033. };
  9034. setTimeout(callback, duration);
  9035. return this;
  9036. };
  9037. $(function () {
  9038. $.support.transition = transitionEnd();
  9039. if (!$.support.transition) return;
  9040. $.event.special.bsTransitionEnd = {
  9041. bindType: $.support.transition.end,
  9042. delegateType: $.support.transition.end,
  9043. handle: function handle(e) {
  9044. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments);
  9045. }
  9046. };
  9047. });
  9048. }((external_jQuery_default()));
  9049. ;// CONCATENATED MODULE: ./app/utils/bootstrap-collapse.js
  9050. function bootstrap_collapse_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { bootstrap_collapse_typeof = function _typeof(obj) { return typeof obj; }; } else { bootstrap_collapse_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return bootstrap_collapse_typeof(obj); }
  9051. /* ========================================================================
  9052. * Bootstrap: collapse.js v3.4.0
  9053. * http://getbootstrap.com/javascript/#collapse
  9054. * ========================================================================
  9055. * Copyright 2011-2016 Twitter, Inc.
  9056. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  9057. * ======================================================================== */
  9058. /* jshint latedef: false */
  9059. +function ($) {
  9060. 'use strict'; // COLLAPSE PUBLIC CLASS DEFINITION
  9061. // ================================
  9062. var Collapse = function Collapse(element, options) {
  9063. this.$element = $(element);
  9064. this.options = $.extend({}, Collapse.DEFAULTS, options);
  9065. this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' + '[data-toggle="collapse"][data-target="#' + element.id + '"]');
  9066. this.transitioning = null;
  9067. if (this.options.parent) {
  9068. this.$parent = this.getParent();
  9069. } else {
  9070. this.addAriaAndCollapsedClass(this.$element, this.$trigger);
  9071. }
  9072. if (this.options.toggle) this.toggle();
  9073. };
  9074. Collapse.VERSION = '3.4.0';
  9075. Collapse.TRANSITION_DURATION = 350;
  9076. Collapse.DEFAULTS = {
  9077. toggle: true
  9078. };
  9079. Collapse.prototype.dimension = function () {
  9080. var hasWidth = this.$element.hasClass('width');
  9081. return hasWidth ? 'width' : 'height';
  9082. };
  9083. Collapse.prototype.show = function () {
  9084. if (this.transitioning || this.$element.hasClass('in')) return;
  9085. var activesData;
  9086. var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing');
  9087. if (actives && actives.length) {
  9088. activesData = actives.data('bs.collapse');
  9089. if (activesData && activesData.transitioning) return;
  9090. }
  9091. var startEvent = $.Event('show.bs.collapse');
  9092. this.$element.trigger(startEvent);
  9093. if (startEvent.isDefaultPrevented()) return;
  9094. if (actives && actives.length) {
  9095. Plugin.call(actives, 'hide');
  9096. activesData || actives.data('bs.collapse', null);
  9097. }
  9098. var dimension = this.dimension();
  9099. this.$element.removeClass('collapse').addClass('collapsing')[dimension](0).attr('aria-expanded', true);
  9100. this.$trigger.removeClass('collapsed').attr('aria-expanded', true);
  9101. this.transitioning = 1;
  9102. var complete = function complete() {
  9103. this.$element.removeClass('collapsing').addClass('collapse in')[dimension]('');
  9104. this.transitioning = 0;
  9105. this.$element.trigger('shown.bs.collapse');
  9106. };
  9107. if (!$.support.transition) return complete.call(this);
  9108. var scrollSize = $.camelCase(['scroll', dimension].join('-'));
  9109. this.$element.one('bsTransitionEnd', $.proxy(complete, this)).emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]);
  9110. };
  9111. Collapse.prototype.hide = function () {
  9112. if (this.transitioning || !this.$element.hasClass('in')) return;
  9113. var startEvent = $.Event('hide.bs.collapse');
  9114. this.$element.trigger(startEvent);
  9115. if (startEvent.isDefaultPrevented()) return;
  9116. var dimension = this.dimension();
  9117. this.$element[dimension](this.$element[dimension]())[0].offsetHeight;
  9118. this.$element.addClass('collapsing').removeClass('collapse in').attr('aria-expanded', false);
  9119. this.$trigger.addClass('collapsed').attr('aria-expanded', false);
  9120. this.transitioning = 1;
  9121. var complete = function complete() {
  9122. this.transitioning = 0;
  9123. this.$element.removeClass('collapsing').addClass('collapse').trigger('hidden.bs.collapse');
  9124. };
  9125. if (!$.support.transition) return complete.call(this);
  9126. this.$element[dimension](0).one('bsTransitionEnd', $.proxy(complete, this)).emulateTransitionEnd(Collapse.TRANSITION_DURATION);
  9127. };
  9128. Collapse.prototype.toggle = function () {
  9129. this[this.$element.hasClass('in') ? 'hide' : 'show']();
  9130. };
  9131. Collapse.prototype.getParent = function () {
  9132. return $(this.options.parent).find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]').each($.proxy(function (i, element) {
  9133. var $element = $(element);
  9134. this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element);
  9135. }, this)).end();
  9136. };
  9137. Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
  9138. var isOpen = $element.hasClass('in');
  9139. $element.attr('aria-expanded', isOpen);
  9140. $trigger.toggleClass('collapsed', !isOpen).attr('aria-expanded', isOpen);
  9141. };
  9142. function getTargetFromTrigger($trigger) {
  9143. var href;
  9144. var target = $trigger.attr('data-target') || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''); // strip for ie7
  9145. return $(target);
  9146. } // COLLAPSE PLUGIN DEFINITION
  9147. // ==========================
  9148. function Plugin(option) {
  9149. return this.each(function () {
  9150. var $this = $(this);
  9151. var data = $this.data('bs.collapse');
  9152. var options = $.extend({}, Collapse.DEFAULTS, $this.data(), bootstrap_collapse_typeof(option) === 'object' && option);
  9153. if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false;
  9154. if (!data) $this.data('bs.collapse', data = new Collapse(this, options));
  9155. if (typeof option === 'string') data[option]();
  9156. });
  9157. }
  9158. var old = $.fn.collapse;
  9159. $.fn.collapse = Plugin;
  9160. $.fn.collapse.Constructor = Collapse; // COLLAPSE NO CONFLICT
  9161. // ====================
  9162. $.fn.collapse.noConflict = function () {
  9163. $.fn.collapse = old;
  9164. return this;
  9165. }; // COLLAPSE DATA-API
  9166. // =================
  9167. $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
  9168. var $this = $(this);
  9169. if (!$this.attr('data-target')) e.preventDefault();
  9170. var $target = getTargetFromTrigger($this);
  9171. var data = $target.data('bs.collapse');
  9172. var option = data ? 'toggle' : $this.data();
  9173. Plugin.call($target, option);
  9174. });
  9175. }((external_jQuery_default()));
  9176. ;// CONCATENATED MODULE: ./app/utils/bootstrap-dropdown.js
  9177. /* ========================================================================
  9178. * Bootstrap: dropdown.js v3.4.1
  9179. * https://getbootstrap.com/docs/3.4/javascript/#dropdowns
  9180. * ========================================================================
  9181. * Copyright 2011-2019 Twitter, Inc.
  9182. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/v3-dev/LICENSE)
  9183. * ======================================================================== */
  9184. +function ($) {
  9185. 'use strict'; // DROPDOWN CLASS DEFINITION
  9186. // =========================
  9187. var backdrop = '.dropdown-backdrop';
  9188. var toggle = '[data-toggle="dropdown"]';
  9189. var Dropdown = function Dropdown(element) {
  9190. $(element).on('click.bs.dropdown', this.toggle);
  9191. };
  9192. Dropdown.VERSION = '3.4.1';
  9193. function getParent($this) {
  9194. var selector = $this.attr('data-target');
  9195. if (!selector) {
  9196. selector = $this.attr('href');
  9197. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, ''); // strip for ie7
  9198. }
  9199. var $parent = selector !== '#' ? $(document).find(selector) : null;
  9200. return $parent && $parent.length ? $parent : $this.parent();
  9201. }
  9202. function clearMenus(e) {
  9203. if (e && e.which === 3) {
  9204. return;
  9205. }
  9206. $(backdrop).remove();
  9207. $(toggle).each(function () {
  9208. var $this = $(this);
  9209. var $parent = getParent($this);
  9210. var relatedTarget = {
  9211. relatedTarget: this
  9212. };
  9213. if (!$parent.hasClass('open')) {
  9214. return;
  9215. }
  9216. if (e && e.type === 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) {
  9217. return;
  9218. }
  9219. $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget));
  9220. if (e.isDefaultPrevented()) {
  9221. return;
  9222. }
  9223. $this.attr('aria-expanded', 'false');
  9224. $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget));
  9225. });
  9226. }
  9227. Dropdown.prototype.toggle = function (e) {
  9228. var $this = $(this);
  9229. if ($this.is('.disabled, :disabled')) {
  9230. return;
  9231. }
  9232. var $parent = getParent($this);
  9233. var isActive = $parent.hasClass('open');
  9234. clearMenus();
  9235. if (!isActive) {
  9236. if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
  9237. // if mobile we use a backdrop because click events don't delegate
  9238. $(document.createElement('div')).addClass('dropdown-backdrop').insertAfter($(this)).on('click', clearMenus);
  9239. }
  9240. var relatedTarget = {
  9241. relatedTarget: this
  9242. };
  9243. $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget));
  9244. if (e.isDefaultPrevented()) {
  9245. return;
  9246. }
  9247. $this.trigger('focus').attr('aria-expanded', 'true');
  9248. $parent.toggleClass('open').trigger($.Event('shown.bs.dropdown', relatedTarget));
  9249. }
  9250. return false;
  9251. };
  9252. Dropdown.prototype.keydown = function (e) {
  9253. if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return;
  9254. var $this = $(this);
  9255. e.preventDefault();
  9256. e.stopPropagation();
  9257. if ($this.is('.disabled, :disabled')) {
  9258. return;
  9259. }
  9260. var $parent = getParent($this);
  9261. var isActive = $parent.hasClass('open');
  9262. if (!isActive && e.which !== 27 || isActive && e.which === 27) {
  9263. if (e.which === 27) {
  9264. $parent.find(toggle).trigger('focus');
  9265. }
  9266. return $this.trigger('click');
  9267. }
  9268. var desc = ' li:not(.disabled):visible a';
  9269. var $items = $parent.find('.dropdown-menu' + desc);
  9270. if (!$items.length) {
  9271. return;
  9272. }
  9273. var index = $items.index(e.target);
  9274. if (e.which === 38 && index > 0) {
  9275. index--;
  9276. } // up
  9277. if (e.which === 40 && index < $items.length - 1) {
  9278. index++;
  9279. } // down
  9280. if (!~index) {
  9281. index = 0;
  9282. }
  9283. $items.eq(index).trigger('focus');
  9284. }; // DROPDOWN PLUGIN DEFINITION
  9285. // ==========================
  9286. function Plugin(option) {
  9287. return this.each(function () {
  9288. var $this = $(this);
  9289. var data = $this.data('bs.dropdown');
  9290. if (!data) $this.data('bs.dropdown', data = new Dropdown(this));
  9291. if (typeof option === 'string') data[option].call($this);
  9292. });
  9293. }
  9294. var old = $.fn.dropdown;
  9295. $.fn.dropdown = Plugin;
  9296. $.fn.dropdown.Constructor = Dropdown; // DROPDOWN NO CONFLICT
  9297. // ====================
  9298. $.fn.dropdown.noConflict = function () {
  9299. $.fn.dropdown = old;
  9300. return this;
  9301. }; // APPLY TO STANDARD DROPDOWN ELEMENTS
  9302. // ===================================
  9303. $(document).on('click.bs.dropdown.data-api', clearMenus).on('click.bs.dropdown.data-api', '.dropdown form', function (e) {
  9304. e.stopPropagation();
  9305. }).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);
  9306. }((external_jQuery_default()));
  9307. ;// CONCATENATED MODULE: ./app/utils/tabs-memory.js
  9308. var tabs_memory_Data = JSON.parse(cookies.get('grav-tabs-state') || '{}');
  9309. external_jQuery_default()('body').on('touchstart click', '[data-tabid]', function (event) {
  9310. event && event.stopPropagation();
  9311. var target = external_jQuery_default()(event.currentTarget);
  9312. tabs_memory_Data[target.data('tabkey')] = target.data('scope');
  9313. cookies.set('grav-tabs-state', JSON.stringify(tabs_memory_Data), {
  9314. expires: Infinity
  9315. });
  9316. var panel = external_jQuery_default()("[id=\"".concat(target.data('tabid'), "\"]"));
  9317. target.siblings('[data-tabid]').removeClass('active');
  9318. target.addClass('active');
  9319. panel.siblings('[id]').removeClass('active');
  9320. panel.addClass('active');
  9321. editor_Instance.editors.each(function (index, editor) {
  9322. var codemirror = external_jQuery_default()(editor).data('codemirror');
  9323. if (!codemirror) {
  9324. return;
  9325. }
  9326. if (codemirror.display.lastWrapWidth === 0) {
  9327. codemirror.refresh();
  9328. }
  9329. });
  9330. });
  9331. ;// CONCATENATED MODULE: ./app/utils/changelog.js
  9332. /* eslint-disable */
  9333. var TRIGGER = null;
  9334. external_jQuery_default()(document).on('click', '[data-remodal-changelog]', function (event) {
  9335. TRIGGER = event.currentTarget;
  9336. });
  9337. external_jQuery_default()(document).on('opened', '[data-remodal-id="changelog"]', function () {
  9338. var instance = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id=changelog]').data('remodal')];
  9339. 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>');
  9340. if (!TRIGGER) {
  9341. return true;
  9342. }
  9343. var url = external_jQuery_default()(TRIGGER).data('remodalChangelog');
  9344. external_jQuery_default().ajax({
  9345. url: url
  9346. }).done(function (data) {
  9347. instance.$modal.html(data);
  9348. });
  9349. });
  9350. external_jQuery_default()(document).on('closed', '[data-remodal-id="changelog"]', function () {
  9351. var instance = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id=changelog]').data('remodal')];
  9352. instance.$modal.html('');
  9353. });
  9354. // EXTERNAL MODULE: ./node_modules/es6-map/index.js
  9355. var es6_map = __webpack_require__(1520);
  9356. var es6_map_default = /*#__PURE__*/__webpack_require__.n(es6_map);
  9357. ;// CONCATENATED MODULE: ./app/utils/sidebar.js
  9358. function sidebar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9359. 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); } }
  9360. function sidebar_createClass(Constructor, protoProps, staticProps) { if (protoProps) sidebar_defineProperties(Constructor.prototype, protoProps); if (staticProps) sidebar_defineProperties(Constructor, staticProps); return Constructor; }
  9361. var MOBILE_BREAKPOINT = 48 - 0.062;
  9362. var DESKTOP_BREAKPOINT = 75 + 0.063;
  9363. var EVENTS = 'touchstart._grav click._grav';
  9364. var TARGETS = '[data-sidebar-mobile-toggle], #overlay';
  9365. var MOBILE_QUERY = "(max-width: ".concat(MOBILE_BREAKPOINT, "em)");
  9366. var DESKTOP_QUERY = "(min-width: ".concat(DESKTOP_BREAKPOINT, "em)");
  9367. var map = new (es6_map_default())();
  9368. var Sidebar = /*#__PURE__*/function () {
  9369. function Sidebar() {
  9370. sidebar_classCallCheck(this, Sidebar);
  9371. this.timeout = null;
  9372. this.isOpen = false;
  9373. this.body = external_jQuery_default()('body');
  9374. this.matchMedia = __webpack_require__.g.matchMedia(MOBILE_QUERY);
  9375. this.enable();
  9376. }
  9377. sidebar_createClass(Sidebar, [{
  9378. key: "enable",
  9379. value: function enable() {
  9380. var sidebar = external_jQuery_default()('#admin-sidebar');
  9381. this.matchMedia.addListener(this._getBound('checkMatch'));
  9382. this.checkMatch(this.matchMedia);
  9383. this.body.on(EVENTS, '[data-sidebar-toggle]', this._getBound('toggleSidebarState'));
  9384. if (sidebar.data('quickopen')) {
  9385. sidebar.hover(this._getBound('quickOpenIn'), this._getBound('quickOpenOut'));
  9386. }
  9387. }
  9388. }, {
  9389. key: "disable",
  9390. value: function disable() {
  9391. var sidebar = external_jQuery_default()('#admin-sidebar');
  9392. this.close();
  9393. this.matchMedia.removeListener(this._getBound('checkMatch'));
  9394. this.body.off(EVENTS, '[data-sidebar-toggle]', this._getBound('toggleSidebarState'));
  9395. if (sidebar.data('quickopen')) {
  9396. sidebar.off('mouseenter mouseleave');
  9397. }
  9398. }
  9399. }, {
  9400. key: "attach",
  9401. value: function attach() {
  9402. this.body.on(EVENTS, TARGETS, this._getBound('toggle'));
  9403. }
  9404. }, {
  9405. key: "detach",
  9406. value: function detach() {
  9407. this.body.off(EVENTS, TARGETS, this._getBound('toggle'));
  9408. }
  9409. }, {
  9410. key: "quickOpenIn",
  9411. value: function quickOpenIn()
  9412. /* event */
  9413. {
  9414. var _this = this;
  9415. var isDesktop = __webpack_require__.g.matchMedia(DESKTOP_QUERY).matches;
  9416. var delay = external_jQuery_default()('#admin-sidebar').data('quickopen-delay') || 500;
  9417. if (this.body.hasClass('sidebar-mobile-open')) {
  9418. return;
  9419. }
  9420. var shouldQuickOpen = isDesktop ? this.body.hasClass('sidebar-closed') : !this.body.hasClass('sidebar-open');
  9421. if (!shouldQuickOpen && !this.body.hasClass('sidebar-quickopen')) {
  9422. return this.quickOpenOut();
  9423. }
  9424. this.timeout = setTimeout(function () {
  9425. _this.body.addClass('sidebar-open sidebar-quickopen');
  9426. external_jQuery_default()(__webpack_require__.g).trigger('sidebar_state._grav', isDesktop);
  9427. }, delay);
  9428. }
  9429. }, {
  9430. key: "quickOpenOut",
  9431. value: function quickOpenOut()
  9432. /* event */
  9433. {
  9434. clearTimeout(this.timeout);
  9435. if (this.body.hasClass('sidebar-quickopen')) {
  9436. this.body.removeClass('sidebar-open sidebar-quickopen');
  9437. }
  9438. return true;
  9439. }
  9440. }, {
  9441. key: "open",
  9442. value: function open(event) {
  9443. var _this2 = this;
  9444. var quick = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9445. if (event) {
  9446. event.preventDefault();
  9447. }
  9448. var overlay = external_jQuery_default()('#overlay');
  9449. var sidebar = external_jQuery_default()('#admin-sidebar');
  9450. this.body.addClass('sidebar-mobile-open');
  9451. overlay.css('display', 'block');
  9452. if (!quick) {
  9453. sidebar.css('display', 'block').animate({
  9454. opacity: 1
  9455. }, 200, function () {
  9456. _this2.isOpen = true;
  9457. });
  9458. } else {
  9459. sidebar.css({
  9460. display: 'block',
  9461. opacity: 1
  9462. });
  9463. this.isOpen = true;
  9464. }
  9465. }
  9466. }, {
  9467. key: "close",
  9468. value: function close(event) {
  9469. var _this3 = this;
  9470. var quick = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9471. if (event) {
  9472. event.preventDefault();
  9473. }
  9474. var overlay = external_jQuery_default()('#overlay');
  9475. var sidebar = external_jQuery_default()('#admin-sidebar');
  9476. this.body.removeClass('sidebar-mobile-open');
  9477. overlay.css('display', 'none');
  9478. if (!quick) {
  9479. sidebar.animate({
  9480. opacity: 0
  9481. }, 200, function () {
  9482. sidebar.css('display', 'none');
  9483. _this3.isOpen = false;
  9484. });
  9485. } else {
  9486. sidebar.css({
  9487. opacity: 0,
  9488. display: 'none'
  9489. });
  9490. this.isOpen = false;
  9491. }
  9492. }
  9493. }, {
  9494. key: "toggle",
  9495. value: function toggle(event) {
  9496. if (event) {
  9497. event.preventDefault();
  9498. }
  9499. return this[this.isOpen ? 'close' : 'open'](event);
  9500. }
  9501. }, {
  9502. key: "toggleSidebarState",
  9503. value: function toggleSidebarState(event) {
  9504. if (event) {
  9505. event.preventDefault();
  9506. }
  9507. clearTimeout(this.timeout);
  9508. var isDesktop = __webpack_require__.g.matchMedia(DESKTOP_QUERY).matches;
  9509. var cookie = null;
  9510. if (isDesktop) {
  9511. this.body.removeClass('sidebar-open');
  9512. }
  9513. if (!isDesktop) {
  9514. this.body.removeClass('sidebar-closed');
  9515. this.body.removeClass('sidebar-mobile-open');
  9516. }
  9517. this.body.toggleClass("sidebar-".concat(isDesktop ? 'closed' : 'open'));
  9518. external_jQuery_default()(__webpack_require__.g).trigger('sidebar_state._grav', isDesktop);
  9519. if (isDesktop) {
  9520. cookie = !this.body.hasClass('sidebar-closed');
  9521. } else {
  9522. cookie = this.body.hasClass('sidebar-open');
  9523. }
  9524. cookies.set('grav-admin-sidebar', cookie, {
  9525. expires: Infinity
  9526. });
  9527. }
  9528. }, {
  9529. key: "checkMatch",
  9530. value: function checkMatch(data) {
  9531. var sidebar = external_jQuery_default()('#admin-sidebar');
  9532. var overlay = external_jQuery_default()('#overlay');
  9533. this.isOpen = false;
  9534. overlay.css('display', 'none');
  9535. sidebar.css({
  9536. display: data.matches ? 'none' : 'inherit',
  9537. opacity: data.matches ? 0 : 1
  9538. });
  9539. if (data.matches) {
  9540. this.body.removeClass('sidebar-open sidebar-closed');
  9541. }
  9542. this[data.matches ? 'attach' : 'detach']();
  9543. }
  9544. }, {
  9545. key: "_resetMap",
  9546. value: function _resetMap() {
  9547. return map.clear();
  9548. }
  9549. }, {
  9550. key: "_getBound",
  9551. value: function _getBound(fn) {
  9552. if (map.has(fn)) {
  9553. return map.get(fn);
  9554. }
  9555. return map.set(fn, this[fn].bind(this)).get(fn);
  9556. }
  9557. }]);
  9558. return Sidebar;
  9559. }();
  9560. var sidebar_Instance = new Sidebar();
  9561. ;// CONCATENATED MODULE: ./app/main.js
  9562. // polyfills
  9563. // bootstrap jQuery extensions
  9564. // tabs memory
  9565. // changelog
  9566. // Main Sidebar
  9567. // starts the keep alive, auto runs every X seconds
  9568. keepalive.start(); // global event to catch sidebar_state changes
  9569. external_jQuery_default()(__webpack_require__.g).on('sidebar_state._grav', function () {
  9570. Object.keys(dashboard.Chart.Instances).forEach(function (chart) {
  9571. setTimeout(function () {
  9572. return dashboard.Chart.Instances[chart].chart.update();
  9573. }, 10);
  9574. });
  9575. });
  9576. /* harmony default export */ const main = ({
  9577. GPM: {
  9578. GPM: GPM,
  9579. Instance: Instance
  9580. },
  9581. KeepAlive: keepalive,
  9582. Dashboard: dashboard,
  9583. Pages: pages,
  9584. Forms: app_forms,
  9585. Updates: {
  9586. Updates: Updates,
  9587. Notifications: updates_notifications,
  9588. Feed: updates_feed,
  9589. Instance: updates_Instance
  9590. },
  9591. Sidebar: {
  9592. Sidebar: Sidebar,
  9593. Instance: sidebar_Instance
  9594. },
  9595. MediaFilter: {
  9596. MediaFilter: Filter,
  9597. Instance: app_media_Instance
  9598. },
  9599. Scrollbar: {
  9600. Scrollbar: {
  9601. deprecated: true
  9602. },
  9603. Instance: {
  9604. deprecated: true
  9605. }
  9606. },
  9607. Utils: {
  9608. request: utils_request,
  9609. toastr: utils_toastr,
  9610. Cookies: cookies
  9611. }
  9612. });
  9613. /***/ }),
  9614. /***/ 36531:
  9615. /***/ ((module, exports, __webpack_require__) => {
  9616. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  9617. /*! version : 4.17.47
  9618. =========================================================
  9619. bootstrap-datetimejs
  9620. https://github.com/Eonasdan/bootstrap-datetimepicker
  9621. Copyright (c) 2015 Jonathan Peterson
  9622. =========================================================
  9623. */
  9624. /*
  9625. The MIT License (MIT)
  9626. Copyright (c) 2015 Jonathan Peterson
  9627. Permission is hereby granted, free of charge, to any person obtaining a copy
  9628. of this software and associated documentation files (the "Software"), to deal
  9629. in the Software without restriction, including without limitation the rights
  9630. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9631. copies of the Software, and to permit persons to whom the Software is
  9632. furnished to do so, subject to the following conditions:
  9633. The above copyright notice and this permission notice shall be included in
  9634. all copies or substantial portions of the Software.
  9635. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9636. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9637. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9638. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9639. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9640. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9641. THE SOFTWARE.
  9642. */
  9643. /* global define:false */
  9644. /* global jQuery:false */
  9645. /* global moment:false */
  9646. (function (factory) {
  9647. 'use strict';
  9648. if (true) {
  9649. // AMD is used - Register as an anonymous module.
  9650. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(73609), __webpack_require__(30381)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  9651. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  9652. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  9653. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  9654. } else {}
  9655. })(function ($, moment) {
  9656. 'use strict';
  9657. if (!moment) {
  9658. throw new Error('bootstrap-datetimepicker requires Moment.js to be loaded first');
  9659. }
  9660. var dateTimePicker = function dateTimePicker(element, options) {
  9661. var picker = {};
  9662. var date;
  9663. var viewDate;
  9664. var unset = true;
  9665. var input;
  9666. var component = false;
  9667. var widget = false;
  9668. var use24Hours;
  9669. var minViewModeNumber = 0;
  9670. var actualFormat;
  9671. var parseFormats;
  9672. var currentViewMode;
  9673. var datePickerModes = [{
  9674. clsName: 'days',
  9675. navFnc: 'M',
  9676. navStep: 1
  9677. }, {
  9678. clsName: 'months',
  9679. navFnc: 'y',
  9680. navStep: 1
  9681. }, {
  9682. clsName: 'years',
  9683. navFnc: 'y',
  9684. navStep: 10
  9685. }, {
  9686. clsName: 'decades',
  9687. navFnc: 'y',
  9688. navStep: 100
  9689. }];
  9690. var viewModes = ['days', 'months', 'years', 'decades'];
  9691. var verticalModes = ['top', 'bottom', 'auto'];
  9692. var horizontalModes = ['left', 'right', 'auto'];
  9693. var toolbarPlacements = ['default', 'top', 'bottom'];
  9694. var keyMap = {
  9695. 'up': 38,
  9696. 38: 'up',
  9697. 'down': 40,
  9698. 40: 'down',
  9699. 'left': 37,
  9700. 37: 'left',
  9701. 'right': 39,
  9702. 39: 'right',
  9703. 'tab': 9,
  9704. 9: 'tab',
  9705. 'escape': 27,
  9706. 27: 'escape',
  9707. 'enter': 13,
  9708. 13: 'enter',
  9709. 'pageUp': 33,
  9710. 33: 'pageUp',
  9711. 'pageDown': 34,
  9712. 34: 'pageDown',
  9713. 'shift': 16,
  9714. 16: 'shift',
  9715. 'control': 17,
  9716. 17: 'control',
  9717. 'space': 32,
  9718. 32: 'space',
  9719. 't': 84,
  9720. 84: 't',
  9721. 'delete': 46,
  9722. 46: 'delete'
  9723. };
  9724. var keyState = {};
  9725. /** ******************************************************************************
  9726. *
  9727. * Private functions
  9728. *
  9729. ********************************************************************************/
  9730. var hasTimeZone = function hasTimeZone() {
  9731. return moment.tz !== undefined && options.timeZone !== undefined && options.timeZone !== null && options.timeZone !== '';
  9732. };
  9733. var getMoment = function getMoment(d) {
  9734. var returnMoment;
  9735. if (d === undefined || d === null) {
  9736. returnMoment = moment(); // TODO should this use format? and locale?
  9737. } else if (moment.isDate(d) || moment.isMoment(d)) {
  9738. // If the date that is passed in is already a Date() or moment() object,
  9739. // pass it directly to moment.
  9740. returnMoment = moment(d);
  9741. } else if (hasTimeZone()) {
  9742. // There is a string to parse and a default time zone
  9743. // parse with the tz function which takes a default time zone if it is not in the format string
  9744. returnMoment = moment.tz(d, parseFormats, options.useStrict, options.timeZone);
  9745. } else {
  9746. returnMoment = moment(d, parseFormats, options.useStrict);
  9747. }
  9748. if (hasTimeZone()) {
  9749. returnMoment.tz(options.timeZone);
  9750. }
  9751. return returnMoment;
  9752. };
  9753. var isEnabled = function isEnabled(granularity) {
  9754. if (typeof granularity !== 'string' || granularity.length > 1) {
  9755. throw new TypeError('isEnabled expects a single character string parameter');
  9756. }
  9757. switch (granularity) {
  9758. case 'y':
  9759. return actualFormat.indexOf('Y') !== -1;
  9760. case 'M':
  9761. return actualFormat.indexOf('M') !== -1;
  9762. case 'd':
  9763. return actualFormat.toLowerCase().indexOf('d') !== -1;
  9764. case 'h':
  9765. case 'H':
  9766. return actualFormat.toLowerCase().indexOf('h') !== -1;
  9767. case 'm':
  9768. return actualFormat.indexOf('m') !== -1;
  9769. case 's':
  9770. return actualFormat.indexOf('s') !== -1;
  9771. default:
  9772. return false;
  9773. }
  9774. };
  9775. var hasTime = function hasTime() {
  9776. return isEnabled('h') || isEnabled('m') || isEnabled('s');
  9777. };
  9778. var hasDate = function hasDate() {
  9779. return isEnabled('y') || isEnabled('M') || isEnabled('d');
  9780. };
  9781. var getDatePickerTemplate = function getDatePickerTemplate() {
  9782. 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))));
  9783. var contTemplate = $('<tbody>').append($('<tr>').append($('<td>').attr('colspan', options.calendarWeeks ? '8' : '7')));
  9784. 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()))];
  9785. };
  9786. var getTimePickerMainTemplate = function getTimePickerMainTemplate() {
  9787. var topRow = $('<tr>');
  9788. var middleRow = $('<tr>');
  9789. var bottomRow = $('<tr>');
  9790. if (isEnabled('h')) {
  9791. topRow.append($('<td>').append($('<a>').attr({
  9792. href: '#',
  9793. tabindex: '-1',
  9794. 'title': options.tooltips.incrementHour
  9795. }).addClass('btn').attr('data-action', 'incrementHours').append($('<span>').addClass(options.icons.up))));
  9796. middleRow.append($('<td>').append($('<span>').addClass('timepicker-hour').attr({
  9797. 'data-time-component': 'hours',
  9798. 'title': options.tooltips.pickHour
  9799. }).attr('data-action', 'showHours')));
  9800. bottomRow.append($('<td>').append($('<a>').attr({
  9801. href: '#',
  9802. tabindex: '-1',
  9803. 'title': options.tooltips.decrementHour
  9804. }).addClass('btn').attr('data-action', 'decrementHours').append($('<span>').addClass(options.icons.down))));
  9805. }
  9806. if (isEnabled('m')) {
  9807. if (isEnabled('h')) {
  9808. topRow.append($('<td>').addClass('separator'));
  9809. middleRow.append($('<td>').addClass('separator').html(':'));
  9810. bottomRow.append($('<td>').addClass('separator'));
  9811. }
  9812. topRow.append($('<td>').append($('<a>').attr({
  9813. href: '#',
  9814. tabindex: '-1',
  9815. 'title': options.tooltips.incrementMinute
  9816. }).addClass('btn').attr('data-action', 'incrementMinutes').append($('<span>').addClass(options.icons.up))));
  9817. middleRow.append($('<td>').append($('<span>').addClass('timepicker-minute').attr({
  9818. 'data-time-component': 'minutes',
  9819. 'title': options.tooltips.pickMinute
  9820. }).attr('data-action', 'showMinutes')));
  9821. bottomRow.append($('<td>').append($('<a>').attr({
  9822. href: '#',
  9823. tabindex: '-1',
  9824. 'title': options.tooltips.decrementMinute
  9825. }).addClass('btn').attr('data-action', 'decrementMinutes').append($('<span>').addClass(options.icons.down))));
  9826. }
  9827. if (isEnabled('s')) {
  9828. if (isEnabled('m')) {
  9829. topRow.append($('<td>').addClass('separator'));
  9830. middleRow.append($('<td>').addClass('separator').html(':'));
  9831. bottomRow.append($('<td>').addClass('separator'));
  9832. }
  9833. topRow.append($('<td>').append($('<a>').attr({
  9834. href: '#',
  9835. tabindex: '-1',
  9836. 'title': options.tooltips.incrementSecond
  9837. }).addClass('btn').attr('data-action', 'incrementSeconds').append($('<span>').addClass(options.icons.up))));
  9838. middleRow.append($('<td>').append($('<span>').addClass('timepicker-second').attr({
  9839. 'data-time-component': 'seconds',
  9840. 'title': options.tooltips.pickSecond
  9841. }).attr('data-action', 'showSeconds')));
  9842. bottomRow.append($('<td>').append($('<a>').attr({
  9843. href: '#',
  9844. tabindex: '-1',
  9845. 'title': options.tooltips.decrementSecond
  9846. }).addClass('btn').attr('data-action', 'decrementSeconds').append($('<span>').addClass(options.icons.down))));
  9847. }
  9848. if (!use24Hours) {
  9849. topRow.append($('<td>').addClass('separator'));
  9850. middleRow.append($('<td>').append($('<button>').addClass('btn btn-primary').attr({
  9851. 'data-action': 'togglePeriod',
  9852. tabindex: '-1',
  9853. 'title': options.tooltips.togglePeriod
  9854. })));
  9855. bottomRow.append($('<td>').addClass('separator'));
  9856. }
  9857. return $('<div>').addClass('timepicker-picker').append($('<table>').addClass('table-condensed').append([topRow, middleRow, bottomRow]));
  9858. };
  9859. var getTimePickerTemplate = function getTimePickerTemplate() {
  9860. var hoursView = $('<div>').addClass('timepicker-hours').append($('<table>').addClass('table-condensed'));
  9861. var minutesView = $('<div>').addClass('timepicker-minutes').append($('<table>').addClass('table-condensed'));
  9862. var secondsView = $('<div>').addClass('timepicker-seconds').append($('<table>').addClass('table-condensed'));
  9863. var ret = [getTimePickerMainTemplate()];
  9864. if (isEnabled('h')) {
  9865. ret.push(hoursView);
  9866. }
  9867. if (isEnabled('m')) {
  9868. ret.push(minutesView);
  9869. }
  9870. if (isEnabled('s')) {
  9871. ret.push(secondsView);
  9872. }
  9873. return ret;
  9874. };
  9875. var getToolbar = function getToolbar() {
  9876. var row = [];
  9877. if (options.showTodayButton) {
  9878. row.push($('<td>').append($('<a>').attr({
  9879. 'data-action': 'today',
  9880. 'title': options.tooltips.today
  9881. }).append($('<span>').addClass(options.icons.today))));
  9882. }
  9883. if (!options.sideBySide && hasDate() && hasTime()) {
  9884. row.push($('<td>').append($('<a>').attr({
  9885. 'data-action': 'togglePicker',
  9886. 'title': options.tooltips.selectTime
  9887. }).append($('<span>').addClass(options.icons.time))));
  9888. }
  9889. if (options.showClear) {
  9890. row.push($('<td>').append($('<a>').attr({
  9891. 'data-action': 'clear',
  9892. 'title': options.tooltips.clear
  9893. }).append($('<span>').addClass(options.icons.clear))));
  9894. }
  9895. if (options.showClose) {
  9896. row.push($('<td>').append($('<a>').attr({
  9897. 'data-action': 'close',
  9898. 'title': options.tooltips.close
  9899. }).append($('<span>').addClass(options.icons.close))));
  9900. }
  9901. return $('<table>').addClass('table-condensed').append($('<tbody>').append($('<tr>').append(row)));
  9902. };
  9903. var getTemplate = function getTemplate() {
  9904. var template = $('<div>').addClass('bootstrap-datetimepicker-widget dropdown-menu');
  9905. var dateView = $('<div>').addClass('datepicker').append(getDatePickerTemplate());
  9906. var timeView = $('<div>').addClass('timepicker').append(getTimePickerTemplate());
  9907. var content = $('<ul>').addClass('list-unstyled');
  9908. var toolbar = $('<li>').addClass('picker-switch' + (options.collapse ? ' accordion-toggle' : '')).append(getToolbar());
  9909. if (options.inline) {
  9910. template.removeClass('dropdown-menu');
  9911. }
  9912. if (use24Hours) {
  9913. template.addClass('usetwentyfour');
  9914. }
  9915. if (isEnabled('s') && !use24Hours) {
  9916. template.addClass('wider');
  9917. }
  9918. if (options.sideBySide && hasDate() && hasTime()) {
  9919. template.addClass('timepicker-sbs');
  9920. if (options.toolbarPlacement === 'top') {
  9921. template.append(toolbar);
  9922. }
  9923. template.append($('<div>').addClass('row').append(dateView.addClass('col-md-6')).append(timeView.addClass('col-md-6')));
  9924. if (options.toolbarPlacement === 'bottom') {
  9925. template.append(toolbar);
  9926. }
  9927. return template;
  9928. }
  9929. if (options.toolbarPlacement === 'top') {
  9930. content.append(toolbar);
  9931. }
  9932. if (hasDate()) {
  9933. content.append($('<li>').addClass(options.collapse && hasTime() ? 'collapse in' : '').append(dateView));
  9934. }
  9935. if (options.toolbarPlacement === 'default') {
  9936. content.append(toolbar);
  9937. }
  9938. if (hasTime()) {
  9939. content.append($('<li>').addClass(options.collapse && hasDate() ? 'collapse' : '').append(timeView));
  9940. }
  9941. if (options.toolbarPlacement === 'bottom') {
  9942. content.append(toolbar);
  9943. }
  9944. return template.append(content);
  9945. };
  9946. var dataToOptions = function dataToOptions() {
  9947. var eData;
  9948. var dataOptions = {};
  9949. if (element.is('input') || options.inline) {
  9950. eData = element.data();
  9951. } else {
  9952. eData = element.find('input').data();
  9953. }
  9954. if (eData.dateOptions && eData.dateOptions instanceof Object) {
  9955. dataOptions = $.extend(true, dataOptions, eData.dateOptions);
  9956. }
  9957. $.each(options, function (key) {
  9958. var attributeName = 'date' + key.charAt(0).toUpperCase() + key.slice(1);
  9959. if (eData[attributeName] !== undefined) {
  9960. dataOptions[key] = eData[attributeName];
  9961. }
  9962. });
  9963. return dataOptions;
  9964. };
  9965. var place = function place() {
  9966. var position = (component || element).position();
  9967. var offset = (component || element).offset();
  9968. var vertical = options.widgetPositioning.vertical;
  9969. var horizontal = options.widgetPositioning.horizontal;
  9970. var parent;
  9971. if (options.widgetParent) {
  9972. parent = options.widgetParent.append(widget);
  9973. } else if (element.is('input')) {
  9974. parent = element.after(widget).parent();
  9975. } else if (options.inline) {
  9976. parent = element.append(widget);
  9977. return;
  9978. } else {
  9979. parent = element;
  9980. element.children().first().after(widget);
  9981. } // Top and bottom logic
  9982. if (vertical === 'auto') {
  9983. if (offset.top + widget.height() * 1.5 >= $(window).height() + $(window).scrollTop() && widget.height() + element.outerHeight() < offset.top) {
  9984. vertical = 'top';
  9985. } else {
  9986. vertical = 'bottom';
  9987. }
  9988. } // Left and right logic
  9989. if (horizontal === 'auto') {
  9990. if (parent.width() < offset.left + widget.outerWidth() / 2 && offset.left + widget.outerWidth() > $(window).width()) {
  9991. horizontal = 'right';
  9992. } else {
  9993. horizontal = 'left';
  9994. }
  9995. }
  9996. if (vertical === 'top') {
  9997. widget.addClass('top').removeClass('bottom');
  9998. } else {
  9999. widget.addClass('bottom').removeClass('top');
  10000. }
  10001. if (horizontal === 'right') {
  10002. widget.addClass('pull-right');
  10003. } else {
  10004. widget.removeClass('pull-right');
  10005. } // find the first parent element that has a non-static css positioning
  10006. if (parent.css('position') === 'static') {
  10007. parent = parent.parents().filter(function () {
  10008. return $(this).css('position') !== 'static';
  10009. }).first();
  10010. }
  10011. if (parent.length === 0) {
  10012. throw new Error('datetimepicker component should be placed within a non-static positioned container');
  10013. }
  10014. widget.css({
  10015. top: vertical === 'top' ? 'auto' : position.top + element.outerHeight(),
  10016. bottom: vertical === 'top' ? parent.outerHeight() - (parent === element ? 0 : position.top) : 'auto',
  10017. left: horizontal === 'left' ? parent === element ? 0 : position.left : 'auto',
  10018. right: horizontal === 'left' ? 'auto' : parent.outerWidth() - element.outerWidth() - (parent === element ? 0 : position.left)
  10019. });
  10020. };
  10021. var notifyEvent = function notifyEvent(e) {
  10022. if (e.type === 'dp.change' && (e.date && e.date.isSame(e.oldDate) || !e.date && !e.oldDate)) {
  10023. return;
  10024. }
  10025. element.trigger(e);
  10026. };
  10027. var viewUpdate = function viewUpdate(e) {
  10028. if (e === 'y') {
  10029. e = 'YYYY';
  10030. }
  10031. notifyEvent({
  10032. type: 'dp.update',
  10033. change: e,
  10034. viewDate: viewDate.clone()
  10035. });
  10036. };
  10037. var showMode = function showMode(dir) {
  10038. if (!widget) {
  10039. return;
  10040. }
  10041. if (dir) {
  10042. currentViewMode = Math.max(minViewModeNumber, Math.min(3, currentViewMode + dir));
  10043. }
  10044. widget.find('.datepicker > div').hide().filter('.datepicker-' + datePickerModes[currentViewMode].clsName).show();
  10045. };
  10046. var fillDow = function fillDow() {
  10047. var row = $('<tr>');
  10048. var currentDate = viewDate.clone().startOf('w').startOf('d');
  10049. if (options.calendarWeeks === true) {
  10050. row.append($('<th>').addClass('cw').text('#'));
  10051. }
  10052. while (currentDate.isBefore(viewDate.clone().endOf('w'))) {
  10053. row.append($('<th>').addClass('dow').text(currentDate.format('dd')));
  10054. currentDate.add(1, 'd');
  10055. }
  10056. widget.find('.datepicker-days thead').append(row);
  10057. };
  10058. var isInDisabledDates = function isInDisabledDates(testDate) {
  10059. return options.disabledDates[testDate.format('YYYY-MM-DD')] === true;
  10060. };
  10061. var isInEnabledDates = function isInEnabledDates(testDate) {
  10062. return options.enabledDates[testDate.format('YYYY-MM-DD')] === true;
  10063. };
  10064. var isInDisabledHours = function isInDisabledHours(testDate) {
  10065. return options.disabledHours[testDate.format('H')] === true;
  10066. };
  10067. var isInEnabledHours = function isInEnabledHours(testDate) {
  10068. return options.enabledHours[testDate.format('H')] === true;
  10069. };
  10070. var isValid = function isValid(targetMoment, granularity) {
  10071. if (!targetMoment.isValid()) {
  10072. return false;
  10073. }
  10074. if (options.disabledDates && granularity === 'd' && isInDisabledDates(targetMoment)) {
  10075. return false;
  10076. }
  10077. if (options.enabledDates && granularity === 'd' && !isInEnabledDates(targetMoment)) {
  10078. return false;
  10079. }
  10080. if (options.minDate && targetMoment.isBefore(options.minDate, granularity)) {
  10081. return false;
  10082. }
  10083. if (options.maxDate && targetMoment.isAfter(options.maxDate, granularity)) {
  10084. return false;
  10085. }
  10086. if (options.daysOfWeekDisabled && granularity === 'd' && options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) {
  10087. return false;
  10088. }
  10089. if (options.disabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && isInDisabledHours(targetMoment)) {
  10090. return false;
  10091. }
  10092. if (options.enabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && !isInEnabledHours(targetMoment)) {
  10093. return false;
  10094. }
  10095. if (options.disabledTimeIntervals && (granularity === 'h' || granularity === 'm' || granularity === 's')) {
  10096. var found = false;
  10097. $.each(options.disabledTimeIntervals, function () {
  10098. if (targetMoment.isBetween(this[0], this[1])) {
  10099. found = true;
  10100. return false;
  10101. }
  10102. });
  10103. if (found) {
  10104. return false;
  10105. }
  10106. }
  10107. return true;
  10108. };
  10109. var fillMonths = function fillMonths() {
  10110. var spans = [];
  10111. var monthsShort = viewDate.clone().startOf('y').startOf('d');
  10112. while (monthsShort.isSame(viewDate, 'y')) {
  10113. spans.push($('<span>').attr('data-action', 'selectMonth').addClass('month').text(monthsShort.format('MMM')));
  10114. monthsShort.add(1, 'M');
  10115. }
  10116. widget.find('.datepicker-months td').empty().append(spans);
  10117. };
  10118. var updateMonths = function updateMonths() {
  10119. var monthsView = widget.find('.datepicker-months');
  10120. var monthsViewHeader = monthsView.find('th');
  10121. var months = monthsView.find('tbody').find('span');
  10122. monthsViewHeader.eq(0).find('span').attr('title', options.tooltips.prevYear);
  10123. monthsViewHeader.eq(1).attr('title', options.tooltips.selectYear);
  10124. monthsViewHeader.eq(2).find('span').attr('title', options.tooltips.nextYear);
  10125. monthsView.find('.disabled').removeClass('disabled');
  10126. if (!isValid(viewDate.clone().subtract(1, 'y'), 'y')) {
  10127. monthsViewHeader.eq(0).addClass('disabled');
  10128. }
  10129. monthsViewHeader.eq(1).text(viewDate.year());
  10130. if (!isValid(viewDate.clone().add(1, 'y'), 'y')) {
  10131. monthsViewHeader.eq(2).addClass('disabled');
  10132. }
  10133. months.removeClass('active');
  10134. if (date.isSame(viewDate, 'y') && !unset) {
  10135. months.eq(date.month()).addClass('active');
  10136. }
  10137. months.each(function (index) {
  10138. if (!isValid(viewDate.clone().month(index), 'M')) {
  10139. $(this).addClass('disabled');
  10140. }
  10141. });
  10142. };
  10143. var updateYears = function updateYears() {
  10144. var yearsView = widget.find('.datepicker-years');
  10145. var yearsViewHeader = yearsView.find('th');
  10146. var startYear = viewDate.clone().subtract(5, 'y');
  10147. var endYear = viewDate.clone().add(6, 'y');
  10148. var html = '';
  10149. yearsViewHeader.eq(0).find('span').attr('title', options.tooltips.prevDecade);
  10150. yearsViewHeader.eq(1).attr('title', options.tooltips.selectDecade);
  10151. yearsViewHeader.eq(2).find('span').attr('title', options.tooltips.nextDecade);
  10152. yearsView.find('.disabled').removeClass('disabled');
  10153. if (options.minDate && options.minDate.isAfter(startYear, 'y')) {
  10154. yearsViewHeader.eq(0).addClass('disabled');
  10155. }
  10156. yearsViewHeader.eq(1).text(startYear.year() + '-' + endYear.year());
  10157. if (options.maxDate && options.maxDate.isBefore(endYear, 'y')) {
  10158. yearsViewHeader.eq(2).addClass('disabled');
  10159. }
  10160. while (!startYear.isAfter(endYear, 'y')) {
  10161. html += '<span data-action="selectYear" class="year' + (startYear.isSame(date, 'y') && !unset ? ' active' : '') + (!isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
  10162. startYear.add(1, 'y');
  10163. }
  10164. yearsView.find('td').html(html);
  10165. };
  10166. var updateDecades = function updateDecades() {
  10167. var decadesView = widget.find('.datepicker-decades');
  10168. var decadesViewHeader = decadesView.find('th');
  10169. var startDecade = moment({
  10170. y: viewDate.year() - viewDate.year() % 100 - 1
  10171. });
  10172. var endDecade = startDecade.clone().add(100, 'y');
  10173. var startedAt = startDecade.clone();
  10174. var minDateDecade = false;
  10175. var maxDateDecade = false;
  10176. var endDecadeYear;
  10177. var html = '';
  10178. decadesViewHeader.eq(0).find('span').attr('title', options.tooltips.prevCentury);
  10179. decadesViewHeader.eq(2).find('span').attr('title', options.tooltips.nextCentury);
  10180. decadesView.find('.disabled').removeClass('disabled');
  10181. if (startDecade.isSame(moment({
  10182. y: 1900
  10183. })) || options.minDate && options.minDate.isAfter(startDecade, 'y')) {
  10184. decadesViewHeader.eq(0).addClass('disabled');
  10185. }
  10186. decadesViewHeader.eq(1).text(startDecade.year() + '-' + endDecade.year());
  10187. if (startDecade.isSame(moment({
  10188. y: 2000
  10189. })) || options.maxDate && options.maxDate.isBefore(endDecade, 'y')) {
  10190. decadesViewHeader.eq(2).addClass('disabled');
  10191. }
  10192. while (!startDecade.isAfter(endDecade, 'y')) {
  10193. endDecadeYear = startDecade.year() + 12;
  10194. minDateDecade = options.minDate && options.minDate.isAfter(startDecade, 'y') && options.minDate.year() <= endDecadeYear;
  10195. maxDateDecade = options.maxDate && options.maxDate.isAfter(startDecade, 'y') && options.maxDate.year() <= endDecadeYear;
  10196. 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>';
  10197. startDecade.add(12, 'y');
  10198. }
  10199. html += '<span></span><span></span><span></span>'; // push the dangling block over, at least this way it's even
  10200. decadesView.find('td').html(html);
  10201. decadesViewHeader.eq(1).text(startedAt.year() + 1 + '-' + startDecade.year());
  10202. };
  10203. var fillDate = function fillDate() {
  10204. var daysView = widget.find('.datepicker-days');
  10205. var daysViewHeader = daysView.find('th');
  10206. var currentDate;
  10207. var html = [];
  10208. var row;
  10209. var clsNames = [];
  10210. var i;
  10211. if (!hasDate()) {
  10212. return;
  10213. }
  10214. daysViewHeader.eq(0).find('span').attr('title', options.tooltips.prevMonth);
  10215. daysViewHeader.eq(1).attr('title', options.tooltips.selectMonth);
  10216. daysViewHeader.eq(2).find('span').attr('title', options.tooltips.nextMonth);
  10217. daysView.find('.disabled').removeClass('disabled');
  10218. daysViewHeader.eq(1).text(viewDate.format(options.dayViewHeaderFormat));
  10219. if (!isValid(viewDate.clone().subtract(1, 'M'), 'M')) {
  10220. daysViewHeader.eq(0).addClass('disabled');
  10221. }
  10222. if (!isValid(viewDate.clone().add(1, 'M'), 'M')) {
  10223. daysViewHeader.eq(2).addClass('disabled');
  10224. }
  10225. currentDate = viewDate.clone().startOf('M').startOf('w').startOf('d');
  10226. for (i = 0; i < 42; i++) {
  10227. // always display 42 days (should show 6 weeks)
  10228. if (currentDate.weekday() === 0) {
  10229. row = $('<tr>');
  10230. if (options.calendarWeeks) {
  10231. row.append('<td class="cw">' + currentDate.week() + '</td>');
  10232. }
  10233. html.push(row);
  10234. }
  10235. clsNames = ['day'];
  10236. if (currentDate.isBefore(viewDate, 'M')) {
  10237. clsNames.push('old');
  10238. }
  10239. if (currentDate.isAfter(viewDate, 'M')) {
  10240. clsNames.push('new');
  10241. }
  10242. if (currentDate.isSame(date, 'd') && !unset) {
  10243. clsNames.push('active');
  10244. }
  10245. if (!isValid(currentDate, 'd')) {
  10246. clsNames.push('disabled');
  10247. }
  10248. if (currentDate.isSame(getMoment(), 'd')) {
  10249. clsNames.push('today');
  10250. }
  10251. if (currentDate.day() === 0 || currentDate.day() === 6) {
  10252. clsNames.push('weekend');
  10253. }
  10254. notifyEvent({
  10255. type: 'dp.classify',
  10256. date: currentDate,
  10257. classNames: clsNames
  10258. });
  10259. row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="' + clsNames.join(' ') + '">' + currentDate.date() + '</td>');
  10260. currentDate.add(1, 'd');
  10261. }
  10262. daysView.find('tbody').empty().append(html);
  10263. updateMonths();
  10264. updateYears();
  10265. updateDecades();
  10266. };
  10267. var fillHours = function fillHours() {
  10268. var table = widget.find('.timepicker-hours table');
  10269. var currentHour = viewDate.clone().startOf('d');
  10270. var html = [];
  10271. var row = $('<tr>');
  10272. if (viewDate.hour() > 11 && !use24Hours) {
  10273. currentHour.hour(12);
  10274. }
  10275. while (currentHour.isSame(viewDate, 'd') && (use24Hours || viewDate.hour() < 12 && currentHour.hour() < 12 || viewDate.hour() > 11)) {
  10276. if (currentHour.hour() % 4 === 0) {
  10277. row = $('<tr>');
  10278. html.push(row);
  10279. }
  10280. row.append('<td data-action="selectHour" class="hour' + (!isValid(currentHour, 'h') ? ' disabled' : '') + '">' + currentHour.format(use24Hours ? 'HH' : 'hh') + '</td>');
  10281. currentHour.add(1, 'h');
  10282. }
  10283. table.empty().append(html);
  10284. };
  10285. var fillMinutes = function fillMinutes() {
  10286. var table = widget.find('.timepicker-minutes table');
  10287. var currentMinute = viewDate.clone().startOf('h');
  10288. var html = [];
  10289. var row = $('<tr>');
  10290. var step = options.stepping === 1 ? 5 : options.stepping;
  10291. while (viewDate.isSame(currentMinute, 'h')) {
  10292. if (currentMinute.minute() % (step * 4) === 0) {
  10293. row = $('<tr>');
  10294. html.push(row);
  10295. }
  10296. row.append('<td data-action="selectMinute" class="minute' + (!isValid(currentMinute, 'm') ? ' disabled' : '') + '">' + currentMinute.format('mm') + '</td>');
  10297. currentMinute.add(step, 'm');
  10298. }
  10299. table.empty().append(html);
  10300. };
  10301. var fillSeconds = function fillSeconds() {
  10302. var table = widget.find('.timepicker-seconds table');
  10303. var currentSecond = viewDate.clone().startOf('m');
  10304. var html = [];
  10305. var row = $('<tr>');
  10306. while (viewDate.isSame(currentSecond, 'm')) {
  10307. if (currentSecond.second() % 20 === 0) {
  10308. row = $('<tr>');
  10309. html.push(row);
  10310. }
  10311. row.append('<td data-action="selectSecond" class="second' + (!isValid(currentSecond, 's') ? ' disabled' : '') + '">' + currentSecond.format('ss') + '</td>');
  10312. currentSecond.add(5, 's');
  10313. }
  10314. table.empty().append(html);
  10315. };
  10316. var fillTime = function fillTime() {
  10317. var toggle;
  10318. var newDate;
  10319. var timeComponents = widget.find('.timepicker span[data-time-component]');
  10320. if (!use24Hours) {
  10321. toggle = widget.find('.timepicker [data-action=togglePeriod]');
  10322. newDate = date.clone().add(date.hours() >= 12 ? -12 : 12, 'h');
  10323. toggle.text(date.format('A'));
  10324. if (isValid(newDate, 'h')) {
  10325. toggle.removeClass('disabled');
  10326. } else {
  10327. toggle.addClass('disabled');
  10328. }
  10329. }
  10330. timeComponents.filter('[data-time-component=hours]').text(date.format(use24Hours ? 'HH' : 'hh'));
  10331. timeComponents.filter('[data-time-component=minutes]').text(date.format('mm'));
  10332. timeComponents.filter('[data-time-component=seconds]').text(date.format('ss'));
  10333. fillHours();
  10334. fillMinutes();
  10335. fillSeconds();
  10336. };
  10337. var update = function update() {
  10338. if (!widget) {
  10339. return;
  10340. }
  10341. fillDate();
  10342. fillTime();
  10343. };
  10344. var setValue = function setValue(targetMoment) {
  10345. var oldDate = unset ? null : date; // case of calling setValue(null or false)
  10346. if (!targetMoment) {
  10347. unset = true;
  10348. input.val('');
  10349. element.data('date', '');
  10350. notifyEvent({
  10351. type: 'dp.change',
  10352. date: false,
  10353. oldDate: oldDate
  10354. });
  10355. update();
  10356. return;
  10357. }
  10358. targetMoment = targetMoment.clone().locale(options.locale);
  10359. if (hasTimeZone()) {
  10360. targetMoment.tz(options.timeZone);
  10361. }
  10362. if (options.stepping !== 1) {
  10363. targetMoment.minutes(Math.round(targetMoment.minutes() / options.stepping) * options.stepping).seconds(0);
  10364. while (options.minDate && targetMoment.isBefore(options.minDate)) {
  10365. targetMoment.add(options.stepping, 'minutes');
  10366. }
  10367. }
  10368. if (isValid(targetMoment)) {
  10369. date = targetMoment;
  10370. viewDate = date.clone();
  10371. input.val(date.format(actualFormat));
  10372. element.data('date', date.format(actualFormat));
  10373. unset = false;
  10374. update();
  10375. notifyEvent({
  10376. type: 'dp.change',
  10377. date: date.clone(),
  10378. oldDate: oldDate
  10379. });
  10380. } else {
  10381. if (!options.keepInvalid) {
  10382. input.val(unset ? '' : date.format(actualFormat));
  10383. } else {
  10384. notifyEvent({
  10385. type: 'dp.change',
  10386. date: targetMoment,
  10387. oldDate: oldDate
  10388. });
  10389. }
  10390. notifyEvent({
  10391. type: 'dp.error',
  10392. date: targetMoment,
  10393. oldDate: oldDate
  10394. });
  10395. }
  10396. };
  10397. /**
  10398. * Hides the widget. Possibly will emit dp.hide
  10399. */
  10400. var hide = function hide() {
  10401. var transitioning = false;
  10402. if (!widget) {
  10403. return picker;
  10404. } // Ignore event if in the middle of a picker transition
  10405. widget.find('.collapse').each(function () {
  10406. var collapseData = $(this).data('collapse');
  10407. if (collapseData && collapseData.transitioning) {
  10408. transitioning = true;
  10409. return false;
  10410. }
  10411. return true;
  10412. });
  10413. if (transitioning) {
  10414. return picker;
  10415. }
  10416. if (component && component.hasClass('btn')) {
  10417. component.toggleClass('active');
  10418. }
  10419. widget.hide();
  10420. $(window).off('resize', place);
  10421. widget.off('click', '[data-action]');
  10422. widget.off('mousedown', false);
  10423. widget.remove();
  10424. widget = false;
  10425. notifyEvent({
  10426. type: 'dp.hide',
  10427. date: date.clone()
  10428. });
  10429. input.blur();
  10430. viewDate = date.clone();
  10431. return picker;
  10432. };
  10433. var clear = function clear() {
  10434. setValue(null);
  10435. };
  10436. var parseInputDate = function parseInputDate(inputDate) {
  10437. if (options.parseInputDate === undefined) {
  10438. if (!moment.isMoment(inputDate) || inputDate instanceof Date) {
  10439. inputDate = getMoment(inputDate);
  10440. }
  10441. } else {
  10442. inputDate = options.parseInputDate(inputDate);
  10443. } // inputDate.locale(options.locale);
  10444. return inputDate;
  10445. };
  10446. /** ******************************************************************************
  10447. *
  10448. * Widget UI interaction functions
  10449. *
  10450. ********************************************************************************/
  10451. var actions = {
  10452. next: function next() {
  10453. var navFnc = datePickerModes[currentViewMode].navFnc;
  10454. viewDate.add(datePickerModes[currentViewMode].navStep, navFnc);
  10455. fillDate();
  10456. viewUpdate(navFnc);
  10457. },
  10458. previous: function previous() {
  10459. var navFnc = datePickerModes[currentViewMode].navFnc;
  10460. viewDate.subtract(datePickerModes[currentViewMode].navStep, navFnc);
  10461. fillDate();
  10462. viewUpdate(navFnc);
  10463. },
  10464. pickerSwitch: function pickerSwitch() {
  10465. showMode(1);
  10466. },
  10467. selectMonth: function selectMonth(e) {
  10468. var month = $(e.target).closest('tbody').find('span').index($(e.target));
  10469. viewDate.month(month);
  10470. if (currentViewMode === minViewModeNumber) {
  10471. setValue(date.clone().year(viewDate.year()).month(viewDate.month()));
  10472. if (!options.inline) {
  10473. hide();
  10474. }
  10475. } else {
  10476. showMode(-1);
  10477. fillDate();
  10478. }
  10479. viewUpdate('M');
  10480. },
  10481. selectYear: function selectYear(e) {
  10482. var year = parseInt($(e.target).text(), 10) || 0;
  10483. viewDate.year(year);
  10484. if (currentViewMode === minViewModeNumber) {
  10485. setValue(date.clone().year(viewDate.year()));
  10486. if (!options.inline) {
  10487. hide();
  10488. }
  10489. } else {
  10490. showMode(-1);
  10491. fillDate();
  10492. }
  10493. viewUpdate('YYYY');
  10494. },
  10495. selectDecade: function selectDecade(e) {
  10496. var year = parseInt($(e.target).data('selection'), 10) || 0;
  10497. viewDate.year(year);
  10498. if (currentViewMode === minViewModeNumber) {
  10499. setValue(date.clone().year(viewDate.year()));
  10500. if (!options.inline) {
  10501. hide();
  10502. }
  10503. } else {
  10504. showMode(-1);
  10505. fillDate();
  10506. }
  10507. viewUpdate('YYYY');
  10508. },
  10509. selectDay: function selectDay(e) {
  10510. var day = viewDate.clone();
  10511. if ($(e.target).is('.old')) {
  10512. day.subtract(1, 'M');
  10513. }
  10514. if ($(e.target).is('.new')) {
  10515. day.add(1, 'M');
  10516. }
  10517. setValue(day.date(parseInt($(e.target).text(), 10)));
  10518. if (!hasTime() && !options.keepOpen && !options.inline) {
  10519. hide();
  10520. }
  10521. },
  10522. incrementHours: function incrementHours() {
  10523. var newDate = date.clone().add(1, 'h');
  10524. if (isValid(newDate, 'h')) {
  10525. setValue(newDate);
  10526. }
  10527. },
  10528. incrementMinutes: function incrementMinutes() {
  10529. var newDate = date.clone().add(options.stepping, 'm');
  10530. if (isValid(newDate, 'm')) {
  10531. setValue(newDate);
  10532. }
  10533. },
  10534. incrementSeconds: function incrementSeconds() {
  10535. var newDate = date.clone().add(1, 's');
  10536. if (isValid(newDate, 's')) {
  10537. setValue(newDate);
  10538. }
  10539. },
  10540. decrementHours: function decrementHours() {
  10541. var newDate = date.clone().subtract(1, 'h');
  10542. if (isValid(newDate, 'h')) {
  10543. setValue(newDate);
  10544. }
  10545. },
  10546. decrementMinutes: function decrementMinutes() {
  10547. var newDate = date.clone().subtract(options.stepping, 'm');
  10548. if (isValid(newDate, 'm')) {
  10549. setValue(newDate);
  10550. }
  10551. },
  10552. decrementSeconds: function decrementSeconds() {
  10553. var newDate = date.clone().subtract(1, 's');
  10554. if (isValid(newDate, 's')) {
  10555. setValue(newDate);
  10556. }
  10557. },
  10558. togglePeriod: function togglePeriod() {
  10559. setValue(date.clone().add(date.hours() >= 12 ? -12 : 12, 'h'));
  10560. },
  10561. togglePicker: function togglePicker(e) {
  10562. var $this = $(e.target);
  10563. var $parent = $this.closest('ul');
  10564. var expanded = $parent.find('.in');
  10565. var closed = $parent.find('.collapse:not(.in)');
  10566. var collapseData;
  10567. if (expanded && expanded.length) {
  10568. collapseData = expanded.data('collapse');
  10569. if (collapseData && collapseData.transitioning) {
  10570. return;
  10571. }
  10572. if (expanded.collapse) {
  10573. // if collapse plugin is available through bootstrap.js then use it
  10574. expanded.collapse('hide');
  10575. closed.collapse('show');
  10576. } else {
  10577. // otherwise just toggle in class on the two views
  10578. expanded.removeClass('in');
  10579. closed.addClass('in');
  10580. }
  10581. if ($this.is('span')) {
  10582. $this.toggleClass(options.icons.time + ' ' + options.icons.date);
  10583. } else {
  10584. $this.find('span').toggleClass(options.icons.time + ' ' + options.icons.date);
  10585. } // NOTE: uncomment if toggled state will be restored in show()
  10586. // if (component) {
  10587. // component.find('span').toggleClass(options.icons.time + ' ' + options.icons.date);
  10588. // }
  10589. }
  10590. },
  10591. showPicker: function showPicker() {
  10592. widget.find('.timepicker > div:not(.timepicker-picker)').hide();
  10593. widget.find('.timepicker .timepicker-picker').show();
  10594. },
  10595. showHours: function showHours() {
  10596. widget.find('.timepicker .timepicker-picker').hide();
  10597. widget.find('.timepicker .timepicker-hours').show();
  10598. },
  10599. showMinutes: function showMinutes() {
  10600. widget.find('.timepicker .timepicker-picker').hide();
  10601. widget.find('.timepicker .timepicker-minutes').show();
  10602. },
  10603. showSeconds: function showSeconds() {
  10604. widget.find('.timepicker .timepicker-picker').hide();
  10605. widget.find('.timepicker .timepicker-seconds').show();
  10606. },
  10607. selectHour: function selectHour(e) {
  10608. var hour = parseInt($(e.target).text(), 10);
  10609. if (!use24Hours) {
  10610. if (date.hours() >= 12) {
  10611. if (hour !== 12) {
  10612. hour += 12;
  10613. }
  10614. } else {
  10615. if (hour === 12) {
  10616. hour = 0;
  10617. }
  10618. }
  10619. }
  10620. setValue(date.clone().hours(hour));
  10621. actions.showPicker.call(picker);
  10622. },
  10623. selectMinute: function selectMinute(e) {
  10624. setValue(date.clone().minutes(parseInt($(e.target).text(), 10)));
  10625. actions.showPicker.call(picker);
  10626. },
  10627. selectSecond: function selectSecond(e) {
  10628. setValue(date.clone().seconds(parseInt($(e.target).text(), 10)));
  10629. actions.showPicker.call(picker);
  10630. },
  10631. clear: clear,
  10632. today: function today() {
  10633. var todaysDate = getMoment();
  10634. if (isValid(todaysDate, 'd')) {
  10635. setValue(todaysDate);
  10636. }
  10637. },
  10638. close: hide
  10639. };
  10640. var doAction = function doAction(e) {
  10641. if ($(e.currentTarget).is('.disabled')) {
  10642. return false;
  10643. }
  10644. actions[$(e.currentTarget).data('action')].apply(picker, arguments);
  10645. return false;
  10646. };
  10647. /**
  10648. * Shows the widget. Possibly will emit dp.show and dp.change
  10649. */
  10650. var show = function show() {
  10651. var currentMoment;
  10652. var useCurrentGranularity = {
  10653. 'year': function year(m) {
  10654. return m.month(0).date(1).hours(0).seconds(0).minutes(0);
  10655. },
  10656. 'month': function month(m) {
  10657. return m.date(1).hours(0).seconds(0).minutes(0);
  10658. },
  10659. 'day': function day(m) {
  10660. return m.hours(0).seconds(0).minutes(0);
  10661. },
  10662. 'hour': function hour(m) {
  10663. return m.seconds(0).minutes(0);
  10664. },
  10665. 'minute': function minute(m) {
  10666. return m.seconds(0);
  10667. }
  10668. };
  10669. if (input.prop('disabled') || !options.ignoreReadonly && input.prop('readonly') || widget) {
  10670. return picker;
  10671. }
  10672. if (input.val() !== undefined && input.val().trim().length !== 0) {
  10673. setValue(parseInputDate(input.val().trim()));
  10674. } else if (unset && options.useCurrent && (options.inline || input.is('input') && input.val().trim().length === 0)) {
  10675. currentMoment = getMoment();
  10676. if (typeof options.useCurrent === 'string') {
  10677. currentMoment = useCurrentGranularity[options.useCurrent](currentMoment);
  10678. }
  10679. setValue(currentMoment);
  10680. }
  10681. widget = getTemplate();
  10682. fillDow();
  10683. fillMonths();
  10684. widget.find('.timepicker-hours').hide();
  10685. widget.find('.timepicker-minutes').hide();
  10686. widget.find('.timepicker-seconds').hide();
  10687. update();
  10688. showMode();
  10689. $(window).on('resize', place);
  10690. widget.on('click', '[data-action]', doAction); // this handles clicks on the widget
  10691. widget.on('mousedown', false);
  10692. if (component && component.hasClass('btn')) {
  10693. component.toggleClass('active');
  10694. }
  10695. place();
  10696. widget.show();
  10697. if (options.focusOnShow && !input.is(':focus')) {
  10698. input.focus();
  10699. }
  10700. notifyEvent({
  10701. type: 'dp.show'
  10702. });
  10703. return picker;
  10704. };
  10705. /**
  10706. * Shows or hides the widget
  10707. */
  10708. var toggle = function toggle() {
  10709. return widget ? hide() : show();
  10710. };
  10711. var keydown = function keydown(e) {
  10712. var handler = null;
  10713. var index;
  10714. var index2;
  10715. var pressedKeys = [];
  10716. var pressedModifiers = {};
  10717. var currentKey = e.which;
  10718. var keyBindKeys;
  10719. var allModifiersPressed;
  10720. var pressed = 'p';
  10721. keyState[currentKey] = pressed;
  10722. for (index in keyState) {
  10723. if (keyState.hasOwnProperty(index) && keyState[index] === pressed) {
  10724. pressedKeys.push(index);
  10725. if (parseInt(index, 10) !== currentKey) {
  10726. pressedModifiers[index] = true;
  10727. }
  10728. }
  10729. }
  10730. for (index in options.keyBinds) {
  10731. if (options.keyBinds.hasOwnProperty(index) && typeof options.keyBinds[index] === 'function') {
  10732. keyBindKeys = index.split(' ');
  10733. if (keyBindKeys.length === pressedKeys.length && keyMap[currentKey] === keyBindKeys[keyBindKeys.length - 1]) {
  10734. allModifiersPressed = true;
  10735. for (index2 = keyBindKeys.length - 2; index2 >= 0; index2--) {
  10736. if (!(keyMap[keyBindKeys[index2]] in pressedModifiers)) {
  10737. allModifiersPressed = false;
  10738. break;
  10739. }
  10740. }
  10741. if (allModifiersPressed) {
  10742. handler = options.keyBinds[index];
  10743. break;
  10744. }
  10745. }
  10746. }
  10747. }
  10748. if (handler) {
  10749. handler.call(picker, widget);
  10750. e.stopPropagation();
  10751. e.preventDefault();
  10752. }
  10753. };
  10754. var keyup = function keyup(e) {
  10755. keyState[e.which] = 'r';
  10756. e.stopPropagation();
  10757. e.preventDefault();
  10758. };
  10759. var change = function change(e) {
  10760. var val = $(e.target).val().trim();
  10761. var parsedDate = val ? parseInputDate(val) : null;
  10762. setValue(parsedDate);
  10763. e.stopImmediatePropagation();
  10764. return false;
  10765. };
  10766. var attachDatePickerElementEvents = function attachDatePickerElementEvents() {
  10767. input.on({
  10768. 'change': change,
  10769. 'blur': options.debug ? '' : hide,
  10770. 'keydown': keydown,
  10771. 'keyup': keyup,
  10772. 'focus': options.allowInputToggle ? show : ''
  10773. });
  10774. if (element.is('input')) {
  10775. input.on({
  10776. 'focus': show
  10777. });
  10778. } else if (component) {
  10779. component.on('click', toggle);
  10780. component.on('mousedown', false);
  10781. }
  10782. };
  10783. var detachDatePickerElementEvents = function detachDatePickerElementEvents() {
  10784. input.off({
  10785. 'change': change,
  10786. 'blur': blur,
  10787. 'keydown': keydown,
  10788. 'keyup': keyup,
  10789. 'focus': options.allowInputToggle ? hide : ''
  10790. });
  10791. if (element.is('input')) {
  10792. input.off({
  10793. 'focus': show
  10794. });
  10795. } else if (component) {
  10796. component.off('click', toggle);
  10797. component.off('mousedown', false);
  10798. }
  10799. };
  10800. var indexGivenDates = function indexGivenDates(givenDatesArray) {
  10801. // Store given enabledDates and disabledDates as keys.
  10802. // This way we can check their existence in O(1) time instead of looping through whole array.
  10803. // (for example: options.enabledDates['2014-02-27'] === true)
  10804. var givenDatesIndexed = {};
  10805. $.each(givenDatesArray, function () {
  10806. var dDate = parseInputDate(this);
  10807. if (dDate.isValid()) {
  10808. givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true;
  10809. }
  10810. });
  10811. return Object.keys(givenDatesIndexed).length ? givenDatesIndexed : false;
  10812. };
  10813. var indexGivenHours = function indexGivenHours(givenHoursArray) {
  10814. // Store given enabledHours and disabledHours as keys.
  10815. // This way we can check their existence in O(1) time instead of looping through whole array.
  10816. // (for example: options.enabledHours['2014-02-27'] === true)
  10817. var givenHoursIndexed = {};
  10818. $.each(givenHoursArray, function () {
  10819. givenHoursIndexed[this] = true;
  10820. });
  10821. return Object.keys(givenHoursIndexed).length ? givenHoursIndexed : false;
  10822. };
  10823. var initFormatting = function initFormatting() {
  10824. var format = options.format || 'L LT';
  10825. actualFormat = format.replace(/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput) {
  10826. var newinput = date.localeData().longDateFormat(formatInput) || formatInput;
  10827. return newinput.replace(/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput2) {
  10828. // temp fix for #740
  10829. return date.localeData().longDateFormat(formatInput2) || formatInput2;
  10830. });
  10831. });
  10832. parseFormats = options.extraFormats ? options.extraFormats.slice() : [];
  10833. if (parseFormats.indexOf(format) < 0 && parseFormats.indexOf(actualFormat) < 0) {
  10834. parseFormats.push(actualFormat);
  10835. }
  10836. use24Hours = actualFormat.toLowerCase().indexOf('a') < 1 && actualFormat.replace(/\[.*?\]/g, '').indexOf('h') < 1;
  10837. if (isEnabled('y')) {
  10838. minViewModeNumber = 2;
  10839. }
  10840. if (isEnabled('M')) {
  10841. minViewModeNumber = 1;
  10842. }
  10843. if (isEnabled('d')) {
  10844. minViewModeNumber = 0;
  10845. }
  10846. currentViewMode = Math.max(minViewModeNumber, currentViewMode);
  10847. if (!unset) {
  10848. setValue(date);
  10849. }
  10850. };
  10851. /** ******************************************************************************
  10852. *
  10853. * Public API functions
  10854. * =====================
  10855. *
  10856. * Important: Do not expose direct references to private objects or the options
  10857. * object to the outer world. Always return a clone when returning values or make
  10858. * a clone when setting a private variable.
  10859. *
  10860. ********************************************************************************/
  10861. picker.destroy = function () {
  10862. // /<summary>Destroys the widget and removes all attached event listeners</summary>
  10863. hide();
  10864. detachDatePickerElementEvents();
  10865. element.removeData('DateTimePicker');
  10866. element.removeData('date');
  10867. };
  10868. picker.toggle = toggle;
  10869. picker.show = show;
  10870. picker.hide = hide;
  10871. picker.disable = function () {
  10872. // /<summary>Disables the input element, the component is attached to, by adding a disabled="true" attribute to it.
  10873. // /If the widget was visible before that call it is hidden. Possibly emits dp.hide</summary>
  10874. hide();
  10875. if (component && component.hasClass('btn')) {
  10876. component.addClass('disabled');
  10877. }
  10878. input.prop('disabled', true);
  10879. return picker;
  10880. };
  10881. picker.enable = function () {
  10882. // /<summary>Enables the input element, the component is attached to, by removing disabled attribute from it.</summary>
  10883. if (component && component.hasClass('btn')) {
  10884. component.removeClass('disabled');
  10885. }
  10886. input.prop('disabled', false);
  10887. return picker;
  10888. };
  10889. picker.ignoreReadonly = function (ignoreReadonly) {
  10890. if (arguments.length === 0) {
  10891. return options.ignoreReadonly;
  10892. }
  10893. if (typeof ignoreReadonly !== 'boolean') {
  10894. throw new TypeError('ignoreReadonly () expects a boolean parameter');
  10895. }
  10896. options.ignoreReadonly = ignoreReadonly;
  10897. return picker;
  10898. };
  10899. picker.options = function (newOptions) {
  10900. if (arguments.length === 0) {
  10901. return $.extend(true, {}, options);
  10902. }
  10903. if (!(newOptions instanceof Object)) {
  10904. throw new TypeError('options() options parameter should be an object');
  10905. }
  10906. $.extend(true, options, newOptions);
  10907. $.each(options, function (key, value) {
  10908. if (picker[key] !== undefined) {
  10909. picker[key](value);
  10910. } else {
  10911. throw new TypeError('option ' + key + ' is not recognized!');
  10912. }
  10913. });
  10914. return picker;
  10915. };
  10916. picker.date = function (newDate) {
  10917. // /<signature helpKeyword="$.fn.datetimepicker.date">
  10918. // /<summary>Returns the component's model current date, a moment object or null if not set.</summary>
  10919. // /<returns type="Moment">date.clone()</returns>
  10920. // /</signature>
  10921. // /<signature>
  10922. // /<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>
  10923. // /<param name="newDate" locid="$.fn.datetimepicker.date_p:newDate">Takes string, Date, moment, null parameter.</param>
  10924. // /</signature>
  10925. if (arguments.length === 0) {
  10926. if (unset) {
  10927. return null;
  10928. }
  10929. return date.clone();
  10930. }
  10931. if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
  10932. throw new TypeError('date() parameter must be one of [null, string, moment or Date]');
  10933. }
  10934. setValue(newDate === null ? null : parseInputDate(newDate));
  10935. return picker;
  10936. };
  10937. picker.format = function (newFormat) {
  10938. // /<summary>test su</summary>
  10939. // /<param name="newFormat">info about para</param>
  10940. // /<returns type="string|boolean">returns foo</returns>
  10941. if (arguments.length === 0) {
  10942. return options.format;
  10943. }
  10944. if (typeof newFormat !== 'string' && (typeof newFormat !== 'boolean' || newFormat !== false)) {
  10945. throw new TypeError('format() expects a string or boolean:false parameter ' + newFormat);
  10946. }
  10947. options.format = newFormat;
  10948. if (actualFormat) {
  10949. initFormatting(); // reinit formatting
  10950. }
  10951. return picker;
  10952. };
  10953. picker.timeZone = function (newZone) {
  10954. if (arguments.length === 0) {
  10955. return options.timeZone;
  10956. }
  10957. if (typeof newZone !== 'string') {
  10958. throw new TypeError('newZone() expects a string parameter');
  10959. }
  10960. options.timeZone = newZone;
  10961. return picker;
  10962. };
  10963. picker.dayViewHeaderFormat = function (newFormat) {
  10964. if (arguments.length === 0) {
  10965. return options.dayViewHeaderFormat;
  10966. }
  10967. if (typeof newFormat !== 'string') {
  10968. throw new TypeError('dayViewHeaderFormat() expects a string parameter');
  10969. }
  10970. options.dayViewHeaderFormat = newFormat;
  10971. return picker;
  10972. };
  10973. picker.extraFormats = function (formats) {
  10974. if (arguments.length === 0) {
  10975. return options.extraFormats;
  10976. }
  10977. if (formats !== false && !(formats instanceof Array)) {
  10978. throw new TypeError('extraFormats() expects an array or false parameter');
  10979. }
  10980. options.extraFormats = formats;
  10981. if (parseFormats) {
  10982. initFormatting(); // reinit formatting
  10983. }
  10984. return picker;
  10985. };
  10986. picker.disabledDates = function (dates) {
  10987. // /<signature helpKeyword="$.fn.datetimepicker.disabledDates">
  10988. // /<summary>Returns an array with the currently set disabled dates on the component.</summary>
  10989. // /<returns type="array">options.disabledDates</returns>
  10990. // /</signature>
  10991. // /<signature>
  10992. // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
  10993. // /options.enabledDates if such exist.</summary>
  10994. // /<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>
  10995. // /</signature>
  10996. if (arguments.length === 0) {
  10997. return options.disabledDates ? $.extend({}, options.disabledDates) : options.disabledDates;
  10998. }
  10999. if (!dates) {
  11000. options.disabledDates = false;
  11001. update();
  11002. return picker;
  11003. }
  11004. if (!(dates instanceof Array)) {
  11005. throw new TypeError('disabledDates() expects an array parameter');
  11006. }
  11007. options.disabledDates = indexGivenDates(dates);
  11008. options.enabledDates = false;
  11009. update();
  11010. return picker;
  11011. };
  11012. picker.enabledDates = function (dates) {
  11013. // /<signature helpKeyword="$.fn.datetimepicker.enabledDates">
  11014. // /<summary>Returns an array with the currently set enabled dates on the component.</summary>
  11015. // /<returns type="array">options.enabledDates</returns>
  11016. // /</signature>
  11017. // /<signature>
  11018. // /<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>
  11019. // /<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>
  11020. // /</signature>
  11021. if (arguments.length === 0) {
  11022. return options.enabledDates ? $.extend({}, options.enabledDates) : options.enabledDates;
  11023. }
  11024. if (!dates) {
  11025. options.enabledDates = false;
  11026. update();
  11027. return picker;
  11028. }
  11029. if (!(dates instanceof Array)) {
  11030. throw new TypeError('enabledDates() expects an array parameter');
  11031. }
  11032. options.enabledDates = indexGivenDates(dates);
  11033. options.disabledDates = false;
  11034. update();
  11035. return picker;
  11036. };
  11037. picker.daysOfWeekDisabled = function (daysOfWeekDisabled) {
  11038. if (arguments.length === 0) {
  11039. return options.daysOfWeekDisabled.splice(0);
  11040. }
  11041. if (typeof daysOfWeekDisabled === 'boolean' && !daysOfWeekDisabled) {
  11042. options.daysOfWeekDisabled = false;
  11043. update();
  11044. return picker;
  11045. }
  11046. if (!(daysOfWeekDisabled instanceof Array)) {
  11047. throw new TypeError('daysOfWeekDisabled() expects an array parameter');
  11048. }
  11049. options.daysOfWeekDisabled = daysOfWeekDisabled.reduce(function (previousValue, currentValue) {
  11050. currentValue = parseInt(currentValue, 10);
  11051. if (currentValue > 6 || currentValue < 0 || isNaN(currentValue)) {
  11052. return previousValue;
  11053. }
  11054. if (previousValue.indexOf(currentValue) === -1) {
  11055. previousValue.push(currentValue);
  11056. }
  11057. return previousValue;
  11058. }, []).sort();
  11059. if (options.useCurrent && !options.keepInvalid) {
  11060. var tries = 0;
  11061. while (!isValid(date, 'd')) {
  11062. date.add(1, 'd');
  11063. if (tries === 31) {
  11064. throw new Error('Tried 31 times to find a valid date');
  11065. }
  11066. tries++;
  11067. }
  11068. setValue(date);
  11069. }
  11070. update();
  11071. return picker;
  11072. };
  11073. picker.maxDate = function (maxDate) {
  11074. if (arguments.length === 0) {
  11075. return options.maxDate ? options.maxDate.clone() : options.maxDate;
  11076. }
  11077. if (typeof maxDate === 'boolean' && maxDate === false) {
  11078. options.maxDate = false;
  11079. update();
  11080. return picker;
  11081. }
  11082. if (typeof maxDate === 'string') {
  11083. if (maxDate === 'now' || maxDate === 'moment') {
  11084. maxDate = getMoment();
  11085. }
  11086. }
  11087. var parsedDate = parseInputDate(maxDate);
  11088. if (!parsedDate.isValid()) {
  11089. throw new TypeError('maxDate() Could not parse date parameter: ' + maxDate);
  11090. }
  11091. if (options.minDate && parsedDate.isBefore(options.minDate)) {
  11092. throw new TypeError('maxDate() date parameter is before options.minDate: ' + parsedDate.format(actualFormat));
  11093. }
  11094. options.maxDate = parsedDate;
  11095. if (options.useCurrent && !options.keepInvalid && date.isAfter(maxDate)) {
  11096. setValue(options.maxDate);
  11097. }
  11098. if (viewDate.isAfter(parsedDate)) {
  11099. viewDate = parsedDate.clone().subtract(options.stepping, 'm');
  11100. }
  11101. update();
  11102. return picker;
  11103. };
  11104. picker.minDate = function (minDate) {
  11105. if (arguments.length === 0) {
  11106. return options.minDate ? options.minDate.clone() : options.minDate;
  11107. }
  11108. if (typeof minDate === 'boolean' && minDate === false) {
  11109. options.minDate = false;
  11110. update();
  11111. return picker;
  11112. }
  11113. if (typeof minDate === 'string') {
  11114. if (minDate === 'now' || minDate === 'moment') {
  11115. minDate = getMoment();
  11116. }
  11117. }
  11118. var parsedDate = parseInputDate(minDate);
  11119. if (!parsedDate.isValid()) {
  11120. throw new TypeError('minDate() Could not parse date parameter: ' + minDate);
  11121. }
  11122. if (options.maxDate && parsedDate.isAfter(options.maxDate)) {
  11123. throw new TypeError('minDate() date parameter is after options.maxDate: ' + parsedDate.format(actualFormat));
  11124. }
  11125. options.minDate = parsedDate;
  11126. if (options.useCurrent && !options.keepInvalid && date.isBefore(minDate)) {
  11127. setValue(options.minDate);
  11128. }
  11129. if (viewDate.isBefore(parsedDate)) {
  11130. viewDate = parsedDate.clone().add(options.stepping, 'm');
  11131. }
  11132. update();
  11133. return picker;
  11134. };
  11135. picker.defaultDate = function (defaultDate) {
  11136. // /<signature helpKeyword="$.fn.datetimepicker.defaultDate">
  11137. // /<summary>Returns a moment with the options.defaultDate option configuration or false if not set</summary>
  11138. // /<returns type="Moment">date.clone()</returns>
  11139. // /</signature>
  11140. // /<signature>
  11141. // /<summary>Will set the picker's inital date. If a boolean:false value is passed the options.defaultDate parameter is cleared.</summary>
  11142. // /<param name="defaultDate" locid="$.fn.datetimepicker.defaultDate_p:defaultDate">Takes a string, Date, moment, boolean:false</param>
  11143. // /</signature>
  11144. if (arguments.length === 0) {
  11145. return options.defaultDate ? options.defaultDate.clone() : options.defaultDate;
  11146. }
  11147. if (!defaultDate) {
  11148. options.defaultDate = false;
  11149. return picker;
  11150. }
  11151. if (typeof defaultDate === 'string') {
  11152. if (defaultDate === 'now' || defaultDate === 'moment') {
  11153. defaultDate = getMoment();
  11154. } else {
  11155. defaultDate = getMoment(defaultDate);
  11156. }
  11157. }
  11158. var parsedDate = parseInputDate(defaultDate);
  11159. if (!parsedDate.isValid()) {
  11160. throw new TypeError('defaultDate() Could not parse date parameter: ' + defaultDate);
  11161. }
  11162. if (!isValid(parsedDate)) {
  11163. throw new TypeError('defaultDate() date passed is invalid according to component setup validations');
  11164. }
  11165. options.defaultDate = parsedDate;
  11166. if (options.defaultDate && options.inline || input.val().trim() === '') {
  11167. setValue(options.defaultDate);
  11168. }
  11169. return picker;
  11170. };
  11171. picker.locale = function (locale) {
  11172. if (arguments.length === 0) {
  11173. return options.locale;
  11174. }
  11175. if (!moment.localeData(locale)) {
  11176. throw new TypeError('locale() locale ' + locale + ' is not loaded from moment locales!');
  11177. }
  11178. options.locale = locale;
  11179. date.locale(options.locale);
  11180. viewDate.locale(options.locale);
  11181. if (actualFormat) {
  11182. initFormatting(); // reinit formatting
  11183. }
  11184. if (widget) {
  11185. hide();
  11186. show();
  11187. }
  11188. return picker;
  11189. };
  11190. picker.stepping = function (stepping) {
  11191. if (arguments.length === 0) {
  11192. return options.stepping;
  11193. }
  11194. stepping = parseInt(stepping, 10);
  11195. if (isNaN(stepping) || stepping < 1) {
  11196. stepping = 1;
  11197. }
  11198. options.stepping = stepping;
  11199. return picker;
  11200. };
  11201. picker.useCurrent = function (useCurrent) {
  11202. var useCurrentOptions = ['year', 'month', 'day', 'hour', 'minute'];
  11203. if (arguments.length === 0) {
  11204. return options.useCurrent;
  11205. }
  11206. if (typeof useCurrent !== 'boolean' && typeof useCurrent !== 'string') {
  11207. throw new TypeError('useCurrent() expects a boolean or string parameter');
  11208. }
  11209. if (typeof useCurrent === 'string' && useCurrentOptions.indexOf(useCurrent.toLowerCase()) === -1) {
  11210. throw new TypeError('useCurrent() expects a string parameter of ' + useCurrentOptions.join(', '));
  11211. }
  11212. options.useCurrent = useCurrent;
  11213. return picker;
  11214. };
  11215. picker.collapse = function (collapse) {
  11216. if (arguments.length === 0) {
  11217. return options.collapse;
  11218. }
  11219. if (typeof collapse !== 'boolean') {
  11220. throw new TypeError('collapse() expects a boolean parameter');
  11221. }
  11222. if (options.collapse === collapse) {
  11223. return picker;
  11224. }
  11225. options.collapse = collapse;
  11226. if (widget) {
  11227. hide();
  11228. show();
  11229. }
  11230. return picker;
  11231. };
  11232. picker.icons = function (icons) {
  11233. if (arguments.length === 0) {
  11234. return $.extend({}, options.icons);
  11235. }
  11236. if (!(icons instanceof Object)) {
  11237. throw new TypeError('icons() expects parameter to be an Object');
  11238. }
  11239. $.extend(options.icons, icons);
  11240. if (widget) {
  11241. hide();
  11242. show();
  11243. }
  11244. return picker;
  11245. };
  11246. picker.tooltips = function (tooltips) {
  11247. if (arguments.length === 0) {
  11248. return $.extend({}, options.tooltips);
  11249. }
  11250. if (!(tooltips instanceof Object)) {
  11251. throw new TypeError('tooltips() expects parameter to be an Object');
  11252. }
  11253. $.extend(options.tooltips, tooltips);
  11254. if (widget) {
  11255. hide();
  11256. show();
  11257. }
  11258. return picker;
  11259. };
  11260. picker.useStrict = function (useStrict) {
  11261. if (arguments.length === 0) {
  11262. return options.useStrict;
  11263. }
  11264. if (typeof useStrict !== 'boolean') {
  11265. throw new TypeError('useStrict() expects a boolean parameter');
  11266. }
  11267. options.useStrict = useStrict;
  11268. return picker;
  11269. };
  11270. picker.sideBySide = function (sideBySide) {
  11271. if (arguments.length === 0) {
  11272. return options.sideBySide;
  11273. }
  11274. if (typeof sideBySide !== 'boolean') {
  11275. throw new TypeError('sideBySide() expects a boolean parameter');
  11276. }
  11277. options.sideBySide = sideBySide;
  11278. if (widget) {
  11279. hide();
  11280. show();
  11281. }
  11282. return picker;
  11283. };
  11284. picker.viewMode = function (viewMode) {
  11285. if (arguments.length === 0) {
  11286. return options.viewMode;
  11287. }
  11288. if (typeof viewMode !== 'string') {
  11289. throw new TypeError('viewMode() expects a string parameter');
  11290. }
  11291. if (viewModes.indexOf(viewMode) === -1) {
  11292. throw new TypeError('viewMode() parameter must be one of (' + viewModes.join(', ') + ') value');
  11293. }
  11294. options.viewMode = viewMode;
  11295. currentViewMode = Math.max(viewModes.indexOf(viewMode), minViewModeNumber);
  11296. showMode();
  11297. return picker;
  11298. };
  11299. picker.toolbarPlacement = function (toolbarPlacement) {
  11300. if (arguments.length === 0) {
  11301. return options.toolbarPlacement;
  11302. }
  11303. if (typeof toolbarPlacement !== 'string') {
  11304. throw new TypeError('toolbarPlacement() expects a string parameter');
  11305. }
  11306. if (toolbarPlacements.indexOf(toolbarPlacement) === -1) {
  11307. throw new TypeError('toolbarPlacement() parameter must be one of (' + toolbarPlacements.join(', ') + ') value');
  11308. }
  11309. options.toolbarPlacement = toolbarPlacement;
  11310. if (widget) {
  11311. hide();
  11312. show();
  11313. }
  11314. return picker;
  11315. };
  11316. picker.widgetPositioning = function (widgetPositioning) {
  11317. if (arguments.length === 0) {
  11318. return $.extend({}, options.widgetPositioning);
  11319. }
  11320. if ({}.toString.call(widgetPositioning) !== '[object Object]') {
  11321. throw new TypeError('widgetPositioning() expects an object variable');
  11322. }
  11323. if (widgetPositioning.horizontal) {
  11324. if (typeof widgetPositioning.horizontal !== 'string') {
  11325. throw new TypeError('widgetPositioning() horizontal variable must be a string');
  11326. }
  11327. widgetPositioning.horizontal = widgetPositioning.horizontal.toLowerCase();
  11328. if (horizontalModes.indexOf(widgetPositioning.horizontal) === -1) {
  11329. throw new TypeError('widgetPositioning() expects horizontal parameter to be one of (' + horizontalModes.join(', ') + ')');
  11330. }
  11331. options.widgetPositioning.horizontal = widgetPositioning.horizontal;
  11332. }
  11333. if (widgetPositioning.vertical) {
  11334. if (typeof widgetPositioning.vertical !== 'string') {
  11335. throw new TypeError('widgetPositioning() vertical variable must be a string');
  11336. }
  11337. widgetPositioning.vertical = widgetPositioning.vertical.toLowerCase();
  11338. if (verticalModes.indexOf(widgetPositioning.vertical) === -1) {
  11339. throw new TypeError('widgetPositioning() expects vertical parameter to be one of (' + verticalModes.join(', ') + ')');
  11340. }
  11341. options.widgetPositioning.vertical = widgetPositioning.vertical;
  11342. }
  11343. update();
  11344. return picker;
  11345. };
  11346. picker.calendarWeeks = function (calendarWeeks) {
  11347. if (arguments.length === 0) {
  11348. return options.calendarWeeks;
  11349. }
  11350. if (typeof calendarWeeks !== 'boolean') {
  11351. throw new TypeError('calendarWeeks() expects parameter to be a boolean value');
  11352. }
  11353. options.calendarWeeks = calendarWeeks;
  11354. update();
  11355. return picker;
  11356. };
  11357. picker.showTodayButton = function (showTodayButton) {
  11358. if (arguments.length === 0) {
  11359. return options.showTodayButton;
  11360. }
  11361. if (typeof showTodayButton !== 'boolean') {
  11362. throw new TypeError('showTodayButton() expects a boolean parameter');
  11363. }
  11364. options.showTodayButton = showTodayButton;
  11365. if (widget) {
  11366. hide();
  11367. show();
  11368. }
  11369. return picker;
  11370. };
  11371. picker.showClear = function (showClear) {
  11372. if (arguments.length === 0) {
  11373. return options.showClear;
  11374. }
  11375. if (typeof showClear !== 'boolean') {
  11376. throw new TypeError('showClear() expects a boolean parameter');
  11377. }
  11378. options.showClear = showClear;
  11379. if (widget) {
  11380. hide();
  11381. show();
  11382. }
  11383. return picker;
  11384. };
  11385. picker.widgetParent = function (widgetParent) {
  11386. if (arguments.length === 0) {
  11387. return options.widgetParent;
  11388. }
  11389. if (typeof widgetParent === 'string') {
  11390. widgetParent = $(widgetParent);
  11391. }
  11392. if (widgetParent !== null && typeof widgetParent !== 'string' && !(widgetParent instanceof $)) {
  11393. throw new TypeError('widgetParent() expects a string or a jQuery object parameter');
  11394. }
  11395. options.widgetParent = widgetParent;
  11396. if (widget) {
  11397. hide();
  11398. show();
  11399. }
  11400. return picker;
  11401. };
  11402. picker.keepOpen = function (keepOpen) {
  11403. if (arguments.length === 0) {
  11404. return options.keepOpen;
  11405. }
  11406. if (typeof keepOpen !== 'boolean') {
  11407. throw new TypeError('keepOpen() expects a boolean parameter');
  11408. }
  11409. options.keepOpen = keepOpen;
  11410. return picker;
  11411. };
  11412. picker.focusOnShow = function (focusOnShow) {
  11413. if (arguments.length === 0) {
  11414. return options.focusOnShow;
  11415. }
  11416. if (typeof focusOnShow !== 'boolean') {
  11417. throw new TypeError('focusOnShow() expects a boolean parameter');
  11418. }
  11419. options.focusOnShow = focusOnShow;
  11420. return picker;
  11421. };
  11422. picker.inline = function (inline) {
  11423. if (arguments.length === 0) {
  11424. return options.inline;
  11425. }
  11426. if (typeof inline !== 'boolean') {
  11427. throw new TypeError('inline() expects a boolean parameter');
  11428. }
  11429. options.inline = inline;
  11430. return picker;
  11431. };
  11432. picker.clear = function () {
  11433. clear();
  11434. return picker;
  11435. };
  11436. picker.keyBinds = function (keyBinds) {
  11437. if (arguments.length === 0) {
  11438. return options.keyBinds;
  11439. }
  11440. options.keyBinds = keyBinds;
  11441. return picker;
  11442. };
  11443. picker.getMoment = function (d) {
  11444. return getMoment(d);
  11445. };
  11446. picker.debug = function (debug) {
  11447. if (typeof debug !== 'boolean') {
  11448. throw new TypeError('debug() expects a boolean parameter');
  11449. }
  11450. options.debug = debug;
  11451. return picker;
  11452. };
  11453. picker.allowInputToggle = function (allowInputToggle) {
  11454. if (arguments.length === 0) {
  11455. return options.allowInputToggle;
  11456. }
  11457. if (typeof allowInputToggle !== 'boolean') {
  11458. throw new TypeError('allowInputToggle() expects a boolean parameter');
  11459. }
  11460. options.allowInputToggle = allowInputToggle;
  11461. return picker;
  11462. };
  11463. picker.showClose = function (showClose) {
  11464. if (arguments.length === 0) {
  11465. return options.showClose;
  11466. }
  11467. if (typeof showClose !== 'boolean') {
  11468. throw new TypeError('showClose() expects a boolean parameter');
  11469. }
  11470. options.showClose = showClose;
  11471. return picker;
  11472. };
  11473. picker.keepInvalid = function (keepInvalid) {
  11474. if (arguments.length === 0) {
  11475. return options.keepInvalid;
  11476. }
  11477. if (typeof keepInvalid !== 'boolean') {
  11478. throw new TypeError('keepInvalid() expects a boolean parameter');
  11479. }
  11480. options.keepInvalid = keepInvalid;
  11481. return picker;
  11482. };
  11483. picker.datepickerInput = function (datepickerInput) {
  11484. if (arguments.length === 0) {
  11485. return options.datepickerInput;
  11486. }
  11487. if (typeof datepickerInput !== 'string') {
  11488. throw new TypeError('datepickerInput() expects a string parameter');
  11489. }
  11490. options.datepickerInput = datepickerInput;
  11491. return picker;
  11492. };
  11493. picker.parseInputDate = function (parseInputDate) {
  11494. if (arguments.length === 0) {
  11495. return options.parseInputDate;
  11496. }
  11497. if (typeof parseInputDate !== 'function') {
  11498. throw new TypeError('parseInputDate() sholud be as function');
  11499. }
  11500. options.parseInputDate = parseInputDate;
  11501. return picker;
  11502. };
  11503. picker.disabledTimeIntervals = function (disabledTimeIntervals) {
  11504. // /<signature helpKeyword="$.fn.datetimepicker.disabledTimeIntervals">
  11505. // /<summary>Returns an array with the currently set disabled dates on the component.</summary>
  11506. // /<returns type="array">options.disabledTimeIntervals</returns>
  11507. // /</signature>
  11508. // /<signature>
  11509. // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
  11510. // /options.enabledDates if such exist.</summary>
  11511. // /<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>
  11512. // /</signature>
  11513. if (arguments.length === 0) {
  11514. return options.disabledTimeIntervals ? $.extend({}, options.disabledTimeIntervals) : options.disabledTimeIntervals;
  11515. }
  11516. if (!disabledTimeIntervals) {
  11517. options.disabledTimeIntervals = false;
  11518. update();
  11519. return picker;
  11520. }
  11521. if (!(disabledTimeIntervals instanceof Array)) {
  11522. throw new TypeError('disabledTimeIntervals() expects an array parameter');
  11523. }
  11524. options.disabledTimeIntervals = disabledTimeIntervals;
  11525. update();
  11526. return picker;
  11527. };
  11528. picker.disabledHours = function (hours) {
  11529. // /<signature helpKeyword="$.fn.datetimepicker.disabledHours">
  11530. // /<summary>Returns an array with the currently set disabled hours on the component.</summary>
  11531. // /<returns type="array">options.disabledHours</returns>
  11532. // /</signature>
  11533. // /<signature>
  11534. // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
  11535. // /options.enabledHours if such exist.</summary>
  11536. // /<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>
  11537. // /</signature>
  11538. if (arguments.length === 0) {
  11539. return options.disabledHours ? $.extend({}, options.disabledHours) : options.disabledHours;
  11540. }
  11541. if (!hours) {
  11542. options.disabledHours = false;
  11543. update();
  11544. return picker;
  11545. }
  11546. if (!(hours instanceof Array)) {
  11547. throw new TypeError('disabledHours() expects an array parameter');
  11548. }
  11549. options.disabledHours = indexGivenHours(hours);
  11550. options.enabledHours = false;
  11551. if (options.useCurrent && !options.keepInvalid) {
  11552. var tries = 0;
  11553. while (!isValid(date, 'h')) {
  11554. date.add(1, 'h');
  11555. if (tries === 24) {
  11556. throw new Error('Tried 24 times to find a valid date');
  11557. }
  11558. tries++;
  11559. }
  11560. setValue(date);
  11561. }
  11562. update();
  11563. return picker;
  11564. };
  11565. picker.enabledHours = function (hours) {
  11566. // /<signature helpKeyword="$.fn.datetimepicker.enabledHours">
  11567. // /<summary>Returns an array with the currently set enabled hours on the component.</summary>
  11568. // /<returns type="array">options.enabledHours</returns>
  11569. // /</signature>
  11570. // /<signature>
  11571. // /<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>
  11572. // /<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>
  11573. // /</signature>
  11574. if (arguments.length === 0) {
  11575. return options.enabledHours ? $.extend({}, options.enabledHours) : options.enabledHours;
  11576. }
  11577. if (!hours) {
  11578. options.enabledHours = false;
  11579. update();
  11580. return picker;
  11581. }
  11582. if (!(hours instanceof Array)) {
  11583. throw new TypeError('enabledHours() expects an array parameter');
  11584. }
  11585. options.enabledHours = indexGivenHours(hours);
  11586. options.disabledHours = false;
  11587. if (options.useCurrent && !options.keepInvalid) {
  11588. var tries = 0;
  11589. while (!isValid(date, 'h')) {
  11590. date.add(1, 'h');
  11591. if (tries === 24) {
  11592. throw new Error('Tried 24 times to find a valid date');
  11593. }
  11594. tries++;
  11595. }
  11596. setValue(date);
  11597. }
  11598. update();
  11599. return picker;
  11600. };
  11601. /**
  11602. * 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.
  11603. * @param {Takes string, viewDate, moment, null parameter.} newDate
  11604. * @returns {viewDate.clone()}
  11605. */
  11606. picker.viewDate = function (newDate) {
  11607. if (arguments.length === 0) {
  11608. return viewDate.clone();
  11609. }
  11610. if (!newDate) {
  11611. viewDate = date.clone();
  11612. return picker;
  11613. }
  11614. if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
  11615. throw new TypeError('viewDate() parameter must be one of [string, moment or Date]');
  11616. }
  11617. viewDate = parseInputDate(newDate);
  11618. viewUpdate();
  11619. return picker;
  11620. }; // initializing element and component attributes
  11621. if (element.is('input')) {
  11622. input = element;
  11623. } else {
  11624. input = element.find(options.datepickerInput);
  11625. if (input.length === 0) {
  11626. input = element.find('input');
  11627. } else if (!input.is('input')) {
  11628. throw new Error('CSS class "' + options.datepickerInput + '" cannot be applied to non input element');
  11629. }
  11630. }
  11631. if (element.hasClass('input-group')) {
  11632. // in case there is more then one 'input-group-addon' Issue #48
  11633. if (element.find('.datepickerbutton').length === 0) {
  11634. component = element.find('.input-group-addon');
  11635. } else {
  11636. component = element.find('.datepickerbutton');
  11637. }
  11638. }
  11639. if (!options.inline && !input.is('input')) {
  11640. throw new Error('Could not initialize DateTimePicker without an input element');
  11641. } // Set defaults for date here now instead of in var declaration
  11642. date = getMoment();
  11643. viewDate = date.clone();
  11644. $.extend(true, options, dataToOptions());
  11645. picker.options(options);
  11646. initFormatting();
  11647. attachDatePickerElementEvents();
  11648. if (input.prop('disabled')) {
  11649. picker.disable();
  11650. }
  11651. if (input.is('input') && input.val().trim().length !== 0) {
  11652. setValue(parseInputDate(input.val().trim()));
  11653. } else if (options.defaultDate && input.attr('placeholder') === undefined) {
  11654. setValue(options.defaultDate);
  11655. }
  11656. if (options.inline) {
  11657. show();
  11658. }
  11659. return picker;
  11660. };
  11661. /** ******************************************************************************
  11662. *
  11663. * jQuery plugin constructor and defaults object
  11664. *
  11665. ********************************************************************************/
  11666. /**
  11667. * See (http://jquery.com/).
  11668. * @name jQuery
  11669. * @class
  11670. * See the jQuery Library (http://jquery.com/) for full details. This just
  11671. * documents the function and classes that are added to jQuery by this plug-in.
  11672. */
  11673. /**
  11674. * See (http://jquery.com/)
  11675. * @name fn
  11676. * @class
  11677. * See the jQuery Library (http://jquery.com/) for full details. This just
  11678. * documents the function and classes that are added to jQuery by this plug-in.
  11679. * @memberOf jQuery
  11680. */
  11681. /**
  11682. * Show comments
  11683. * @class datetimepicker
  11684. * @memberOf jQuery.fn
  11685. */
  11686. $.fn.datetimepicker = function (options) {
  11687. options = options || {};
  11688. var args = Array.prototype.slice.call(arguments, 1);
  11689. var isInstance = true;
  11690. var thisMethods = ['destroy', 'hide', 'show', 'toggle'];
  11691. var returnValue;
  11692. if (_typeof(options) === 'object') {
  11693. return this.each(function () {
  11694. var $this = $(this);
  11695. var _options;
  11696. if (!$this.data('DateTimePicker')) {
  11697. // create a private copy of the defaults object
  11698. _options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
  11699. $this.data('DateTimePicker', dateTimePicker($this, _options));
  11700. }
  11701. });
  11702. } else if (typeof options === 'string') {
  11703. this.each(function () {
  11704. var $this = $(this);
  11705. var instance = $this.data('DateTimePicker');
  11706. if (!instance) {
  11707. throw new Error('bootstrap-datetimepicker("' + options + '") method was called on an element that is not using DateTimePicker');
  11708. }
  11709. returnValue = instance[options].apply(instance, args);
  11710. isInstance = returnValue === instance;
  11711. });
  11712. if (isInstance || $.inArray(options, thisMethods) > -1) {
  11713. return this;
  11714. }
  11715. return returnValue;
  11716. }
  11717. throw new TypeError('Invalid arguments for DateTimePicker: ' + options);
  11718. };
  11719. $.fn.datetimepicker.defaults = {
  11720. timeZone: '',
  11721. format: false,
  11722. dayViewHeaderFormat: 'MMMM YYYY',
  11723. extraFormats: false,
  11724. stepping: 1,
  11725. minDate: false,
  11726. maxDate: false,
  11727. useCurrent: true,
  11728. collapse: true,
  11729. locale: moment.locale(),
  11730. defaultDate: false,
  11731. disabledDates: false,
  11732. enabledDates: false,
  11733. icons: {
  11734. time: 'glyphicon glyphicon-time',
  11735. date: 'glyphicon glyphicon-calendar',
  11736. up: 'glyphicon glyphicon-chevron-up',
  11737. down: 'glyphicon glyphicon-chevron-down',
  11738. previous: 'glyphicon glyphicon-chevron-left',
  11739. next: 'glyphicon glyphicon-chevron-right',
  11740. today: 'glyphicon glyphicon-screenshot',
  11741. clear: 'glyphicon glyphicon-trash',
  11742. close: 'glyphicon glyphicon-remove'
  11743. },
  11744. tooltips: {
  11745. today: 'Go to today',
  11746. clear: 'Clear selection',
  11747. close: 'Close the picker',
  11748. selectMonth: 'Select Month',
  11749. prevMonth: 'Previous Month',
  11750. nextMonth: 'Next Month',
  11751. selectYear: 'Select Year',
  11752. prevYear: 'Previous Year',
  11753. nextYear: 'Next Year',
  11754. selectDecade: 'Select Decade',
  11755. prevDecade: 'Previous Decade',
  11756. nextDecade: 'Next Decade',
  11757. prevCentury: 'Previous Century',
  11758. nextCentury: 'Next Century',
  11759. pickHour: 'Pick Hour',
  11760. incrementHour: 'Increment Hour',
  11761. decrementHour: 'Decrement Hour',
  11762. pickMinute: 'Pick Minute',
  11763. incrementMinute: 'Increment Minute',
  11764. decrementMinute: 'Decrement Minute',
  11765. pickSecond: 'Pick Second',
  11766. incrementSecond: 'Increment Second',
  11767. decrementSecond: 'Decrement Second',
  11768. togglePeriod: 'Toggle Period',
  11769. selectTime: 'Select Time'
  11770. },
  11771. useStrict: false,
  11772. sideBySide: false,
  11773. daysOfWeekDisabled: false,
  11774. calendarWeeks: false,
  11775. viewMode: 'days',
  11776. toolbarPlacement: 'default',
  11777. showTodayButton: false,
  11778. showClear: false,
  11779. showClose: false,
  11780. widgetPositioning: {
  11781. horizontal: 'auto',
  11782. vertical: 'auto'
  11783. },
  11784. widgetParent: null,
  11785. ignoreReadonly: false,
  11786. keepOpen: false,
  11787. focusOnShow: true,
  11788. inline: false,
  11789. keepInvalid: false,
  11790. datepickerInput: '.datepickerinput',
  11791. keyBinds: {
  11792. up: function up(widget) {
  11793. if (!widget) {
  11794. return;
  11795. }
  11796. var d = this.date() || this.getMoment();
  11797. if (widget.find('.datepicker').is(':visible')) {
  11798. this.date(d.clone().subtract(7, 'd'));
  11799. } else {
  11800. this.date(d.clone().add(this.stepping(), 'm'));
  11801. }
  11802. },
  11803. down: function down(widget) {
  11804. if (!widget) {
  11805. this.show();
  11806. return;
  11807. }
  11808. var d = this.date() || this.getMoment();
  11809. if (widget.find('.datepicker').is(':visible')) {
  11810. this.date(d.clone().add(7, 'd'));
  11811. } else {
  11812. this.date(d.clone().subtract(this.stepping(), 'm'));
  11813. }
  11814. },
  11815. 'control up': function controlUp(widget) {
  11816. if (!widget) {
  11817. return;
  11818. }
  11819. var d = this.date() || this.getMoment();
  11820. if (widget.find('.datepicker').is(':visible')) {
  11821. this.date(d.clone().subtract(1, 'y'));
  11822. } else {
  11823. this.date(d.clone().add(1, 'h'));
  11824. }
  11825. },
  11826. 'control down': function controlDown(widget) {
  11827. if (!widget) {
  11828. return;
  11829. }
  11830. var d = this.date() || this.getMoment();
  11831. if (widget.find('.datepicker').is(':visible')) {
  11832. this.date(d.clone().add(1, 'y'));
  11833. } else {
  11834. this.date(d.clone().subtract(1, 'h'));
  11835. }
  11836. },
  11837. left: function left(widget) {
  11838. if (!widget) {
  11839. return;
  11840. }
  11841. var d = this.date() || this.getMoment();
  11842. if (widget.find('.datepicker').is(':visible')) {
  11843. this.date(d.clone().subtract(1, 'd'));
  11844. }
  11845. },
  11846. right: function right(widget) {
  11847. if (!widget) {
  11848. return;
  11849. }
  11850. var d = this.date() || this.getMoment();
  11851. if (widget.find('.datepicker').is(':visible')) {
  11852. this.date(d.clone().add(1, 'd'));
  11853. }
  11854. },
  11855. pageUp: function pageUp(widget) {
  11856. if (!widget) {
  11857. return;
  11858. }
  11859. var d = this.date() || this.getMoment();
  11860. if (widget.find('.datepicker').is(':visible')) {
  11861. this.date(d.clone().subtract(1, 'M'));
  11862. }
  11863. },
  11864. pageDown: function pageDown(widget) {
  11865. if (!widget) {
  11866. return;
  11867. }
  11868. var d = this.date() || this.getMoment();
  11869. if (widget.find('.datepicker').is(':visible')) {
  11870. this.date(d.clone().add(1, 'M'));
  11871. }
  11872. },
  11873. enter: function enter() {
  11874. this.hide();
  11875. },
  11876. escape: function escape() {
  11877. this.hide();
  11878. },
  11879. // tab: function (widget) { //this break the flow of the form. disabling for now
  11880. // var toggle = widget.find('.picker-switch a[data-action="togglePicker"]');
  11881. // if(toggle.length > 0) toggle.click();
  11882. // },
  11883. 'control space': function controlSpace(widget) {
  11884. if (!widget) {
  11885. return;
  11886. }
  11887. if (widget.find('.timepicker').is(':visible')) {
  11888. widget.find('.btn[data-action="togglePeriod"]').click();
  11889. }
  11890. },
  11891. t: function t() {
  11892. this.date(this.getMoment());
  11893. },
  11894. 'delete': function _delete() {
  11895. this.clear();
  11896. }
  11897. },
  11898. debug: false,
  11899. allowInputToggle: false,
  11900. disabledTimeIntervals: false,
  11901. disabledHours: false,
  11902. enabledHours: false,
  11903. viewDate: false
  11904. };
  11905. return $.fn.datetimepicker;
  11906. });
  11907. /***/ }),
  11908. /***/ 92511:
  11909. /***/ (() => {
  11910. // localStorage
  11911. (function () {
  11912. function isSupported() {
  11913. var item = 'localStoragePollyfill';
  11914. try {
  11915. localStorage.setItem(item, item);
  11916. localStorage.removeItem(item);
  11917. sessionStorage.setItem(item, item);
  11918. sessionStorage.removeItem(item);
  11919. return true;
  11920. } catch (e) {
  11921. return false;
  11922. }
  11923. }
  11924. if (!isSupported()) {
  11925. try {
  11926. Storage.prototype._data = {};
  11927. Storage.prototype.setItem = function (id, val) {
  11928. this._data[id] = String(val);
  11929. return this._data[id];
  11930. };
  11931. Storage.prototype.getItem = function (id) {
  11932. return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
  11933. };
  11934. Storage.prototype.removeItem = function (id) {
  11935. return delete this._data[id];
  11936. };
  11937. Storage.prototype.clear = function () {
  11938. this._data = {};
  11939. return this._data;
  11940. };
  11941. } catch (e) {
  11942. console.error('localStorage pollyfill error: ', e);
  11943. }
  11944. }
  11945. })();
  11946. /***/ }),
  11947. /***/ 46700:
  11948. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  11949. var map = {
  11950. "./af": 42786,
  11951. "./af.js": 42786,
  11952. "./ar": 30867,
  11953. "./ar-dz": 14130,
  11954. "./ar-dz.js": 14130,
  11955. "./ar-kw": 96135,
  11956. "./ar-kw.js": 96135,
  11957. "./ar-ly": 56440,
  11958. "./ar-ly.js": 56440,
  11959. "./ar-ma": 47702,
  11960. "./ar-ma.js": 47702,
  11961. "./ar-sa": 16040,
  11962. "./ar-sa.js": 16040,
  11963. "./ar-tn": 37100,
  11964. "./ar-tn.js": 37100,
  11965. "./ar.js": 30867,
  11966. "./az": 31083,
  11967. "./az.js": 31083,
  11968. "./be": 9808,
  11969. "./be.js": 9808,
  11970. "./bg": 68338,
  11971. "./bg.js": 68338,
  11972. "./bm": 67438,
  11973. "./bm.js": 67438,
  11974. "./bn": 8905,
  11975. "./bn-bd": 76225,
  11976. "./bn-bd.js": 76225,
  11977. "./bn.js": 8905,
  11978. "./bo": 11560,
  11979. "./bo.js": 11560,
  11980. "./br": 1278,
  11981. "./br.js": 1278,
  11982. "./bs": 80622,
  11983. "./bs.js": 80622,
  11984. "./ca": 2468,
  11985. "./ca.js": 2468,
  11986. "./cs": 5822,
  11987. "./cs.js": 5822,
  11988. "./cv": 50877,
  11989. "./cv.js": 50877,
  11990. "./cy": 47373,
  11991. "./cy.js": 47373,
  11992. "./da": 24780,
  11993. "./da.js": 24780,
  11994. "./de": 59740,
  11995. "./de-at": 60217,
  11996. "./de-at.js": 60217,
  11997. "./de-ch": 60894,
  11998. "./de-ch.js": 60894,
  11999. "./de.js": 59740,
  12000. "./dv": 5300,
  12001. "./dv.js": 5300,
  12002. "./el": 50837,
  12003. "./el.js": 50837,
  12004. "./en-au": 78348,
  12005. "./en-au.js": 78348,
  12006. "./en-ca": 77925,
  12007. "./en-ca.js": 77925,
  12008. "./en-gb": 22243,
  12009. "./en-gb.js": 22243,
  12010. "./en-ie": 46436,
  12011. "./en-ie.js": 46436,
  12012. "./en-il": 47207,
  12013. "./en-il.js": 47207,
  12014. "./en-in": 44175,
  12015. "./en-in.js": 44175,
  12016. "./en-nz": 76319,
  12017. "./en-nz.js": 76319,
  12018. "./en-sg": 31662,
  12019. "./en-sg.js": 31662,
  12020. "./eo": 92915,
  12021. "./eo.js": 92915,
  12022. "./es": 55655,
  12023. "./es-do": 55251,
  12024. "./es-do.js": 55251,
  12025. "./es-mx": 96112,
  12026. "./es-mx.js": 96112,
  12027. "./es-us": 71146,
  12028. "./es-us.js": 71146,
  12029. "./es.js": 55655,
  12030. "./et": 5603,
  12031. "./et.js": 5603,
  12032. "./eu": 77763,
  12033. "./eu.js": 77763,
  12034. "./fa": 76959,
  12035. "./fa.js": 76959,
  12036. "./fi": 11897,
  12037. "./fi.js": 11897,
  12038. "./fil": 42549,
  12039. "./fil.js": 42549,
  12040. "./fo": 94694,
  12041. "./fo.js": 94694,
  12042. "./fr": 94470,
  12043. "./fr-ca": 63049,
  12044. "./fr-ca.js": 63049,
  12045. "./fr-ch": 52330,
  12046. "./fr-ch.js": 52330,
  12047. "./fr.js": 94470,
  12048. "./fy": 5044,
  12049. "./fy.js": 5044,
  12050. "./ga": 29295,
  12051. "./ga.js": 29295,
  12052. "./gd": 2101,
  12053. "./gd.js": 2101,
  12054. "./gl": 38794,
  12055. "./gl.js": 38794,
  12056. "./gom-deva": 27884,
  12057. "./gom-deva.js": 27884,
  12058. "./gom-latn": 23168,
  12059. "./gom-latn.js": 23168,
  12060. "./gu": 95349,
  12061. "./gu.js": 95349,
  12062. "./he": 24206,
  12063. "./he.js": 24206,
  12064. "./hi": 30094,
  12065. "./hi.js": 30094,
  12066. "./hr": 30316,
  12067. "./hr.js": 30316,
  12068. "./hu": 22138,
  12069. "./hu.js": 22138,
  12070. "./hy-am": 11423,
  12071. "./hy-am.js": 11423,
  12072. "./id": 29218,
  12073. "./id.js": 29218,
  12074. "./is": 90135,
  12075. "./is.js": 90135,
  12076. "./it": 90626,
  12077. "./it-ch": 10150,
  12078. "./it-ch.js": 10150,
  12079. "./it.js": 90626,
  12080. "./ja": 39183,
  12081. "./ja.js": 39183,
  12082. "./jv": 24286,
  12083. "./jv.js": 24286,
  12084. "./ka": 12105,
  12085. "./ka.js": 12105,
  12086. "./kk": 47772,
  12087. "./kk.js": 47772,
  12088. "./km": 18758,
  12089. "./km.js": 18758,
  12090. "./kn": 79282,
  12091. "./kn.js": 79282,
  12092. "./ko": 33730,
  12093. "./ko.js": 33730,
  12094. "./ku": 1408,
  12095. "./ku.js": 1408,
  12096. "./ky": 33291,
  12097. "./ky.js": 33291,
  12098. "./lb": 36841,
  12099. "./lb.js": 36841,
  12100. "./lo": 55466,
  12101. "./lo.js": 55466,
  12102. "./lt": 57010,
  12103. "./lt.js": 57010,
  12104. "./lv": 37595,
  12105. "./lv.js": 37595,
  12106. "./me": 39861,
  12107. "./me.js": 39861,
  12108. "./mi": 35493,
  12109. "./mi.js": 35493,
  12110. "./mk": 95966,
  12111. "./mk.js": 95966,
  12112. "./ml": 87341,
  12113. "./ml.js": 87341,
  12114. "./mn": 5115,
  12115. "./mn.js": 5115,
  12116. "./mr": 10370,
  12117. "./mr.js": 10370,
  12118. "./ms": 9847,
  12119. "./ms-my": 41237,
  12120. "./ms-my.js": 41237,
  12121. "./ms.js": 9847,
  12122. "./mt": 72126,
  12123. "./mt.js": 72126,
  12124. "./my": 56165,
  12125. "./my.js": 56165,
  12126. "./nb": 64924,
  12127. "./nb.js": 64924,
  12128. "./ne": 16744,
  12129. "./ne.js": 16744,
  12130. "./nl": 93901,
  12131. "./nl-be": 59814,
  12132. "./nl-be.js": 59814,
  12133. "./nl.js": 93901,
  12134. "./nn": 83877,
  12135. "./nn.js": 83877,
  12136. "./oc-lnc": 92135,
  12137. "./oc-lnc.js": 92135,
  12138. "./pa-in": 15858,
  12139. "./pa-in.js": 15858,
  12140. "./pl": 64495,
  12141. "./pl.js": 64495,
  12142. "./pt": 89520,
  12143. "./pt-br": 57971,
  12144. "./pt-br.js": 57971,
  12145. "./pt.js": 89520,
  12146. "./ro": 96459,
  12147. "./ro.js": 96459,
  12148. "./ru": 21793,
  12149. "./ru.js": 21793,
  12150. "./sd": 40950,
  12151. "./sd.js": 40950,
  12152. "./se": 10490,
  12153. "./se.js": 10490,
  12154. "./si": 90124,
  12155. "./si.js": 90124,
  12156. "./sk": 64249,
  12157. "./sk.js": 64249,
  12158. "./sl": 34082,
  12159. "./sl.js": 34082,
  12160. "./sq": 51104,
  12161. "./sq.js": 51104,
  12162. "./sr": 49131,
  12163. "./sr-cyrl": 79915,
  12164. "./sr-cyrl.js": 79915,
  12165. "./sr.js": 49131,
  12166. "./ss": 85893,
  12167. "./ss.js": 85893,
  12168. "./sv": 98760,
  12169. "./sv.js": 98760,
  12170. "./sw": 91172,
  12171. "./sw.js": 91172,
  12172. "./ta": 27333,
  12173. "./ta.js": 27333,
  12174. "./te": 23110,
  12175. "./te.js": 23110,
  12176. "./tet": 52095,
  12177. "./tet.js": 52095,
  12178. "./tg": 44257,
  12179. "./tg.js": 44257,
  12180. "./th": 9041,
  12181. "./th.js": 9041,
  12182. "./tk": 19005,
  12183. "./tk.js": 19005,
  12184. "./tl-ph": 75768,
  12185. "./tl-ph.js": 75768,
  12186. "./tlh": 89444,
  12187. "./tlh.js": 89444,
  12188. "./tr": 72397,
  12189. "./tr.js": 72397,
  12190. "./tzl": 28254,
  12191. "./tzl.js": 28254,
  12192. "./tzm": 51106,
  12193. "./tzm-latn": 30699,
  12194. "./tzm-latn.js": 30699,
  12195. "./tzm.js": 51106,
  12196. "./ug-cn": 9288,
  12197. "./ug-cn.js": 9288,
  12198. "./uk": 67691,
  12199. "./uk.js": 67691,
  12200. "./ur": 13795,
  12201. "./ur.js": 13795,
  12202. "./uz": 6791,
  12203. "./uz-latn": 60588,
  12204. "./uz-latn.js": 60588,
  12205. "./uz.js": 6791,
  12206. "./vi": 65666,
  12207. "./vi.js": 65666,
  12208. "./x-pseudo": 14378,
  12209. "./x-pseudo.js": 14378,
  12210. "./yo": 75805,
  12211. "./yo.js": 75805,
  12212. "./zh-cn": 83839,
  12213. "./zh-cn.js": 83839,
  12214. "./zh-hk": 55726,
  12215. "./zh-hk.js": 55726,
  12216. "./zh-mo": 99807,
  12217. "./zh-mo.js": 99807,
  12218. "./zh-tw": 74152,
  12219. "./zh-tw.js": 74152
  12220. };
  12221. function webpackContext(req) {
  12222. var id = webpackContextResolve(req);
  12223. return __webpack_require__(id);
  12224. }
  12225. function webpackContextResolve(req) {
  12226. if(!__webpack_require__.o(map, req)) {
  12227. var e = new Error("Cannot find module '" + req + "'");
  12228. e.code = 'MODULE_NOT_FOUND';
  12229. throw e;
  12230. }
  12231. return map[req];
  12232. }
  12233. webpackContext.keys = function webpackContextKeys() {
  12234. return Object.keys(map);
  12235. };
  12236. webpackContext.resolve = webpackContextResolve;
  12237. module.exports = webpackContext;
  12238. webpackContext.id = 46700;
  12239. /***/ }),
  12240. /***/ 73609:
  12241. /***/ ((module) => {
  12242. "use strict";
  12243. module.exports = jQuery;
  12244. /***/ })
  12245. /******/ });
  12246. /************************************************************************/
  12247. /******/ // The module cache
  12248. /******/ var __webpack_module_cache__ = {};
  12249. /******/
  12250. /******/ // The require function
  12251. /******/ function __webpack_require__(moduleId) {
  12252. /******/ // Check if module is in cache
  12253. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  12254. /******/ if (cachedModule !== undefined) {
  12255. /******/ return cachedModule.exports;
  12256. /******/ }
  12257. /******/ // Create a new module (and put it into the cache)
  12258. /******/ var module = __webpack_module_cache__[moduleId] = {
  12259. /******/ id: moduleId,
  12260. /******/ loaded: false,
  12261. /******/ exports: {}
  12262. /******/ };
  12263. /******/
  12264. /******/ // Execute the module function
  12265. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  12266. /******/
  12267. /******/ // Flag the module as loaded
  12268. /******/ module.loaded = true;
  12269. /******/
  12270. /******/ // Return the exports of the module
  12271. /******/ return module.exports;
  12272. /******/ }
  12273. /******/
  12274. /******/ // expose the modules object (__webpack_modules__)
  12275. /******/ __webpack_require__.m = __webpack_modules__;
  12276. /******/
  12277. /************************************************************************/
  12278. /******/ /* webpack/runtime/amd define */
  12279. /******/ (() => {
  12280. /******/ __webpack_require__.amdD = function () {
  12281. /******/ throw new Error('define cannot be used indirect');
  12282. /******/ };
  12283. /******/ })();
  12284. /******/
  12285. /******/ /* webpack/runtime/chunk loaded */
  12286. /******/ (() => {
  12287. /******/ var deferred = [];
  12288. /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
  12289. /******/ if(chunkIds) {
  12290. /******/ priority = priority || 0;
  12291. /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
  12292. /******/ deferred[i] = [chunkIds, fn, priority];
  12293. /******/ return;
  12294. /******/ }
  12295. /******/ var notFulfilled = Infinity;
  12296. /******/ for (var i = 0; i < deferred.length; i++) {
  12297. /******/ var [chunkIds, fn, priority] = deferred[i];
  12298. /******/ var fulfilled = true;
  12299. /******/ for (var j = 0; j < chunkIds.length; j++) {
  12300. /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
  12301. /******/ chunkIds.splice(j--, 1);
  12302. /******/ } else {
  12303. /******/ fulfilled = false;
  12304. /******/ if(priority < notFulfilled) notFulfilled = priority;
  12305. /******/ }
  12306. /******/ }
  12307. /******/ if(fulfilled) {
  12308. /******/ deferred.splice(i--, 1)
  12309. /******/ result = fn();
  12310. /******/ }
  12311. /******/ }
  12312. /******/ return result;
  12313. /******/ };
  12314. /******/ })();
  12315. /******/
  12316. /******/ /* webpack/runtime/compat get default export */
  12317. /******/ (() => {
  12318. /******/ // getDefaultExport function for compatibility with non-harmony modules
  12319. /******/ __webpack_require__.n = (module) => {
  12320. /******/ var getter = module && module.__esModule ?
  12321. /******/ () => (module['default']) :
  12322. /******/ () => (module);
  12323. /******/ __webpack_require__.d(getter, { a: getter });
  12324. /******/ return getter;
  12325. /******/ };
  12326. /******/ })();
  12327. /******/
  12328. /******/ /* webpack/runtime/define property getters */
  12329. /******/ (() => {
  12330. /******/ // define getter functions for harmony exports
  12331. /******/ __webpack_require__.d = (exports, definition) => {
  12332. /******/ for(var key in definition) {
  12333. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  12334. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  12335. /******/ }
  12336. /******/ }
  12337. /******/ };
  12338. /******/ })();
  12339. /******/
  12340. /******/ /* webpack/runtime/global */
  12341. /******/ (() => {
  12342. /******/ __webpack_require__.g = (function() {
  12343. /******/ if (typeof globalThis === 'object') return globalThis;
  12344. /******/ try {
  12345. /******/ return this || new Function('return this')();
  12346. /******/ } catch (e) {
  12347. /******/ if (typeof window === 'object') return window;
  12348. /******/ }
  12349. /******/ })();
  12350. /******/ })();
  12351. /******/
  12352. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  12353. /******/ (() => {
  12354. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  12355. /******/ })();
  12356. /******/
  12357. /******/ /* webpack/runtime/make namespace object */
  12358. /******/ (() => {
  12359. /******/ // define __esModule on exports
  12360. /******/ __webpack_require__.r = (exports) => {
  12361. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  12362. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  12363. /******/ }
  12364. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  12365. /******/ };
  12366. /******/ })();
  12367. /******/
  12368. /******/ /* webpack/runtime/node module decorator */
  12369. /******/ (() => {
  12370. /******/ __webpack_require__.nmd = (module) => {
  12371. /******/ module.paths = [];
  12372. /******/ if (!module.children) module.children = [];
  12373. /******/ return module;
  12374. /******/ };
  12375. /******/ })();
  12376. /******/
  12377. /******/ /* webpack/runtime/jsonp chunk loading */
  12378. /******/ (() => {
  12379. /******/ // no baseURI
  12380. /******/
  12381. /******/ // object to store loaded and loading chunks
  12382. /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
  12383. /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
  12384. /******/ var installedChunks = {
  12385. /******/ 328: 0
  12386. /******/ };
  12387. /******/
  12388. /******/ // no chunk on demand loading
  12389. /******/
  12390. /******/ // no prefetching
  12391. /******/
  12392. /******/ // no preloaded
  12393. /******/
  12394. /******/ // no HMR
  12395. /******/
  12396. /******/ // no HMR manifest
  12397. /******/
  12398. /******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
  12399. /******/
  12400. /******/ // install a JSONP callback for chunk loading
  12401. /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
  12402. /******/ var [chunkIds, moreModules, runtime] = data;
  12403. /******/ // add "moreModules" to the modules object,
  12404. /******/ // then flag all "chunkIds" as loaded and fire callback
  12405. /******/ var moduleId, chunkId, i = 0;
  12406. /******/ for(moduleId in moreModules) {
  12407. /******/ if(__webpack_require__.o(moreModules, moduleId)) {
  12408. /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
  12409. /******/ }
  12410. /******/ }
  12411. /******/ if(runtime) var result = runtime(__webpack_require__);
  12412. /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
  12413. /******/ for(;i < chunkIds.length; i++) {
  12414. /******/ chunkId = chunkIds[i];
  12415. /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
  12416. /******/ installedChunks[chunkId][0]();
  12417. /******/ }
  12418. /******/ installedChunks[chunkIds[i]] = 0;
  12419. /******/ }
  12420. /******/ return __webpack_require__.O(result);
  12421. /******/ }
  12422. /******/
  12423. /******/ var chunkLoadingGlobal = self["webpackChunkGrav"] = self["webpackChunkGrav"] || [];
  12424. /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
  12425. /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
  12426. /******/ })();
  12427. /******/
  12428. /************************************************************************/
  12429. /******/
  12430. /******/ // startup
  12431. /******/ // Load entry module and return exports
  12432. /******/ // This entry module depends on other loaded chunks and execution need to be delayed
  12433. /******/ var __webpack_exports__ = __webpack_require__.O(undefined, [736], () => (__webpack_require__(40535)))
  12434. /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
  12435. /******/ Grav = __webpack_exports__;
  12436. /******/
  12437. /******/ })()
  12438. ;