123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273 |
- var Grav;
- /******/ (() => { // webpackBootstrap
- /******/ var __webpack_modules__ = ({
- /***/ 56299:
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- "use strict";
- // ESM COMPAT FLAG
- __webpack_require__.r(__webpack_exports__);
- // EXPORTS
- __webpack_require__.d(__webpack_exports__, {
- "default": () => (/* binding */ main)
- });
- // EXTERNAL MODULE: ./node_modules/@babel/polyfill/lib/index.js
- var lib = __webpack_require__(26981);
- // EXTERNAL MODULE: external "jQuery"
- var external_jQuery_ = __webpack_require__(65311);
- var external_jQuery_default = /*#__PURE__*/__webpack_require__.n(external_jQuery_);
- ;// CONCATENATED MODULE: ./app/utils/remodal.js
- /* Remodal from https://github.com/vodkabears/Remodal
- * With Stackable option from https://github.com/antstorm/Remodal patch
- */
- !function (root, factory) {
- return factory(root, (external_jQuery_default()));
- }(undefined, function (global, $) {
- 'use strict';
- /**
- * Name of the plugin
- * @private
- * @const
- * @type {String}
- */
- var PLUGIN_NAME = 'remodal';
- /**
- * Namespace for CSS and events
- * @private
- * @const
- * @type {String}
- */
- var NAMESPACE = window.REMODAL_GLOBALS && window.REMODAL_GLOBALS.NAMESPACE || PLUGIN_NAME;
- /**
- * Animationstart event with vendor prefixes
- * @private
- * @const
- * @type {String}
- */
- var ANIMATIONSTART_EVENTS = $.map(['animationstart', 'webkitAnimationStart', 'MSAnimationStart', 'oAnimationStart'], function (eventName) {
- return eventName + '.' + NAMESPACE;
- }).join(' ');
- /**
- * Animationend event with vendor prefixes
- * @private
- * @const
- * @type {String}
- */
- var ANIMATIONEND_EVENTS = $.map(['animationend', 'webkitAnimationEnd', 'MSAnimationEnd', 'oAnimationEnd'], function (eventName) {
- return eventName + '.' + NAMESPACE;
- }).join(' ');
- /**
- * Default settings
- * @private
- * @const
- * @type {Object}
- */
- var DEFAULTS = $.extend({
- hashTracking: true,
- closeOnConfirm: true,
- closeOnCancel: true,
- closeOnEscape: true,
- closeOnOutsideClick: true,
- modifier: '',
- stack: false,
- appendTo: null
- }, window.REMODAL_GLOBALS && window.REMODAL_GLOBALS.DEFAULTS);
- /**
- * States of the Remodal
- * @private
- * @const
- * @enum {String}
- */
- var STATES = {
- CLOSING: 'closing',
- CLOSED: 'closed',
- OPENING: 'opening',
- OPENED: 'opened'
- };
- /**
- * Reasons of the state change.
- * @private
- * @const
- * @enum {String}
- */
- var STATE_CHANGE_REASONS = {
- CONFIRMATION: 'confirmation',
- CANCELLATION: 'cancellation'
- };
- /**
- * Is animation supported?
- * @private
- * @const
- * @type {Boolean}
- */
- var IS_ANIMATION = function () {
- var style = document.createElement('div').style;
- return style.animationName !== undefined || style.WebkitAnimationName !== undefined || style.MozAnimationName !== undefined || style.msAnimationName !== undefined || style.OAnimationName !== undefined;
- }();
- /**
- * Is iOS?
- * @private
- * @const
- * @type {Boolean}
- */
- var IS_IOS = /iPad|iPhone|iPod/.test(navigator.platform);
- /**
- * Current modal
- * @private
- * @type {Remodal}
- */
- var openModals = [];
- /**
- * Scrollbar position
- * @private
- * @type {Number}
- */
- var scrollTop;
- /**
- * Returns an animation duration
- * @private
- * @param {jQuery} $elem
- * @returns {Number}
- */
- function getAnimationDuration($elem) {
- 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') {
- return 0;
- }
- 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';
- 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';
- 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';
- var max;
- var len;
- var num;
- var i;
- duration = duration.split(', ');
- delay = delay.split(', ');
- iterationCount = iterationCount.split(', '); // The 'duration' size is the same as the 'delay' size
- for (i = 0, len = duration.length, max = Number.NEGATIVE_INFINITY; i < len; i++) {
- num = parseFloat(duration[i]) * parseInt(iterationCount[i], 10) + parseFloat(delay[i]);
- if (num > max) {
- max = num;
- }
- }
- return max;
- }
- /**
- * Returns a scrollbar width
- * @private
- * @returns {Number}
- */
- function getScrollbarWidth() {
- if ($(document).height() <= $(window).height()) {
- return 0;
- }
- var outer = document.createElement('div');
- var inner = document.createElement('div');
- var widthNoScroll;
- var widthWithScroll;
- outer.style.visibility = 'hidden';
- outer.style.width = '100px';
- document.body.appendChild(outer);
- widthNoScroll = outer.offsetWidth; // Force scrollbars
- outer.style.overflow = 'scroll'; // Add inner div
- inner.style.width = '100%';
- outer.appendChild(inner);
- widthWithScroll = inner.offsetWidth; // Remove divs
- outer.parentNode.removeChild(outer);
- return widthNoScroll - widthWithScroll;
- }
- /**
- * Locks the screen
- * @private
- */
- function lockScreen() {
- if (IS_IOS) {
- return;
- }
- var $html = $('html');
- var lockedClass = namespacify('is-locked');
- var paddingRight;
- var $body;
- if (!$html.hasClass(lockedClass)) {
- $body = $(document.body); // Zepto does not support '-=', '+=' in the `css` method
- paddingRight = parseInt($body.css('padding-right'), 10) + getScrollbarWidth();
- $body.css('padding-right', paddingRight + 'px');
- $html.addClass(lockedClass);
- }
- }
- /**
- * Unlocks the screen
- * @private
- */
- function unlockScreen() {
- if (IS_IOS) {
- return;
- }
- var $html = $('html');
- var lockedClass = namespacify('is-locked');
- var paddingRight;
- var $body;
- if ($html.hasClass(lockedClass)) {
- $body = $(document.body); // Zepto does not support '-=', '+=' in the `css` method
- paddingRight = parseInt($body.css('padding-right'), 10) - getScrollbarWidth();
- $body.css('padding-right', paddingRight + 'px');
- $html.removeClass(lockedClass);
- }
- }
- /**
- * Sets a state for an instance
- * @private
- * @param {Remodal} instance
- * @param {STATES} state
- * @param {Boolean} isSilent If true, Remodal does not trigger events
- * @param {String} Reason of a state change.
- */
- function setState(instance, state, isSilent, reason) {
- var newState = namespacify('is', state);
- var allStates = [namespacify('is', STATES.CLOSING), namespacify('is', STATES.OPENING), namespacify('is', STATES.CLOSED), namespacify('is', STATES.OPENED)].join(' ');
- instance.$bg.removeClass(allStates).addClass(newState);
- instance.$overlay.removeClass(allStates).addClass(newState);
- instance.$wrapper.removeClass(allStates).addClass(newState);
- instance.$modal.removeClass(allStates).addClass(newState);
- instance.state = state;
- !isSilent && instance.$modal.trigger({
- type: state,
- reason: reason
- }, [{
- reason: reason
- }]);
- }
- /**
- * Synchronizes with the animation
- * @param {Function} doBeforeAnimation
- * @param {Function} doAfterAnimation
- * @param {Remodal} instance
- */
- function syncWithAnimation(doBeforeAnimation, doAfterAnimation, instance) {
- var runningAnimationsCount = 0;
- var handleAnimationStart = function handleAnimationStart(e) {
- if (e.target !== this) {
- return;
- }
- runningAnimationsCount++;
- };
- var handleAnimationEnd = function handleAnimationEnd(e) {
- if (e.target !== this) {
- return;
- }
- if (--runningAnimationsCount === 0) {
- // Remove event listeners
- $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) {
- instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS);
- });
- doAfterAnimation();
- }
- };
- $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) {
- instance[elemName].on(ANIMATIONSTART_EVENTS, handleAnimationStart).on(ANIMATIONEND_EVENTS, handleAnimationEnd);
- });
- doBeforeAnimation(); // If the animation is not supported by a browser or its duration is 0
- if (getAnimationDuration(instance.$bg) === 0 && getAnimationDuration(instance.$overlay) === 0 && getAnimationDuration(instance.$wrapper) === 0 && getAnimationDuration(instance.$modal) === 0) {
- // Remove event listeners
- $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) {
- instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS);
- });
- doAfterAnimation();
- }
- }
- /**
- * Closes immediately
- * @private
- * @param {Remodal} instance
- */
- function halt(instance) {
- if (instance.state === STATES.CLOSED) {
- return;
- }
- $.each(['$bg', '$overlay', '$wrapper', '$modal'], function (index, elemName) {
- instance[elemName].off(ANIMATIONSTART_EVENTS + ' ' + ANIMATIONEND_EVENTS);
- });
- removeModal(instance);
- instance.$bg.removeClass(instance.settings.modifier);
- instance.$overlay.removeClass(instance.settings.modifier).hide();
- instance.$wrapper.hide();
- if (openModals.length === 0) {
- unlockScreen();
- }
- setState(instance, STATES.CLOSED, true);
- }
- /**
- * Parses a string with options
- * @private
- * @param str
- * @returns {Object}
- */
- function parseOptions(str) {
- var obj = {};
- var arr;
- var len;
- var val;
- var i; // Remove spaces before and after delimiters
- str = str.replace(/\s*:\s*/g, ':').replace(/\s*,\s*/g, ','); // Parse a string
- arr = str.split(',');
- for (i = 0, len = arr.length; i < len; i++) {
- arr[i] = arr[i].split(':');
- val = arr[i][1]; // Convert a string value if it is like a boolean
- if (typeof val === 'string' || val instanceof String) {
- val = val === 'true' || (val === 'false' ? false : val);
- } // Convert a string value if it is like a number
- if (typeof val === 'string' || val instanceof String) {
- val = !isNaN(val) ? +val : val;
- }
- obj[arr[i][0]] = val;
- }
- return obj;
- }
- /**
- * Generates a string separated by dashes and prefixed with NAMESPACE
- * @private
- * @param {...String}
- * @returns {String}
- */
- function namespacify() {
- var result = NAMESPACE;
- for (var i = 0; i < arguments.length; ++i) {
- result += '-' + arguments[i];
- }
- return result;
- }
- /**
- * Handles the hashchange event
- * @private
- * @listens hashchange
- */
- function handleHashChangeEvent() {
- var id = location.hash.replace('#', '');
- var instance;
- var $elem;
- var current = currentModal();
- if (!id) {
- // Check if we have currently opened modal and animation was completed
- if (current && current.state === STATES.OPENED && current.settings.hashTracking) {
- current.close();
- }
- } else {
- if (!current || current.id !== id) {
- // Catch syntax error if your hash is bad
- try {
- $elem = $('[data-' + PLUGIN_NAME + '-id="' + id + '"]');
- } catch (err) {}
- if ($elem && $elem.length) {
- instance = $[PLUGIN_NAME].lookup[$elem.data(PLUGIN_NAME)];
- if (instance && instance.settings.hashTracking) {
- instance.open();
- }
- }
- }
- }
- }
- function currentModal() {
- return openModals[openModals.length - 1];
- }
- function removeModal(remodal) {
- var index = openModals.indexOf(remodal);
- if (index >= 0) {
- openModals.slice(index, 1);
- }
- }
- /**
- * Remodal constructor
- * @constructor
- * @param {jQuery} $modal
- * @param {Object} options
- */
- function Remodal($modal, options) {
- var $body = $(document.body);
- var $appendTo = $body;
- var remodal = this;
- remodal.id = $modal.attr('data-' + PLUGIN_NAME + '-id');
- remodal.settings = $.extend({}, DEFAULTS, options);
- remodal.index = $[PLUGIN_NAME].lookup.push(remodal) - 1;
- remodal.state = STATES.CLOSED; // remodal.$overlay = $('.' + namespacify('overlay'));
- if (remodal.settings.appendTo !== null && remodal.settings.appendTo.length) {
- $appendTo = $(remodal.settings.appendTo);
- }
- if (!remodal.$overlay) {
- remodal.$overlay = $('<div>').addClass(namespacify('overlay') + ' ' + namespacify('is', STATES.CLOSED)).hide();
- $appendTo.append(remodal.$overlay);
- }
- remodal.$bg = $('.' + namespacify('bg')).addClass(namespacify('is', STATES.CLOSED));
- remodal.$modal = $modal.addClass(NAMESPACE + ' ' + namespacify('is-initialized') + ' ' + remodal.settings.modifier + ' ' + namespacify('is', STATES.CLOSED)).attr('tabindex', '-1');
- remodal.$wrapper = $('<div>').addClass(namespacify('wrapper') + ' ' + remodal.settings.modifier + ' ' + namespacify('is', STATES.CLOSED)).hide().append(remodal.$modal);
- $appendTo.append(remodal.$wrapper); // Add the event listener for the close button
- remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="close"]', function (e) {
- e.preventDefault();
- remodal.close();
- }); // Add the event listener for the cancel button
- remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="cancel"]', function (e) {
- e.preventDefault();
- remodal.$modal.trigger(STATE_CHANGE_REASONS.CANCELLATION);
- if (remodal.settings.closeOnCancel) {
- remodal.close(STATE_CHANGE_REASONS.CANCELLATION);
- }
- }); // Add the event listener for the confirm button
- remodal.$wrapper.on('click.' + NAMESPACE, '[data-' + PLUGIN_NAME + '-action="confirm"]', function (e) {
- e.preventDefault();
- remodal.$modal.trigger(STATE_CHANGE_REASONS.CONFIRMATION);
- if (remodal.settings.closeOnConfirm) {
- remodal.close(STATE_CHANGE_REASONS.CONFIRMATION);
- }
- }); // Add the event listener for the overlay
- remodal.$wrapper.on('click.' + NAMESPACE, function (e) {
- var $target = $(e.target);
- var isWrapper = $target.hasClass(namespacify('wrapper'));
- var isWithin = $target.closest('.' + namespacify('is', STATES.OPENED)).length;
- if (!isWrapper && isWithin) {
- return;
- }
- if (remodal.settings.closeOnOutsideClick) {
- remodal.close();
- }
- });
- }
- /**
- * Opens a modal window
- * @public
- */
- Remodal.prototype.open = function () {
- var remodal = this;
- var current;
- var modalCount; // Check if the animation was completed
- if (remodal.state === STATES.OPENING || remodal.state === STATES.CLOSING) {
- return;
- } // id = remodal.$modal.attr('data-' + PLUGIN_NAME + '-id');
- if (remodal.id && remodal.settings.hashTracking) {
- scrollTop = $(window).scrollTop();
- location.hash = remodal.id;
- }
- if (!remodal.settings.stack) {
- current = currentModal();
- if (current && current !== remodal) {
- halt(current);
- }
- }
- modalCount = openModals.push(remodal);
- remodal.$overlay.css('z-index', function (_, value) {
- return parseInt(value, 10) + modalCount;
- });
- remodal.$wrapper.css('z-index', function (_, value) {
- return parseInt(value, 10) + modalCount;
- });
- lockScreen();
- remodal.$bg.addClass(remodal.settings.modifier);
- remodal.$overlay.addClass(remodal.settings.modifier).show();
- remodal.$wrapper.show().scrollTop(0);
- remodal.$modal.focus();
- syncWithAnimation(function () {
- setState(remodal, STATES.OPENING);
- }, function () {
- setState(remodal, STATES.OPENED);
- }, remodal);
- };
- /**
- * Closes a modal window
- * @public
- * @param {String} reason
- */
- Remodal.prototype.close = function (reason) {
- var remodal = this;
- var current; // Check if the animation was completed
- if (remodal.state === STATES.OPENING || remodal.state === STATES.CLOSING || remodal.state === STATES.CLOSED) {
- return;
- }
- removeModal(remodal);
- if (remodal.settings.hashTracking && remodal.id === location.hash.substr(1)) {
- current = currentModal();
- if (current) {
- location.hash = current.id;
- } else {
- location.hash = '';
- $(window).scrollTop(scrollTop);
- }
- }
- syncWithAnimation(function () {
- setState(remodal, STATES.CLOSING, false, reason);
- }, function () {
- remodal.$bg.removeClass(remodal.settings.modifier);
- remodal.$overlay.removeClass(remodal.settings.modifier).hide();
- remodal.$wrapper.hide();
- if (openModals.length === 0) {
- unlockScreen();
- }
- setState(remodal, STATES.CLOSED, false, reason);
- }, remodal);
- };
- /**
- * Returns a current state of a modal
- * @public
- * @returns {STATES}
- */
- Remodal.prototype.getState = function () {
- return this.state;
- };
- /**
- * Destroys a modal
- * @public
- */
- Remodal.prototype.destroy = function () {
- var lookup = $[PLUGIN_NAME].lookup;
- var instanceCount;
- halt(this);
- this.$wrapper.remove();
- delete lookup[this.index];
- instanceCount = $.grep(lookup, function (instance) {
- return !!instance;
- }).length;
- if (instanceCount === 0) {
- this.$overlay.remove();
- this.$bg.removeClass(namespacify('is', STATES.CLOSING) + ' ' + namespacify('is', STATES.OPENING) + ' ' + namespacify('is', STATES.CLOSED) + ' ' + namespacify('is', STATES.OPENED));
- }
- };
- /**
- * Special plugin object for instances
- * @public
- * @type {Object}
- */
- $[PLUGIN_NAME] = {
- lookup: []
- };
- /**
- * Plugin constructor
- * @constructor
- * @param {Object} options
- * @returns {JQuery}
- */
- $.fn[PLUGIN_NAME] = function (opts) {
- var instance;
- var $elem;
- this.each(function (index, elem) {
- $elem = $(elem);
- if ($elem.data(PLUGIN_NAME) == null) {
- instance = new Remodal($elem, opts);
- $elem.data(PLUGIN_NAME, instance.index);
- if (instance.settings.hashTracking && instance.id === location.hash.substr(1)) {
- instance.open();
- }
- } else {
- instance = $[PLUGIN_NAME].lookup[$elem.data(PLUGIN_NAME)];
- }
- });
- return instance;
- };
- $(document).ready(function () {
- // data-remodal-target opens a modal window with the special Id
- $(document).on('click', '[data-' + PLUGIN_NAME + '-target]', function (e) {
- e.preventDefault();
- var elem = e.currentTarget;
- var id = elem.getAttribute('data-' + PLUGIN_NAME + '-target');
- var $target = $('[data-' + PLUGIN_NAME + '-id="' + id + '"]');
- $[PLUGIN_NAME].lookup[$target.data(PLUGIN_NAME)].open();
- }); // Auto initialization of modal windows
- // They should have the 'remodal' class attribute
- // Also you can write the `data-remodal-options` attribute to pass params into the modal
- $(document).find('.' + NAMESPACE).each(function (i, container) {
- var $container = $(container);
- var options = $container.data(PLUGIN_NAME + '-options');
- if (!options) {
- options = {};
- } else if (typeof options === 'string' || options instanceof String) {
- options = parseOptions(options);
- }
- $container[PLUGIN_NAME](options);
- }); // Handles the keydown event
- $(document).on('keydown.' + NAMESPACE, function (e) {
- var current = currentModal();
- if (current && current.settings.closeOnEscape && current.state === STATES.OPENED && e.keyCode === 27) {
- current.close();
- }
- }); // Handles the hashchange event
- $(window).on('hashchange.' + NAMESPACE, handleHashChangeEvent);
- });
- });
- // EXTERNAL MODULE: ./node_modules/simplebar/dist/simplebar.min.js
- var simplebar_min = __webpack_require__(85766);
- // EXTERNAL MODULE: ./node_modules/dropzone/dist/dropzone.js
- var dist_dropzone = __webpack_require__(32025);
- var dropzone_default = /*#__PURE__*/__webpack_require__.n(dist_dropzone);
- // EXTERNAL MODULE: ./node_modules/toastr/toastr.js
- var toastr = __webpack_require__(8901);
- var toastr_default = /*#__PURE__*/__webpack_require__.n(toastr);
- ;// CONCATENATED MODULE: ./app/utils/toastr.js
- (toastr_default()).options.positionClass = 'toast-top-right';
- (toastr_default()).options.preventDuplicates = true;
- /* harmony default export */ const utils_toastr = ((toastr_default()));
- ;// CONCATENATED MODULE: ./app/utils/offline.js
- var offlineElement = external_jQuery_default()('#offline-status');
- external_jQuery_default()(window).on('offline', function () {
- offlineElement.slideDown();
- });
- external_jQuery_default()(window).on('online', function () {
- offlineElement.slideUp();
- });
- external_jQuery_default()(document).ready(function () {
- if (!offline) {
- offlineElement.slideDown();
- }
- }); // assume online if can't check
- /* harmony default export */ const offline = (typeof __webpack_require__.g.navigator.onLine !== 'undefined' ? __webpack_require__.g.navigator.onLine : true);
- ;// CONCATENATED MODULE: external "GravAdmin"
- const external_GravAdmin_namespaceObject = GravAdmin;
- // EXTERNAL MODULE: ./node_modules/mout/string/trim.js
- var trim = __webpack_require__(78579);
- var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
- ;// CONCATENATED MODULE: ./app/utils/response.js
- var UNLOADING = false;
- var error = function error(response) {
- var error = new Error(response.statusText || response || '');
- error.response = response;
- return error;
- };
- function parseStatus(response) {
- return response;
- /* Whoops can handle JSON responses so we don't need this for now.
- if (response.status >= 200 && response.status < 300) {
- return response;
- } else {
- throw error(response);
- }
- */
- }
- function parseJSON(response) {
- return response.text().then(function (text) {
- var parsed = text;
- try {
- parsed = JSON.parse(text);
- } catch (error) {
- var content = document.createElement('div');
- content.innerHTML = text;
- var the_error = new Error();
- the_error.stack = trim_default()(content.innerText);
- throw the_error;
- }
- return parsed;
- });
- }
- function userFeedback(response) {
- if (UNLOADING) {
- return true;
- }
- var status = response.status || (response.error ? 'error' : '');
- var message = response.message || (response.error ? response.error.message : null);
- var settings = response.toastr || null;
- var backup;
- switch (status) {
- case 'unauthenticated':
- document.location.href = external_GravAdmin_namespaceObject.config.base_url_relative;
- throw error('Logged out');
- case 'unauthorized':
- status = 'error';
- message = message || 'Unauthorized.';
- break;
- case 'error':
- status = 'error';
- message = message || 'Unknown error.';
- break;
- case 'success':
- status = 'success';
- message = message || '';
- break;
- default:
- status = 'error';
- message = message || 'Invalid AJAX response.';
- break;
- }
- if (settings) {
- backup = Object.assign({}, utils_toastr.options);
- Object.keys(settings).forEach(function (key) {
- utils_toastr.options[key] = settings[key];
- });
- }
- if (message && (offline || !offline && status !== 'error')) {
- utils_toastr[status === 'success' ? 'success' : 'error'](message);
- }
- if (settings) {
- utils_toastr.options = backup;
- }
- return response;
- }
- function userFeedbackError(error) {
- if (UNLOADING) {
- return true;
- }
- var stack = error.stack ? "<pre><code>".concat(error.stack, "</code></pre>") : '';
- utils_toastr.error("Fetch Failed: <br /> ".concat(error.message, " ").concat(stack));
- console.error("".concat(error.message, " at ").concat(error.stack));
- }
- external_jQuery_default()(__webpack_require__.g).on('beforeunload._ajax', function () {
- UNLOADING = true;
- });
- ;// CONCATENATED MODULE: ./app/utils/request.js
- var raw;
- var request = function request(url) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
- return true;
- };
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
- if (options.method && options.method === 'post') {
- var data = new FormData();
- options.body = Object.assign({
- 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce
- }, options.body || {});
- Object.keys(options.body).map(function (key) {
- return data.append(key, options.body[key]);
- });
- options.body = data;
- }
- options = Object.assign({
- credentials: 'same-origin',
- headers: {
- 'Accept': 'application/json'
- }
- }, options);
- return fetch(url, options).then(function (response) {
- raw = response;
- return response;
- }).then(parseStatus).then(parseJSON).then(userFeedback).then(function (response) {
- return callback(response, raw);
- })["catch"](userFeedbackError);
- };
- /* harmony default export */ const utils_request = (request);
- ;// CONCATENATED MODULE: ./app/forms/fields/files.js
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- // import EXIF from 'exif-js';
- // translations
- var Dictionary = {
- dictCancelUpload: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_CANCEL_UPLOAD,
- dictCancelUploadConfirmation: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_CANCEL_UPLOAD_CONFIRMATION,
- dictDefaultMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_DEFAULT_MESSAGE,
- dictFallbackMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FALLBACK_MESSAGE,
- dictFallbackText: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FALLBACK_TEXT,
- dictFileTooBig: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_FILE_TOO_BIG,
- dictInvalidFileType: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_INVALID_FILE_TYPE,
- dictMaxFilesExceeded: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_MAX_FILES_EXCEEDED,
- dictRemoveFile: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_REMOVE_FILE,
- dictResponseError: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROPZONE_RESPONSE_ERROR
- };
- (dropzone_default()).autoDiscover = false;
- (dropzone_default()).options.gravPageDropzone = {};
- (dropzone_default()).confirm = function (question, accepted, rejected) {
- var doc = external_jQuery_default()(document);
- var modalSelector = '[data-remodal-id="delete-media"]';
- var removeEvents = function removeEvents() {
- doc.off('confirmation', modalSelector, accept);
- doc.off('cancellation', modalSelector, reject);
- external_jQuery_default()(modalSelector).find('.remodal-confirm').removeClass('pointer-events-disabled');
- };
- var accept = function accept() {
- accepted && accepted();
- removeEvents();
- };
- var reject = function reject() {
- rejected && rejected();
- removeEvents();
- };
- (external_jQuery_default()).remodal.lookup[external_jQuery_default()(modalSelector).data('remodal')].open();
- doc.on('confirmation', modalSelector, accept);
- doc.on('cancellation', modalSelector, reject);
- };
- var DropzoneMediaConfig = {
- timeout: 0,
- thumbnailWidth: 200,
- thumbnailHeight: 150,
- addRemoveLinks: false,
- dictDefaultMessage: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DROP_FILES_HERE_TO_UPLOAD.replace(/</g, '<').replace(/>/g, '>'),
- dictRemoveFileConfirmation: '[placeholder]',
- 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()
- }; // global.EXIF = EXIF;
- var ACCEPT_FUNC = function ACCEPT_FUNC(file, done, settings) {
- var resolution = settings.resolution;
- if (!resolution) return done();
- var reader = new FileReader();
- var error = '';
- var hasMin = resolution.min && (resolution.min.width || resolution.min.height);
- var hasMax = resolution.max && (resolution.max.width || resolution.max.height);
- if (hasMin || !(settings.resizeWidth || settings.resizeHeight) && hasMax) {
- reader.onload = function (event) {
- if (!/image\//.test(file.type)) {
- done();
- return;
- }
- var image = new Image();
- image.src = event.target.result;
- image.onerror = function () {
- done(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_UPLOAD);
- };
- image.onload = function () {
- var _this = this;
- if (resolution.min) {
- Object.keys(resolution.min).forEach(function (attr) {
- if (resolution.min[attr] && _this[attr] < resolution.min[attr]) {
- error += external_GravAdmin_namespaceObject.translations.PLUGIN_FORM.RESOLUTION_MIN.replace(/{{attr}}/g, attr).replace(/{{min}}/g, resolution.min[attr]);
- }
- });
- }
- if (!(settings.resizeWidth || settings.resizeHeight)) {
- if (resolution.max) {
- Object.keys(resolution.max).forEach(function (attr) {
- if (resolution.max[attr] && _this[attr] > resolution.max[attr]) {
- error += external_GravAdmin_namespaceObject.translations.PLUGIN_FORM.RESOLUTION_MAX.replace(/{{attr}}/g, attr).replace(/{{max}}/g, resolution.max[attr]);
- }
- });
- }
- }
- URL.revokeObjectURL(image.src); // release memory
- return error ? done(error) : done();
- };
- };
- reader.readAsDataURL(file);
- } else {
- return error ? done(error) : done();
- }
- };
- var FilesField = /*#__PURE__*/function () {
- function FilesField() {
- var _this2 = this;
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref$container = _ref.container,
- container = _ref$container === void 0 ? '.dropzone.files-upload' : _ref$container,
- _ref$options = _ref.options,
- options = _ref$options === void 0 ? {} : _ref$options;
- _classCallCheck(this, FilesField);
- this.container = external_jQuery_default()(container);
- if (!this.container.length) {
- return;
- }
- this.urls = {};
- this.customPost = this.container.data('filePostAdd') || {};
- this.options = Object.assign({}, Dictionary, DropzoneMediaConfig, {
- klass: this,
- url: this.container.data('file-url-add') || external_GravAdmin_namespaceObject.config.current_url,
- acceptedFiles: this.container.data('media-types'),
- init: this.initDropzone
- }, this.container.data('dropzone-options'), options);
- this.options = Object.assign({}, this.options, {
- accept: function accept(file, done) {
- ACCEPT_FUNC(file, done, this.options);
- }
- });
- this.dropzone = new (dropzone_default())(container, this.options);
- this.dropzone.on('complete', this.onDropzoneComplete.bind(this));
- this.dropzone.on('success', this.onDropzoneSuccess.bind(this));
- this.dropzone.on('addedfile', this.onDropzoneAddedFile.bind(this));
- this.dropzone.on('removedfile', this.onDropzoneRemovedFile.bind(this));
- this.dropzone.on('sending', this.onDropzoneSending.bind(this));
- this.dropzone.on('error', this.onDropzoneError.bind(this));
- this.container.on('mouseenter', '[data-dz-view]', function (e) {
- var value = JSON.parse(_this2.container.find('[name][type="hidden"]').val() || '{}');
- var target = external_jQuery_default()(e.currentTarget);
- var file = target.parent('.dz-preview').find('.dz-filename');
- var filename = encodeURI(file.text());
- var URL = Object.keys(value).filter(function (key) {
- return value[key].name === filename;
- }).shift();
- target.attr('href', "".concat(external_GravAdmin_namespaceObject.config.base_url_simple, "/").concat(URL));
- });
- }
- _createClass(FilesField, [{
- key: "initDropzone",
- value: function initDropzone() {
- var _this3 = this;
- var files = this.options.klass.container.find('[data-file]');
- var dropzone = this;
- if (!files.length) {
- return;
- }
- files.each(function (index, file) {
- file = external_jQuery_default()(file);
- var data = file.data('file');
- var mock = {
- name: data.name,
- size: data.size,
- type: data.type,
- status: (dropzone_default()).ADDED,
- accepted: true,
- url: _this3.options.url,
- removeUrl: data.remove
- };
- dropzone.files.push(mock);
- dropzone.options.addedfile.call(dropzone, mock);
- if (mock.type.match(/^image\//)) {
- dropzone.options.thumbnail.call(dropzone, mock, data.path);
- dropzone.createThumbnailFromUrl(mock, data.path);
- }
- file.remove();
- });
- }
- }, {
- key: "getURI",
- value: function getURI() {
- return this.container.data('mediaUri') || '';
- }
- }, {
- key: "onDropzoneSending",
- value: function onDropzoneSending(file, xhr, formData) {
- var _this4 = this;
- if (Object.keys(this.customPost).length) {
- Object.keys(this.customPost).forEach(function (key) {
- formData.append(key, _this4.customPost[key]);
- });
- } else {
- formData.append('name', this.options.dotNotation);
- formData.append('task', 'filesupload');
- formData.append('uri', this.getURI());
- }
- formData.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
- }
- }, {
- key: "onDropzoneSuccess",
- value: function onDropzoneSuccess(file, response, xhr) {
- response = typeof response === 'string' ? JSON.parse(response) : response;
- if (this.options.reloadPage) {
- __webpack_require__.g.location.reload();
- } // store params for removing file from session before it gets saved
- if (response.session) {
- file.sessionParams = response.session;
- file.removeUrl = this.options.url; // Touch field value to force a mutation detection
- var input = this.container.find('[name][type="hidden"]');
- var value = input.val();
- input.val(value + ' ');
- }
- return this.handleError({
- file: file,
- data: response,
- mode: 'removeFile',
- msg: "<p>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_UPLOAD, " <strong>{{fileName}}</strong></p>\n <pre>").concat(response.message, "</pre>")
- });
- }
- }, {
- key: "onDropzoneComplete",
- value: function onDropzoneComplete(file) {
- if (!file.accepted && !file.rejected) {
- var data = {
- status: 'error',
- message: "".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_UNSUPPORTED, ": ").concat(file.name.match(/\..+/).join(''))
- };
- return this.handleError({
- file: file,
- data: data,
- mode: 'removeFile',
- msg: "<p>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FILE_ERROR_ADD, " <strong>{{fileName}}</strong></p>\n <pre>").concat(data.message, "</pre>")
- });
- }
- if (this.options.reloadPage) {
- __webpack_require__.g.location.reload();
- }
- }
- }, {
- key: "b64_to_utf8",
- value: function b64_to_utf8(str) {
- str = str.replace(/\s/g, '');
- return decodeURIComponent(escape(window.atob(str)));
- }
- }, {
- key: "onDropzoneAddedFile",
- value: function onDropzoneAddedFile(file) {
- return this.dropzone.options.addedfile(file);
- }
- }, {
- key: "onDropzoneRemovedFile",
- value: function onDropzoneRemovedFile(file) {
- var _this5 = this;
- if (!file.accepted || file.rejected) {
- return;
- }
- var url = file.removeUrl || this.urls["delete"] || this.options.url;
- var path = (url || '').match(/path:(.*)\//);
- var body = {
- filename: file.name,
- uri: this.getURI()
- };
- if (file.sessionParams) {
- body.task = 'filessessionremove';
- body.session = file.sessionParams;
- }
- var customPost = this.container.data('filePostRemove') || {};
- if (Object.keys(customPost).length) {
- body = {};
- Object.keys(customPost).forEach(function (key) {
- body[key] = customPost[key];
- });
- }
- body['filename'] = file.name;
- body['admin-nonce'] = external_GravAdmin_namespaceObject.config.admin_nonce;
- utils_request(url, {
- method: 'post',
- body: body
- }, function () {
- if (!path) {
- return;
- }
- path = _this5.b64_to_utf8(path[1]);
- var input = _this5.container.find('[name][type="hidden"]');
- var data = JSON.parse(input.val() || '{}');
- delete data[path];
- input.val(JSON.stringify(data));
- });
- }
- }, {
- key: "onDropzoneError",
- value: function onDropzoneError(file, response, xhr) {
- var message = xhr ? response.error.message : response;
- external_jQuery_default()(file.previewElement).find('[data-dz-errormessage]').html(message);
- return this.handleError({
- file: file,
- data: {
- status: 'error'
- },
- msg: "<pre>".concat(message, "</pre>")
- });
- }
- }, {
- key: "handleError",
- value: function handleError(options) {
- var file = options.file,
- data = options.data,
- mode = options.mode,
- msg = options.msg;
- if (data.status !== 'error' && data.status !== 'unauthorized') {
- return;
- }
- switch (mode) {
- case 'addBack':
- if (file instanceof File) {
- this.dropzone.addFile.call(this.dropzone, file);
- } else {
- this.dropzone.files.push(file);
- this.dropzone.options.addedfile.call(this.dropzone, file);
- this.dropzone.options.thumbnail.call(this.dropzone, file, file.extras.url);
- }
- break;
- case 'removeFile':
- default:
- if (~this.dropzone.files.indexOf(file)) {
- file.rejected = true;
- this.dropzone.removeFile.call(this.dropzone, file, {
- silent: true
- });
- }
- break;
- }
- var modal = external_jQuery_default()('[data-remodal-id="generic"]');
- var cleanName = file.name.replace('<', '<').replace('>', '>');
- modal.find('.error-content').html(msg.replace('{{fileName}}', cleanName));
- (external_jQuery_default()).remodal.lookup[modal.data('remodal')].open();
- }
- }]);
- return FilesField;
- }();
- function UriToMarkdown(uri) {
- uri = uri.replace(/@3x|@2x|@1x/, '');
- uri = uri.replace(/\(/g, '%28');
- uri = uri.replace(/\)/g, '%29');
- var title = uri.split('.').slice(0, -1).join('.');
- 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, ")");
- }
- var instances = [];
- var cache = external_jQuery_default()();
- var onAddedNodes = function onAddedNodes(event, target
- /* , record, instance */
- ) {
- var files = external_jQuery_default()(target).find('.dropzone.files-upload');
- if (!files.length) {
- return;
- }
- files.each(function (index, file) {
- file = external_jQuery_default()(file);
- if (!~cache.index(file)) {
- addNode(file);
- }
- });
- };
- var addNode = function addNode(container) {
- container = external_jQuery_default()(container);
- var input = container.find('input[type="file"]');
- var settings = container.data('grav-file-settings') || {};
- if (settings.accept && ~settings.accept.indexOf('*')) {
- settings.accept = [''];
- }
- var options = {
- url: container.data('file-url-add') || (container.closest('form').attr('action') || external_GravAdmin_namespaceObject.config.current_url) + '.json',
- paramName: settings.paramName || 'file',
- dotNotation: settings.name || 'file',
- acceptedFiles: settings.accept ? settings.accept.join(',') : input.attr('accept') || container.data('media-types'),
- maxFilesize: typeof settings.filesize !== 'undefined' ? settings.filesize : 256,
- maxFiles: settings.limit || null,
- resizeWidth: settings.resizeWidth || null,
- resizeHeight: settings.resizeHeight || null,
- resizeQuality: settings.resizeQuality || null,
- resolution: settings.resolution || null,
- accept: function accept(file, done) {
- ACCEPT_FUNC(file, done, settings);
- }
- };
- cache = cache.add(container);
- container = container[0];
- instances.push(new FilesField({
- container: container,
- options: options
- }));
- };
- var Instance = function () {
- external_jQuery_default()('.dropzone.files-upload').each(function (i, container) {
- return addNode(container);
- });
- external_jQuery_default()('body').on('mutation._grav', onAddedNodes);
- return instances;
- }();
- // EXTERNAL MODULE: ./node_modules/events/events.js
- var events = __webpack_require__(17187);
- var events_default = /*#__PURE__*/__webpack_require__.n(events);
- ;// CONCATENATED MODULE: ./app/utils/gpm.js
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
- function gpm_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function gpm_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function gpm_createClass(Constructor, protoProps, staticProps) { if (protoProps) gpm_defineProperties(Constructor.prototype, protoProps); if (staticProps) gpm_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
- 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); }; }
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- 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; } }
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
- var GPM = /*#__PURE__*/function (_EventEmitter) {
- _inherits(GPM, _EventEmitter);
- var _super = _createSuper(GPM);
- function GPM() {
- var _this;
- var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'getUpdates';
- gpm_classCallCheck(this, GPM);
- _this = _super.call(this);
- _this.payload = {};
- _this.raw = {};
- _this.action = action;
- return _this;
- }
- gpm_createClass(GPM, [{
- key: "setPayload",
- value: function setPayload() {
- var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- this.payload = payload;
- this.emit('payload', payload);
- return this;
- }
- }, {
- key: "setAction",
- value: function setAction() {
- var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'getUpdates';
- this.action = action;
- this.emit('action', action);
- return this;
- }
- }, {
- key: "fetch",
- value: function (_fetch) {
- function fetch() {
- return _fetch.apply(this, arguments);
- }
- fetch.toString = function () {
- return _fetch.toString();
- };
- return fetch;
- }(function () {
- var _this2 = this;
- var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
- return true;
- };
- var flush = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- var data = new FormData();
- data.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
- if (flush) {
- data.append('flush', true);
- }
- this.emit('fetching', this);
- fetch("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/update.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getUpdates"), {
- credentials: 'same-origin',
- method: 'post',
- body: data
- }).then(function (response) {
- _this2.raw = response;
- return response;
- }).then(parseStatus).then(parseJSON).then(function (response) {
- return _this2.response(response);
- }).then(function (response) {
- return callback(response, _this2.raw);
- }).then(function (response) {
- return _this2.emit('fetched', _this2.payload, _this2.raw, _this2);
- })["catch"](userFeedbackError);
- })
- }, {
- key: "response",
- value: function response(_response) {
- this.payload = _response;
- return _response;
- }
- }]);
- return GPM;
- }((events_default()));
- var gpm_Instance = new GPM();
- ;// CONCATENATED MODULE: ./app/utils/keepalive.js
- function keepalive_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function keepalive_createClass(Constructor, protoProps, staticProps) { if (protoProps) keepalive_defineProperties(Constructor.prototype, protoProps); if (staticProps) keepalive_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var MAX_SAFE_DELAY = 2147483647;
- var KeepAlive = /*#__PURE__*/function () {
- function KeepAlive() {
- keepalive_classCallCheck(this, KeepAlive);
- this.active = false;
- }
- keepalive_createClass(KeepAlive, [{
- key: "start",
- value: function start() {
- var _this = this;
- var timeout = external_GravAdmin_namespaceObject.config.admin_timeout / 1.5 * 1000;
- this.timer = setInterval(function () {
- return _this.fetch();
- }, Math.min(timeout, MAX_SAFE_DELAY));
- this.active = true;
- }
- }, {
- key: "stop",
- value: function stop() {
- clearInterval(this.timer);
- this.active = false;
- }
- }, {
- key: "fetch",
- value: function (_fetch) {
- function fetch() {
- return _fetch.apply(this, arguments);
- }
- fetch.toString = function () {
- return _fetch.toString();
- };
- return fetch;
- }(function () {
- var data = new FormData();
- data.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
- fetch("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "keepAlive"), {
- credentials: 'same-origin',
- method: 'post',
- body: data
- })["catch"](userFeedbackError);
- })
- }]);
- return KeepAlive;
- }();
- /* harmony default export */ const keepalive = (new KeepAlive());
- // EXTERNAL MODULE: ./node_modules/mout/array/unique.js
- var unique = __webpack_require__(79863);
- var unique_default = /*#__PURE__*/__webpack_require__.n(unique);
- ;// CONCATENATED MODULE: ./app/updates/notifications.js
- function notifications_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function notifications_createClass(Constructor, protoProps, staticProps) { if (protoProps) notifications_defineProperties(Constructor.prototype, protoProps); if (staticProps) notifications_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var canFetchNotifications = function canFetchNotifications() {
- return external_GravAdmin_namespaceObject.config.notifications.enabled;
- };
- var notificationsFilters = function notificationsFilters() {
- return external_GravAdmin_namespaceObject.config.notifications.filters;
- };
- var Notifications = /*#__PURE__*/function () {
- function Notifications() {
- notifications_classCallCheck(this, Notifications);
- }
- notifications_createClass(Notifications, [{
- key: "fetch",
- value: // Grav.default.Notifications.fetch()
- function fetch() {
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref$filter = _ref.filter,
- filter = _ref$filter === void 0 ? notificationsFilters() : _ref$filter,
- _ref$refresh = _ref.refresh,
- refresh = _ref$refresh === void 0 ? false : _ref$refresh;
- if (!canFetchNotifications()) {
- return false;
- }
- var feed = external_jQuery_default()('#notifications');
- var loader = feed.find('.widget-loader');
- var content = feed.find('.widget-content > ul');
- loader.find('div').remove();
- loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
- loader.show();
- content.hide();
- var processNotifications = function processNotifications(response) {
- var notifications = response.notifications;
- external_jQuery_default()('#notifications').find('.widget-content > ul').empty();
- if (notifications) {
- Object.keys(notifications).forEach(function (location) {
- return Notifications.processLocation(location, notifications[location]);
- });
- }
- };
- utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getNotifications"), {
- method: 'post',
- body: {
- refresh: refresh,
- filter: filter
- }
- }, function (response) {
- processNotifications(response);
- })["catch"](function () {
- var widget = external_jQuery_default()('#notifications .widget-content');
- widget.find('.widget-loader').find('div').remove();
- widget.find('.widget-loader').append('<div>Failed to retrieve notifications</div>').find('.fa-spin').removeClass('fa-spin fa-refresh').addClass('fa-warning');
- });
- }
- }], [{
- key: "addShowAllInFeed",
- value: function addShowAllInFeed() {
- external_jQuery_default()('#notifications ul').append('<li class="show-all" data-notification-action="show-all-notifications">Show all</li>');
- }
- }, {
- key: "showNotificationInFeed",
- value: function showNotificationInFeed(notification) {
- var notifications = external_jQuery_default()('#notifications').removeClass('hidden');
- var loader = notifications.find('.widget-loader').hide();
- var content = notifications.find('.widget-content > ul').show();
- loader.find('div').remove();
- loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
- content.append(notification).find('li:nth-child(n+11)').addClass('hidden'); // hide all items > 10
- if (content.find('li.hidden').length) {
- Notifications.addShowAllInFeed();
- }
- }
- }, {
- key: "showNotificationInTop",
- value: function showNotificationInTop(notification) {
- var container = external_jQuery_default()('.top-notifications-container');
- var dummy = external_jQuery_default()('<div />').html(notification);
- container.removeClass('hidden').append(dummy.children());
- dummy.children().slideDown(150);
- }
- }, {
- key: "showNotificationInDashboard",
- value: function showNotificationInDashboard(notification) {
- var container = external_jQuery_default()('.dashboard-notifications-container');
- var dummy = external_jQuery_default()('<div />').html(notification);
- container.removeClass('hidden').append(dummy.children());
- dummy.children().slideDown(150);
- }
- }, {
- key: "showNotificationInPlugins",
- value: function showNotificationInPlugins(notification) {
- var container = external_jQuery_default()('.plugins-notifications-container');
- var dummy = external_jQuery_default()('<div />').html(notification);
- container.removeClass('hidden').append(dummy.children());
- dummy.children().slideDown(150);
- }
- }, {
- key: "showNotificationInThemes",
- value: function showNotificationInThemes(notification) {
- var container = external_jQuery_default()('.themes-notifications-container');
- var dummy = external_jQuery_default()('<div />').html(notification);
- container.removeClass('hidden').append(dummy.children());
- dummy.children().slideDown(150);
- }
- }, {
- key: "processLocation",
- value: function processLocation(location, notification) {
- switch (location) {
- case 'feed':
- Notifications.showNotificationInFeed(notification);
- break;
- case 'top':
- if (!notification.read) {
- Notifications.showNotificationInTop(notification);
- }
- break;
- case 'dashboard':
- if (!notification.read) {
- Notifications.showNotificationInDashboard(notification);
- }
- break;
- case 'plugins':
- if (!notification.read) {
- Notifications.showNotificationInPlugins(notification);
- }
- break;
- case 'themes':
- if (!notification.read) {
- Notifications.showNotificationInThemes(notification);
- }
- break;
- }
- }
- }]);
- return Notifications;
- }();
- var notifications = new Notifications();
- /* harmony default export */ const updates_notifications = (notifications);
- if (canFetchNotifications()) {
- notifications.fetch();
- /* Hide a notification and store it hidden */
- // <a href="#" data-notification-action="hide-notification" data-notification-id="${notification.id}" class="close hide-notification"><i class="fa fa-close"></i></a>
- external_jQuery_default()(document).on('click', '[data-notification-action="hide-notification"]', function (event) {
- var notification_id = external_jQuery_default()(event.target).parents('.hide-notification').data('notification-id');
- 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);
- utils_request(url, {
- method: 'post'
- }, function () {});
- external_jQuery_default()(event.target).parents('.single-notification').hide();
- });
- external_jQuery_default()(document).on('click', '[data-notification-action="hide-notification"]', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var notification = target.parent();
- notification.slideUp(function () {
- return notification.remove();
- });
- });
- external_jQuery_default()(document).on('click', '[data-notification-action="show-all-notifications"]', function (event) {
- external_jQuery_default()('#notifications .show-all').hide();
- external_jQuery_default()('#notifications .hidden').removeClass('hidden');
- });
- external_jQuery_default()(document).on('click', '[data-refresh="notifications"]', function (event) {
- event.preventDefault();
- notifications.fetch({
- filter: ['feed'],
- refresh: true
- });
- });
- }
- ;// CONCATENATED MODULE: ./app/updates/feed.js
- function feed_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function feed_createClass(Constructor, protoProps, staticProps) { if (protoProps) feed_defineProperties(Constructor.prototype, protoProps); if (staticProps) feed_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getNewsFeed");
- var Feed = /*#__PURE__*/function () {
- function Feed() {
- feed_classCallCheck(this, Feed);
- this.data = null;
- }
- feed_createClass(Feed, [{
- key: "fetch",
- value: function fetch() {
- var _this = this;
- var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
- utils_request(URI, {
- method: 'post',
- body: {
- refresh: refresh
- }
- }, function (response) {
- _this.data = response;
- callback(response);
- });
- }
- }, {
- key: "refresh",
- value: function refresh() {
- var _refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- var feed = external_jQuery_default()('#news-feed .widget-content');
- if (!feed.length) {
- return;
- }
- var loader = feed.find('.widget-loader');
- loader.find('div').remove();
- loader.find('.fa-warning').removeClass('fa-warning').addClass('fa-refresh fa-spin');
- loader.show();
- feed.find('> ul').hide();
- if (!this.data || this.data.error || _refresh) {
- this.fetch(_refresh, this.updateContent.bind(this));
- } else {
- this.updateContent();
- }
- }
- }, {
- key: "updateContent",
- value: function updateContent() {
- var feed = external_jQuery_default()('#news-feed .widget-content');
- if (!feed.length) {
- return;
- }
- var loader = feed.find('.widget-loader').hide();
- var content = feed.find('> ul').empty().show();
- if (this.data.error || this.data.status === 'error') {
- loader.show().find('div').remove();
- loader.find('.fa-refresh').removeClass('fa-refresh fa-spin').addClass('fa-warning');
- loader.append("<div>".concat(this.data.error ? this.data.error.message : this.data.message || 'Unable to download news feed', "</div>"));
- return;
- }
- if (this.data && this.data.feed_data) {
- content.append(this.data.feed_data);
- }
- }
- }]);
- return Feed;
- }();
- var feed = new Feed();
- external_jQuery_default()(document).ready(function () {
- return feed.refresh();
- });
- external_jQuery_default()(document).on('click', '[data-refresh="feed"]', function (event) {
- event.preventDefault();
- feed.refresh(true);
- });
- /* harmony default export */ const updates_feed = (feed);
- ;// CONCATENATED MODULE: ./app/updates/check.js
- // Check for updates trigger
- external_jQuery_default()('[data-gpm-checkupdates]').on('click', function () {
- var element = external_jQuery_default()(this);
- element.find('i').addClass('fa-spin');
- gpm_Instance.fetch(function (response) {
- element.find('i').removeClass('fa-spin');
- var payload = response.payload;
- if (!payload) {
- return;
- }
- if (!payload.grav.isUpdatable && !payload.resources.total) {
- utils_toastr.success(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.EVERYTHING_UP_TO_DATE);
- } else {
- var grav = payload.grav.isUpdatable ? 'Grav v' + payload.grav.available : '';
- var resources = payload.resources.total ? payload.resources.total + ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATES_ARE_AVAILABLE : '';
- if (!resources) {
- grav += ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IS_AVAILABLE_FOR_UPDATE;
- }
- utils_toastr.info(grav + (grav && resources ? ' ' + external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.AND + ' ' : '') + resources);
- }
- }, true);
- });
- ;// CONCATENATED MODULE: ./app/utils/formatbytes.js
- var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
- function formatBytes(bytes, decimals) {
- if (bytes === 0) return '0 Byte';
- var k = 1000;
- var value = Math.floor(Math.log(bytes) / Math.log(k));
- var decimal = decimals + 1 || 3;
- return (bytes / Math.pow(k, value)).toPrecision(decimal) + ' ' + sizes[value];
- }
- ;// CONCATENATED MODULE: ./app/updates/update.js
- // Dashboard update and Grav update
- external_jQuery_default()(document).on('click.remodal', '[data-remodal-id="update-grav"] [data-remodal-action="confirm"]', function () {
- var element = external_jQuery_default()('#grav-update-button');
- element.html("".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATING_PLEASE_WAIT, " ").concat(formatBytes(updates_Instance.payload.grav.assets["grav-update"].size), ".."));
- element.attr('disabled', 'disabled').find('> .fa').removeClass('fa-cloud-download').addClass('fa-refresh fa-spin');
- utils_request(updates_Instance.updateURL, function (response) {
- if (response.type === 'updategrav') {
- external_jQuery_default()('[data-gpm-grav]').remove();
- external_jQuery_default()('#footer .grav-version').html(response.version);
- }
- element.removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin').addClass('fa-cloud-download');
- });
- });
- ;// CONCATENATED MODULE: ./app/updates/channel-switcher.js
- var switcher = external_jQuery_default()('input[type="radio"][name="channel-switch"]');
- if (switcher) {
- switcher.on('change', function (event) {
- var radio = external_jQuery_default()(event.target);
- var url = "".concat(radio.parent('[data-url]').data('url'));
- utils_request(url, {
- method: 'post',
- body: {
- task: 'gpmRelease',
- release: radio.val()
- }
- }, function (response) {
- if (response.reload) {
- __webpack_require__.g.location.reload();
- }
- });
- });
- }
- ;// CONCATENATED MODULE: ./app/updates/index.js
- function updates_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function updates_createClass(Constructor, protoProps, staticProps) { if (protoProps) updates_defineProperties(Constructor.prototype, protoProps); if (staticProps) updates_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var Updates = /*#__PURE__*/function () {
- function Updates() {
- var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- updates_classCallCheck(this, Updates);
- this.setPayload(payload);
- this.task = "task".concat(external_GravAdmin_namespaceObject.config.param_sep);
- this.updateURL = '';
- }
- updates_createClass(Updates, [{
- key: "setPayload",
- value: function setPayload() {
- var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- this.payload = payload;
- return this;
- }
- }, {
- key: "fetch",
- value: function fetch() {
- var _this = this;
- var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
- gpm_Instance.fetch(function (response) {
- return _this.setPayload(response);
- }, force);
- return this;
- }
- }, {
- key: "maintenance",
- value: function maintenance() {
- var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'hide';
- var element = external_jQuery_default()('#updates [data-update-packages]');
- element[mode === 'show' ? 'fadeIn' : 'fadeOut']();
- if (mode === 'hide') {
- external_jQuery_default()('.badges.with-updates').removeClass('with-updates').find('.badge.updates').remove();
- }
- return this;
- }
- }, {
- key: "grav",
- value: function grav() {
- var payload = this.payload.grav;
- if (payload && payload.isUpdatable) {
- var task = this.task;
- var bar = '';
- if (!payload.isSymlink) {
- 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);
- 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>");
- } else {
- 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>");
- }
- 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 ");
- var element = external_jQuery_default()('[data-gpm-grav]').removeClass('hidden');
- if (element.is(':empty')) {
- element.hide();
- }
- element.addClass('grav').html("".concat(bar)).slideDown(150, function () {
- var c = 5;
- var x = setInterval(function () {
- c -= 1;
- element.find('.pointer-events-none .cnt-down').text('(' + c + 's)');
- }, 1000);
- setTimeout(function () {
- clearInterval(x);
- element.find('.pointer-events-none .cnt-down').remove();
- element.find('.pointer-events-none').removeClass('pointer-events-none');
- }, 5000);
- }).parent('#messages').addClass('default-box-shadow');
- }
- return this;
- }
- }, {
- key: "resources",
- value: function resources() {
- if (!this.payload || !this.payload.resources || !this.payload.resources.total) {
- return this.maintenance('hide');
- }
- var is_current_package_latest = true;
- var map = ['plugins', 'themes'];
- var singles = ['plugin', 'theme'];
- var _this$payload$resourc = this.payload.resources,
- plugins = _this$payload$resourc.plugins,
- themes = _this$payload$resourc.themes;
- if (!this.payload.resources.total) {
- return this;
- }
- [plugins, themes].forEach(function (resources, index) {
- if (!resources || Array.isArray(resources)) {
- return;
- }
- var length = Object.keys(resources).length;
- var type = map[index]; // sidebar
- external_jQuery_default()("#admin-menu a[href$=\"/".concat(map[index], "\"]")).find('.badges').addClass('with-updates').find('.badge.updates').text(length);
- var type_translation = ''; // update all
- if (type === 'plugins') {
- type_translation = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PLUGINS;
- } else {
- type_translation = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.THEMES;
- }
- var updateAll = external_jQuery_default()(".grav-update.".concat(type));
- 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 "));
- var existing_slugs = external_jQuery_default()('[data-update-packages]').attr('data-packages-slugs') || '';
- if (existing_slugs) {
- existing_slugs = existing_slugs.split(',');
- } else {
- existing_slugs = [];
- }
- var slugs = unique_default()(existing_slugs.concat(Object.keys(resources))).join();
- external_jQuery_default()('[data-update-packages]').attr('data-packages-slugs', "".concat(slugs));
- Object.keys(resources).forEach(function (item) {
- // listing page
- var container = external_jQuery_default()("[data-gpm-".concat(singles[index], "=\"").concat(item, "\"]"));
- var element = container.find('.gpm-name');
- var url = element.find('a');
- var content_wrapper = container.parents('.content-wrapper');
- if (type === 'plugins' && !element.find('.badge.update').length) {
- 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>"));
- content_wrapper.addClass('has-updates');
- } else if (type === 'themes') {
- element.append("<div class=\"gpm-ribbon\"><a href=\"".concat(url.attr('href'), "\">").concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UPDATE.toUpperCase(), "</a></div>"));
- content_wrapper.addClass('has-updates');
- } // details page
- if (container.length) {
- var details = external_jQuery_default()(".grav-update.".concat(singles[index]));
- if (details.length) {
- var releaseType = resources[item].type === 'testing' ? '<span class="gpm-testing">test release</span>' : '';
- 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');
- is_current_package_latest = false;
- }
- }
- });
- external_jQuery_default()('[data-update-packages]').removeClass('hidden');
- });
- external_jQuery_default()('.content-wrapper').addClass('updates-checked');
- if (!is_current_package_latest) {
- external_jQuery_default()('.warning-reinstall-not-latest-release').removeClass('hidden');
- }
- }
- }]);
- return Updates;
- }();
- var updates_Instance = new Updates();
- // automatically refresh UI for updates (graph, sidebar, plugin/themes pages) after every fetch
- gpm_Instance.on('fetched', function (response, raw) {
- updates_Instance.setPayload(response.payload || {});
- updates_Instance.grav().resources();
- });
- if (external_GravAdmin_namespaceObject.config.enable_auto_updates_check === '1') {
- gpm_Instance.fetch();
- }
- // EXTERNAL MODULE: ./node_modules/chartist/dist/chartist.js
- var chartist = __webpack_require__(69259);
- var chartist_default = /*#__PURE__*/__webpack_require__.n(chartist);
- ;// CONCATENATED MODULE: ./app/dashboard/chart.js
- function chart_typeof(obj) { "@babel/helpers - typeof"; return chart_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, chart_typeof(obj); }
- function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = chart_getPrototypeOf(object); if (object === null) break; } return object; }
- function chart_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) chart_setPrototypeOf(subClass, superClass); }
- function chart_setPrototypeOf(o, p) { chart_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return chart_setPrototypeOf(o, p); }
- 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); }; }
- function chart_possibleConstructorReturn(self, call) { if (call && (chart_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return chart_assertThisInitialized(self); }
- function chart_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- 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; } }
- function chart_getPrototypeOf(o) { chart_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return chart_getPrototypeOf(o); }
- function chart_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function chart_createClass(Constructor, protoProps, staticProps) { if (protoProps) chart_defineProperties(Constructor.prototype, protoProps); if (staticProps) chart_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- // let isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
- var defaults = {
- data: {
- series: [100, 0]
- },
- options: {
- Pie: {
- donut: true,
- donutWidth: 10,
- startAngle: 0,
- total: 100,
- showLabel: false,
- height: 150,
- // chartPadding: !isFirefox ? 10 : 25 // workaround for older versions of firefox
- chartPadding: 5
- },
- Bar: {
- height: 164,
- chartPadding: 20,
- // workaround for older versions of firefox
- axisX: {
- showGrid: false,
- labelOffset: {
- x: 0,
- y: 0
- }
- },
- axisY: {
- offset: 15,
- showLabel: true,
- showGrid: true,
- labelOffset: {
- x: 5,
- y: 5
- },
- scaleMinSpace: 25
- }
- }
- }
- };
- var Chart = /*#__PURE__*/function () {
- function Chart(element) {
- var _this = this;
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- chart_classCallCheck(this, Chart);
- this.element = external_jQuery_default()(element) || [];
- if (!this.element[0]) {
- return;
- }
- var type = (this.element.data('chart-type') || 'pie').toLowerCase();
- this.type = type.charAt(0).toUpperCase() + type.substr(1).toLowerCase();
- options = Object.assign({}, defaults.options[this.type], options);
- data = Object.assign({}, defaults.data, data);
- Object.assign(this, {
- options: options,
- data: data
- });
- this.chart = (chartist_default())[this.type](this.element.find('.ct-chart').empty()[0], this.data, this.options);
- this.chart.on('created', function () {
- _this.element.find('.hidden').removeClass('hidden'); // FIX: workaround for chartist issue not allowing HTML in labels anymore
- // https://github.com/gionkunz/chartist-js/issues/937
- _this.element.find('.ct-label').each(function (index, label) {
- label = external_jQuery_default()(label);
- var text = label.html().replace('<', '<').replace('>', '>');
- label.html(text);
- });
- });
- }
- chart_createClass(Chart, [{
- key: "updateData",
- value: function updateData(data) {
- Object.assign(this.data, data);
- this.chart.update(this.data);
- }
- }]);
- return Chart;
- }();
- ;
- var UpdatesChart = /*#__PURE__*/function (_Chart) {
- chart_inherits(UpdatesChart, _Chart);
- var _super = chart_createSuper(UpdatesChart);
- function UpdatesChart(element) {
- var _this2;
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- chart_classCallCheck(this, UpdatesChart);
- _this2 = _super.call(this, element, options, data);
- _this2.chart.on('draw', function (data) {
- return _this2.draw(data);
- });
- gpm_Instance.on('fetched', function (response) {
- if (!response.payload) {
- return;
- }
- var payload = response.payload.grav;
- var missing = (response.payload.resources.total + (payload.isUpdatable ? 1 : 0)) * 100 / (response.payload.installed + (payload.isUpdatable ? 1 : 0));
- var updated = 100 - missing;
- _this2.updateData({
- series: [updated, missing]
- });
- if (response.payload.resources.total) {
- updates_Instance.maintenance('show');
- }
- });
- return _this2;
- }
- chart_createClass(UpdatesChart, [{
- key: "draw",
- value: function draw(data) {
- if (data.index) {
- return;
- }
- var notice = external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN[data.value === 100 ? 'FULLY_UPDATED' : 'UPDATES_AVAILABLE'];
- this.element.find('.numeric span').text("".concat(Math.round(data.value), "%"));
- this.element.find('.js__updates-available-description').html(notice);
- this.element.find('.hidden').removeClass('hidden');
- }
- }, {
- key: "updateData",
- value: function updateData(data) {
- _get(chart_getPrototypeOf(UpdatesChart.prototype), "updateData", this).call(this, data); // missing updates
- if (this.data.series[0] < 100) {
- this.element.closest('#updates').find('[data-update-packages]').fadeIn();
- }
- }
- }]);
- return UpdatesChart;
- }(Chart);
- var charts = {};
- external_jQuery_default()('[data-chart-name]').each(function () {
- var element = external_jQuery_default()(this);
- var name = element.data('chart-name') || '';
- var options = element.data('chart-options') || {};
- var data = element.data('chart-data') || {};
- if (name === 'updates') {
- charts[name] = new UpdatesChart(element, options, data);
- } else {
- charts[name] = new Chart(element, options, data);
- }
- });
- var Instances = charts;
- ;// CONCATENATED MODULE: ./app/dashboard/cache.js
- function cache_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function cache_createClass(Constructor, protoProps, staticProps) { if (protoProps) cache_defineProperties(Constructor.prototype, protoProps); if (staticProps) cache_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var getUrl = function getUrl() {
- var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
- if (type) {
- type = "cleartype:".concat(type, "/");
- }
- 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);
- };
- var Cache = /*#__PURE__*/function () {
- function Cache() {
- var _this = this;
- cache_classCallCheck(this, Cache);
- this.element = external_jQuery_default()('[data-clear-cache]');
- external_jQuery_default()('body').on('click', '[data-clear-cache]', function (event) {
- return _this.clear(event, event.target);
- });
- }
- cache_createClass(Cache, [{
- key: "clear",
- value: function clear(event, element) {
- var _this2 = this;
- var type = '';
- if (event && event.preventDefault) {
- event.preventDefault();
- }
- if (typeof event === 'string') {
- type = event;
- }
- element = element ? external_jQuery_default()(element) : external_jQuery_default()("[data-clear-cache-type=\"".concat(type, "\"]"));
- type = type || external_jQuery_default()(element).data('clear-cache-type') || '';
- var url = element.data('clearCache') || getUrl(type);
- this.disable();
- utils_request(url, function () {
- return _this2.enable();
- });
- }
- }, {
- key: "enable",
- value: function enable() {
- this.element.removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin fa-retweet').addClass('fa-retweet');
- }
- }, {
- key: "disable",
- value: function disable() {
- this.element.attr('disabled', 'disabled').find('> .fa').removeClass('fa-retweet').addClass('fa-refresh fa-spin');
- }
- }]);
- return Cache;
- }();
- var cache_Instance = new Cache();
- ;// CONCATENATED MODULE: ./app/dashboard/backup.js
- external_jQuery_default()('[data-backup][data-ajax*="backup/"]').on('click', function () {
- var element = external_jQuery_default()(this);
- var url = element.data('ajax');
- var inDropdown = element.closest('.dropdown-menu');
- (inDropdown.length ? inDropdown : element).closest('.button-group').find('> button:first').attr('disabled', 'disabled').find('> .fa').removeClass('fa-life-ring').addClass('fa-spin fa-refresh');
- utils_request(url, function
- /* response */
- () {
- if (Instances && Instances.backups) {
- Instances.backups.updateData({
- series: [0, 100]
- });
- Instances.backups.element.find('.numeric').html("0 <em>".concat(external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.DAYS.toLowerCase(), "</em>"));
- }
- (inDropdown.length ? inDropdown : element).closest('.button-group').find('> button:first').removeAttr('disabled').find('> .fa').removeClass('fa-spin fa-refresh').addClass('fa-life-ring');
- });
- });
- external_jQuery_default()('[data-backup][data-ajax*="backupDelete"]').on('click', function () {
- var element = external_jQuery_default()(this);
- var url = element.data('ajax');
- var tr = element.closest('tr');
- tr.addClass('deleting');
- utils_request(url, function (response) {
- if (response.status === 'success') {
- tr.remove();
- } else {
- tr.removeClass('deleting');
- }
- });
- });
- ;// CONCATENATED MODULE: ./app/dashboard/index.js
- /* harmony default export */ const dashboard = ({
- Chart: {
- Chart: Chart,
- UpdatesChart: UpdatesChart,
- Instances: Instances
- },
- Cache: cache_Instance
- });
- // EXTERNAL MODULE: ./node_modules/sortablejs/modular/sortable.esm.js
- var sortable_esm = __webpack_require__(51474);
- // EXTERNAL MODULE: ./node_modules/debounce/index.js
- var debounce = __webpack_require__(20296);
- var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce);
- // EXTERNAL MODULE: ./app/utils/storage.js
- var storage = __webpack_require__(31619);
- ;// CONCATENATED MODULE: ./app/pages/tree.js
- function tree_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function tree_createClass(Constructor, protoProps, staticProps) { if (protoProps) tree_defineProperties(Constructor.prototype, protoProps); if (staticProps) tree_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var sessionKey = 'grav:admin:pages';
- if (!sessionStorage.getItem(sessionKey)) {
- sessionStorage.setItem(sessionKey, '{}');
- }
- var PagesTree = /*#__PURE__*/function () {
- function PagesTree(query) {
- var _this = this;
- var elements = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
- tree_classCallCheck(this, PagesTree);
- this.query = query;
- this.elements = external_jQuery_default()(elements !== undefined ? elements : this.query);
- this.session = JSON.parse(sessionStorage.getItem(sessionKey) || '{}');
- if (!this.elements.length) {
- return;
- }
- this.restore();
- this.elements.find('.page-icon').on('click', function (event) {
- return _this.toggle(event.target);
- });
- this.elements.data('tree_init', 1);
- external_jQuery_default()('[data-page-toggleall]').on('click', function (event) {
- var element = external_jQuery_default()(event.target).closest('[data-page-toggleall]');
- var action = element.data('page-toggleall');
- _this[action]();
- });
- }
- tree_createClass(PagesTree, [{
- key: "reload",
- value: function reload() {
- var elements = external_jQuery_default()(this.query).filter(function (index, element) {
- return !external_jQuery_default()(element).data('tree_init');
- });
- if (!elements.length) {
- return;
- }
- this.constructor(this.query, elements);
- }
- }, {
- key: "toggle",
- value: function toggle(elements) {
- var _this2 = this;
- var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- if (typeof elements === 'string') {
- elements = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")).find('[data-toggle="children"]');
- }
- elements = external_jQuery_default()(elements || this.elements);
- elements.each(function (index, element) {
- element = external_jQuery_default()(element);
- var state = _this2.getState(element.closest('[data-toggle="children"]'));
- _this2[state.isOpen ? 'collapse' : 'expand'](state.id, dontStore);
- });
- }
- }, {
- key: "collapse",
- value: function collapse(elements) {
- var _this3 = this;
- var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- if (typeof elements === 'string') {
- elements = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]")).find('[data-toggle="children"]');
- }
- elements = external_jQuery_default()(elements || this.elements);
- elements.each(function (index, element) {
- element = external_jQuery_default()(element);
- var state = _this3.getState(element);
- if (state.isOpen) {
- state.children.hide();
- state.icon.removeClass('children-open').addClass('children-closed');
- if (!dontStore) {
- delete _this3.session[state.id];
- }
- }
- });
- if (!dontStore) {
- this.save();
- }
- }
- }, {
- key: "expand",
- value: function expand(elements) {
- var _this4 = this;
- var dontStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- if (typeof elements === 'string') {
- var element = external_jQuery_default()("[data-nav-id=\"".concat(elements, "\"]"));
- var parents = element.parents('[data-nav-id]'); // loop back through parents, we don't want to expand an hidden child
- if (parents.length) {
- parents = parents.find('[data-toggle="children"]:first');
- parents = parents.add(element.find('[data-toggle="children"]:first'));
- return this.expand(parents, dontStore);
- }
- elements = element.find('[data-toggle="children"]:first');
- }
- elements = external_jQuery_default()(elements || this.elements);
- elements.each(function (index, element) {
- element = external_jQuery_default()(element);
- var state = _this4.getState(element);
- if (!state.isOpen) {
- state.children.show();
- state.icon.removeClass('children-closed').addClass('children-open');
- if (!dontStore) {
- _this4.session[state.id] = 1;
- }
- }
- });
- if (!dontStore) {
- this.save();
- }
- }
- }, {
- key: "restore",
- value: function restore() {
- var _this5 = this;
- this.collapse(null, true);
- Object.keys(this.session).forEach(function (key) {
- _this5.expand(key, 'no-store');
- });
- }
- }, {
- key: "save",
- value: function save() {
- return sessionStorage.setItem(sessionKey, JSON.stringify(this.session));
- }
- }, {
- key: "getState",
- value: function getState(element) {
- element = external_jQuery_default()(element);
- return {
- id: element.closest('[data-nav-id]').data('nav-id'),
- children: element.closest('li.page-item').find('ul:first'),
- icon: element.find('.page-icon'),
- get isOpen() {
- return this.icon.hasClass('children-open');
- }
- };
- }
- }]);
- return PagesTree;
- }();
- var tree_Instance = new PagesTree('[data-toggle="children"]');
- // EXTERNAL MODULE: ./node_modules/selectize/dist/js/selectize.js
- var selectize = __webpack_require__(25703);
- var selectize_default = /*#__PURE__*/__webpack_require__.n(selectize);
- ;// CONCATENATED MODULE: ./app/utils/selectize-required-fix.js
- /**
- * This is a plugin to override the `.refreshValidityState` method of
- * the Selectize library (https://selectize.github.io/selectize.js/).
- * The library is not maintained anymore (as of 2017-09-13) and contains
- * a bug which causes Microsoft Edge to not work with selectized [required]
- * form fields. This plugin should be removed if
- * https://github.com/selectize/selectize.js/pull/1320 is ever merged
- * and a new version of Selectize gets released.
- */
- selectize_default().define('required-fix', function (options) {
- var _this = this;
- this.refreshValidityState = function () {
- if (!_this.isRequired) return false;
- var invalid = !_this.items.length;
- _this.isInvalid = invalid;
- if (invalid) {
- _this.$control_input.attr('required', '');
- _this.$input.removeAttr('required');
- } else {
- _this.$control_input.removeAttr('required');
- _this.$input.attr('required');
- }
- };
- });
- ;// CONCATENATED MODULE: ./app/pages/filter.js
- function filter_typeof(obj) { "@babel/helpers - typeof"; return filter_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, filter_typeof(obj); }
- function filter_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function filter_createClass(Constructor, protoProps, staticProps) { if (protoProps) filter_defineProperties(Constructor.prototype, protoProps); if (staticProps) filter_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- /* @formatter:off */
- /* eslint-disable */
- var options = [{
- flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.MODULE,
- key: 'Module',
- cat: 'mode'
- }, {
- flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.VISIBLE,
- key: 'Visible',
- cat: 'mode'
- }, {
- flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ROUTABLE,
- key: 'Routable',
- cat: 'mode'
- }, {
- flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PUBLISHED,
- key: 'Published',
- cat: 'mode'
- }, {
- flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_MODULE,
- key: 'NonModule',
- cat: 'mode'
- }, {
- flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_VISIBLE,
- key: 'NonVisible',
- cat: 'mode'
- }, {
- flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_ROUTABLE,
- key: 'NonRoutable',
- cat: 'mode'
- }, {
- flag: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.NON_PUBLISHED,
- key: 'NonPublished',
- cat: 'mode'
- }];
- /* @formatter:on */
- /* eslint-enable */
- var PagesFilter = /*#__PURE__*/function () {
- function PagesFilter(filters, search) {
- var _this = this;
- filter_classCallCheck(this, PagesFilter);
- this.filters = external_jQuery_default()(filters);
- this.search = external_jQuery_default()(search);
- this.options = options;
- this.tree = tree_Instance;
- var storage = JSON.parse(localStorage.getItem('grav:admin:pages:filter') || '{}');
- if (!this.filters.length || !this.search.length) {
- return;
- }
- this.labels = this.filters.data('filter-labels');
- this.search.on('input', debounce_default()(function () {
- return _this.filter();
- }, 250));
- this.filters.on('change', function () {
- return _this.filter();
- }); // restore state
- if (storage.flags || storage.query) {
- this.setValues(storage);
- this.filter();
- }
- this._initSelectize();
- }
- filter_createClass(PagesFilter, [{
- key: "filter",
- value: function filter(value) {
- var _this2 = this;
- var data = {
- flags: '',
- query: ''
- };
- if (filter_typeof(value) === 'object') {
- Object.assign(data, value);
- }
- if (typeof value === 'string') {
- data.query = value;
- }
- if (typeof value === 'undefined') {
- data.flags = this.filters.val();
- data.query = this.search.val();
- }
- if (!Object.keys(data).filter(function (key) {
- return data[key] !== '';
- }).length) {
- this.resetValues();
- return;
- }
- data.flags = data.flags.replace(/(\s{1,})?,(\s{1,})?/g, ',');
- this.setValues({
- flags: data.flags,
- query: data.query
- }, 'silent');
- utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/pages-filter.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "filterPages"), {
- method: 'post',
- body: data
- }, function (response) {
- _this2.refreshDOM(response);
- });
- }
- }, {
- key: "refreshDOM",
- value: function refreshDOM(response) {
- var _this3 = this;
- var items = external_jQuery_default()('[data-nav-id]');
- if (!response) {
- items.removeClass('search-match').show();
- this.tree.restore();
- return;
- }
- items.removeClass('search-match').hide();
- response.results.forEach(function (page) {
- var match = items.filter("[data-nav-id=\"".concat(page, "\"]")).addClass('search-match').show();
- match.parents('[data-nav-id]').addClass('search-match').show();
- _this3.tree.expand(page, 'no-store');
- });
- }
- }, {
- key: "setValues",
- value: function setValues(_ref, silent) {
- var _ref$flags = _ref.flags,
- flags = _ref$flags === void 0 ? '' : _ref$flags,
- _ref$query = _ref.query,
- query = _ref$query === void 0 ? '' : _ref$query;
- var flagsArray = flags.replace(/(\s{1,})?,(\s{1,})?/g, ',').split(',');
- if (this.filters.val() !== flags) {
- var selectize = this.filters.data('selectize');
- this.filters[selectize ? 'setValue' : 'val'](flagsArray, silent);
- }
- if (this.search.val() !== query) {
- this.search.val(query);
- }
- localStorage.setItem('grav:admin:pages:filter', JSON.stringify({
- flags: flags,
- query: query
- }));
- }
- }, {
- key: "resetValues",
- value: function resetValues() {
- this.setValues('', 'silent');
- this.refreshDOM();
- }
- }, {
- key: "_initSelectize",
- value: function _initSelectize() {
- var _this4 = this;
- var extras = {
- type: this.filters.data('filter-types') || {},
- access: this.filters.data('filter-access-levels') || {}
- };
- Object.keys(extras).forEach(function (cat) {
- Object.keys(extras[cat]).forEach(function (key) {
- _this4.options.push({
- cat: cat,
- key: key,
- flag: extras[cat][key]
- });
- });
- });
- this.filters.selectize({
- maxItems: null,
- valueField: 'key',
- labelField: 'flag',
- searchField: ['flag', 'key'],
- options: this.options,
- optgroups: this.labels,
- optgroupField: 'cat',
- optgroupLabelField: 'name',
- optgroupValueField: 'id',
- optgroupOrder: this.labels.map(function (item) {
- return item.id;
- }),
- plugins: ['optgroup_columns', 'required-fix']
- });
- }
- }]);
- return PagesFilter;
- }();
- var filter_Instance = new PagesFilter('input[name="page-filter"]', 'input[name="page-search"]');
- // EXTERNAL MODULE: ./node_modules/speakingurl/index.js
- var speakingurl = __webpack_require__(989);
- var speakingurl_default = /*#__PURE__*/__webpack_require__.n(speakingurl);
- ;// CONCATENATED MODULE: ./app/utils/jquery-utils.js
- var _this = undefined;
- // jQuery no parents filter
- (external_jQuery_default()).expr[":"].noparents = external_jQuery_default().expr.createPseudo(function (text) {
- return function (element) {
- return external_jQuery_default()(element).parents(text).length < 1;
- };
- }); // Slugify
- // CommonJS and ES6 version of https://github.com/madflow/jquery-slugify
- (external_jQuery_default()).fn.slugify = function (source, options) {
- return _this.each(function (element) {
- var target = external_jQuery_default()(element);
- var source = external_jQuery_default()(source);
- target.on('keyup change', function () {
- target.data('locked', target.val() !== '' && target.val() !== undefined);
- });
- source.on('keyup change', function () {
- if (target.data('locked') === true) {
- return true;
- }
- var isInput = target.is('input') || target.is('textarea');
- target[isInput ? 'val' : 'text'](external_jQuery_default().slugify(source.val(), options));
- });
- });
- }; // Static method.
- (external_jQuery_default()).slugify = function (sourceString, options) {
- options = external_jQuery_default().extend({}, (external_jQuery_default()).slugify.options, options);
- options.lang = options.lang || external_jQuery_default()('html').prop('lang');
- if (typeof options.preSlug === 'function') {
- sourceString = options.preSlug(sourceString);
- }
- sourceString = options.slugFunc(sourceString, options);
- if (typeof options.postSlug === 'function') {
- sourceString = options.postSlug(sourceString);
- }
- return sourceString;
- }; // Default plugin options
- (external_jQuery_default()).slugify.options = {
- preSlug: null,
- postSlug: null,
- slugFunc: function slugFunc(input, opts) {
- return speakingurl_default()(input, opts);
- }
- };
- ;// CONCATENATED MODULE: ./app/pages/page/add.js
- var custom = false;
- 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]"]');
- 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]"]');
- var getFields = function getFields(type, target) {
- target = external_jQuery_default()(target);
- var query = "[data-remodal-id=\"".concat(target.closest('[data-remodal-id]').data('remodal-id'), "\"]");
- return {
- title: type === 'title' ? external_jQuery_default()(target) : external_jQuery_default()("".concat(query, " input[name=\"data[title]\"]")),
- folder: type === 'folder' ? external_jQuery_default()(target) : external_jQuery_default()("".concat(query, " input[name=\"data[folder]\"]"))
- };
- };
- title.on('input focus blur', function (event) {
- if (custom) {
- return true;
- }
- var elements = getFields('title', event.currentTarget);
- var slug = external_jQuery_default().slugify(elements.title.val(), {
- custom: {
- "'": '',
- '‘': '',
- '’': ''
- }
- });
- elements.folder.val(slug);
- });
- folder.on('input', function (event) {
- var elements = getFields('folder', event.currentTarget);
- var input = elements.folder.get(0);
- var value = elements.folder.val();
- var selection = {
- start: input.selectionStart,
- end: input.selectionEnd
- };
- value = value.toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, '');
- elements.folder.val(value);
- custom = !!value; // restore cursor position
- input.setSelectionRange(selection.start, selection.end);
- });
- folder.on('focus blur', function (event) {
- getFields('title').title.trigger('input');
- });
- external_jQuery_default()(document).on('change', '[name="data[route]"]', function (event) {
- var rawroute = external_jQuery_default()(event.currentTarget).val();
- var pageTemplate = external_jQuery_default()('[name="data[name]"]');
- var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "getChildTypes");
- if (pageTemplate.length === 0) {
- return;
- }
- utils_request(URI, {
- method: 'post',
- body: {
- rawroute: rawroute
- }
- }, function (response) {
- var type = response.child_type;
- if (type !== '' && type !== 'default') {
- pageTemplate.val(type);
- pageTemplate.data('selectize').setValue(type);
- }
- });
- });
- ;// CONCATENATED MODULE: ./app/pages/page/move.js
- external_jQuery_default()(document).on('click', '[data-page-move] button[name="task"][value="save"]', function (event) {
- /* let route = $('form#blueprints:first select[name="data[route]"]');
- let moveTo = $('[data-page-move] select').val();
- if (route.length && route.val() !== moveTo) {
- let selectize = route.data('selectize');
- route.val(moveTo);
- if (selectize) selectize.setValue(moveTo);
- }*/
- var modal = external_jQuery_default()(event.currentTarget).closest('[data-remodal-id]');
- var parents = modal.data('parents') || {};
- var finder = parents.finder;
- if (!parents || !finder) {
- return true;
- }
- var field = parents.field;
- var parentLabel = parents.parentLabel;
- var parentName = parents.parentName;
- var selection = finder.findLastActive().item[0];
- var value = selection._item[finder.config.valueKey];
- var name = selection._item[finder.config.labelKey];
- field.val(value);
- parentLabel.text(value);
- parentName.text(name);
- finder.config.defaultPath = value;
- external_jQuery_default()('<div />').css({
- backgroundColor: 'rgba(255, 255, 255, 0.1)',
- position: 'fixed',
- top: 0,
- left: 0,
- width: '100vw',
- height: '100vh',
- zIndex: 15000
- }).appendTo(external_jQuery_default()('body'));
- });
- /*
- $(document).on('click', '[data-remodal-id="parents"] [data-parents-select]', (event) => {
- const modal = $(event.currentTarget).closest('[data-remodal-id]');
- const parents = modal.data('parents');
- const finder = parents.finder;
- const field = parents.field;
- const parentLabel = parents.parentLabel;
- const parentName = parents.parentName;
- const selection = finder.findLastActive().item[0];
- const value = selection._item[finder.config.valueKey];
- const name = selection._item[finder.config.labelKey];
- field.val(value);
- parentLabel.text(value);
- parentName.text(name);
- finder.config.defaultPath = value;
- const remodal = $.remodal.lookup[$(`[data-remodal-id="${modal.data('remodalId')}"]`).data('remodal')];
- remodal.close();
- });
- */
- ;// CONCATENATED MODULE: ./app/pages/page/delete.js
- external_jQuery_default()(document).on('click', '[data-remodal-target="delete"]', function () {
- var confirm = external_jQuery_default()('[data-remodal-id="delete"] [data-delete-action]');
- var link = external_jQuery_default()(this).data('delete-url');
- confirm.data('delete-action', link);
- });
- external_jQuery_default()(document).on('click', '[data-delete-action]', function () {
- var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id="delete"]').data('remodal')];
- __webpack_require__.g.location.href = external_jQuery_default()(this).data('delete-action');
- remodal.close();
- });
- ;// CONCATENATED MODULE: ./app/pages/page/unset.js
- external_jQuery_default()(document).on('click', '.dz-unset', function () {
- var file_upload = external_jQuery_default()(this).closest('.files-upload');
- external_jQuery_default()(this).closest('.dz-image-preview').remove();
- var unset_image = external_jQuery_default()(this).closest('.dz-image-preview').find('[data-dz-name]').text().trim();
- var images = JSON.parse(file_upload.find('input[data-grav-field="hidden"]').val()) || {};
- var image_array = {};
- external_jQuery_default().each(images, function (ind, obj) {
- if (!ind.endsWith(unset_image)) {
- image_array[ind] = obj;
- }
- });
- file_upload.find('input[data-grav-field="hidden"]').val(JSON.stringify(image_array));
- });
- ;// CONCATENATED MODULE: ./app/pages/page/disable-buttons.js
- external_jQuery_default()('.disable-after-click').on('click', function () {
- external_jQuery_default()(this).addClass('pointer-events-disabled');
- });
- ;// CONCATENATED MODULE: ./app/utils/cookies.js
- function cookies_typeof(obj) { "@babel/helpers - typeof"; return cookies_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, cookies_typeof(obj); }
- /*
- * Cookies.js - 1.2.3-grav
- * https://github.com/ScottHamper/Cookies
- *
- * With SameSite support by Grav
- *
- * This is free and unencumbered software released into the public domain.
- */
- var factory = function factory(window) {
- var _arguments = arguments;
- if (cookies_typeof(window.document) !== 'object') {
- throw new Error('Cookies.js requires a `window` with a `document` object');
- }
- var Cookies = function Cookies(key, value, options) {
- return _arguments.length === 1 ? Cookies.get(key) : Cookies.set(key, value, options);
- }; // Allows for setter injection in unit tests
- Cookies._document = window.document; // Used to ensure cookie keys do not collide with
- // built-in `Object` properties
- Cookies._cacheKeyPrefix = 'cookey.'; // Hurr hurr, :)
- Cookies._maxExpireDate = new Date('Fri, 31 Dec 9999 23:59:59 UTC');
- Cookies.defaults = {
- path: '/',
- secure: false,
- sameSite: 'Lax'
- };
- Cookies.get = function (key) {
- if (Cookies._cachedDocumentCookie !== Cookies._document.cookie) {
- Cookies._renewCache();
- }
- var value = Cookies._cache[Cookies._cacheKeyPrefix + key];
- return value === undefined ? undefined : decodeURIComponent(value);
- };
- Cookies.set = function (key, value, options) {
- options = Cookies._getExtendedOptions(options);
- options.expires = Cookies._getExpiresDate(value === undefined ? -1 : options.expires);
- Cookies._document.cookie = Cookies._generateCookieString(key, value, options);
- return Cookies;
- };
- Cookies.expire = function (key, options) {
- return Cookies.set(key, undefined, options);
- };
- Cookies._getExtendedOptions = function (options) {
- return {
- path: options && options.path || Cookies.defaults.path,
- domain: options && options.domain || Cookies.defaults.domain,
- expires: options && options.expires || Cookies.defaults.expires,
- secure: options && options.secure !== undefined ? options.secure : Cookies.defaults.secure,
- sameSite: options && options.sameSite || Cookies.defaults.sameSite
- };
- };
- Cookies._isValidDate = function (date) {
- return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
- };
- Cookies._getExpiresDate = function (expires, now) {
- now = now || new Date();
- if (typeof expires === 'number') {
- expires = expires === Infinity ? Cookies._maxExpireDate : new Date(now.getTime() + expires * 1000);
- } else if (typeof expires === 'string') {
- expires = new Date(expires);
- }
- if (expires && !Cookies._isValidDate(expires)) {
- throw new Error('`expires` parameter cannot be converted to a valid Date instance');
- }
- return expires;
- };
- Cookies._generateCookieString = function (key, value, options) {
- key = key.replace(/[^#$&+\^`|]/g, encodeURIComponent);
- key = key.replace(/\(/g, '%28').replace(/\)/g, '%29');
- value = (value + '').replace(/[^!#$&-+\--:<-\[\]-~]/g, encodeURIComponent);
- options = options || {};
- var cookieString = key + '=' + value;
- cookieString += options.path ? ';path=' + options.path : '';
- cookieString += options.domain ? ';domain=' + options.domain : '';
- cookieString += options.expires ? ';expires=' + options.expires.toUTCString() : '';
- cookieString += options.secure ? ';secure' : '';
- cookieString += options.sameSite ? ';SameSite=' + options.sameSite : '';
- return cookieString;
- };
- Cookies._getCacheFromString = function (documentCookie) {
- var cookieCache = {};
- var cookiesArray = documentCookie ? documentCookie.split('; ') : [];
- for (var i = 0; i < cookiesArray.length; i++) {
- var cookieKvp = Cookies._getKeyValuePairFromCookieString(cookiesArray[i]);
- if (cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] === undefined) {
- cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] = cookieKvp.value;
- }
- }
- return cookieCache;
- };
- Cookies._getKeyValuePairFromCookieString = function (cookieString) {
- // "=" is a valid character in a cookie value according to RFC6265, so cannot `split('=')`
- var separatorIndex = cookieString.indexOf('='); // IE omits the "=" when the cookie value is an empty string
- separatorIndex = separatorIndex < 0 ? cookieString.length : separatorIndex;
- var key = cookieString.substr(0, separatorIndex);
- var decodedKey;
- try {
- decodedKey = decodeURIComponent(key);
- } catch (e) {
- if (console && typeof console.error === 'function') {
- console.error('Could not decode cookie with key "' + key + '"', e);
- }
- }
- return {
- key: decodedKey,
- value: cookieString.substr(separatorIndex + 1) // Defer decoding value until accessed
- };
- };
- Cookies._renewCache = function () {
- Cookies._cache = Cookies._getCacheFromString(Cookies._document.cookie);
- Cookies._cachedDocumentCookie = Cookies._document.cookie;
- };
- Cookies._areEnabled = function () {
- var testKey = 'cookies.js';
- var areEnabled = Cookies.set(testKey, 1).get(testKey) === '1';
- Cookies.expire(testKey);
- return areEnabled;
- };
- Cookies.enabled = Cookies._areEnabled();
- return Cookies;
- };
- __webpack_require__.g.Cookies = __webpack_require__.g && cookies_typeof(__webpack_require__.g.document) === 'object' ? factory(__webpack_require__.g) : factory;
- /* harmony default export */ const cookies = (__webpack_require__.g.Cookies);
- ;// CONCATENATED MODULE: ./app/forms/fields/editor/buttons.js
- var replacer = function replacer(_ref) {
- var name = _ref.name,
- replace = _ref.replace,
- codemirror = _ref.codemirror,
- button = _ref.button,
- _ref$mode = _ref.mode,
- mode = _ref$mode === void 0 ? 'replaceSelections' : _ref$mode,
- runner = _ref.runner;
- button.on("click.editor.".concat(name), function () {
- strategies[mode]({
- token: '$1',
- template: replace,
- codemirror: codemirror,
- runner: runner
- });
- });
- };
- var strategies = {
- replaceSelections: function replaceSelections(_ref2) {
- var template = _ref2.template,
- token = _ref2.token,
- codemirror = _ref2.codemirror,
- runner = _ref2.runner;
- var replacements = [];
- var ranges = [];
- var selections = codemirror.getSelections();
- var list = codemirror.listSelections();
- var accumulator = {};
- selections.forEach(function (selection, index) {
- var markup = template.replace(token, selection);
- var cursor = markup.indexOf('$cur');
- var _list$index$anchor = list[index].anchor,
- line = _list$index$anchor.line,
- ch = _list$index$anchor.ch;
- markup = markup.replace('$cur', '');
- markup = runner ? runner(selection, markup, list) : markup;
- replacements.push(markup);
- if (!accumulator[line]) {
- accumulator[line] = 0;
- }
- ch += accumulator[line] + (cursor === -1 ? markup.length : cursor);
- var range = {
- ch: ch,
- line: line
- };
- ranges.push({
- anchor: range,
- head: range
- });
- accumulator[line] += markup.length - selection.length;
- });
- codemirror.replaceSelections(replacements);
- codemirror.setSelections(ranges);
- codemirror.focus();
- },
- replaceLine: function replaceLine(_ref3) {
- var template = _ref3.template,
- token = _ref3.token,
- codemirror = _ref3.codemirror,
- runner = _ref3.runner;
- var list = codemirror.listSelections();
- var range;
- list.forEach(function (selection) {
- var lines = {
- min: Math.min(selection.anchor.line, selection.head.line),
- max: Math.max(selection.anchor.line, selection.head.line)
- };
- codemirror.eachLine(lines.min, lines.max + 1, function (handler) {
- var markup = template.replace(token, handler.text);
- var line = codemirror.getLineNumber(handler);
- markup = runner ? runner(handler, markup) : markup;
- codemirror.replaceRange(markup, {
- line: line,
- ch: 0
- }, {
- line: line,
- ch: markup.length
- });
- range = {
- line: line,
- ch: markup.length
- };
- });
- });
- codemirror.setSelection(range, range, 'end');
- codemirror.focus();
- },
- replaceRange: function replaceRange() {}
- };
- var flipDisabled = function flipDisabled(codemirror, button, type) {
- var hasHistory = codemirror.historySize()[type];
- var element = button.find('a');
- button[hasHistory ? 'removeClass' : 'addClass']('button-disabled');
- if (!hasHistory) {
- element.attr('title-disabled', element.attr('title'));
- element.attr('data-hint-disabled', element.attr('data-hint'));
- element.removeAttr('title').removeAttr('data-hint');
- } else {
- element.attr('title', element.attr('title-disabled'));
- element.attr('data-hint', element.attr('data-hint-disabled'));
- element.removeAttr('title-disabled').removeAttr('data-hint-disabled');
- }
- };
- /* harmony default export */ const buttons = ({
- navigation: [{
- undo: {
- identifier: 'undo',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNDO,
- label: '<i class="fa fa-fw fa-undo"></i>',
- modes: [],
- action: function action(_ref4) {
- var codemirror = _ref4.codemirror,
- button = _ref4.button,
- textarea = _ref4.textarea;
- button.addClass('button-disabled');
- codemirror.on('change', function () {
- return flipDisabled(codemirror, button, 'undo');
- });
- button.on('click.editor.undo', function () {
- codemirror.undo();
- });
- }
- }
- }, {
- redo: {
- identifier: 'redo',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.REDO,
- label: '<i class="fa fa-fw fa-repeat"></i>',
- modes: [],
- action: function action(_ref5) {
- var codemirror = _ref5.codemirror,
- button = _ref5.button,
- textarea = _ref5.textarea;
- button.addClass('button-disabled');
- codemirror.on('change', function () {
- return flipDisabled(codemirror, button, 'redo');
- });
- button.on('click.editor.redo', function () {
- codemirror.redo();
- });
- }
- }
- }, {
- headers: {
- identifier: 'headers',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.HEADERS,
- label: '<i class="fa fa-fw fa-header"></i>',
- modes: ['gfm', 'markdown'],
- children: [{
- h1: {
- identifier: 'h1',
- label: '<i class="fa fa-fw fa-header"></i>1',
- modes: ['gfm', 'markdown'],
- action: function action(_ref6) {
- var codemirror = _ref6.codemirror,
- button = _ref6.button,
- textarea = _ref6.textarea;
- replacer({
- name: 'h1',
- replace: '# $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }, {
- h2: {
- identifier: 'h2',
- label: '<i class="fa fa-fw fa-header"></i>2',
- modes: ['gfm', 'markdown'],
- action: function action(_ref7) {
- var codemirror = _ref7.codemirror,
- button = _ref7.button,
- textarea = _ref7.textarea;
- replacer({
- name: 'h2',
- replace: '## $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }, {
- h3: {
- identifier: 'h3',
- label: '<i class="fa fa-fw fa-header"></i>3',
- modes: ['gfm', 'markdown'],
- action: function action(_ref8) {
- var codemirror = _ref8.codemirror,
- button = _ref8.button,
- textarea = _ref8.textarea;
- replacer({
- name: 'h3',
- replace: '### $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }, {
- h4: {
- identifier: 'h4',
- label: '<i class="fa fa-fw fa-header"></i>4',
- modes: ['gfm', 'markdown'],
- action: function action(_ref9) {
- var codemirror = _ref9.codemirror,
- button = _ref9.button,
- textarea = _ref9.textarea;
- replacer({
- name: 'h4',
- replace: '#### $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }, {
- h5: {
- identifier: 'h5',
- label: '<i class="fa fa-fw fa-header"></i>5',
- modes: ['gfm', 'markdown'],
- action: function action(_ref10) {
- var codemirror = _ref10.codemirror,
- button = _ref10.button,
- textarea = _ref10.textarea;
- replacer({
- name: 'h5',
- replace: '##### $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }, {
- h6: {
- identifier: 'h6',
- label: '<i class="fa fa-fw fa-header"></i>6',
- modes: ['gfm', 'markdown'],
- action: function action(_ref11) {
- var codemirror = _ref11.codemirror,
- button = _ref11.button,
- textarea = _ref11.textarea;
- replacer({
- name: 'h6',
- replace: '###### $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }]
- }
- }, {
- bold: {
- identifier: 'bold',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.BOLD,
- label: '<i class="fa fa-fw fa-bold"></i>',
- modes: ['gfm', 'markdown'],
- shortcut: ['Ctrl-B', 'Cmd-B'],
- action: function action(_ref12) {
- var codemirror = _ref12.codemirror,
- button = _ref12.button,
- textarea = _ref12.textarea;
- replacer({
- name: 'bold',
- replace: '**$1$cur**',
- codemirror: codemirror,
- button: button
- });
- }
- }
- }, {
- italic: {
- identifier: 'italic',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ITALIC,
- label: '<i class="fa fa-fw fa-italic"></i>',
- modes: ['gfm', 'markdown'],
- shortcut: ['Ctrl-I', 'Cmd-I'],
- action: function action(_ref13) {
- var codemirror = _ref13.codemirror,
- button = _ref13.button,
- textarea = _ref13.textarea;
- replacer({
- name: 'italic',
- replace: '_$1$cur_',
- codemirror: codemirror,
- button: button
- });
- }
- }
- }, {
- strike: {
- identifier: 'strike',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.STRIKETHROUGH,
- label: '<i class="fa fa-fw fa-strikethrough"></i>',
- modes: ['gfm', 'markdown'],
- action: function action(_ref14) {
- var codemirror = _ref14.codemirror,
- button = _ref14.button,
- textarea = _ref14.textarea;
- replacer({
- name: 'strike',
- replace: '~~$1$cur~~',
- codemirror: codemirror,
- button: button
- });
- }
- }
- }, {
- delimiter: {
- identifier: 'delimiter',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.SUMMARY_DELIMITER,
- label: '<i class="fa fa-fw fa-minus"></i>',
- modes: ['gfm', 'markdown'],
- action: function action(_ref15) {
- var codemirror = _ref15.codemirror,
- button = _ref15.button,
- textarea = _ref15.textarea;
- replacer({
- name: 'delimiter',
- replace: "".concat(external_GravAdmin_namespaceObject.config.site.delimiter, "$1"),
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }, {
- link: {
- identifier: 'link',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.LINK,
- label: '<i class="fa fa-fw fa-link"></i>',
- modes: ['gfm', 'markdown'],
- shortcut: ['Ctrl-K', 'Cmd-K'],
- action: function action(_ref16) {
- var codemirror = _ref16.codemirror,
- button = _ref16.button,
- textarea = _ref16.textarea;
- replacer({
- name: 'link',
- replace: '[$1]($cur)',
- codemirror: codemirror,
- button: button
- });
- }
- }
- }, {
- image: {
- identifier: 'image',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.IMAGE,
- label: '<i class="fa fa-fw fa-picture-o"></i>',
- modes: ['gfm', 'markdown'],
- action: function action(_ref17) {
- var codemirror = _ref17.codemirror,
- button = _ref17.button,
- textarea = _ref17.textarea;
- replacer({
- name: 'image',
- replace: '![$1]($cur)',
- codemirror: codemirror,
- button: button
- });
- }
- }
- }, {
- blockquote: {
- identifier: 'blockquote',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.BLOCKQUOTE,
- label: '<i class="fa fa-fw fa-quote-right"></i>',
- modes: ['gfm', 'markdown'],
- action: function action(_ref18) {
- var codemirror = _ref18.codemirror,
- button = _ref18.button,
- textarea = _ref18.textarea;
- replacer({
- name: 'blockquote',
- replace: '> $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }, {
- listUl: {
- identifier: 'listUl',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.UNORDERED_LIST,
- label: '<i class="fa fa-fw fa-list-ul"></i>',
- modes: ['gfm', 'markdown'],
- action: function action(_ref19) {
- var codemirror = _ref19.codemirror,
- button = _ref19.button,
- textarea = _ref19.textarea;
- replacer({
- name: 'listUl',
- replace: '* $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine'
- });
- }
- }
- }, {
- listOl: {
- identifier: 'listOl',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.ORDERED_LIST,
- label: '<i class="fa fa-fw fa-list-ol"></i>',
- modes: ['gfm', 'markdown'],
- action: function action(_ref20) {
- var codemirror = _ref20.codemirror,
- button = _ref20.button,
- textarea = _ref20.textarea;
- replacer({
- name: 'listOl',
- replace: '. $1',
- codemirror: codemirror,
- button: button,
- mode: 'replaceLine',
- runner: function runner(line, markup) {
- var lineNo = codemirror.getLineNumber(line);
- var previousLine = codemirror.getLine(lineNo - 1) || '';
- var match = previousLine.match(/^(\d+)\./);
- var prefix = 1 + (match ? Number(match[1]) : 0);
- return "".concat(prefix).concat(markup);
- }
- });
- }
- }
- }],
- states: [{
- code: {
- identifier: 'editor',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.EDITOR,
- label: '<i class="fa fa-fw fa-code"></i>',
- action: function action(_ref21) {
- var codemirror = _ref21.codemirror,
- button = _ref21.button,
- textarea = _ref21.textarea,
- ui = _ref21.ui;
- if (textarea.data('grav-editor-mode') === 'editor') {
- button.addClass('editor-active');
- }
- button.on('click.states.editor', function () {
- button.siblings().removeClass('editor-active');
- button.addClass('editor-active');
- textarea.data('grav-editor-mode', 'editor');
- var previewContainer = textarea.data('grav-editor-preview-container');
- var content = textarea.parent('.grav-editor-content');
- content.addClass('is-active');
- ui.navigation.find('.grav-editor-actions').css('visibility', 'visible');
- if (previewContainer) {
- previewContainer.removeClass('is-active');
- }
- });
- }
- }
- }, {
- preview: {
- identifier: 'preview',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.PREVIEW,
- label: '<i class="fa fa-fw fa-eye"></i>',
- modes: ['gfm', 'markdown'],
- action: function action(_ref22) {
- var codemirror = _ref22.codemirror,
- button = _ref22.button,
- textarea = _ref22.textarea,
- ui = _ref22.ui;
- if (textarea.data('grav-editor-mode') === 'preview') {
- button.addClass('editor-active');
- }
- button.on('click.states.preview', function () {
- var previewContainer = textarea.data('grav-editor-preview-container');
- var content = textarea.parent('.grav-editor-content');
- button.siblings().removeClass('editor-active');
- button.addClass('editor-active');
- textarea.data('grav-editor-mode', 'preview');
- if (!previewContainer) {
- previewContainer = external_jQuery_default()('<div class="grav-editor-preview" />');
- content.after(previewContainer);
- textarea.data('grav-editor-preview-container', previewContainer);
- }
- previewContainer.css({
- height: content.height()
- });
- previewContainer.addClass('is-active');
- content.removeClass('is-active');
- ui.navigation.find('.grav-editor-actions').css('visibility', 'hidden');
- var url = "".concat(textarea.data('grav-urlpreview'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "processmarkdown");
- var params = textarea.closest('form').serializeArray();
- var body = {};
- params.map(function (obj) {
- body[obj.name] = obj.value;
- });
- utils_request(url, {
- method: 'post',
- body: body
- }, function (response) {
- return previewContainer.html(response.preview);
- });
- });
- }
- }
- }, {
- fullscreen: {
- identifier: 'fullscreen',
- title: external_GravAdmin_namespaceObject.translations.PLUGIN_ADMIN.FULLSCREEN,
- label: '<i class="fa fa-fw fa-expand"></i>',
- action: function action(_ref23) {
- var codemirror = _ref23.codemirror,
- button = _ref23.button,
- textarea = _ref23.textarea;
- button.on('click.editor.fullscreen', function () {
- var container = textarea.closest('.grav-editor');
- var wrapper = codemirror.getWrapperElement();
- var contentWrapper = external_jQuery_default()('.content-wrapper');
- if (!container.hasClass('grav-editor-fullscreen')) {
- textarea.data('fullScreenRestore', {
- scrollTop: __webpack_require__.g.pageYOffset,
- scrollLeft: __webpack_require__.g.pageXOffset,
- width: wrapper.style.width,
- height: wrapper.style.height
- });
- wrapper.style.width = '';
- wrapper.style.height = textarea.parent('.grav-editor-content').height() + 'px';
- __webpack_require__.g.document.documentElement.style.overflow = 'hidden';
- var hints = container.find('.grav-editor-toolbar .hint--top');
- if (hints) {
- hints.removeClass('hint--top').addClass('hint--bottom');
- external_jQuery_default()(hints[hints.length - 1]).addClass('hint--bottom-left');
- }
- if (contentWrapper) {
- contentWrapper.css('overflow', 'visible');
- }
- } else {
- __webpack_require__.g.document.documentElement.style.overflow = '';
- var state = textarea.data('fullScreenRestore');
- wrapper.style.width = state.width;
- wrapper.style.height = state.height;
- __webpack_require__.g.scrollTo(state.scrollLeft, state.scrollTop);
- var _hints = container.find('.grav-editor-toolbar .hint--bottom');
- if (_hints) {
- _hints.removeClass('hint--bottom').addClass('hint--top');
- external_jQuery_default()(_hints[_hints.length - 1]).removeClass('hint--bottom-left');
- }
- if (contentWrapper) {
- contentWrapper.css('overflow', 'auto');
- }
- }
- container.toggleClass('grav-editor-fullscreen');
- setTimeout(function () {
- codemirror.refresh(); // this.preview.parent().css('height', this.code.height());
- external_jQuery_default()(__webpack_require__.g).trigger('resize');
- }, 5);
- });
- }
- }
- }]
- });
- // EXTERNAL MODULE: ./node_modules/codemirror/lib/codemirror.js
- var codemirror = __webpack_require__(4631);
- var codemirror_default = /*#__PURE__*/__webpack_require__.n(codemirror);
- // EXTERNAL MODULE: ./node_modules/watchjs/src/watch.js
- var watch = __webpack_require__(29950);
- // EXTERNAL MODULE: ./node_modules/js-yaml/dist/js-yaml.mjs
- var js_yaml = __webpack_require__(1272);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/css/css.js
- var css = __webpack_require__(36629);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/gfm/gfm.js
- var gfm = __webpack_require__(42425);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/htmlmixed/htmlmixed.js
- var htmlmixed = __webpack_require__(16531);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/javascript/javascript.js
- var javascript = __webpack_require__(96876);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/markdown/markdown.js
- var markdown = __webpack_require__(49047);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/php/php.js
- var php = __webpack_require__(36702);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/sass/sass.js
- var sass = __webpack_require__(81201);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/twig/twig.js
- var twig = __webpack_require__(54702);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/xml/xml.js
- var xml = __webpack_require__(29589);
- // EXTERNAL MODULE: ./node_modules/codemirror/mode/yaml/yaml.js
- var yaml = __webpack_require__(53631);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/edit/continuelist.js
- var continuelist = __webpack_require__(23350);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/mode/overlay.js
- var overlay = __webpack_require__(14146);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/selection/active-line.js
- var active_line = __webpack_require__(20017);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/lint.js
- var lint = __webpack_require__(3256);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/lint.css
- var lint_lint = __webpack_require__(46226);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/css-lint.js
- var css_lint = __webpack_require__(41423);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/javascript-lint.js
- var javascript_lint = __webpack_require__(96477);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/json-lint.js
- var json_lint = __webpack_require__(62193);
- // EXTERNAL MODULE: ./node_modules/codemirror/addon/lint/yaml-lint.js
- var yaml_lint = __webpack_require__(82783);
- ;// CONCATENATED MODULE: ./app/forms/fields/editor.js
- function editor_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function editor_createClass(Constructor, protoProps, staticProps) { if (protoProps) editor_defineProperties(Constructor.prototype, protoProps); if (staticProps) editor_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- __webpack_require__.g.jsyaml = js_yaml/* default */.ZP; // Modes
- // Add-ons
- var IS_MOUSEDOWN = false;
- var ThemesMap = ['paper'];
- var Defaults = {
- codemirror: {
- mode: 'htmlmixed',
- theme: 'paper',
- lineWrapping: true,
- dragDrop: true,
- autoCloseTags: true,
- matchTags: true,
- autoCloseBrackets: true,
- matchBrackets: true,
- indentUnit: 4,
- indentWithTabs: false,
- tabSize: 4,
- hintOptions: {
- completionSingle: false
- },
- extraKeys: {
- 'Enter': 'newlineAndIndentContinueMarkdownList'
- }
- }
- };
- var EditorField = /*#__PURE__*/function () {
- function EditorField(options) {
- var _this = this;
- editor_classCallCheck(this, EditorField);
- var body = external_jQuery_default()('body');
- this.editors = external_jQuery_default()();
- this.options = Object.assign({}, Defaults, options);
- this.buttons = buttons;
- this.buttonStrategies = strategies;
- (0,watch.watch)(buttons, function
- /* key, modifier, prev, next */
- () {
- _this.editors.each(function (index, editor) {
- return external_jQuery_default()(editor).data('toolbar').renderButtons();
- });
- });
- external_jQuery_default()('[data-grav-editor]').each(function (index, editor) {
- return _this.addEditor(editor);
- });
- external_jQuery_default()(function () {
- body.trigger('grav-editor-ready');
- });
- body.on('mutation._grav', this._onAddedNodes.bind(this));
- body.on('mouseup._grav', function () {
- if (!IS_MOUSEDOWN) {
- return true;
- }
- body.unbind('mousemove._grav');
- IS_MOUSEDOWN = false;
- });
- body.on('mousedown._grav', '.grav-editor-resizer', function (event) {
- event && event.preventDefault();
- IS_MOUSEDOWN = true;
- var target = external_jQuery_default()(event.currentTarget);
- var container = target.siblings('.grav-editor-content');
- var editor = container.find('.CodeMirror');
- var codemirror = container.find('textarea').data('codemirror');
- body.on('mousemove._grav', function (event) {
- editor.css('height', Math.max(100, event.pageY - container.offset().top));
- codemirror.refresh();
- });
- });
- }
- editor_createClass(EditorField, [{
- key: "addButton",
- value: function addButton(button, options) {
- if (options && (options.before || options.after)) {
- var index = this.buttons.navigation.findIndex(function (obj) {
- var key = Object.keys(obj).shift();
- return obj[key].identifier === (options.before || options.after);
- });
- if (!~index) {
- options = 'end';
- } else {
- this.buttons.navigation.splice(options.before ? index : index + 1, 0, button);
- }
- }
- if (options === 'start') {
- this.buttons.navigation.splice(0, 0, button);
- }
- if (!options || options === 'end') {
- this.buttons.navigation.push(button);
- }
- }
- }, {
- key: "addEditor",
- value: function addEditor(textarea) {
- textarea = external_jQuery_default()(textarea);
- var options = Object.assign({}, this.options.codemirror, textarea.data('grav-editor').codemirror);
- var theme = options.theme || 'paper';
- this.editors = this.editors.add(textarea);
- if (theme && !~ThemesMap.indexOf(theme)) {
- ThemesMap.push(theme); // let themeCSS = `https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.12.0/theme/${theme}.min.css`;
- // $('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', themeCSS));
- }
- if (options.mode === 'yaml') {
- Object.assign(options.extraKeys, {
- Tab: function Tab(cm) {
- cm.replaceSelection(' ', 'end');
- }
- });
- }
- var editor = codemirror_default().fromTextArea(textarea.get(0), options);
- textarea.data('codemirror', editor);
- textarea.data('toolbar', new Toolbar(textarea));
- textarea.addClass('code-mirrored');
- if (options.toolbar === false) {
- textarea.data('toolbar').ui.navigation.addClass('grav-editor-hide-toolbar');
- }
- editor.on('change', function () {
- return editor.save();
- });
- }
- }, {
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target
- /* , record, instance */
- ) {
- var _this2 = this;
- var editors = external_jQuery_default()(target).find('[data-grav-editor]');
- if (!editors.length) {
- return;
- }
- editors.each(function (index, editor) {
- editor = external_jQuery_default()(editor);
- if (!~_this2.editors.index(editor)) {
- _this2.addEditor(editor);
- }
- });
- }
- }]);
- return EditorField;
- }();
- var Toolbar = /*#__PURE__*/function () {
- function Toolbar(editor) {
- editor_classCallCheck(this, Toolbar);
- this.editor = external_jQuery_default()(editor);
- this.codemirror = this.editor.data('codemirror');
- this.buttons = buttons.navigation;
- this.ui = {
- navigation: external_jQuery_default()(Toolbar.templates().navigation)
- };
- this.editor.parent('.grav-editor-content').before(this.ui.navigation).after(this.ui.states);
- this.renderButtons();
- }
- editor_createClass(Toolbar, [{
- key: "renderButtons",
- value: function renderButtons() {
- var _this3 = this;
- var map = {
- 'actions': 'navigation',
- 'modes': 'states'
- };
- ['actions', 'modes'].forEach(function (type) {
- _this3.ui.navigation.find(".grav-editor-".concat(type)).empty().append('<ul />');
- buttons[map[type]].forEach(function (button) {
- return _this3.renderButton(button, type);
- });
- });
- }
- }, {
- key: "renderButton",
- value: function renderButton(button, type) {
- var _this4 = this;
- var location = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- Object.keys(button).forEach(function (key) {
- var obj = button[key];
- if (!obj.modes) {
- obj.modes = [];
- }
- if (!~_this4.codemirror.options.ignore.indexOf(key) && (!obj.modes.length || obj.modes.indexOf(_this4.codemirror.options.mode) > -1)) {
- var hint = obj.title ? "data-hint=\"".concat(obj.title, "\"") : '';
- var element = external_jQuery_default()("<li class=\"grav-editor-button-".concat(key, "\"><a class=\"hint--top\" ").concat(hint, ">").concat(obj.label, "</a></li>"));
- (location || _this4.ui.navigation.find(".grav-editor-".concat(type, " ul:not(.dropdown-menu)"))).append(element);
- if (obj.shortcut) {
- _this4.addShortcut(obj.identifier, obj.shortcut, element);
- }
- obj.action && obj.action.call(obj.action, {
- codemirror: _this4.codemirror,
- button: element,
- textarea: _this4.editor,
- ui: _this4.ui
- });
- if (obj.children) {
- var childrenContainer = external_jQuery_default()('<ul class="dropdown-menu" />');
- element.addClass('button-group').find('a').wrap('<div class="dropdown-toggle" data-toggle="dropdown"></div>');
- element.find('a').append(' <i class="fa fa-caret-down"></i>');
- element.append(childrenContainer);
- obj.children.forEach(function (child) {
- return _this4.renderButton(child, type, childrenContainer);
- });
- }
- }
- });
- }
- }, {
- key: "addShortcut",
- value: function addShortcut(identifier, shortcut, element) {
- var _this5 = this;
- var map = {};
- if (!Array.isArray(shortcut)) {
- shortcut = [shortcut];
- }
- shortcut.forEach(function (key) {
- map[key] = function () {
- element.trigger("click.editor.".concat(identifier), [_this5.codemirror]);
- };
- });
- this.codemirror.addKeyMap(map);
- }
- }], [{
- key: "templates",
- value: function templates() {
- return {
- navigation: "\n <div class=\"grav-editor-toolbar\">\n <div class=\"grav-editor-actions\"></div>\n <div class=\"grav-editor-modes\"></div>\n </div>\n "
- };
- }
- }]);
- return Toolbar;
- }();
- var editor_Instance = new EditorField();
- ;// CONCATENATED MODULE: ./app/pages/page/media.js
- function media_typeof(obj) { "@babel/helpers - typeof"; return media_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, media_typeof(obj); }
- function media_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function media_createClass(Constructor, protoProps, staticProps) { if (protoProps) media_defineProperties(Constructor.prototype, protoProps); if (staticProps) media_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- function media_get() { if (typeof Reflect !== "undefined" && Reflect.get) { media_get = Reflect.get; } else { media_get = function _get(target, property, receiver) { var base = media_superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return media_get.apply(this, arguments); }
- function media_superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = media_getPrototypeOf(object); if (object === null) break; } return object; }
- function media_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) media_setPrototypeOf(subClass, superClass); }
- function media_setPrototypeOf(o, p) { media_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return media_setPrototypeOf(o, p); }
- 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); }; }
- function media_possibleConstructorReturn(self, call) { if (call && (media_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return media_assertThisInitialized(self); }
- function media_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- 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; } }
- function media_getPrototypeOf(o) { media_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return media_getPrototypeOf(o); }
- 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();
- var PageMedia = /*#__PURE__*/function (_FilesField) {
- media_inherits(PageMedia, _FilesField);
- var _super = media_createSuper(PageMedia);
- function PageMedia() {
- var _this;
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref$container = _ref.container,
- container = _ref$container === void 0 ? '#grav-dropzone' : _ref$container,
- _ref$options = _ref.options,
- options = _ref$options === void 0 ? {} : _ref$options;
- media_classCallCheck(this, PageMedia);
- options = Object.assign(options, {
- previewTemplate: previewTemplate
- });
- _this = _super.call(this, {
- container: container,
- options: options
- });
- if (!_this.container.length) {
- return media_possibleConstructorReturn(_this);
- }
- _this.urls = {
- fetch: "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "listmedia"),
- add: "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "addmedia"),
- "delete": "".concat(_this.container.data('media-url'), "/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "delmedia")
- };
- _this.dropzone.options.url = _this.urls.add;
- if (typeof _this.options.fetchMedia === 'undefined' || _this.options.fetchMedia) {
- _this.fetchMedia();
- }
- if (typeof _this.options.attachDragDrop === 'undefined' || _this.options.attachDragDrop) {
- _this.attachDragDrop();
- }
- var field = external_jQuery_default()("[name=\"".concat(_this.container.data('dropzone-field'), "\"]"));
- if (field.length) {
- _this.sortable = new sortable_esm/* default */.ZP(_this.container.get(0), {
- animation: 150,
- // forceFallback: true,
- setData: function setData(dataTransfer, target) {
- target = external_jQuery_default()(target);
- var uri = encodeURI(target.find('.dz-filename').text());
- var shortcode = UriToMarkdown(uri);
- _this.dropzone.disable();
- target.addClass('hide-backface');
- dataTransfer.effectAllowed = 'copy';
- dataTransfer.setData('text', shortcode);
- },
- onSort: function onSort() {
- var names = [];
- _this.container.find('[data-dz-name]').each(function (index, file) {
- file = external_jQuery_default()(file);
- var name = file.text().trim();
- names.push(name);
- });
- field.val(names.join(','));
- }
- });
- }
- return _this;
- }
- media_createClass(PageMedia, [{
- key: "fetchMedia",
- value: function fetchMedia() {
- var _this2 = this;
- var order = this.container.closest('.form-field').find('[name="data[header][media_order]"]').val();
- var body = {
- uri: this.getURI(),
- order: order
- };
- var url = this.urls.fetch;
- utils_request(url, {
- method: 'post',
- body: body
- }, function (response) {
- var results = response.results;
- Object.keys(results).forEach(function (name) {
- var data = results[name];
- var mock = {
- name: name,
- size: data.size,
- accepted: true,
- extras: data
- };
- _this2.dropzone.files.push(mock);
- _this2.dropzone.options.addedfile.call(_this2.dropzone, mock);
- _this2.dropzone.options.thumbnail.call(_this2.dropzone, mock, data.url);
- });
- _this2.updateThumbsSize();
- _this2.container.find('.dz-preview').prop('draggable', 'true');
- });
- }
- }, {
- key: "onDropzoneSending",
- value: function onDropzoneSending(file, xhr, formData) {
- /*
- // Cannot call super because Safari and IE API don't implement `delete`
- super.onDropzoneSending(file, xhr, formData);
- formData.delete('task');
- */
- formData.append('name', this.options.dotNotation || file.name);
- formData.append('admin-nonce', external_GravAdmin_namespaceObject.config.admin_nonce);
- formData.append('uri', this.getURI());
- }
- }, {
- key: "onDropzoneComplete",
- value: function onDropzoneComplete(file) {
- media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneComplete", this).call(this, file);
- if (this.sortable) {
- this.sortable.options.onSort();
- } // accepted
- this.updateThumbsSize();
- this.updateMediaCount();
- external_jQuery_default()('.dz-preview').prop('draggable', 'true');
- }
- }, {
- key: "onDropzoneAddedFile",
- value: function onDropzoneAddedFile(file) {
- for (var _len = arguments.length, extra = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- extra[_key - 1] = arguments[_key];
- }
- media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneAddedFile", this).call(this, file, extra);
- this.updateThumbsSize();
- }
- }, {
- key: "onDropzoneRemovedFile",
- value: function onDropzoneRemovedFile(file) {
- var _get2;
- for (var _len2 = arguments.length, extra = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
- extra[_key2 - 1] = arguments[_key2];
- }
- (_get2 = media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneRemovedFile", this)).call.apply(_get2, [this, file].concat(extra));
- this.updateMediaCount();
- if (this.sortable) {
- this.sortable.options.onSort();
- }
- }
- }, {
- key: "updateThumbsSize",
- value: function updateThumbsSize() {
- var status = JSON.parse(cookies.get('grav-admin-pagemedia') || '{}');
- if (status.width) {
- var input = this.container.closest('.pagemedia-field').find('.media-resizer');
- updateMediaSizes(input[0], status.width, false);
- }
- }
- }, {
- key: "updateMediaCount",
- value: function updateMediaCount() {
- var element = this.container.closest('.pagemedia-field').find('[data-pagemedia-count]');
- element.text("(".concat(this.dropzone.files.length, ")"));
- }
- }, {
- key: "attachDragDrop",
- value: function attachDragDrop() {
- var _this3 = this;
- this.container.delegate('[data-dz-insert]', 'click', function (e) {
- var target = external_jQuery_default()(e.currentTarget).parent('.dz-preview').find('.dz-filename');
- var editor = editor_Instance.editors.filter(function (index, editor) {
- return external_jQuery_default()(editor).attr('name') === 'data[content]';
- });
- if (editor.length) {
- editor = editor.data('codemirror');
- editor.focus();
- var filename = encodeURI(target.text());
- var shortcode = UriToMarkdown(filename);
- editor.doc.replaceSelection(shortcode);
- }
- });
- this.container.delegate('[data-dz-view]', 'mouseenter', function (e) {
- var target = external_jQuery_default()(e.currentTarget);
- var file = target.parent('.dz-preview').find('.dz-filename');
- var filename = encodeURI(file.text());
- var URL = target.closest('[data-media-path]').data('media-path');
- var original = _this3.dropzone.files.filter(function (file) {
- return encodeURI(file.name) === filename;
- }).shift();
- original = original && (original.extras && original.extras.original || encodeURI(original.name));
- target.attr('href', "".concat(URL, "/").concat(original));
- });
- this.container.delegate('[data-dz-metadata]', 'click', function (e) {
- e.preventDefault();
- var target = external_jQuery_default()(e.currentTarget);
- var file = target.parent('.dz-preview').find('.dz-filename');
- var filename = encodeURI(file.text());
- var cleanName = file.text().replace('<', '<').replace('>', '>');
- var fileObj = _this3.dropzone.files.filter(function (file) {
- return file.name === __webpack_require__.g.decodeURI(filename);
- }).shift() || {};
- if (!fileObj.extras) {
- fileObj.extras = {
- metadata: []
- };
- }
- if (Array.isArray(fileObj.extras.metadata) && !fileObj.extras.metadata.length) {
- fileObj.extras.metadata = {
- '': "".concat(cleanName, ".meta.yaml doesn't exist")
- };
- }
- fileObj = fileObj.extras;
- var modal_element = external_jQuery_default()('body').find('[data-remodal-id="metadata"]');
- var modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
- modal_element.find('h1 strong').html(cleanName);
- if (fileObj.url) {
- modal_element.find('.meta-preview').html("<img src=\"".concat(fileObj.url, "\" />"));
- }
- var container = modal_element.find('.meta-content').html('<ul />').find('ul');
- Object.keys(fileObj.metadata).forEach(function (meta) {
- var cleanMeta = fileObj.metadata[meta].replace('<', '<').replace('>', '>');
- container.append("<li><strong>".concat(meta ? meta + ':' : '', "</strong> ").concat(cleanMeta, "</li>"));
- });
- modal.open();
- });
- this.container.delegate('.dz-preview', 'dragstart', function (e) {
- var target = external_jQuery_default()(e.currentTarget);
- var uri = encodeURI(target.find('.dz-filename').text());
- var shortcode = UriToMarkdown(uri);
- _this3.dropzone.disable();
- target.addClass('hide-backface');
- e.originalEvent.dataTransfer.effectAllowed = 'copy';
- e.originalEvent.dataTransfer.setData('text', shortcode);
- });
- this.container.delegate('.dz-preview', 'dragend', function (e) {
- var target = external_jQuery_default()(e.currentTarget);
- _this3.dropzone.enable();
- target.removeClass('hide-backface');
- });
- }
- }]);
- return PageMedia;
- }(FilesField);
- var updateMediaSizes = function updateMediaSizes(input, width) {
- var store = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- var storageLocation = input.dataset.storageLocation || 'grav-admin-pagemedia';
- var status = JSON.parse(cookies.get(storageLocation) || '{}');
- var height = 150 * width / 200;
- var media = external_jQuery_default()(input).closest('.pagemedia-field').find('.dz-details, [data-dz-thumbnail]');
- media.css({
- width: width,
- height: height
- });
- if (store) {
- var data = Object.assign({}, status, {
- width: width
- });
- cookies.set(storageLocation, JSON.stringify(data), {
- expires: Infinity
- });
- }
- };
- var updateMediaCollapseStatus = function updateMediaCollapseStatus(element) {
- var store = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- var storageLocation = element.dataset.storageLocation || 'grav-admin-pagemedia';
- var status = JSON.parse(cookies.get(storageLocation) || '{}');
- element = external_jQuery_default()(element);
- var icon = element.find('i.fa');
- var container = element.closest('.pagemedia-field');
- var panel = container.find('.form-data');
- var slider = container.find('.media-resizer').parent();
- var isCollapsed = !icon.hasClass('fa-chevron-down');
- var collapsed = !isCollapsed;
- icon.removeClass('fa-chevron-down fa-chevron-right').addClass(isCollapsed ? 'fa-chevron-down' : 'fa-chevron-right');
- slider[isCollapsed ? 'removeClass' : 'addClass']('hidden');
- panel[isCollapsed ? 'slideDown' : 'slideUp']();
- if (store) {
- var data = Object.assign({}, status, {
- collapsed: collapsed
- });
- cookies.set(storageLocation, JSON.stringify(data), {
- expires: Infinity
- });
- }
- };
- external_jQuery_default()(document).on('input', '.media-resizer', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var width = target.val();
- updateMediaSizes(event.currentTarget, width);
- });
- external_jQuery_default()(document).on('click', '.media-collapser', function (event) {
- updateMediaCollapseStatus(event.currentTarget);
- });
- external_jQuery_default()(document).ready(function () {
- external_jQuery_default()('.media-resizer').each(function (index, input) {
- var storageLocation = input.dataset.storageLocation || 'grav-admin-pagemedia';
- var status = JSON.parse(cookies.get(storageLocation) || '{}');
- if (status.width) {
- updateMediaSizes(input, status.width, false);
- }
- });
- });
- var media_Instance = new PageMedia();
- ;// CONCATENATED MODULE: ./app/pages/page/multilang.js
- external_jQuery_default()('[name="task"][value="saveas"], [name="task"][value="switchlanguage"]').on('mousedown touchstart', function (event) {
- var fields = ['lang', 'redirect'];
- var element = external_jQuery_default()(event.currentTarget);
- var form = external_jQuery_default()("#".concat(element.attr('form')));
- if (!form.length) {
- return;
- }
- fields.forEach(function (field) {
- var value = element.attr(field);
- if (!value) {
- return;
- }
- var input = form.find("[name=\"data[".concat(field, "]\"]"));
- if (!input.length) {
- input = external_jQuery_default()("<input type=\"hidden\" name=\"data[".concat(field, "]\" value=\"\" />"));
- form.append(input);
- }
- input.val(value);
- });
- return true;
- });
- ;// CONCATENATED MODULE: ./app/pages/page/index.js
- var page_switcher = external_jQuery_default()('input[type="radio"][name="mode-switch"]');
- if (page_switcher) {
- var page_link = page_switcher.closest(':checked').data('leave-url');
- var fakeLink = external_jQuery_default()("<a href=\"".concat(page_link, "\" />"));
- page_switcher.parent().append(fakeLink);
- page_switcher.siblings('label').on('mousedown touchdown', function (event) {
- event.preventDefault(); // let remodal = $.remodal.lookup[$('[data-remodal-id="changes"]').data('remodal')];
- var confirm = external_jQuery_default()('[data-remodal-id="changes"] [data-leave-action="continue"]');
- confirm.one('click', function () {
- external_jQuery_default()(__webpack_require__.g).on('beforeunload._grav');
- fakeLink.off('click._grav');
- external_jQuery_default()(event.target).trigger('click');
- });
- fakeLink.trigger('click._grav');
- });
- page_switcher.on('change', function (event) {
- var radio = external_jQuery_default()(event.target);
- page_link = radio.data('leave-url');
- setTimeout(function () {
- return fakeLink.attr('href', page_link).get(0).click();
- }, 5);
- });
- }
- /* harmony default export */ const page = ({
- Media: {
- PageMedia: PageMedia,
- PageMediaInstances: media_Instance
- }
- });
- ;// CONCATENATED MODULE: ./app/pages/index.js
- var pad = function pad(n, s) {
- return "000".concat(n).substr(-s);
- }; // Pages Ordering
- var Ordering = null;
- var orderingElement = external_jQuery_default()('#ordering');
- if (orderingElement.length) {
- Ordering = new sortable_esm/* default */.ZP(orderingElement.get(0), {
- filter: '.ignore',
- onUpdate: function onUpdate() {
- /* Old single page index behavior
- let item = $(event.item);
- let index = orderingElement.children().index(item) + 1;
- $('[data-order]').val(index);
- */
- var indexes = [];
- var children = orderingElement.children();
- var padZero = (children.length + '').split('').length;
- children.each(function (index, item) {
- item = external_jQuery_default()(item);
- indexes.push(item.data('id'));
- item.find('.page-order').text("".concat(pad(index + 1, padZero), "."));
- });
- external_jQuery_default()('[data-order]').val(indexes.join(','));
- }
- });
- external_jQuery_default()(document).on('input', '[name="data[folder]"]', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var activeOrder = external_jQuery_default()('[data-id][data-active-id]');
- activeOrder.data('id', target.val());
- Ordering.options.onUpdate();
- });
- }
- /* harmony default export */ const pages = ({
- Ordering: Ordering,
- Page: page,
- PageFilters: {
- PageFilters: PagesFilter,
- Instance: filter_Instance
- }
- });
- // EXTERNAL MODULE: ./node_modules/immutable/dist/immutable.es.js
- var immutable_es = __webpack_require__(35369);
- // EXTERNAL MODULE: ./node_modules/immutablediff/src/diff.js
- var src_diff = __webpack_require__(64847);
- var diff_default = /*#__PURE__*/__webpack_require__.n(src_diff);
- ;// CONCATENATED MODULE: ./app/forms/state.js
- function state_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function state_createClass(Constructor, protoProps, staticProps) { if (protoProps) state_defineProperties(Constructor.prototype, protoProps); if (staticProps) state_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var FormLoadState = {};
- var DOMBehaviors = {
- attach: function attach() {
- this.preventUnload();
- this.preventClickAway();
- },
- preventUnload: function preventUnload() {
- var selector = '[name="task"][value^="save"], [data-delete-action], [data-flex-safe-action]';
- if (external_jQuery_default()._data(window, 'events') && (external_jQuery_default()._data(window, 'events').beforeunload || []).filter(function (event) {
- return event.namespace === '_grav';
- }).length) {
- return;
- } // Allow some elements to leave the page without native confirmation
- external_jQuery_default()(selector).on('click._grav', function (event) {
- external_jQuery_default()(__webpack_require__.g).off('beforeunload');
- }); // Catch browser uri change / refresh attempt and stop it if the form state is dirty
- external_jQuery_default()(__webpack_require__.g).on('beforeunload._grav', function () {
- if (state_Instance.equals() === false) {
- 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.';
- }
- });
- },
- preventClickAway: function preventClickAway() {
- var selector = 'a[href]:not([href^="#"]):not([target="_blank"]):not([href^="javascript:"])';
- 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) {
- return event.namespace === '_grav';
- })) {
- return;
- } // Prevent clicking away if the form state is dirty
- // instead, display a confirmation before continuing
- external_jQuery_default()(selector).on('click._grav', function (event) {
- var isClean = state_Instance.equals();
- if (isClean === null || isClean) {
- return true;
- }
- event.preventDefault();
- var destination = external_jQuery_default()(this).attr('href');
- var modal = external_jQuery_default()('[data-remodal-id="changes"]');
- var lookup = (external_jQuery_default()).remodal.lookup[modal.data('remodal')];
- var buttons = external_jQuery_default()('a.button', modal);
- var handler = function handler(event) {
- event.preventDefault();
- var action = external_jQuery_default()(this).data('leave-action');
- buttons.off('click', handler);
- lookup.close();
- if (action === 'continue') {
- external_jQuery_default()(__webpack_require__.g).off('beforeunload');
- __webpack_require__.g.location.href = destination;
- }
- };
- buttons.on('click', handler);
- lookup.open();
- });
- }
- };
- var FormState = /*#__PURE__*/function () {
- function FormState() {
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
- ignore: [],
- form_id: 'blueprints'
- };
- state_classCallCheck(this, FormState);
- this.options = options;
- this.refresh();
- if (!this.form || !this.fields.length) {
- return;
- }
- FormLoadState = this.collect();
- this.loadState = FormLoadState;
- DOMBehaviors.attach();
- }
- state_createClass(FormState, [{
- key: "refresh",
- value: function refresh() {
- this.form = external_jQuery_default()("form#".concat(this.options.form_id)).filter(':noparents(.remodal)');
- 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)');
- return this;
- }
- }, {
- key: "collect",
- value: function collect() {
- var _this = this;
- if (!this.form || !this.fields.length) {
- return;
- }
- var values = {};
- this.refresh().fields.each(function (index, field) {
- field = external_jQuery_default()(field);
- var name = field.prop('name');
- var type = field.prop('type');
- var tag = field.prop('tagName').toLowerCase();
- var value;
- if (name.startsWith('toggleable_') || name === 'data[lang]' || name === 'data[redirect]') {
- return;
- }
- switch (type) {
- case 'checkbox':
- value = field.is(':checked');
- break;
- case 'radio':
- if (!field.is(':checked')) {
- return;
- }
- value = field.val();
- break;
- default:
- value = field.val();
- }
- if (tag === 'select' && value === null) {
- value = '';
- }
- if (Array.isArray(value)) {
- value = value.join('|');
- }
- if (name && !~_this.options.ignore.indexOf(name)) {
- values[name] = value;
- }
- });
- return immutable_es/* default.OrderedMap */.ZP.OrderedMap(values);
- }
- }, {
- key: "diff",
- value: function diff() {
- return diff_default()(FormLoadState, this.collect());
- } // When the form doesn't exist or there are no fields, `equals` returns `null`
- // for this reason, _NEVER_ check with !Instance.equals(), use Instance.equals() === false
- }, {
- key: "equals",
- value: function equals() {
- if (!this.form || !this.fields.length) {
- return null;
- }
- return immutable_es/* default.is */.ZP.is(FormLoadState, this.collect());
- }
- }]);
- return FormState;
- }();
- ;
- var state_Instance = new FormState();
- ;// CONCATENATED MODULE: ./app/forms/form.js
- function form_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function form_createClass(Constructor, protoProps, staticProps) { if (protoProps) form_defineProperties(Constructor.prototype, protoProps); if (staticProps) form_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- /* Dependencies for checking if changes happened since load on a form
- import toastr from '../utils/toastr';
- import { translations } from 'grav-config';
- import { Instance as FormState } from './state';
- */
- var Form = /*#__PURE__*/function () {
- function Form(form) {
- var _this = this;
- form_classCallCheck(this, Form);
- this.form = external_jQuery_default()(form);
- if (!this.form.length || this.form.prop('tagName').toLowerCase() !== 'form') {
- return;
- }
- /* Option for not saving while nothing in a form has changed
- this.form.on('submit', (event) => {
- if (FormState.equals()) {
- event.preventDefault();
- toastr.info(translations.PLUGIN_ADMIN.NOTHING_TO_SAVE);
- }
- }); */
- this._attachShortcuts();
- this._attachToggleables();
- this._attachDisabledFields();
- this._submitUncheckedFields();
- this.observer = new MutationObserver(this.addedNodes);
- this.form.each(function (index, form) {
- return _this.observer.observe(form, {
- subtree: true,
- childList: true
- });
- });
- }
- form_createClass(Form, [{
- key: "_attachShortcuts",
- value: function _attachShortcuts() {
- // CTRL + S / CMD + S - shortcut for [Save] when available
- var saveTask = external_jQuery_default()('#titlebar [name="task"][value="save"][form="blueprints"]');
- if (saveTask.length) {
- external_jQuery_default()(__webpack_require__.g).on('keydown', function (event) {
- var key = String.fromCharCode(event.which).toLowerCase();
- if (!event.shiftKey && (event.ctrlKey && !event.altKey || event.metaKey) && key === 's') {
- event.preventDefault();
- saveTask.click();
- }
- });
- }
- }
- }, {
- key: "_attachToggleables",
- value: function _attachToggleables() {
- var query = '[data-grav-field="toggleable"] input[type="checkbox"]';
- this.form.on('change', query, function (event) {
- var toggle = external_jQuery_default()(event.target);
- var enabled = toggle.is(':checked');
- var parent = toggle.closest('.form-field');
- var label = parent.find('label.toggleable');
- var fields = parent.find('.form-data');
- var inputs = fields.find('input, select, textarea, button');
- label.add(fields).css('opacity', enabled ? '' : 0.7);
- inputs.map(function (index, input) {
- var isSelectize = input.selectize;
- input = external_jQuery_default()(input);
- if (isSelectize) {
- isSelectize[enabled ? 'enable' : 'disable']();
- } else {
- input.prop('disabled', !enabled);
- }
- });
- });
- this.form.find(query).trigger('change');
- }
- }, {
- key: "_attachDisabledFields",
- value: function _attachDisabledFields() {
- var prefix = '.form-field-toggleable .form-data';
- var query = [];
- ['input', 'select', 'label[for]', 'textarea', '.selectize-control'].forEach(function (item) {
- query.push("".concat(prefix, " ").concat(item));
- });
- this.form.on('mousedown', query.join(', '), function (event) {
- var input = external_jQuery_default()(event.target);
- var isFor = input.prop('for');
- var isSelectize = (input.hasClass('selectize-control') || input.parents('.selectize-control')).length;
- if (isFor) {
- input = external_jQuery_default()("[id=\"".concat(isFor, "\"]"));
- }
- if (isSelectize) {
- input = input.closest('.selectize-control').siblings('select[name]');
- }
- if (!input.prop('disabled')) {
- return true;
- }
- var toggle = input.closest('.form-field').find('[data-grav-field="toggleable"] input[type="checkbox"]');
- toggle.trigger('click');
- });
- }
- }, {
- key: "_submitUncheckedFields",
- value: function _submitUncheckedFields() {
- var submitted = false;
- this.form.each(function (index, form) {
- form = external_jQuery_default()(form);
- form.on('submit', function () {
- // workaround for MS Edge, submitting multiple forms at the same time
- if (submitted) {
- return false;
- }
- var formId = form.attr('id');
- var unchecked = form.find('input[type="checkbox"]:not(:checked):not(:disabled)');
- var submit = form.find('[type="submit"]').add("[form=\"".concat(formId, "\"][type=\"submit\"]"));
- if (!unchecked.length) {
- return true;
- }
- submit.addClass('pointer-events-disabled');
- unchecked.each(function (index, element) {
- element = external_jQuery_default()(element);
- var name = element.prop('name');
- var fake = external_jQuery_default()("<input type=\"hidden\" name=\"".concat(name, "\" value=\"0\" />"));
- form.append(fake);
- });
- submitted = true;
- return true;
- });
- });
- }
- }, {
- key: "addedNodes",
- value: function addedNodes(mutations) {
- var _this2 = this;
- mutations.forEach(function (mutation) {
- if (mutation.type !== 'childList') {
- return;
- }
- if (mutation.addedNodes) {
- external_jQuery_default()('body').trigger('mutation._grav', mutation.target, mutation, _this2);
- }
- if (mutation.removedNodes) {
- external_jQuery_default()('body').trigger('mutation_removed._grav', {
- target: mutation.target,
- mutation: mutation
- }, _this2);
- }
- });
- }
- }]);
- return Form;
- }();
- var form_Instance = new Form('form#blueprints');
- ;// CONCATENATED MODULE: ./app/forms/fields/filepicker.js
- function filepicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function filepicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) filepicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) filepicker_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- // const insertTextAt = (string, index, text) => [string.slice(0, index), text, string.slice(index)].join('');
- var FilePickerField = /*#__PURE__*/function () {
- function FilePickerField(options) {
- var _this = this;
- filepicker_classCallCheck(this, FilePickerField);
- this.items = external_jQuery_default()();
- this.options = Object.assign({}, this.defaults, options);
- external_jQuery_default()('[data-grav-filepicker]').each(function (index, element) {
- return _this.addItem(element);
- });
- external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
- }
- filepicker_createClass(FilePickerField, [{
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target
- /* , record, instance */
- ) {
- var _this2 = this;
- var fields = external_jQuery_default()(target).find('[data-grav-filepicker]');
- if (!fields.length) {
- return;
- }
- fields.each(function (index, field) {
- field = external_jQuery_default()(field);
- if (!~_this2.items.index(field)) {
- _this2.addItem(field);
- }
- });
- }
- }, {
- key: "addItem",
- value: function addItem(element) {
- element = external_jQuery_default()(element);
- this.items = this.items.add(element);
- var tag = element.prop('tagName').toLowerCase();
- var isInput = tag === 'input' || tag === 'select';
- var field = isInput ? element : element.find('input, select');
- var folder = '';
- var thumbs = {};
- var onDemand = field.closest('[data-ondemand]').length > 0;
- if (!field.length || field.get(0).selectize) {
- return;
- }
- var getData = function getData(field, callback) {
- var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
- var url = external_GravAdmin_namespaceObject.config.current_url + ".json/task".concat(external_GravAdmin_namespaceObject.config.param_sep, "getFilesInFolder");
- var parent = field.closest('[data-grav-filepicker]');
- var name = parent.data('name');
- var value = parent.data('value');
- var params = JSON.stringify(external_GravAdmin_namespaceObject.uri_params || '{}');
- utils_request(url, {
- method: 'post',
- body: {
- name: name,
- params: params
- }
- }, function (response) {
- if (typeof response.files === 'undefined') {
- return;
- }
- var data = [];
- thumbs = response.thumbs || {};
- for (var i = 0; i < response.files.length; i++) {
- if (mode === 'selected' && response.files[i] !== value) {
- continue;
- }
- data.push({
- 'name': response.files[i],
- 'status': 'available',
- thumb: thumbs[response.files[i]] || ''
- });
- }
- for (var _i = 0; _i < response.pending.length; _i++) {
- if (mode === 'selected' && response.pending[_i] !== value) {
- continue;
- }
- data.push({
- 'name': response.pending[_i],
- 'status': 'pending',
- thumb: thumbs[response.pending[_i]] || ''
- });
- }
- folder = response.folder;
- callback(data, value);
- });
- };
- var imagesPreview = field.closest('[data-preview-images]').length > 0;
- var selectedIsRendered = false;
- var renderOption = function renderOption(item, escape) {
- var image = '';
- if (imagesPreview && folder && (!item.status || item.status === 'available') && item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i)) {
- // const fallback2x = insertTextAt(`${config.base_url_relative}/../${folder}/${item.name}`, -4, '@2x');
- // const fallback3x = insertTextAt(`${config.base_url_relative}/../${folder}/${item.name}`, -4, '@3x');
- 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}'}"
- image = "<img class=\"filepicker-field-image\" src=\"".concat(source, "\" />");
- }
- return "<div>\n <span class=\"title\">\n ".concat(image, " <span class=\"name filepicker-field-name\">").concat(escape(item.name), "</span>\n </span>\n </div>");
- };
- field.selectize({
- plugins: ['required-fix'],
- valueField: 'name',
- labelField: 'name',
- searchField: 'name',
- optgroups: [{
- $order: 1,
- value: 'pending',
- label: 'Pending'
- }, {
- $order: 2,
- value: 'available',
- label: 'Available'
- }],
- optgroupField: 'status',
- // lockOptgroupOrder: true,
- create: false,
- preload: false,
- // 'focus',
- render: {
- option: function option(item, escape) {
- return renderOption(item, escape);
- },
- item: function item(_item, escape) {
- return renderOption(_item, escape);
- }
- },
- onInitialize: function onInitialize() {
- if (!onDemand) {
- this.load(function (callback) {
- return getData(field, function (data) {
- return callback(data);
- }, 'selected');
- });
- }
- },
- onLoad: function
- /* data */
- onLoad() {
- if (!selectedIsRendered) {
- var name = this.getValue();
- this.updateOption(name, {
- name: name
- });
- selectedIsRendered = true;
- }
- },
- onFocus: function onFocus() {
- this.load(function (callback) {
- return getData(field, function (data) {
- return callback(data);
- });
- });
- }
- });
- }
- }]);
- return FilePickerField;
- }();
- var filepicker_Instance = new FilePickerField();
- ;// CONCATENATED MODULE: ./app/utils/selectize-option-click.js
- selectize_default().define('option_click', function (options) {
- var self = this;
- var setup = self.setup;
- this.setup = function () {
- setup.apply(self, arguments);
- var clicking = false; // Detect click on a .clickable
- self.$dropdown_content.on('mousedown click', function (e) {
- var target = external_jQuery_default()(e.target);
- if (target.hasClass('clickable') || target.closest('.clickable').length) {
- if (e.type === 'mousedown') {
- clicking = true;
- self.isFocused = false; // awful hack to defuse the document mousedown listener
- } else {
- self.isFocused = true;
- setTimeout(function () {
- clicking = false; // wait until blur has been preempted
- });
- }
- } else {
- // cleanup in case user right-clicked or dragged off the element
- clicking = false;
- self.isFocused = true;
- }
- }); // Intercept default handlers
- self.$dropdown.off('mousedown click', '[data-selectable]').on('mousedown click', '[data-selectable]', function () {
- if (!clicking) {
- return self.onOptionSelect.apply(self, arguments);
- }
- });
- self.$control_input.off('blur').on('blur', function () {
- if (!clicking) {
- return self.onBlur.apply(self, arguments);
- }
- });
- };
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/selectize.js
- function selectize_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function selectize_createClass(Constructor, protoProps, staticProps) { if (protoProps) selectize_defineProperties(Constructor.prototype, protoProps); if (staticProps) selectize_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var PagesRoute = {
- option: function option(item, escape) {
- var label = escape(item.text).split(' ');
- var arrows = label.shift();
- var slug = label.shift();
- 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>");
- }
- };
- var SelectizeField = /*#__PURE__*/function () {
- function SelectizeField() {
- var _this = this;
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- selectize_classCallCheck(this, SelectizeField);
- this.options = Object.assign({}, options);
- this.elements = [];
- external_jQuery_default()('[data-grav-selectize]').each(function (index, element) {
- return _this.add(element);
- });
- external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
- }
- selectize_createClass(SelectizeField, [{
- key: "add",
- value: function add(element) {
- element = external_jQuery_default()(element);
- if (element.closest('template').length) {
- return false;
- }
- var tag = element.prop('tagName').toLowerCase();
- var isInput = tag === 'input' || tag === 'select';
- var data = (isInput ? element.closest('[data-grav-selectize]') : element).data('grav-selectize') || {};
- var field = isInput ? element : element.find('input, select');
- if (field.attr('name') === 'data[route]') {
- data = external_jQuery_default().extend({}, data, {
- render: PagesRoute
- });
- }
- if (!field.length || field.get(0).selectize) {
- return;
- }
- var plugins = external_jQuery_default().merge(data.plugins ? data.plugins : [], ['required-fix']);
- field.selectize(external_jQuery_default().extend({}, data, {
- plugins: plugins
- }));
- this.elements.push(field.data('selectize'));
- }
- }, {
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target
- /* , record, instance */
- ) {
- var _this2 = this;
- var fields = external_jQuery_default()(target).find('select.fancy, input.fancy, [data-grav-selectize]').filter(function (index, element) {
- return !external_jQuery_default()(element).closest('template').length;
- });
- if (!fields.length) {
- return;
- }
- fields.each(function (index, field) {
- return _this2.add(field);
- });
- }
- }]);
- return SelectizeField;
- }();
- var selectize_Instance = new SelectizeField();
- ;// CONCATENATED MODULE: ./app/forms/fields/array.js
- function array_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function array_createClass(Constructor, protoProps, staticProps) { if (protoProps) array_defineProperties(Constructor.prototype, protoProps); if (staticProps) array_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var body = external_jQuery_default()('body');
- var Template = /*#__PURE__*/function () {
- function Template(container) {
- array_classCallCheck(this, Template);
- this.container = external_jQuery_default()(container);
- if (this.getName() === undefined) {
- this.container = this.container.closest('[data-grav-array-name]');
- }
- }
- array_createClass(Template, [{
- key: "getName",
- value: function getName() {
- return this.container.data('grav-array-name') || '';
- }
- }, {
- key: "getKeyPlaceholder",
- value: function getKeyPlaceholder() {
- return this.container.data('grav-array-keyname') || 'Key';
- }
- }, {
- key: "getValuePlaceholder",
- value: function getValuePlaceholder() {
- return this.container.data('grav-array-valuename') || 'Value';
- }
- }, {
- key: "isValueOnly",
- value: function isValueOnly() {
- return this.container.find('[data-grav-array-mode="value_only"]:first').length || false;
- }
- }, {
- key: "isTextArea",
- value: function isTextArea() {
- return this.container.data('grav-array-textarea') || false;
- }
- }, {
- key: "shouldBeDisabled",
- value: function shouldBeDisabled() {
- // check for toggleables, if field is toggleable and it's not enabled, render disabled
- var toggle = this.container.closest('.form-field').find('[data-grav-field="toggleable"] input[type="checkbox"]');
- return toggle.length && toggle.is(':not(:checked)');
- }
- }, {
- key: "getNewRow",
- value: function getNewRow() {
- var tpl = '';
- 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(), "\" />");
- if (this.isValueOnly()) {
- 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 ");
- } else {
- 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 ");
- }
- 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>";
- return tpl;
- }
- }]);
- return Template;
- }();
- var ArrayField = /*#__PURE__*/function () {
- function ArrayField() {
- var _this = this;
- array_classCallCheck(this, ArrayField);
- body.on('input', '[data-grav-array-type="key"], [data-grav-array-type="value"]', function (event) {
- return _this.actionInput(event);
- });
- body.on('click touch', '[data-grav-array-action]:not([data-grav-array-action="sort"])', function (event) {
- return _this.actionEvent(event);
- });
- this.arrays = external_jQuery_default()();
- external_jQuery_default()('[data-grav-field="array"]').each(function (index, list) {
- return _this.addArray(list);
- });
- external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
- }
- array_createClass(ArrayField, [{
- key: "addArray",
- value: function addArray(list) {
- var _this2 = this;
- list = external_jQuery_default()(list);
- list.find('[data-grav-array-type="container"]').each(function (index, container) {
- container = external_jQuery_default()(container);
- if (container.data('array-sort') || container[0].hasAttribute('data-array-nosort')) {
- return;
- }
- container.data('array-sort', new sortable_esm/* default */.ZP(container.get(0), {
- handle: '.fa-bars',
- animation: 150,
- onUpdate: function onUpdate() {
- var item = container.find('[data-grav-array-type="row"]:first');
- _this2._setTemplate(item);
- var template = item.data('array-template');
- _this2.refreshNames(template);
- }
- }));
- });
- }
- }, {
- key: "actionInput",
- value: function actionInput(event) {
- var element = external_jQuery_default()(event.target);
- var type = element.data('grav-array-type');
- this._setTemplate(element);
- var template = element.data('array-template');
- var keyElement = type === 'key' ? element : element.siblings('[data-grav-array-type="key"]:first');
- var valueElement = type === 'value' ? element : element.siblings('[data-grav-array-type="value"]:first');
- var escaped_name = !template.isValueOnly() ? keyElement.val() : this.getIndexFor(element);
- escaped_name = escaped_name.toString().replace(/\[/g, '%5B').replace(/]/g, '%5D');
- var name = "".concat(template.getName(), "[").concat(escaped_name, "]");
- if (!template.isValueOnly() && !keyElement.val() && !valueElement.val()) {
- valueElement.attr('name', '');
- } else {
- // valueElement.attr('name', !valueElement.val() ? template.getName() : name);
- valueElement.attr('name', name);
- }
- this.refreshNames(template);
- }
- }, {
- key: "actionEvent",
- value: function actionEvent(event) {
- event && event.preventDefault();
- var element = external_jQuery_default()(event.target);
- var action = element.data('grav-array-action');
- var container = element.parents('[data-grav-array-type="container"]');
- this._setTemplate(element);
- this["".concat(action, "Action")](element);
- var siblings = container.find('> div');
- container[siblings.length > 1 ? 'removeClass' : 'addClass']('one-child');
- }
- }, {
- key: "addAction",
- value: function addAction(element) {
- var template = element.data('array-template');
- var row = element.closest('[data-grav-array-type="row"]');
- row.after(template.getNewRow());
- }
- }, {
- key: "remAction",
- value: function remAction(element) {
- var template = element.data('array-template');
- var row = element.closest('[data-grav-array-type="row"]');
- var isLast = !row.siblings().length;
- if (isLast) {
- var newRow = external_jQuery_default()(template.getNewRow());
- row.after(newRow);
- newRow.find('[data-grav-array-type="value"]:last').attr('name', template.getName());
- }
- row.remove();
- this.refreshNames(template);
- }
- }, {
- key: "refreshNames",
- value: function refreshNames(template) {
- if (!template.isValueOnly()) {
- return;
- }
- var row = template.container.find('> div > [data-grav-array-type="row"]');
- var inputs = row.find('[name]:not([name=""])');
- inputs.each(function (index, input) {
- input = external_jQuery_default()(input);
- var preserved_name = input.closest('[data-grav-array-name]');
- var name = "".concat(preserved_name.attr('data-grav-array-name'), "[").concat(index, "]");
- input.attr('name', name);
- });
- if (!inputs.length) {
- row.find('[data-grav-array-type="value"]').attr('name', template.getName());
- }
- }
- }, {
- key: "getIndexFor",
- value: function getIndexFor(element) {
- var template = element.data('array-template');
- var row = element.closest('[data-grav-array-type="row"]');
- return template.container.find("".concat(template.isValueOnly() ? '> div ' : '', " > [data-grav-array-type=\"row\"]")).index(row);
- }
- }, {
- key: "_setTemplate",
- value: function _setTemplate(element) {
- if (!element.data('array-template')) {
- element.data('array-template', new Template(element.closest('[data-grav-array-name]')));
- }
- }
- }, {
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target
- /* , record, instance */
- ) {
- var _this3 = this;
- var arrays = external_jQuery_default()(target).find('[data-grav-field="array"]');
- if (!arrays.length) {
- return;
- }
- arrays.each(function (index, list) {
- list = external_jQuery_default()(list);
- if (!~_this3.arrays.index(list)) {
- _this3.addArray(list);
- }
- });
- }
- }]);
- return ArrayField;
- }();
- var array_Instance = new ArrayField();
- ;// CONCATENATED MODULE: ./app/forms/fields/collections.js
- function collections_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function collections_createClass(Constructor, protoProps, staticProps) { if (protoProps) collections_defineProperties(Constructor.prototype, protoProps); if (staticProps) collections_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var CollectionsField = /*#__PURE__*/function () {
- function CollectionsField() {
- var _this = this;
- collections_classCallCheck(this, CollectionsField);
- this.lists = external_jQuery_default()();
- var body = external_jQuery_default()('body');
- external_jQuery_default()('[data-type="collection"]').each(function (index, list) {
- return _this.addList(list);
- });
- body.on('mutation._grav', this._onAddedNodes.bind(this));
- body.on('click', function (event) {
- var target = external_jQuery_default()(event.target);
- if (!(target.is('[data-action="confirm"], [data-action="delete"]') || target.closest('[data-action="confirm"], [data-action="delete"]').length)) {
- CollectionsField.closeConfirmations();
- }
- });
- }
- collections_createClass(CollectionsField, [{
- key: "addList",
- value: function addList(list) {
- var _this2 = this;
- list = external_jQuery_default()(list);
- this.lists = this.lists.add(list);
- list.on('click', '> .collection-actions [data-action="add"]', function (event) {
- return _this2.addItem(event);
- });
- list.on('click', '> ul > li > .item-actions [data-action="confirm"]', function (event) {
- return _this2.confirmRemove(event);
- });
- list.on('click', '> ul > li > .item-actions [data-action="delete"]', function (event) {
- return _this2.removeItem(event);
- });
- list.on('click', '> ul > li > .item-actions [data-action="collapse"]', function (event) {
- return _this2.collapseItem(event);
- });
- list.on('click', '> ul > li > .item-actions [data-action="expand"]', function (event) {
- return _this2.expandItem(event);
- });
- list.on('click', '> .collection-actions [data-action-sort="date"]', function (event) {
- return _this2.sortItems(event);
- });
- list.on('click', '> .collection-actions [data-action="collapse_all"]', function (event) {
- return _this2.collapseItems(event);
- });
- list.on('click', '> .collection-actions [data-action="expand_all"]', function (event) {
- return _this2.expandItems(event);
- });
- list.on('input change', '[data-key-observe]', function (event) {
- return _this2.observeKey(event);
- });
- list.find('[data-collection-holder]').each(function (index, container) {
- container = external_jQuery_default()(container);
- if (container.data('collection-sort') || container[0].hasAttribute('data-collection-nosort')) {
- return;
- }
- container.data('collection-sort', new sortable_esm/* default */.ZP(container.get(0), {
- forceFallback: false,
- handle: '.collection-sort',
- animation: 150,
- onUpdate: function onUpdate() {
- return _this2.reindex(container);
- }
- }));
- });
- this._updateActionsStateBasedOnMinMax(list);
- }
- }, {
- key: "addItem",
- value: function addItem(event) {
- var button = external_jQuery_default()(event.currentTarget);
- var position = button.data('action-add') || 'bottom';
- var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
- var template = external_jQuery_default()(list.find('> [data-collection-template="new"]').data('collection-template-html'));
- this._updateActionsStateBasedOnMinMax(list);
- var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
- var maxItems = list.data('max');
- if (typeof maxItems !== 'undefined' && items.length >= maxItems) {
- return;
- }
- list.find('> [data-collection-holder]')[position === 'top' ? 'prepend' : 'append'](template);
- this.reindex(list);
- items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
- var topAction = list.closest('[data-type="collection"]').find('[data-action-add="top"]');
- var sortAction = list.closest('[data-type="collection"]').find('[data-action="sort"]');
- if (items.length) {
- if (topAction.length) {
- topAction.parent().removeClass('hidden');
- }
- if (sortAction.length && items.length > 1) {
- sortAction.removeClass('hidden');
- }
- } // refresh toggleables in a list
- external_jQuery_default()('[data-grav-field="toggleable"] input[type="checkbox"]').trigger('change');
- }
- }, {
- key: "confirmRemove",
- value: function confirmRemove(event) {
- var button = external_jQuery_default()(event.currentTarget);
- var list = external_jQuery_default()(button.closest('.item-actions'));
- var action = list.find('.list-confirm-deletion[data-action="delete"]');
- var isHidden = action.hasClass('hidden');
- CollectionsField.closeConfirmations();
- action[isHidden ? 'removeClass' : 'addClass']('hidden');
- }
- }, {
- key: "removeItem",
- value: function removeItem(event) {
- var button = external_jQuery_default()(event.currentTarget);
- var item = button.closest('[data-collection-item]');
- var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
- var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
- var minItems = list.data('min');
- if (typeof minItems !== 'undefined' && items.length <= minItems) {
- return;
- }
- item.remove();
- this.reindex(list);
- items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
- var topAction = list.closest('[data-type="collection"]').find('[data-action-add="top"]');
- var sortAction = list.closest('[data-type="collection"]').find('[data-action="sort"]');
- if (!items.length) {
- if (topAction.length) {
- topAction.parent().addClass('hidden');
- }
- }
- if (sortAction.length && items.length <= 1) {
- sortAction.addClass('hidden');
- }
- this._updateActionsStateBasedOnMinMax(list);
- }
- }, {
- key: "collapseItems",
- value: function collapseItems(event) {
- var button = external_jQuery_default()(event.currentTarget);
- var items = external_jQuery_default()(button.closest('[data-type="collection"]')).find('> ul > [data-collection-item] > .item-actions [data-action="collapse"]');
- items.click();
- }
- }, {
- key: "collapseItem",
- value: function collapseItem(event) {
- var button = external_jQuery_default()(event.currentTarget);
- var item = button.closest('[data-collection-item]');
- button.attr('data-action', 'expand').removeClass('fa-chevron-circle-down').addClass('fa-chevron-circle-right');
- item.addClass('collection-collapsed');
- }
- }, {
- key: "expandItems",
- value: function expandItems(event) {
- var button = external_jQuery_default()(event.currentTarget);
- var items = external_jQuery_default()(button.closest('[data-type="collection"]')).find('> ul > [data-collection-item] > .item-actions [data-action="expand"]');
- items.click();
- }
- }, {
- key: "expandItem",
- value: function expandItem(event) {
- var button = external_jQuery_default()(event.currentTarget);
- var item = button.closest('[data-collection-item]');
- button.attr('data-action', 'collapse').removeClass('fa-chevron-circle-right').addClass('fa-chevron-circle-down');
- item.removeClass('collection-collapsed');
- }
- }, {
- key: "sortItems",
- value: function sortItems(event) {
- var button = external_jQuery_default()(event.currentTarget);
- var sortby = button.data('action-sort');
- var sortby_dir = button.data('action-sort-dir') || 'asc';
- var list = external_jQuery_default()(button.closest('[data-type="collection"]'));
- var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
- items.sort(function (a, b) {
- var A = external_jQuery_default()(a).find('[name$="[' + sortby + ']"]');
- var B = external_jQuery_default()(b).find('[name$="[' + sortby + ']"]');
- var sort;
- if (sortby_dir === 'asc') {
- sort = A.val() < B.val() ? -1 : A.val() > B.val() ? 1 : 0;
- } else {
- sort = A.val() > B.val() ? -1 : A.val() < B.val() ? 1 : 0;
- }
- return sort;
- }).each(function (_, container) {
- external_jQuery_default()(container).parent().append(container);
- });
- this.reindex(list);
- }
- }, {
- key: "observeKey",
- value: function observeKey(event) {
- var input = external_jQuery_default()(event.target);
- var value = input.val();
- var item = input.closest('[data-collection-key]');
- item.data('collection-key-backup', item.data('collection-key')).data('collection-key', value);
- this.reindex(null, item);
- }
- }, {
- key: "reindex",
- value: function reindex(list, items) {
- items = items || external_jQuery_default()(list).closest('[data-type="collection"]').find('> ul > [data-collection-item]');
- items.each(function (index, item) {
- item = external_jQuery_default()(item);
- var observed = item.find('[data-key-observe]');
- var observedValue = observed.val();
- var hasCustomKey = observed.length;
- var currentKey = item.data('collection-key-backup');
- item.attr('data-collection-key', hasCustomKey ? observedValue : index);
- ['name', 'data-grav-field-name', 'for', 'id', 'data-grav-file-settings', 'data-file-post-add', 'data-file-post-remove', 'data-grav-array-name', 'data-grav-elements'].forEach(function (prop) {
- item.find('[' + prop + '], [_' + prop + ']').each(function () {
- var element = external_jQuery_default()(this);
- var indexes = [];
- var array_index = null;
- var regexps = [new RegExp('\\[(\\d+|\\*|' + currentKey + ')\\]', 'g'), new RegExp('\\.(\\d+|\\*|' + currentKey + ')\\.', 'g')]; // special case to preserve array field index keys
- if (prop === 'name' && element.data('gravArrayType')) {
- var match_index = element.attr(prop).match(/\[[0-9]{1,}\]$/);
- var pattern = element[0].closest('[data-grav-array-name]').dataset.gravArrayName;
- if (match_index && pattern) {
- array_index = match_index[0];
- element.attr(prop, "".concat(pattern).concat(match_index[0]));
- return;
- }
- }
- if (hasCustomKey && !observedValue) {
- element.attr("_".concat(prop), element.attr(prop));
- element.attr(prop, null);
- return;
- }
- if (element.attr("_".concat(prop))) {
- element.attr(prop, element.attr("_".concat(prop)));
- element.attr("_".concat(prop), null);
- }
- element.parents('[data-collection-key]').map(function (idx, parent) {
- return indexes.push(external_jQuery_default()(parent).attr('data-collection-key'));
- });
- indexes.reverse();
- var matchedKey = currentKey;
- var replaced = element.attr(prop).replace(regexps[0], function
- /* str, p1, offset */
- () {
- var extras = '';
- if (array_index) {
- extras = array_index;
- console.log(indexes, extras);
- }
- matchedKey = indexes.shift() || matchedKey;
- return "[".concat(matchedKey, "]").concat(extras);
- });
- replaced = replaced.replace(regexps[1], function
- /* str, p1, offset */
- () {
- matchedKey = indexes.shift() || matchedKey;
- return ".".concat(matchedKey, ".");
- });
- element.attr(prop, replaced);
- });
- });
- });
- }
- }, {
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target
- /* , record, instance */
- ) {
- var _this3 = this;
- var collections = external_jQuery_default()(target).find('[data-type="collection"]');
- if (!collections.length) {
- return;
- }
- collections.each(function (index, collection) {
- collection = external_jQuery_default()(collection);
- if (!~_this3.lists.index(collection)) {
- _this3.addList(collection);
- }
- });
- }
- }, {
- key: "_updateActionsStateBasedOnMinMax",
- value: function _updateActionsStateBasedOnMinMax(list) {
- var items = list.closest('[data-type="collection"]').find('> ul > [data-collection-item]');
- var minItems = list.data('min');
- var maxItems = list.data('max');
- list.find('> .collection-actions [data-action="add"]').attr('disabled', false);
- list.find('> ul > li > .item-actions [data-action="delete"]').attr('disabled', false);
- if (typeof minItems !== 'undefined' && items.length <= minItems) {
- list.find('> ul > li > .item-actions [data-action="delete"]').attr('disabled', true);
- }
- if (typeof maxItems !== 'undefined' && items.length >= maxItems) {
- list.find('> .collection-actions [data-action="add"]').attr('disabled', true);
- }
- }
- }], [{
- key: "closeConfirmations",
- value: function closeConfirmations() {
- external_jQuery_default()('.list-confirm-deletion[data-action="delete"]').addClass('hidden');
- }
- }]);
- return CollectionsField;
- }();
- var collections_Instance = new CollectionsField();
- // EXTERNAL MODULE: ./app/utils/bootstrap-datetimepicker.js
- var bootstrap_datetimepicker = __webpack_require__(19912);
- ;// CONCATENATED MODULE: ./app/forms/fields/datetime.js
- function datetime_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function datetime_createClass(Constructor, protoProps, staticProps) { if (protoProps) datetime_defineProperties(Constructor.prototype, protoProps); if (staticProps) datetime_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var DateTimeField = /*#__PURE__*/function () {
- function DateTimeField(options) {
- var _this = this;
- datetime_classCallCheck(this, DateTimeField);
- this.items = external_jQuery_default()();
- this.options = Object.assign({}, this.defaults, options);
- external_jQuery_default()('[data-grav-datetime]').each(function (index, field) {
- return _this.addItem(field);
- });
- external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
- }
- datetime_createClass(DateTimeField, [{
- key: "defaults",
- get: function get() {
- return {
- showTodayButton: true,
- showClear: true,
- locale: external_GravAdmin_namespaceObject.config.language || 'en',
- icons: {
- time: 'fa fa-clock-o',
- date: 'fa fa-calendar-o',
- up: 'fa fa-chevron-up',
- down: 'fa fa-chevron-down',
- previous: 'fa fa-chevron-left',
- next: 'fa fa-chevron-right',
- today: 'fa fa-bullseye',
- clear: 'fa fa-trash-o',
- close: 'fa fa-remove'
- }
- };
- }
- }, {
- key: "addItem",
- value: function addItem(list) {
- list = external_jQuery_default()(list);
- this.items = this.items.add(list);
- if (list.data('DateTimePicker')) {
- return;
- }
- var options = Object.assign({}, this.options, list.data('grav-datetime') || {});
- list.datetimepicker(options).on('dp.show dp.update', this._disableDecades);
- list.siblings('.field-icons').on('click', function () {
- return list.mousedown().focus();
- });
- }
- }, {
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target
- /* , record, instance */
- ) {
- var _this2 = this;
- var fields = external_jQuery_default()(target).find('[data-grav-datetime]');
- if (!fields.length) {
- return;
- }
- fields.each(function (index, field) {
- field = external_jQuery_default()(field);
- if (!~_this2.items.index(field)) {
- _this2.addItem(field);
- }
- });
- }
- }, {
- key: "_disableDecades",
- value: function _disableDecades() {
- external_jQuery_default()('.datepicker-years .picker-switch').removeAttr('title').on('click', function (e) {
- return e.stopPropagation();
- });
- }
- }]);
- return DateTimeField;
- }();
- var datetime_Instance = new DateTimeField();
- // EXTERNAL MODULE: ./node_modules/mout/math/clamp.js
- var clamp = __webpack_require__(19188);
- var clamp_default = /*#__PURE__*/__webpack_require__.n(clamp);
- // EXTERNAL MODULE: ./node_modules/mout/function/bind.js
- var bind = __webpack_require__(84596);
- var bind_default = /*#__PURE__*/__webpack_require__.n(bind);
- ;// CONCATENATED MODULE: ./app/utils/colors.js
- // Parses a string and returns a valid hex string when possible
- // parseHex('#fff') => '#ffffff'
- var parseHex = function parseHex(string) {
- string = string.replace(/[^A-F0-9]/ig, '');
- if (string.length !== 3 && string.length !== 6) return '';
- if (string.length === 3) {
- string = string[0] + string[0] + string[1] + string[1] + string[2] + string[2];
- }
- return '#' + string.toLowerCase();
- }; // Converts an HSB object to an RGB object
- // hsb2rgb({h: 0, s: 0, b: 100}) => {r: 255, g: 255, b: 255}
- var hsb2rgb = function hsb2rgb(hsb) {
- var rgb = {};
- var h = Math.round(hsb.h);
- var s = Math.round(hsb.s * 255 / 100);
- var v = Math.round(hsb.b * 255 / 100);
- if (s === 0) {
- rgb.r = rgb.g = rgb.b = v;
- } else {
- var t1 = v;
- var t2 = (255 - s) * v / 255;
- var t3 = (t1 - t2) * (h % 60) / 60;
- if (h === 360) h = 0;
- if (h < 60) {
- rgb.r = t1;
- rgb.b = t2;
- rgb.g = t2 + t3;
- } else if (h < 120) {
- rgb.g = t1;
- rgb.b = t2;
- rgb.r = t1 - t3;
- } else if (h < 180) {
- rgb.g = t1;
- rgb.r = t2;
- rgb.b = t2 + t3;
- } else if (h < 240) {
- rgb.b = t1;
- rgb.r = t2;
- rgb.g = t1 - t3;
- } else if (h < 300) {
- rgb.b = t1;
- rgb.g = t2;
- rgb.r = t2 + t3;
- } else if (h < 360) {
- rgb.r = t1;
- rgb.g = t2;
- rgb.b = t1 - t3;
- } else {
- rgb.r = 0;
- rgb.g = 0;
- rgb.b = 0;
- }
- }
- return {
- r: Math.round(rgb.r),
- g: Math.round(rgb.g),
- b: Math.round(rgb.b)
- };
- }; // Converts an RGB object to a HEX string
- // rgb2hex({r: 255, g: 255, b: 255}) => #ffffff
- var rgb2hex = function rgb2hex(rgb) {
- var hex = [rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)];
- hex.forEach(function (val, nr) {
- if (val.length === 1) hex[nr] = '0' + val;
- });
- return '#' + hex.join('');
- }; // Converts and RGB(a) string to a HEX string
- // rgbstr2hex('rgba(255, 255, 255, 0.5)') => #ffffff
- var rgbstr2hex = function rgbstr2hex(rgb) {
- rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
- 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) : '';
- }; // Converts an HSB object to a HEX string
- // hsb2hex({h: 0, s: 0, b: 100}) => #ffffff
- var hsb2hex = function hsb2hex(hsb) {
- return rgb2hex(hsb2rgb(hsb));
- }; // Converts a HEX string to an HSB object
- // hex2hsb('#ffffff') => {h: 0, s: 0, b: 100}
- var hex2hsb = function hex2hsb(hex) {
- var hsb = rgb2hsb(hex2rgb(hex));
- if (hsb.s === 0) hsb.h = 360;
- return hsb;
- }; // Converts an RGB object to an HSB object
- // rgb2hsb({r: 255, g: 255, b: 255}) => {h: 0, s: 0, b: 100}
- var rgb2hsb = function rgb2hsb(rgb) {
- var hsb = {
- h: 0,
- s: 0,
- b: 0
- };
- var min = Math.min(rgb.r, rgb.g, rgb.b);
- var max = Math.max(rgb.r, rgb.g, rgb.b);
- var delta = max - min;
- hsb.b = max;
- hsb.s = max !== 0 ? 255 * delta / max : 0;
- if (hsb.s !== 0) {
- if (rgb.r === max) {
- hsb.h = (rgb.g - rgb.b) / delta;
- } else if (rgb.g === max) {
- hsb.h = 2 + (rgb.b - rgb.r) / delta;
- } else {
- hsb.h = 4 + (rgb.r - rgb.g) / delta;
- }
- } else {
- hsb.h = -1;
- }
- hsb.h *= 60;
- if (hsb.h < 0) {
- hsb.h += 360;
- }
- hsb.s *= 100 / 255;
- hsb.b *= 100 / 255;
- return hsb;
- }; // Converts a HEX string to an RGB object
- // hex2rgb('#ffffff') => {r: 255, g: 255, b: 255}
- var hex2rgb = function hex2rgb(hex) {
- hex = parseInt(hex.indexOf('#') > -1 ? hex.substring(1) : hex, 16);
- return {
- /* jshint ignore:start */
- r: hex >> 16,
- g: (hex & 0x00FF00) >> 8,
- b: hex & 0x0000FF
- /* jshint ignore:end */
- };
- };
- ;// CONCATENATED MODULE: ./app/forms/fields/colorpicker.js
- function colorpicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function colorpicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) colorpicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) colorpicker_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
- var colorpicker_body = external_jQuery_default()('body');
- var MOUSEDOWN = 'mousedown touchstart MSPointerDown pointerdown';
- var MOUSEMOVE = 'mousemove touchmove MSPointerMove pointermove';
- var MOUSEUP = 'mouseup touchend MSPointerUp pointerup';
- var FOCUSIN = isFirefox ? 'focus' : 'focusin';
- var ColorpickerField = /*#__PURE__*/function () {
- function ColorpickerField(selector) {
- var _this = this;
- colorpicker_classCallCheck(this, ColorpickerField);
- this.selector = selector;
- this.field = external_jQuery_default()(this.selector);
- this.options = Object.assign({}, this.field.data('grav-colorpicker'));
- this.built = false;
- this.attach();
- if (this.options.update) {
- this.field.on('change._grav_colorpicker', function (event, field, hex, opacity) {
- var backgroundColor = hex;
- var rgb = hex2rgb(hex);
- if (opacity < 1) {
- backgroundColor = 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + opacity + ')';
- }
- var target = field.closest(_this.options.update);
- if (!target.length) {
- target = field.siblings(_this.options.update);
- }
- if (!target.length) {
- target = field.parent('.g-colorpicker').find(_this.options.update);
- }
- target.css({
- backgroundColor: backgroundColor
- });
- });
- }
- }
- colorpicker_createClass(ColorpickerField, [{
- key: "attach",
- value: function attach() {
- var _this2 = this;
- colorpicker_body.on(FOCUSIN, this.selector, function (event) {
- return _this2.show(event, event.currentTarget);
- });
- colorpicker_body.on(MOUSEDOWN, this.selector + ' .g-colorpicker, ' + this.selector + ' .g-colorpicker i', this.bound('iconClick'));
- colorpicker_body.on('keydown', this.selector, function (event) {
- switch (event.keyCode) {
- case 9:
- // tab
- _this2.hide();
- break;
- case 13: // enter
- case 27:
- // esc
- _this2.hide();
- event.currentTarget.blur();
- break;
- }
- return true;
- }); // Update on keyup
- colorpicker_body.on('keyup', this.selector, function (event) {
- _this2.updateFromInput(true, event.currentTarget);
- return true;
- }); // Update on paste
- colorpicker_body.on('paste', this.selector, function (event) {
- setTimeout(function () {
- return _this2.updateFromInput(true, event.currentTarget);
- }, 1);
- });
- }
- }, {
- key: "show",
- value: function show(event, target) {
- target = external_jQuery_default()(target);
- if (!this.built) {
- this.build();
- }
- this.element = target;
- this.reposition();
- this.wrapper.addClass('cp-visible');
- this.updateFromInput();
- this.wrapper.on(MOUSEDOWN, '.cp-grid, .cp-slider, .cp-opacity-slider', this.bound('bodyDown'));
- colorpicker_body.on(MOUSEMOVE, this.bound('bodyMove'));
- colorpicker_body.on(MOUSEDOWN, this.bound('bodyClick'));
- colorpicker_body.on(MOUSEUP, this.bound('targetReset'));
- external_jQuery_default()('#admin-main > .content-wrapper').on('scroll', this.bound('reposition'));
- }
- }, {
- key: "hide",
- value: function hide() {
- if (!this.built) {
- return;
- }
- this.wrapper.removeClass('cp-visible');
- this.wrapper.undelegate(MOUSEDOWN, '.cp-grid, .cp-slider, .cp-opacity-slider', this.bound('bodyDown'));
- colorpicker_body.off(MOUSEMOVE, this.bound('bodyMove'));
- colorpicker_body.off(MOUSEDOWN, this.bound('bodyClick'));
- colorpicker_body.off(MOUSEUP, this.bound('targetReset'));
- external_jQuery_default()('#admin-main > .content-wrapper').on('scroll', this.bound('reposition'));
- }
- }, {
- key: "build",
- value: function build() {
- var _this3 = this;
- this.wrapper = external_jQuery_default()('<div class="cp-wrapper cp-with-opacity cp-mode-hue" />');
- this.slider = external_jQuery_default()('<div class="cp-slider cp-sprite" />').appendTo(this.wrapper).append(external_jQuery_default()('<div class="cp-picker" />'));
- this.opacitySlider = external_jQuery_default()('<div class="cp-opacity-slider cp-sprite" />').appendTo(this.wrapper).append(external_jQuery_default()('<div class="cp-picker" />'));
- 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" />'));
- external_jQuery_default()('<div />').appendTo(this.grid.find('.cp-picker'));
- var tabs = external_jQuery_default()('<div class="cp-tabs" />').appendTo(this.wrapper);
- this.tabs = {
- hue: external_jQuery_default()('<div class="cp-tab-hue active" />').text('HUE').appendTo(tabs),
- brightness: external_jQuery_default()('<div class="cp-tab-brightness" />').text('BRI').appendTo(tabs),
- saturation: external_jQuery_default()('<div class="cp-tab-saturation" />').text('SAT').appendTo(tabs),
- wheel: external_jQuery_default()('<div class="cp-tab-wheel" />').text('WHEEL').appendTo(tabs),
- transparent: external_jQuery_default()('<div class="cp-tab-transp" />').text('TRANSPARENT').appendTo(tabs)
- };
- tabs.on(MOUSEDOWN, '> div', function (event) {
- var element = external_jQuery_default()(event.currentTarget);
- if (element.is(_this3.tabs.transparent)) {
- var sliderHeight = _this3.opacitySlider.height();
- _this3.opacity = 0;
- _this3.opacitySlider.find('.cp-picker').css({
- 'top': clamp_default()(sliderHeight - sliderHeight * _this3.opacity, 0, sliderHeight)
- });
- _this3.move(_this3.opacitySlider, {
- manualOpacity: true
- });
- return;
- }
- var active = tabs.find('.active');
- var mode = active.attr('class').replace(/\s|active|cp-tab-/g, '');
- var newMode = element.attr('class').replace(/\s|active|cp-tab-/g, '');
- _this3.wrapper.removeClass('cp-mode-' + mode).addClass('cp-mode-' + newMode);
- active.removeClass('active');
- element.addClass('active');
- _this3.mode = newMode;
- _this3.updateFromInput();
- });
- this.wrapper.appendTo('.content-wrapper');
- this.built = true;
- this.mode = 'hue';
- }
- }, {
- key: "reposition",
- value: function reposition() {
- var ct = external_jQuery_default()('.content-wrapper')[0];
- var offset = this.element[0].getBoundingClientRect();
- var ctOffset = ct.getBoundingClientRect();
- var delta = {
- x: 0,
- y: 0
- };
- if (this.options.offset) {
- delta.x = this.options.offset.x || 0;
- delta.y = this.options.offset.y || 0;
- }
- this.wrapper.css({
- top: offset.top + offset.height + ct.scrollTop - ctOffset.top + delta.y,
- left: offset.left + ct.scrollLeft - ctOffset.left + delta.x
- });
- }
- }, {
- key: "iconClick",
- value: function iconClick(event) {
- if (this.wrapper && this.wrapper.hasClass('cp-visible')) {
- return true;
- }
- event && event.preventDefault();
- var input = external_jQuery_default()(event.currentTarget).find('input');
- setTimeout(function () {
- return input.focus();
- }, 50);
- }
- }, {
- key: "bodyMove",
- value: function bodyMove(event) {
- event && event.preventDefault();
- if (this.target) {
- this.move(this.target, event);
- }
- }
- }, {
- key: "bodyClick",
- value: function bodyClick(event) {
- var target = external_jQuery_default()(event.target);
- if (!target.closest('.cp-wrapper').length && !target.is(this.selector)) {
- this.hide();
- }
- }
- }, {
- key: "bodyDown",
- value: function bodyDown(event) {
- event && event.preventDefault();
- this.target = external_jQuery_default()(event.currentTarget);
- this.move(this.target, event, true);
- }
- }, {
- key: "targetReset",
- value: function targetReset(event) {
- event && event.preventDefault();
- this.target = null;
- }
- }, {
- key: "move",
- value: function move(target, event) {
- var input = this.element;
- var picker = target.find('.cp-picker');
- var clientRect = target[0].getBoundingClientRect();
- var offsetX = clientRect.left + window.scrollX;
- var offsetY = clientRect.top + window.scrollY;
- var x = Math.round((event ? event.pageX : 0) - offsetX);
- var y = Math.round((event ? event.pageY : 0) - offsetY);
- var wx;
- var wy;
- var r;
- var phi; // Touch support
- var touchEvents = event.changedTouches || event.originalEvent && event.originalEvent.changedTouches;
- if (event && touchEvents) {
- x = (touchEvents ? touchEvents[0].pageX : 0) - offsetX;
- y = (touchEvents ? touchEvents[0].pageY : 0) - offsetY;
- }
- if (event && event.manualOpacity) {
- y = clientRect.height;
- } // Constrain picker to its container
- if (x < 0) x = 0;
- if (y < 0) y = 0;
- if (x > clientRect.width) x = clientRect.width;
- if (y > clientRect.height) y = clientRect.height; // Constrain color wheel values to the wheel
- if (target.parent('.cp-mode-wheel').length && picker.parent('.cp-grid').length) {
- wx = 75 - x;
- wy = 75 - y;
- r = Math.sqrt(wx * wx + wy * wy);
- phi = Math.atan2(wy, wx);
- if (phi < 0) phi += Math.PI * 2;
- if (r > 75) {
- x = 75 - 75 * Math.cos(phi);
- y = 75 - 75 * Math.sin(phi);
- }
- x = Math.round(x);
- y = Math.round(y);
- } // Move the picker
- if (target.hasClass('cp-grid')) {
- picker.css({
- top: y,
- left: x
- });
- this.updateFromPicker(input, target);
- } else {
- picker.css({
- top: y
- });
- this.updateFromPicker(input, target);
- }
- }
- }, {
- key: "updateFromInput",
- value: function updateFromInput(dontFireEvent, element) {
- element = element ? external_jQuery_default()(element) : this.element;
- var value = element.val();
- var opacity = value.replace(/\s/g, '').match(/^rgba?\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},(.+)\)/);
- var hex;
- var hsb;
- value = rgbstr2hex(value) || value;
- opacity = opacity ? clamp_default()(opacity[1], 0, 1) : 1;
- if (!(hex = parseHex(value))) {
- hex = '#ffffff';
- }
- hsb = hex2hsb(hex);
- if (this.built) {
- // opacity
- this.opacity = opacity;
- var sliderHeight = this.opacitySlider.height();
- this.opacitySlider.find('.cp-picker').css({
- 'top': clamp_default()(sliderHeight - sliderHeight * this.opacity, 0, sliderHeight)
- }); // bg color
- var gridHeight = this.grid.height();
- var gridWidth = this.grid.width();
- var r;
- var phi;
- var x;
- var y;
- sliderHeight = this.slider.height();
- switch (this.mode) {
- case 'wheel':
- // Set grid position
- r = clamp_default()(Math.ceil(hsb.s * 0.75), 0, gridHeight / 2);
- phi = hsb.h * Math.PI / 180;
- x = clamp_default()(75 - Math.cos(phi) * r, 0, gridWidth);
- y = clamp_default()(75 - Math.sin(phi) * r, 0, gridHeight);
- this.grid.css({
- backgroundColor: 'transparent'
- }).find('.cp-picker').css({
- top: y,
- left: x
- }); // Set slider position
- y = 150 - hsb.b / (100 / gridHeight);
- if (hex === '') y = 0;
- this.slider.find('.cp-picker').css({
- top: y
- }); // Update panel color
- this.slider.css({
- backgroundColor: hsb2hex({
- h: hsb.h,
- s: hsb.s,
- b: 100
- })
- });
- break;
- case 'saturation':
- // Set grid position
- x = clamp_default()(5 * hsb.h / 12, 0, 150);
- y = clamp_default()(gridHeight - Math.ceil(hsb.b / (100 / gridHeight)), 0, gridHeight);
- this.grid.find('.cp-picker').css({
- top: y,
- left: x
- }); // Set slider position
- y = clamp_default()(sliderHeight - hsb.s * (sliderHeight / 100), 0, sliderHeight);
- this.slider.find('.cp-picker').css({
- top: y
- }); // Update UI
- this.slider.css({
- backgroundColor: hsb2hex({
- h: hsb.h,
- s: 100,
- b: hsb.b
- })
- });
- this.grid.find('.cp-grid-inner').css({
- opacity: hsb.s / 100
- });
- break;
- case 'brightness':
- // Set grid position
- x = clamp_default()(5 * hsb.h / 12, 0, 150);
- y = clamp_default()(gridHeight - Math.ceil(hsb.s / (100 / gridHeight)), 0, gridHeight);
- this.grid.find('.cp-picker').css({
- top: y,
- left: x
- }); // Set slider position
- y = clamp_default()(sliderHeight - hsb.b * (sliderHeight / 100), 0, sliderHeight);
- this.slider.find('.cp-picker').css({
- top: y
- }); // Update UI
- this.slider.css({
- backgroundColor: hsb2hex({
- h: hsb.h,
- s: hsb.s,
- b: 100
- })
- });
- this.grid.find('.cp-grid-inner').css({
- opacity: 1 - hsb.b / 100
- });
- break;
- case 'hue':
- default:
- // Set grid position
- x = clamp_default()(Math.ceil(hsb.s / (100 / gridWidth)), 0, gridWidth);
- y = clamp_default()(gridHeight - Math.ceil(hsb.b / (100 / gridHeight)), 0, gridHeight);
- this.grid.find('.cp-picker').css({
- top: y,
- left: x
- }); // Set slider position
- y = clamp_default()(sliderHeight - hsb.h / (360 / sliderHeight), 0, sliderHeight);
- this.slider.find('.cp-picker').css({
- top: y
- }); // Update panel color
- this.grid.css({
- backgroundColor: hsb2hex({
- h: hsb.h,
- s: 100,
- b: 100
- })
- });
- break;
- }
- }
- if (!dontFireEvent) {
- element.val(this.getValue(hex));
- }
- (this.element || element).trigger('change._grav_colorpicker', [element, hex, opacity]);
- }
- }, {
- key: "updateFromPicker",
- value: function updateFromPicker(input, target) {
- var getCoords = function getCoords(picker, container) {
- var left, top;
- if (!picker.length || !container) return null;
- left = picker[0].getBoundingClientRect().left;
- top = picker[0].getBoundingClientRect().top;
- return {
- x: left - container[0].getBoundingClientRect().left + picker[0].offsetWidth / 2,
- y: top - container[0].getBoundingClientRect().top + picker[0].offsetHeight / 2
- };
- };
- var hex;
- var hue;
- var saturation;
- var brightness;
- var x;
- var y;
- var r;
- var phi; // Panel objects
- var grid = this.wrapper.find('.cp-grid');
- var slider = this.wrapper.find('.cp-slider');
- var opacitySlider = this.wrapper.find('.cp-opacity-slider'); // Picker objects
- var gridPicker = grid.find('.cp-picker');
- var sliderPicker = slider.find('.cp-picker');
- var opacityPicker = opacitySlider.find('.cp-picker'); // Picker positions
- var gridPos = getCoords(gridPicker, grid);
- var sliderPos = getCoords(sliderPicker, slider);
- var opacityPos = getCoords(opacityPicker, opacitySlider); // Sizes
- var gridWidth = grid[0].getBoundingClientRect().width;
- var gridHeight = grid[0].getBoundingClientRect().height;
- var sliderHeight = slider[0].getBoundingClientRect().height;
- var opacitySliderHeight = opacitySlider[0].getBoundingClientRect().height;
- var value = this.element.val();
- value = rgbstr2hex(value) || value;
- if (!(hex = parseHex(value))) {
- hex = '#ffffff';
- } // Handle colors
- if (target.hasClass('cp-grid') || target.hasClass('cp-slider')) {
- // Determine HSB values
- switch (this.mode) {
- case 'wheel':
- // Calculate hue, saturation, and brightness
- x = gridWidth / 2 - gridPos.x;
- y = gridHeight / 2 - gridPos.y;
- r = Math.sqrt(x * x + y * y);
- phi = Math.atan2(y, x);
- if (phi < 0) phi += Math.PI * 2;
- if (r > 75) {
- r = 75;
- gridPos.x = 69 - 75 * Math.cos(phi);
- gridPos.y = 69 - 75 * Math.sin(phi);
- }
- saturation = clamp_default()(r / 0.75, 0, 100);
- hue = clamp_default()(phi * 180 / Math.PI, 0, 360);
- brightness = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
- hex = hsb2hex({
- h: hue,
- s: saturation,
- b: brightness
- }); // Update UI
- slider.css({
- backgroundColor: hsb2hex({
- h: hue,
- s: saturation,
- b: 100
- })
- });
- break;
- case 'saturation':
- // Calculate hue, saturation, and brightness
- hue = clamp_default()(parseInt(gridPos.x * (360 / gridWidth), 10), 0, 360);
- saturation = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
- brightness = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
- hex = hsb2hex({
- h: hue,
- s: saturation,
- b: brightness
- }); // Update UI
- slider.css({
- backgroundColor: hsb2hex({
- h: hue,
- s: 100,
- b: brightness
- })
- });
- grid.find('.cp-grid-inner').css({
- opacity: saturation / 100
- });
- break;
- case 'brightness':
- // Calculate hue, saturation, and brightness
- hue = clamp_default()(parseInt(gridPos.x * (360 / gridWidth), 10), 0, 360);
- saturation = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
- brightness = clamp_default()(100 - Math.floor(sliderPos.y * (100 / sliderHeight)), 0, 100);
- hex = hsb2hex({
- h: hue,
- s: saturation,
- b: brightness
- }); // Update UI
- slider.css({
- backgroundColor: hsb2hex({
- h: hue,
- s: saturation,
- b: 100
- })
- });
- grid.find('.cp-grid-inner').css({
- opacity: 1 - brightness / 100
- });
- break;
- default:
- // Calculate hue, saturation, and brightness
- hue = clamp_default()(360 - parseInt(sliderPos.y * (360 / sliderHeight), 10), 0, 360);
- saturation = clamp_default()(Math.floor(gridPos.x * (100 / gridWidth)), 0, 100);
- brightness = clamp_default()(100 - Math.floor(gridPos.y * (100 / gridHeight)), 0, 100);
- hex = hsb2hex({
- h: hue,
- s: saturation,
- b: brightness
- }); // Update UI
- grid.css({
- backgroundColor: hsb2hex({
- h: hue,
- s: 100,
- b: 100
- })
- });
- break;
- }
- } // Handle opacity
- if (target.hasClass('cp-opacity-slider')) {
- this.opacity = parseFloat(1 - opacityPos.y / opacitySliderHeight).toFixed(2);
- } // Adjust case
- input.val(this.getValue(hex)); // Handle change event
- this.element.trigger('change._grav_colorpicker', [this.element, hex, this.opacity]);
- }
- }, {
- key: "getValue",
- value: function getValue(hex) {
- if (this.opacity === 1) {
- return hex;
- }
- var rgb = hex2rgb(hex);
- return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + this.opacity + ')';
- }
- }, {
- key: "bound",
- value: function bound(name) {
- var bound = this._bound || (this._bound = {});
- return bound[name] || (bound[name] = bind_default()(this[name], this));
- }
- }]);
- return ColorpickerField;
- }();
- var colorpicker_Instance = new ColorpickerField('[data-grav-colorpicker]');
- ;// CONCATENATED MODULE: ./app/forms/fields/folder.js
- var Regenerate = function Regenerate() {
- var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '[name="data[folder]"]';
- var element = external_jQuery_default()(field);
- var title = external_jQuery_default()('[name="data[header][title]"]');
- var slug = external_jQuery_default().slugify(title.val(), {
- custom: {
- "'": ''
- }
- });
- element.addClass('highlight').val(slug);
- setTimeout(function () {
- return element.removeClass('highlight');
- }, 500);
- };
- external_jQuery_default()(document).on('click', '[data-regenerate]', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var field = external_jQuery_default()(target.data('regenerate'));
- Regenerate(field);
- });
- /* harmony default export */ const fields_folder = (Regenerate);
- // EXTERNAL MODULE: ./node_modules/mout/object/forIn.js
- var forIn = __webpack_require__(15473);
- var forIn_default = /*#__PURE__*/__webpack_require__.n(forIn);
- ;// CONCATENATED MODULE: ./app/forms/fields/selectunique.js
- function selectunique_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function selectunique_createClass(Constructor, protoProps, staticProps) { if (protoProps) selectunique_defineProperties(Constructor.prototype, protoProps); if (staticProps) selectunique_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- // import { config } from 'grav-config';
- var Data = {};
- var SelectUniqueField = /*#__PURE__*/function () {
- function SelectUniqueField(options) {
- var _this = this;
- selectunique_classCallCheck(this, SelectUniqueField);
- var body = external_jQuery_default()('body');
- this.items = external_jQuery_default()();
- this.options = Object.assign({}, this.defaults, options);
- external_jQuery_default()('[data-select-observe]').each(function (index, element) {
- return _this.addSelect(element);
- }).last().trigger('change', {
- load: true
- });
- body.on('mutation._grav', this._onAddedNodes.bind(this));
- body.on('mutation_removed._grav', this._onRemovedNodes.bind(this));
- }
- selectunique_createClass(SelectUniqueField, [{
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target, record, instance) {
- var _this2 = this;
- var fields = external_jQuery_default()(target).find('[data-select-observe]');
- if (!fields.length) {
- return;
- }
- fields.each(function (index, field) {
- field = external_jQuery_default()(field);
- if (!~_this2.items.index(field)) {
- _this2.addSelect(field);
- }
- });
- }
- }, {
- key: "_onRemovedNodes",
- value: function _onRemovedNodes(event, data
- /* , instance */
- ) {
- var _this3 = this;
- var target = external_jQuery_default()(data.target);
- var holder = target.data('collectionHolder');
- if (!holder) {
- return false;
- }
- var node = external_jQuery_default()(data.mutation.removedNodes);
- var value = node.find('[data-select-observe]').val();
- if (value) {
- Data[holder].state[value] = value;
- }
- target.find('[data-select-observe]').each(function (index, field) {
- field = external_jQuery_default()(field);
- if (field.val() !== value) {
- _this3.updateOptions(field);
- }
- });
- }
- }, {
- key: "addSelect",
- value: function addSelect(element) {
- var _this4 = this;
- this.items = this.items.add(element);
- element = external_jQuery_default()(element);
- var value = element.attr('value');
- var holder = element.closest('[data-collection-holder]').data('collectionHolder');
- var options = element.closest('[data-select-unique]').data('selectUnique');
- if (!Data[holder]) {
- var data = {};
- if (Array.isArray(options)) {
- options.slice(0).map(function (item) {
- data[item] = item;
- });
- } else {
- data = Object.assign({}, options);
- }
- Data[holder] = {
- original: null,
- state: null
- };
- Data[holder].original = Object.assign({}, data);
- Data[holder].state = Object.assign({}, data);
- }
- this.updateOptions(element);
- element.data('originalValue', value);
- element.on('change', function (event, extras) {
- var target = external_jQuery_default()(event.currentTarget);
- if (target.data('dummyChange')) {
- target.data('dummyChange', false);
- return false;
- }
- _this4.refreshOptions(target, extras && extras.load ? null : element.data('originalValue'));
- element.data('originalValue', target.val());
- });
- }
- }, {
- key: "updateOptions",
- value: function updateOptions(element) {
- element = external_jQuery_default()(element);
- var value = element.attr('value');
- var holder = element.closest('[data-collection-holder]').data('collectionHolder');
- forIn_default()(Data[holder].state, function (v, k) {
- var selected = k === value ? 'selected="selected"' : '';
- if (element.get(0).selectize) {
- var selectize = element.data('selectize');
- selectize.removeOption(k);
- selectize.addOption({
- value: k,
- text: v
- });
- } else {
- element.append("<option value=\"".concat(k, "\" ").concat(selected, ">").concat(v, "</option>"));
- }
- if (selected) {
- if (element.get(0).selectize) {
- var _selectize = element.data('selectize');
- _selectize.setValue(k);
- }
- delete Data[holder].state[value];
- }
- });
- }
- }, {
- key: "refreshOptions",
- value: function refreshOptions(element, originalValue) {
- var value = element.val();
- var holder = element.closest('[data-collection-holder]').data('collectionHolder');
- delete Data[holder].state[value];
- if (originalValue && Data[holder].original[originalValue]) {
- Data[holder].state[originalValue] = Data[holder].original[originalValue];
- }
- this.items.each(function (index, select) {
- select = external_jQuery_default()(select);
- if (select[0] === element[0]) {
- return;
- }
- var selectedValue = select.val();
- select.data('dummyChange', true);
- if (select.get(0).selectize) {
- var selectize = select.data('selectize');
- if (selectize) {
- selectize.clearOptions();
- if (selectedValue) {
- selectize.addOption({
- value: selectedValue,
- text: Data[holder].original[selectedValue] || selectedValue
- });
- }
- forIn_default()(Data[holder].state, function (v, k) {
- selectize.addOption({
- value: k,
- text: v
- });
- });
- selectize.setValue(selectedValue, true);
- }
- } else {
- select.empty();
- forIn_default()(Data[holder].state, function (v, k) {
- var selected = k === selectedValue ? 'selected="selected"' : '';
- select.append("<option value=\"".concat(k, "\" ").concat(selected, ">").concat(v, "</option>"));
- });
- }
- select.data('dummyChange', false);
- });
- }
- }]);
- return SelectUniqueField;
- }();
- var selectunique_Instance = new SelectUniqueField();
- ;// CONCATENATED MODULE: ./app/forms/fields/iconpicker.js
- function iconpicker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function iconpicker_createClass(Constructor, protoProps, staticProps) { if (protoProps) iconpicker_defineProperties(Constructor.prototype, protoProps); if (staticProps) iconpicker_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- /* Icon Picker by QueryLoop
- * Author: @eliorivero
- * URL: http://queryloop.com/
- * License: GPLv2
- */
- var iconpicker_defaults = {
- 'mode': 'dialog',
- // show overlay 'dialog' panel or slide down 'inline' panel
- 'closeOnPick': true,
- // whether to close panel after picking or 'no'
- 'save': 'class',
- // save icon 'class' or 'code'
- 'size': '',
- 'classes': {
- 'launcher': '',
- // extra classes for launcher buttons
- 'clear': 'remove-times',
- // extra classes for button that removes preview and clears field
- 'highlight': '',
- // extra classes when highlighting an icon
- 'close': '' // extra classes for close button
- },
- 'iconSets': {
- // example data structure. Used to specify which launchers will be created
- 'genericon': 'Genericon',
- // create a launcher to pick genericon icons
- 'fa': 'FontAwesome' // create a launcher to pick fontawesome icons
- }
- };
- var QL_Icon_Picker = /*#__PURE__*/function () {
- function QL_Icon_Picker(element, options) {
- iconpicker_classCallCheck(this, QL_Icon_Picker);
- this.iconSet = '';
- this.iconSetName = '';
- this.$field = '';
- this.element = element;
- this.settings = external_jQuery_default().extend({}, iconpicker_defaults, options);
- this._defaults = iconpicker_defaults;
- this.init();
- }
- iconpicker_createClass(QL_Icon_Picker, [{
- key: "init",
- value: function init() {
- var $brick = external_jQuery_default()(this.element);
- var pickerId = $brick.data('pickerid');
- var $preview = external_jQuery_default()('<div class="icon-preview icon-preview-' + pickerId + '" />');
- this.$field = $brick.find('input'); // Add preview area
- this.makePreview($brick, pickerId, $preview); // Make button to clear field and remove preview
- this.makeClear(pickerId, $preview); // Make buttons that open the panel of icons
- this.makeLaunchers($brick, pickerId); // Prepare display styles, inline and dialog
- this.makeDisplay($brick);
- }
- }, {
- key: "makePreview",
- value: function makePreview($brick, pickerId, $preview) {
- var $icon = external_jQuery_default()('<i />');
- var iconValue = this.$field.val();
- $preview.prependTo($brick);
- $icon.prependTo($preview);
- if (iconValue !== '') {
- $preview.addClass('icon-preview-on');
- $icon.addClass(iconValue);
- }
- }
- }, {
- key: "makeClear",
- value: function makeClear(pickerId, $preview) {
- var base = this;
- 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
- $clear.hide().prependTo($preview); // If there's a icon saved in the field, show remove icon button
- if (base.$field.val() !== '') {
- $clear.show();
- }
- $preview.on('click', '.remove-icon', function (e) {
- e.preventDefault();
- base.$field.val('');
- $preview.removeClass('icon-preview-on').find('i').removeClass();
- external_jQuery_default()(this).hide();
- });
- }
- }, {
- key: "makeDisplay",
- value: function makeDisplay($brick) {
- var base = this;
- var close = base.settings.classes.close;
- var $body = external_jQuery_default()('body');
- var $close = external_jQuery_default()('<a href="#" class="icon-picker-close"/>');
- if (base.settings.mode === 'inline') {
- $brick.find('.icon-set').append($close).removeClass('dialog').addClass('ip-inline ' + base.settings.size).parent().addClass('icon-set-wrap');
- } else if (base.settings.mode === 'dialog') {
- external_jQuery_default()('.icon-set').addClass('dialog ' + base.settings.size);
- if (external_jQuery_default()('.icon-picker-overlay').length <= 0) {
- $body.append('<div class="icon-picker-overlay"/>').append($close);
- }
- }
- $body.on('click', '.icon-picker-close, .icon-picker-overlay', function (e) {
- e.preventDefault();
- base.closePicker($brick, external_jQuery_default()(base.iconSet), base.settings.mode);
- }).on('mouseenter mouseleave', '.icon-picker-close', function (e) {
- if (e.type === 'mouseenter') {
- external_jQuery_default()(this).addClass(close);
- } else {
- external_jQuery_default()(this).removeClass(close);
- }
- });
- }
- }, {
- key: "makeLaunchers",
- value: function makeLaunchers($brick) {
- var base = this;
- var dataIconSets = $brick.data('iconsets');
- var iconSet;
- if (typeof dataIconSets === 'undefined') {
- dataIconSets = base.settings.iconSets;
- }
- for (iconSet in dataIconSets) {
- if (dataIconSets.hasOwnProperty(iconSet)) {
- $brick.append('<a class="launch-icons button ' + base.settings.classes.launcher + '" data-icons="' + iconSet + '">' + dataIconSets[iconSet] + '</a>');
- }
- }
- $brick.find('.launch-icons').on('click', function (e) {
- e.preventDefault();
- var $self = external_jQuery_default()(this);
- var theseIcons = $self.data('icons');
- base.iconSetName = theseIcons;
- base.iconSet = '.' + theseIcons + '-set'; // Initialize picker
- base.iconPick($brick); // Show icon picker
- base.showPicker($brick, external_jQuery_default()(base.iconSet), base.settings.mode);
- });
- }
- }, {
- key: "iconPick",
- value: function iconPick($brick) {
- var base = this;
- var highlight = 'icon-highlight ' + base.settings.classes.highlight;
- external_jQuery_default()(base.iconSet).on('click', 'li', function (e) {
- e.preventDefault();
- var $icon = external_jQuery_default()(this);
- var icon = $icon.data(base.settings.save); // Mark as selected
- external_jQuery_default()('.icon-selected').removeClass('icon-selected');
- $icon.addClass('icon-selected');
- if (base.$field.data('format') === 'short') {
- icon = icon.slice(6);
- } // Save icon value to field
- base.$field.val(icon); // Close icon picker
- if (base.settings.closeOnPick) {
- base.closePicker($brick, $icon.closest(base.iconSet), base.settings.mode);
- } // Set preview
- base.setPreview($icon.data('class')); // Broadcast event passing the selected icon.
- external_jQuery_default()('body').trigger('iconselected.queryloop', icon);
- });
- external_jQuery_default()(base.iconSet).on('mouseenter mouseleave', 'li', function (e) {
- if (e.type === 'mouseenter') {
- external_jQuery_default()(this).addClass(highlight);
- } else {
- external_jQuery_default()(this).removeClass(highlight);
- }
- });
- }
- }, {
- key: "showPicker",
- value: function showPicker($brick, $icons, mode) {
- if (mode === 'inline') {
- external_jQuery_default()('.icon-set').removeClass('ip-inline-open');
- $brick.find($icons).toggleClass('ip-inline-open');
- } else if (mode === 'dialog') {
- $brick.find('.icon-picker-close').addClass('make-visible');
- $brick.find('.icon-picker-overlay').addClass('make-visible');
- $icons.addClass('dialog-open');
- }
- $icons.find('.icon-selected').removeClass('icon-selected');
- var selectedIcon = this.$field.val().replace(' ', '.');
- if (selectedIcon !== '') {
- if (this.settings.save === 'class') {
- $icons.find('.' + selectedIcon).addClass('icon-selected');
- } else {
- $icons.find('[data-code="' + selectedIcon + '"]').addClass('icon-selected');
- }
- } // Broadcast event when the picker is shown passing the picker mode.
- external_jQuery_default()('body').trigger('iconpickershow.queryloop', mode);
- }
- }, {
- key: "closePicker",
- value: function closePicker($brick, $icons, mode) {
- // Remove event so they don't fire from a different picker
- external_jQuery_default()(this.iconSet).off('click', 'li');
- if (mode === 'inline') {
- $brick.find($icons).removeClass('ip-inline-open');
- } else if (mode === 'dialog') {
- external_jQuery_default()('.icon-picker-close, .icon-picker-overlay').removeClass('make-visible');
- } // Broadcast event when the picker is closed passing the picker mode.
- external_jQuery_default()('body').trigger('iconpickerclose.queryloop', mode);
- external_jQuery_default()('.icon-set').removeClass('dialog-open');
- }
- }, {
- key: "setPreview",
- value: function setPreview(preview) {
- var $preview = external_jQuery_default()(this.element).find('.icon-preview');
- $preview.addClass('icon-preview-on').find('i').removeClass().addClass(this.iconSetName).addClass(preview);
- $preview.find('a').show();
- }
- }]);
- return QL_Icon_Picker;
- }();
- /* Grav */
- // extend $ with 3rd party QL Icon Picker
- (external_jQuery_default()).fn.qlIconPicker = function (options) {
- this.each(function () {
- if (!external_jQuery_default().data(this, 'plugin_qlIconPicker')) {
- external_jQuery_default().data(this, 'plugin_qlIconPicker', new QL_Icon_Picker(this, options));
- }
- });
- return this;
- };
- var IconpickerField = /*#__PURE__*/function () {
- function IconpickerField(options) {
- var _this = this;
- iconpicker_classCallCheck(this, IconpickerField);
- this.items = external_jQuery_default()();
- this.options = Object.assign({}, this.defaults, options);
- external_jQuery_default()('[data-grav-iconpicker]').each(function (index, element) {
- return _this.addItem(element);
- });
- external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
- }
- iconpicker_createClass(IconpickerField, [{
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target
- /* , record, instance */
- ) {
- var _this2 = this;
- var fields = external_jQuery_default()(target).find('[data-grav-iconpicker]');
- if (!fields.length) {
- return;
- }
- fields.each(function (index, field) {
- field = external_jQuery_default()(field);
- if (!~_this2.items.index(field)) {
- _this2.addItem(field);
- }
- });
- }
- }, {
- key: "addItem",
- value: function addItem(element) {
- element = external_jQuery_default()(element);
- this.items = this.items.add(element);
- element.find('.icon-picker').qlIconPicker({
- 'save': 'class'
- }); // hack to remove extra icon sets that are just copies
- external_jQuery_default()('.icon-set:not(:first)').remove();
- }
- }]);
- return IconpickerField;
- }();
- var iconpicker_Instance = new IconpickerField(); // Fix to close the dialog when clicking outside
- external_jQuery_default()(document).on('click', function (event) {
- var target = external_jQuery_default()(event.target);
- var match = '.icon-set.dialog-open, .launch-icons[data-icons]';
- if (!target.is(match) && !target.closest(match).length) {
- var dialogs = external_jQuery_default()('.icon-set.dialog-open'); // skip if there's no dialog open
- if (dialogs.length) {
- dialogs.each(function (index, dialog) {
- var picker = external_jQuery_default()(dialog).siblings('.icon-picker');
- var data = picker.data('plugin_qlIconPicker');
- data.closePicker(picker, external_jQuery_default()(data.iconSet), data.settings.mode);
- });
- }
- }
- });
- ;// CONCATENATED MODULE: ./app/utils/cron-ui.js
- function cron_ui_typeof(obj) { "@babel/helpers - typeof"; return cron_ui_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, cron_ui_typeof(obj); }
- /* eslint-disable */
- /*
- * This file is part of the Arnapou jqCron package.
- *
- * (c) Arnaud Buathier <arnaud@arnapou.net>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- /**
- * Default settings
- */
- var jqCronDefaultSettings = {
- texts: {},
- 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],
- 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],
- 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"],
- 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],
- lang: 'en',
- enabled_minute: false,
- enabled_hour: true,
- enabled_day: true,
- enabled_week: true,
- enabled_month: true,
- enabled_year: true,
- multiple_dom: false,
- multiple_month: false,
- multiple_mins: false,
- multiple_dow: false,
- multiple_time_hours: false,
- multiple_time_minutes: false,
- numeric_zero_pad: false,
- default_period: 'day',
- default_value: '',
- no_reset_button: true,
- disabled: false,
- bind_to: null,
- bind_method: {
- set: function set($element, value) {
- $element.is(':input') ? $element.val(value) : $element.data('jqCronValue', value);
- },
- get: function get($element) {
- return $element.is(':input') ? $element.val() : $element.data('jqCronValue');
- }
- }
- };
- /**
- * Custom extend of json for jqCron settings.
- * We don't use jQuery.extend because simple extend does not fit our needs, and deep extend has a bad
- * feature for us : it replaces keys of "Arrays" instead of replacing the full array.
- */
- (function ($) {
- var extend = function extend(dst, src) {
- for (var i in src) {
- if ($.isPlainObject(src[i])) {
- dst[i] = extend(dst[i] && $.isPlainObject(dst[i]) ? dst[i] : {}, src[i]);
- } else if ($.isArray(src[i])) {
- dst[i] = src[i].slice(0);
- } else if (src[i] !== undefined) {
- dst[i] = src[i];
- }
- }
- return dst;
- };
- this.jqCronMergeSettings = function (obj) {
- return extend(extend({}, jqCronDefaultSettings), obj || {});
- };
- }).call(window, (external_jQuery_default()));
- /**
- * Shortcut to get the instance of jqCron instance from one jquery object
- */
- (function ($) {
- $.fn.jqCronGetInstance = function () {
- return this.data('jqCron');
- };
- }).call(window, (external_jQuery_default()));
- /**
- * Main plugin
- */
- (function ($) {
- $.fn.jqCron = function (settings) {
- var saved_settings = settings;
- return this.each(function () {
- var cron, saved;
- var $this = $(this);
- var settings = jqCronMergeSettings(saved_settings); // clone settings
- var translations = settings.texts[settings.lang];
- if (cron_ui_typeof(translations) !== 'object' || $.isEmptyObject(translations)) {
- 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().');
- return;
- }
- if (!settings.jquery_container) {
- if ($this.is(':container')) {
- settings.jquery_element = $this.uniqueId('jqCron');
- } else if ($this.is(':autoclose')) {
- // delete already generated dom if exists
- if ($this.next('.jqCron').length == 1) {
- $this.next('.jqCron').remove();
- } // generate new
- settings.jquery_element = $('<span class="jqCron"></span>').uniqueId('jqCron').insertAfter($this);
- } else {
- console && console.error(settings.texts[settings.lang].error1.replace('%s', this.tagName));
- return;
- }
- } // autoset bind_to if it is an input
- if ($this.is(':input')) {
- settings.bind_to = settings.bind_to || $this;
- } // init cron object
- if (settings.bind_to) {
- if (settings.bind_to.is(':input')) {
- // auto bind from input to object if an input, textarea ...
- settings.bind_to.blur(function () {
- var value = settings.bind_method.get(settings.bind_to);
- $this.jqCronGetInstance().setCron(value);
- });
- }
- saved = settings.bind_method.get(settings.bind_to);
- cron = new jqCron(settings);
- cron.setCron(saved);
- } else {
- cron = new jqCron(settings);
- }
- $(this).data('jqCron', cron);
- });
- };
- }).call(window, (external_jQuery_default()));
- /**
- * jqCron class
- */
- (function ($) {
- var jqCronInstances = [];
- function jqCron(settings) {
- var _initialized = false;
- var _self = this;
- var _$elt = this;
- var _$obj = $('<span class="jqCron-container"></span>');
- var _$blocks = $('<span class="jqCron-blocks"></span>');
- var _$blockPERIOD = $('<span class="jqCron-period"></span>');
- var _$blockDOM = $('<span class="jqCron-dom"></span>');
- var _$blockMONTH = $('<span class="jqCron-month"></span>');
- var _$blockMINS = $('<span class="jqCron-mins"></span>');
- var _$blockDOW = $('<span class="jqCron-dow"></span>');
- var _$blockTIME = $('<span class="jqCron-time"></span>');
- var _$cross = $('<span class="jqCron-cross">✘</span>');
- var _selectors = [];
- var _selectorPeriod, _selectorMins, _selectorTimeH, _selectorTimeM, _selectorDow, _selectorDom, _selectorMonth; // instanciate a new selector
- function newSelector($block, multiple, type) {
- var selector = new jqCronSelector(_self, $block, multiple, type);
- selector.$.bind('selector:open', function () {
- // we close all opened selectors of all other jqCron
- for (var n = jqCronInstances.length; n--;) {
- if (jqCronInstances[n] != _self) {
- jqCronInstances[n].closeSelectors();
- } else {
- // we close all other opened selectors of this jqCron
- for (var o = _selectors.length; o--;) {
- if (_selectors[o] != selector) {
- _selectors[o].close();
- }
- }
- }
- }
- });
- selector.$.bind('selector:change', function () {
- var boundChanged = false; // don't propagate if not initialized
- if (!_initialized) return; // bind data between two minute selectors (only if they have the same multiple settings)
- if (settings.multiple_mins == settings.multiple_time_minutes) {
- if (selector == _selectorMins) {
- boundChanged = _selectorTimeM.setValue(_selectorMins.getValue());
- } else if (selector == _selectorTimeM) {
- boundChanged = _selectorMins.setValue(_selectorTimeM.getValue());
- }
- } // we propagate the change event to the main object
- boundChanged || _$obj.trigger('cron:change', _self.getCron());
- });
- _selectors.push(selector);
- return selector;
- } // disable the selector
- this.disable = function () {
- _$obj.addClass('disable');
- settings.disable = true;
- _self.closeSelectors();
- }; // return if the selector is disabled
- this.isDisabled = function () {
- return settings.disable == true;
- }; // enable the selector
- this.enable = function () {
- _$obj.removeClass('disable');
- settings.disable = false;
- }; // get cron value
- this.getCron = function () {
- var period = _selectorPeriod.getValue();
- var items = ['*', '*', '*', '*', '*'];
- if (period == 'hour') {
- items[0] = _selectorMins.getCronValue();
- }
- if (period == 'day' || period == 'week' || period == 'month' || period == 'year') {
- items[0] = _selectorTimeM.getCronValue();
- items[1] = _selectorTimeH.getCronValue();
- }
- if (period == 'month' || period == 'year') {
- items[2] = _selectorDom.getCronValue();
- }
- if (period == 'year') {
- items[3] = _selectorMonth.getCronValue();
- }
- if (period == 'week') {
- items[4] = _selectorDow.getCronValue();
- }
- return items.join(' ');
- }; // set cron (string like * * * * *)
- this.setCron = function (str) {
- if (!str) return;
- try {
- str = str.replace(/\s+/g, ' ').replace(/^ +/, '').replace(/ +$/, ''); // sanitize
- var mask = str.replace(/[^\* ]/g, '-').replace(/-+/g, '-').replace(/ +/g, '');
- var items = str.split(' ');
- if (items.length != 5) _self.error(_self.getText('error2'));
- if (mask == '*****') {
- // 1 possibility
- _selectorPeriod.setValue('minute');
- } else if (mask == '-****') {
- // 1 possibility
- _selectorPeriod.setValue('hour');
- _selectorMins.setCronValue(items[0]);
- _selectorTimeM.setCronValue(items[0]);
- } else if (mask.substring(2, mask.length) == '***') {
- // 4 possibilities
- _selectorPeriod.setValue('day');
- _selectorMins.setCronValue(items[0]);
- _selectorTimeM.setCronValue(items[0]);
- _selectorTimeH.setCronValue(items[1]);
- } else if (mask.substring(2, mask.length) == '-**') {
- // 4 possibilities
- _selectorPeriod.setValue('month');
- _selectorMins.setCronValue(items[0]);
- _selectorTimeM.setCronValue(items[0]);
- _selectorTimeH.setCronValue(items[1]);
- _selectorDom.setCronValue(items[2]);
- } else if (mask.substring(2, mask.length) == '**-') {
- // 4 possibilities
- _selectorPeriod.setValue('week');
- _selectorMins.setCronValue(items[0]);
- _selectorTimeM.setCronValue(items[0]);
- _selectorTimeH.setCronValue(items[1]);
- _selectorDow.setCronValue(items[4]);
- } else if (mask.substring(3, mask.length) == '-*') {
- // 8 possibilities
- _selectorPeriod.setValue('year');
- _selectorMins.setCronValue(items[0]);
- _selectorTimeM.setCronValue(items[0]);
- _selectorTimeH.setCronValue(items[1]);
- _selectorDom.setCronValue(items[2]);
- _selectorMonth.setCronValue(items[3]);
- } else {
- _self.error(_self.getText('error4'));
- }
- _self.clearError();
- } catch (e) {}
- }; // close all child selectors
- this.closeSelectors = function () {
- for (var n = _selectors.length; n--;) {
- _selectors[n].close();
- }
- }; // get the main element id
- this.getId = function () {
- return _$elt.attr('id');
- }; // get the translated text
- this.getText = function (key) {
- var text = settings.texts[settings.lang][key] || null;
- if (typeof text == "string" && text.match('<b')) {
- text = text.replace(/(<b *\/>)/gi, '</span><b /><span class="jqCron-text">');
- text = '<span class="jqCron-text">' + text + '</span>';
- }
- return text;
- }; // get the human readable text
- this.getHumanText = function () {
- var texts = [];
- _$obj.find('> span > span:visible').find('.jqCron-text, .jqCron-selector > span').each(function () {
- var text = $(this).text().replace(/\s+$/g, '').replace(/^\s+/g, '');
- text && texts.push(text);
- });
- return texts.join(' ').replace(/\s:\s/g, ':');
- }; // get settings
- this.getSettings = function () {
- return settings;
- }; // display an error
- this.error = function (msg) {
- console && console.error('[jqCron Error] ' + msg);
- _$obj.addClass('jqCron-error').attr('title', msg);
- throw msg;
- }; // clear error
- this.clearError = function () {
- _$obj.attr('title', '').removeClass('jqCron-error');
- }; // clear
- this.clear = function () {
- _selectorDom.setValue([]);
- _selectorDow.setValue([]);
- _selectorMins.setValue([]);
- _selectorMonth.setValue([]);
- _selectorTimeH.setValue([]);
- _selectorTimeM.setValue([]);
- _self.triggerChange();
- }; // init (called in constructor)
- this.init = function () {
- var n, i, labelsList, list;
- if (_initialized) return;
- settings = jqCronMergeSettings(settings);
- settings.jquery_element || _self.error(_self.getText('error3'));
- _$elt = settings.jquery_element;
- _$elt.append(_$obj);
- _$obj.data('id', settings.id);
- _$obj.data('jqCron', _self);
- _$obj.append(_$blocks);
- settings.no_reset_button || _$obj.append(_$cross);
- !settings.disable || _$obj.addClass('disable');
- _$blocks.append(_$blockPERIOD);
- if (/^(ko)$/i.test(settings.lang)) {
- _$blocks.append(_$blockMONTH, _$blockDOM);
- } else {
- _$blocks.append(_$blockDOM, _$blockMONTH);
- }
- _$blocks.append(_$blockMINS);
- _$blocks.append(_$blockDOW);
- _$blocks.append(_$blockTIME); // various binding
- _$cross.click(function () {
- _self.isDisabled() || _self.clear();
- }); // binding from cron to target
- _$obj.bind('cron:change', function (evt, value) {
- if (!settings.bind_to) return;
- settings.bind_method.set && settings.bind_method.set(settings.bind_to, value);
- _self.clearError();
- }); // PERIOD
- _$blockPERIOD.append(_self.getText('text_period'));
- _selectorPeriod = newSelector(_$blockPERIOD, false, 'period');
- settings.enabled_minute && _selectorPeriod.add('minute', _self.getText('name_minute'));
- settings.enabled_hour && _selectorPeriod.add('hour', _self.getText('name_hour'));
- settings.enabled_day && _selectorPeriod.add('day', _self.getText('name_day'));
- settings.enabled_week && _selectorPeriod.add('week', _self.getText('name_week'));
- settings.enabled_month && _selectorPeriod.add('month', _self.getText('name_month'));
- settings.enabled_year && _selectorPeriod.add('year', _self.getText('name_year'));
- _selectorPeriod.$.bind('selector:change', function (e, value) {
- _$blockDOM.hide();
- _$blockMONTH.hide();
- _$blockMINS.hide();
- _$blockDOW.hide();
- _$blockTIME.hide();
- if (value == 'hour') {
- _$blockMINS.show();
- } else if (value == 'day') {
- _$blockTIME.show();
- } else if (value == 'week') {
- _$blockDOW.show();
- _$blockTIME.show();
- } else if (value == 'month') {
- _$blockDOM.show();
- _$blockTIME.show();
- } else if (value == 'year') {
- _$blockDOM.show();
- _$blockMONTH.show();
- _$blockTIME.show();
- }
- });
- _selectorPeriod.setValue(settings.default_period); // MINS (minutes)
- _$blockMINS.append(_self.getText('text_mins'));
- _selectorMins = newSelector(_$blockMINS, settings.multiple_mins, 'minutes');
- for (i = 0, list = settings.minutes; i < list.length; i++) {
- _selectorMins.add(list[i], list[i]);
- } // TIME (hour:min)
- _$blockTIME.append(_self.getText('text_time'));
- _selectorTimeH = newSelector(_$blockTIME, settings.multiple_time_hours, 'time_hours');
- for (i = 0, list = settings.hours, labelsList = settings.hour_labels; i < list.length; i++) {
- _selectorTimeH.add(list[i], labelsList[i]);
- }
- _selectorTimeM = newSelector(_$blockTIME, settings.multiple_time_minutes, 'time_minutes');
- for (i = 0, list = settings.minutes; i < list.length; i++) {
- _selectorTimeM.add(list[i], list[i]);
- } // DOW (day of week)
- _$blockDOW.append(_self.getText('text_dow'));
- _selectorDow = newSelector(_$blockDOW, settings.multiple_dow, 'day_of_week');
- for (i = 0, list = _self.getText('weekdays'); i < list.length; i++) {
- _selectorDow.add(i + 1, list[i]);
- } // DOM (day of month)
- _$blockDOM.append(_self.getText('text_dom'));
- _selectorDom = newSelector(_$blockDOM, settings.multiple_dom, 'day_of_month');
- for (i = 0, list = settings.monthdays; i < list.length; i++) {
- _selectorDom.add(list[i], list[i]);
- } // MONTH (day of week)
- _$blockMONTH.append(_self.getText('text_month'));
- _selectorMonth = newSelector(_$blockMONTH, settings.multiple_month, 'month');
- for (i = 0, list = _self.getText('months'); i < list.length; i++) {
- _selectorMonth.add(i + 1, list[i]);
- } // close all selectors when we click in body
- $('body').click(function () {
- var i,
- n = _selectors.length;
- for (i = 0; i < n; i++) {
- _selectors[i].close();
- }
- });
- _initialized = true; // default value
- if (settings.default_value) {
- _self.setCron(settings.default_value);
- }
- }; // trigger a change event
- this.triggerChange = function () {
- _$obj.trigger('cron:change', _self.getCron());
- }; // store instance in array
- jqCronInstances.push(this); // expose main jquery object
- this.$ = _$obj; // init
- try {
- this.init();
- _self.triggerChange();
- } catch (e) {}
- }
- this.jqCron = jqCron;
- }).call(window, (external_jQuery_default()));
- /**
- * jqCronSelector class
- */
- (function ($) {
- function jqCronSelector(_cron, _$block, _multiple, _type) {
- var _self = this;
- var _$list = $('<ul class="jqCron-selector-list"></ul>');
- var _$title = $('<span class="jqCron-selector-title"></span>');
- var _$selector = $('<span class="jqCron-selector"></span>');
- var _values = {};
- var _value = [];
- var _hasNumericTexts = true;
- var _numeric_zero_pad = _cron.getSettings().numeric_zero_pad; // return an array without doublon
- function array_unique(l) {
- var i = 0,
- n = l.length,
- k = {},
- a = [];
- while (i < n) {
- k[l[i]] || (k[l[i]] = true && a.push(l[i]));
- i++;
- }
- return a;
- } // get the value (an array if multiple, else a single value)
- this.getValue = function () {
- return _multiple ? _value : _value[0];
- }; // get a correct string for cron
- this.getCronValue = function () {
- if (_value.length == 0) return '*';
- var cron = [_value[0]],
- i,
- s = _value[0],
- c = _value[0],
- n = _value.length;
- for (i = 1; i < n; i++) {
- if (_value[i] == c + 1) {
- c = _value[i];
- cron[cron.length - 1] = s + '-' + c;
- } else {
- s = c = _value[i];
- cron.push(c);
- }
- }
- return cron.join(',');
- }; // set the cron value
- this.setCronValue = function (str) {
- var values = [],
- m,
- i,
- n;
- if (str !== '*') {
- while (str != '') {
- // test "*/n" expression
- m = str.match(/^\*\/([0-9]+),?/);
- if (m && m.length == 2) {
- for (i = 0; i <= 59; i += m[1] | 0) {
- values.push(i);
- }
- str = str.replace(m[0], '');
- continue;
- } // test "a-b/n" expression
- m = str.match(/^([0-9]+)-([0-9]+)\/([0-9]+),?/);
- if (m && m.length == 4) {
- for (i = m[1] | 0; i <= (m[2] | 0); i += m[3] | 0) {
- values.push(i);
- }
- str = str.replace(m[0], '');
- continue;
- } // test "a-b" expression
- m = str.match(/^([0-9]+)-([0-9]+),?/);
- if (m && m.length == 3) {
- for (i = m[1] | 0; i <= (m[2] | 0); i++) {
- values.push(i);
- }
- str = str.replace(m[0], '');
- continue;
- } // test "c" expression
- m = str.match(/^([0-9]+),?/);
- if (m && m.length == 2) {
- values.push(m[1] | 0);
- str = str.replace(m[0], '');
- continue;
- } // something goes wrong in the expression
- return;
- }
- }
- _self.setValue(values);
- }; // close the selector
- this.close = function () {
- _$selector.trigger('selector:close');
- }; // open the selector
- this.open = function () {
- _$selector.trigger('selector:open');
- }; // whether the selector is open
- this.isOpened = function () {
- return _$list.is(':visible');
- }; // add a selected value to the list
- this.addValue = function (key) {
- var values = _multiple ? _value.slice(0) : []; // clone array
- values.push(key);
- _self.setValue(values);
- }; // remove a selected value from the list
- this.removeValue = function (key) {
- if (_multiple) {
- var i,
- newValue = [];
- for (i = 0; i < _value.length; i++) {
- if (key != [_value[i]]) {
- newValue.push(_value[i]);
- }
- }
- _self.setValue(newValue);
- } else {
- _self.clear();
- }
- }; // set the selected value(s) of the list
- this.setValue = function (keys) {
- var i,
- newKeys = [],
- saved = _value.join(' ');
- if (!$.isArray(keys)) keys = [keys];
- _$list.find('li').removeClass('selected');
- keys = array_unique(keys);
- keys.sort(function (a, b) {
- var ta = cron_ui_typeof(a);
- var tb = cron_ui_typeof(b);
- if (ta == tb && ta == "number") return a - b;else return String(a) == String(b) ? 0 : String(a) < String(b) ? -1 : 1;
- });
- if (_multiple) {
- for (i = 0; i < keys.length; i++) {
- if (keys[i] in _values) {
- _values[keys[i]].addClass('selected');
- newKeys.push(keys[i]);
- }
- }
- } else {
- if (keys[0] in _values) {
- _values[keys[0]].addClass('selected');
- newKeys.push(keys[0]);
- }
- } // remove unallowed values
- _value = newKeys;
- if (saved != _value.join(' ')) {
- _$selector.trigger('selector:change', _multiple ? keys : keys[0]);
- return true;
- }
- return false;
- }; // get the title text
- this.getTitleText = function () {
- var getValueText = function getValueText(key) {
- return key in _values ? _values[key].text() : key;
- };
- if (_value.length == 0) {
- return _cron.getText('empty_' + _type) || _cron.getText('empty');
- }
- var cron = [getValueText(_value[0])],
- i,
- s = _value[0],
- c = _value[0],
- n = _value.length;
- for (i = 1; i < n; i++) {
- if (_value[i] == c + 1) {
- c = _value[i];
- cron[cron.length - 1] = getValueText(s) + '-' + getValueText(c);
- } else {
- s = c = _value[i];
- cron.push(getValueText(c));
- }
- }
- return cron.join(',');
- }; // clear list
- this.clear = function () {
- _values = {};
- _self.setValue([]);
- _$list.empty();
- }; // add a (key, value) pair
- this.add = function (key, value) {
- if (!(value + '').match(/^[0-9]+$/)) _hasNumericTexts = false;
- if (_numeric_zero_pad && _hasNumericTexts && value < 10) {
- value = '0' + value;
- }
- var $item = $('<li>' + value + '</li>');
- _$list.append($item);
- _values[key] = $item;
- $item.click(function () {
- if (_multiple && $(this).hasClass('selected')) {
- _self.removeValue(key);
- } else {
- _self.addValue(key);
- if (!_multiple) _self.close();
- }
- });
- }; // expose main jquery object
- this.$ = _$selector; // constructor
- _$block.find('b:eq(0)').after(_$selector).remove();
- _$selector.addClass('jqCron-selector-' + _$block.find('.jqCron-selector').length).append(_$title).append(_$list).bind('selector:open', function () {
- if (_hasNumericTexts) {
- var nbcols = 1,
- n = _$list.find('li').length;
- 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;
- _$list.addClass('cols' + nbcols);
- }
- _$list.show();
- }).bind('selector:close', function () {
- _$list.hide();
- }).bind('selector:change', function () {
- _$title.html(_self.getTitleText());
- }).click(function (e) {
- e.stopPropagation();
- }).trigger('selector:change');
- $.fn.disableSelection && _$selector.disableSelection(); // only work with jQuery UI
- _$title.click(function (e) {
- _self.isOpened() || _cron.isDisabled() ? _self.close() : _self.open();
- });
- _self.close();
- _self.clear();
- }
- this.jqCronSelector = jqCronSelector;
- }).call(window, (external_jQuery_default()));
- /**
- * Generate unique id for each element.
- * Skip elements which have already an id.
- */
- (function ($) {
- var jqUID = 0;
- var jqGetUID = function jqGetUID(prefix) {
- var id;
- while (1) {
- jqUID++;
- id = (prefix || 'JQUID') + '' + jqUID;
- if (!document.getElementById(id)) return id;
- }
- };
- $.fn.uniqueId = function (prefix) {
- return this.each(function () {
- if ($(this).attr('id')) return;
- var id = jqGetUID(prefix);
- $(this).attr('id', id);
- });
- };
- }).call(window, (external_jQuery_default()));
- /**
- * Extends jQuery selectors with new block selector
- */
- (function ($) {
- $.extend($.expr[':'], {
- container: function container(a) {
- return (a.tagName + '').toLowerCase() in {
- a: 1,
- abbr: 1,
- acronym: 1,
- address: 1,
- b: 1,
- big: 1,
- blockquote: 1,
- button: 1,
- cite: 1,
- code: 1,
- dd: 1,
- del: 1,
- dfn: 1,
- div: 1,
- dt: 1,
- em: 1,
- fieldset: 1,
- form: 1,
- h1: 1,
- h2: 1,
- h3: 1,
- h4: 1,
- h5: 1,
- h6: 1,
- i: 1,
- ins: 1,
- kbd: 1,
- label: 1,
- li: 1,
- p: 1,
- pre: 1,
- q: 1,
- samp: 1,
- small: 1,
- span: 1,
- strong: 1,
- sub: 1,
- sup: 1,
- td: 1,
- tt: 1
- };
- },
- autoclose: function autoclose(a) {
- return (a.tagName + '').toLowerCase() in {
- area: 1,
- base: 1,
- basefont: 1,
- br: 1,
- col: 1,
- frame: 1,
- hr: 1,
- img: 1,
- input: 1,
- link: 1,
- meta: 1,
- param: 1
- };
- }
- });
- }).call(window, (external_jQuery_default()));
- ;// CONCATENATED MODULE: ./app/forms/fields/cron.js
- function cron_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function cron_createClass(Constructor, protoProps, staticProps) { if (protoProps) cron_defineProperties(Constructor.prototype, protoProps); if (staticProps) cron_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var CronField = /*#__PURE__*/function () {
- function CronField() {
- var _this = this;
- cron_classCallCheck(this, CronField);
- this.items = external_jQuery_default()();
- external_jQuery_default()('[data-grav-field="cron"]').each(function (index, cron) {
- return _this.addCron(cron);
- });
- external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
- }
- cron_createClass(CronField, [{
- key: "addCron",
- value: function addCron(cron) {
- cron = external_jQuery_default()(cron);
- this.items = this.items.add(cron);
- cron.find('.cron-selector').each(function (index, container) {
- container = external_jQuery_default()(container);
- var input = container.closest('[data-grav-field]').find('input');
- container.jqCron({
- numeric_zero_pad: true,
- enabled_minute: true,
- multiple_dom: true,
- multiple_month: true,
- multiple_mins: true,
- multiple_dow: true,
- multiple_time_hours: true,
- multiple_time_minutes: true,
- default_period: 'hour',
- default_value: input.val() || '* * * * *',
- no_reset_button: false,
- bind_to: input,
- bind_method: {
- set: function set($element, value) {
- $element.val(value);
- }
- },
- texts: {
- en: {
- empty: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY"],
- empty_minutes: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY"],
- empty_time_hours: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_HOUR"],
- empty_time_minutes: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_MINUTE"],
- empty_day_of_week: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_DAY_OF_WEEK"],
- empty_day_of_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_DAY_OF_MONTH"],
- empty_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.EVERY_MONTH"],
- name_minute: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.MINUTE"],
- name_hour: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.HOUR"],
- name_day: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.DAY"],
- name_week: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.WEEK"],
- name_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.MONTH"],
- name_year: external_GravAdmin_namespaceObject.translations.GRAV_CORE["NICETIME.YEAR"],
- text_period: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_PERIOD"],
- text_mins: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_MINS"],
- text_time: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_TIME"],
- text_dow: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_DOW"],
- text_month: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_MONTH"],
- text_dom: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.TEXT_DOM"],
- error1: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR1"],
- error2: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR2"],
- error3: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR3"],
- error4: external_GravAdmin_namespaceObject.translations.GRAV_CORE["CRON.ERROR4"],
- weekdays: external_GravAdmin_namespaceObject.translations.GRAV_CORE.DAYS_OF_THE_WEEK,
- months: external_GravAdmin_namespaceObject.translations.GRAV_CORE.MONTHS_OF_THE_YEAR
- }
- }
- });
- });
- }
- }, {
- key: "_onAddedNodes",
- value: function _onAddedNodes(event, target
- /* , record, instance */
- ) {
- var _this2 = this;
- var crons = external_jQuery_default()(target).find('[data-grav-field="cron"]');
- if (!crons.length) {
- return;
- }
- crons.each(function (index, list) {
- list = external_jQuery_default()(list);
- if (!~_this2.items.index(list)) {
- _this2.addCron(list);
- }
- });
- }
- }]);
- return CronField;
- }();
- var cron_Instance = new CronField();
- // EXTERNAL MODULE: ./node_modules/eventemitter3/index.js
- var eventemitter3 = __webpack_require__(26729);
- var eventemitter3_default = /*#__PURE__*/__webpack_require__.n(eventemitter3);
- ;// CONCATENATED MODULE: ./app/utils/finderjs.js
- function finderjs_typeof(obj) { "@babel/helpers - typeof"; return finderjs_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, finderjs_typeof(obj); }
- function finderjs_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function finderjs_createClass(Constructor, protoProps, staticProps) { if (protoProps) finderjs_defineProperties(Constructor.prototype, protoProps); if (staticProps) finderjs_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- /**
- * (c) Trilby Media, LLC
- * Author Djamil Legato
- *
- * Based on Mark Matyas's Finderjs
- * MIT License
- */
- var DEFAULTS = {
- labelKey: 'name',
- valueKey: 'value',
- // new
- childKey: 'children',
- iconKey: 'icon',
- // new
- itemKey: 'item-key',
- // new
- pathBar: true,
- className: {
- container: 'fjs-container',
- pathBar: 'fjs-path-bar',
- col: 'fjs-col',
- list: 'fjs-list',
- item: 'fjs-item',
- active: 'fjs-active',
- children: 'fjs-has-children',
- url: 'fjs-url',
- itemPrepend: 'fjs-item-prepend',
- itemContent: 'fjs-item-content',
- itemAppend: 'fjs-item-append'
- }
- };
- var Finder = /*#__PURE__*/function () {
- function Finder(container, data, options) {
- var _this = this;
- finderjs_classCallCheck(this, Finder);
- this.$emitter = new (eventemitter3_default())();
- this.container = external_jQuery_default()(container);
- this.data = data;
- this.config = external_jQuery_default().extend({}, DEFAULTS, options); // dom events
- this.container.on('click', this.clickEvent.bind(this));
- this.container.on('keydown', this.keydownEvent.bind(this)); // internal events
- this.$emitter.on('item-selected', this.itemSelected.bind(this));
- this.$emitter.on('create-column', this.addColumn.bind(this));
- this.$emitter.on('navigate', this.navigate.bind(this));
- this.$emitter.on('go-to', this.goTo.bind(this, this.data));
- this.container.addClass(this.config.className.container).attr('tabindex', 0);
- this.createColumn(this.data);
- if (this.config.pathBar) {
- this.pathBar = this.createPathBar();
- this.pathBar.on('click', '[data-breadcrumb-node]', function (event) {
- event.preventDefault();
- var location = external_jQuery_default()(event.currentTarget).data('breadcrumbNode');
- _this.goTo(_this.data, location);
- });
- } // '' is <Root>
- if (this.config.defaultPath || this.config.defaultPath === '') {
- this.goTo(this.data, this.config.defaultPath);
- }
- }
- finderjs_createClass(Finder, [{
- key: "reload",
- value: function reload() {
- var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.data;
- this.createColumn(data); // '' is <Root>
- if (this.config.defaultPath || this.config.defaultPath === '') {
- this.goTo(data, this.config.defaultPath);
- }
- }
- }, {
- key: "createColumn",
- value: function createColumn(data, parent) {
- var _this2 = this;
- var callback = function callback(data) {
- return _this2.createColumn(data, parent);
- };
- if (typeof data === 'function') {
- data.call(this, parent, callback);
- } else if (Array.isArray(data) || finderjs_typeof(data) === 'object') {
- if (finderjs_typeof(data) === 'object') {
- data = Array.from(data);
- }
- var list = this.createList(data);
- var div = external_jQuery_default()('<div />');
- div.append(list).addClass(this.config.className.col);
- this.$emitter.emit('create-column', div);
- return div;
- } else {
- throw new Error('Unknown data type');
- }
- }
- }, {
- key: "createPathBar",
- value: function createPathBar() {
- this.container.siblings(".".concat(this.config.className.pathBar)).remove();
- var pathBar = external_jQuery_default()("<div class=\"".concat(this.config.className.pathBar, "\" />"));
- pathBar.insertAfter(this.container);
- return pathBar;
- }
- }, {
- key: "clickEvent",
- value: function clickEvent(event) {
- event.stopPropagation();
- event.preventDefault();
- var target = external_jQuery_default()(event.target);
- var column = target.closest(".".concat(this.config.className.col));
- var item = target.closest(".".concat(this.config.className.item));
- if (item.length) {
- this.$emitter.emit('item-selected', {
- column: column,
- item: item
- });
- }
- }
- }, {
- key: "keydownEvent",
- value: function keydownEvent(event) {
- var codes = {
- 37: 'left',
- 38: 'up',
- 39: 'right',
- 40: 'down'
- };
- if (event.keyCode in codes) {
- event.stopPropagation();
- event.preventDefault();
- this.$emitter.emit('navigate', {
- direction: codes[event.keyCode]
- });
- }
- }
- }, {
- key: "itemSelected",
- value: function itemSelected(value) {
- var element = value.item;
- if (!element.length) {
- return false;
- }
- var item = element[0]._item;
- var column = value.column;
- var data = item[this.config.childKey] || this.data;
- var active = external_jQuery_default()(column).find(".".concat(this.config.className.active));
- if (active.length) {
- active.removeClass(this.config.className.active);
- }
- element.addClass(this.config.className.active);
- column.nextAll().remove(); // ?!?!?
- this.container[0].focus();
- window.scrollTo(window.pageXOffset, window.pageYOffset);
- this.updatePathBar();
- var newColumn;
- if (data) {
- newColumn = this.createColumn(data, item);
- this.$emitter.emit('interior-selected', item);
- } else {
- this.$emitter.emit('leaf-selected', item);
- }
- return newColumn;
- }
- }, {
- key: "addColumn",
- value: function addColumn(column) {
- this.container.append(column);
- this.$emitter.emit('column-created', column);
- }
- }, {
- key: "navigate",
- value: function navigate(value) {
- var active = this.findLastActive();
- var direction = value.direction;
- var column;
- var item;
- var target;
- if (active) {
- item = active.item;
- column = active.column;
- if (direction === 'up' && item.prev().length) {
- target = item.prev();
- } else if (direction === 'down' && item.next().length) {
- target = item.next();
- } else if (direction === 'right' && column.next().length) {
- column = column.next();
- target = column.find(".".concat(this.config.className.item)).first();
- } else if (direction === 'left' && column.prev().length) {
- column = column.prev();
- target = column.find(".".concat(this.config.className.active)).first() || column.find(".".concat(this.config.className.item));
- }
- } else {
- column = this.container.find(".".concat(this.config.className.col)).first();
- target = column.find(".".concat(this.config.className.item)).first();
- }
- if (target) {
- this.$emitter.emit('item-selected', {
- column: column,
- item: target
- });
- }
- }
- }, {
- key: "goTo",
- value: function goTo(data, path) {
- var _this3 = this;
- path = Array.isArray(path) ? path : path.split('/').map(function (bit) {
- return bit.trim();
- }).filter(Boolean);
- if (path.length) {
- this.container.children().remove();
- }
- if (typeof data === 'function') {
- data.call(this, null, function (data) {
- return _this3.selectPath(path, data);
- });
- } else {
- this.selectPath(path, data);
- }
- }
- }, {
- key: "selectPath",
- value: function selectPath(path, data, column) {
- var _this4 = this;
- column = column || (path.length ? this.createColumn(data) : this.container.find("> .".concat(this.config.className.col)));
- var current = path[0] || '';
- var children = data.find(function (item) {
- return item[_this4.config.itemKey] === current;
- });
- var newColumn = this.itemSelected({
- column: column,
- item: column.find("[data-fjs-item=\"".concat(current, "\"]")).first()
- });
- path.shift();
- if (path.length && children) {
- this.selectPath(path, children[this.config.childKey], newColumn);
- }
- }
- }, {
- key: "findLastActive",
- value: function findLastActive() {
- var active = this.container.find(".".concat(this.config.className.active));
- if (!active.length) {
- return null;
- }
- var item = active.last();
- var column = item.closest(".".concat(this.config.className.col));
- return {
- item: item,
- column: column
- };
- }
- }, {
- key: "createList",
- value: function createList(data) {
- var _this5 = this;
- var list = external_jQuery_default()('<ul />');
- var items = data.map(function (item) {
- return _this5.createItem(item);
- });
- var fragments = items.reduce(function (fragment, current) {
- fragment.appendChild(current[0] || current);
- return fragment;
- }, document.createDocumentFragment());
- list.append(fragments).addClass(this.config.className.list);
- return list;
- }
- }, {
- key: "createItem",
- value: function createItem(item) {
- var listItem = external_jQuery_default()('<li />');
- var listItemClasses = [this.config.className.item];
- var link = external_jQuery_default()('<a />');
- var createItemContent = this.config.createItemContent || this.createItemContent;
- var fragment = createItemContent.call(this, item);
- link.append(fragment).attr('href', '').attr('tabindex', -1);
- if (item.url) {
- link.attr('href', item.url);
- listItemClasses.push(item.className);
- }
- if (item[this.config.childKey]) {
- listItemClasses.push(this.config.className[this.config.childKey]);
- }
- listItemClasses.push("fjs-item-".concat(item.type));
- listItem.addClass(listItemClasses.join(' '));
- listItem.append(link).attr('data-fjs-item', item[this.config.itemKey]);
- listItem[0]._item = item;
- return listItem;
- }
- }, {
- key: "updatePathBar",
- value: function updatePathBar() {
- var _this6 = this;
- if (!this.config.pathBar) {
- return false;
- }
- var activeItems = this.container.find(".".concat(this.config.className.active));
- var itemKeys = '';
- this.pathBar.children().empty();
- activeItems.each(function (index, activeItem) {
- var item = activeItem._item;
- var isLast = index + 1 === activeItems.length;
- itemKeys += "/".concat(item[_this6.config.itemKey]);
- _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 "));
- });
- }
- }, {
- key: "getIcon",
- value: function getIcon(type) {
- switch (type) {
- case 'root':
- return 'fa-sitemap';
- case 'file':
- return 'fa-file-o';
- case 'dir':
- default:
- return 'fa-folder';
- }
- }
- }]);
- return Finder;
- }();
- /* harmony default export */ const finderjs = (Finder);
- ;// CONCATENATED MODULE: ./app/forms/fields/parents.js
- function parents_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function parents_createClass(Constructor, protoProps, staticProps) { if (protoProps) parents_defineProperties(Constructor.prototype, protoProps); if (staticProps) parents_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var XHRUUID = 0;
- var parents_Instances = {};
- var Parents = /*#__PURE__*/function () {
- function Parents(container, field, data) {
- var _this = this;
- parents_classCallCheck(this, Parents);
- this.container = external_jQuery_default()(container);
- this.fieldName = field.attr('name');
- this.field = external_jQuery_default()("[name=\"".concat(this.fieldName, "\"]"));
- this.data = data;
- this.parentLabel = external_jQuery_default()("[data-parents-field-label=\"".concat(this.fieldName, "\"]"));
- this.parentName = external_jQuery_default()("[data-parents-field-name=\"".concat(this.fieldName, "\"]"));
- var dataLoad = this.dataLoad;
- this.finder = new finderjs(this.container, function (parent, callback) {
- return dataLoad.call(_this, parent, callback);
- }, {
- labelKey: 'name',
- defaultPath: this.field.val(),
- createItemContent: function createItemContent(item) {
- return Parents.createItemContent(this.config, item);
- }
- });
- /*
- this.finder.$emitter.on('leaf-selected', (item) => {
- console.log('selected', item);
- this.finder.emit('create-column', () => this.createSimpleColumn(item));
- });
- this.finder.$emitter.on('item-selected', (selected) => {
- console.log('selected', selected);
- // for future use only - create column-card creation for file with details like in macOS finder
- // this.finder.$emitter('create-column', () => this.createSimpleColumn(selected));
- }); */
- this.finder.$emitter.on('column-created', function () {
- _this.container[0].scrollLeft = _this.container[0].scrollWidth - _this.container[0].clientWidth;
- });
- }
- parents_createClass(Parents, [{
- key: "createSimpleColumn",
- value: function createSimpleColumn(item) {}
- }, {
- key: "dataLoad",
- value: function dataLoad(parent, callback) {
- var _this2 = this;
- if (!parent) {
- return callback(this.data);
- }
- if (parent.type !== 'dir' || !parent['has-children']) {
- return false;
- }
- var UUID = ++XHRUUID;
- this.startLoader();
- external_jQuery_default().ajax({
- url: "".concat(external_GravAdmin_namespaceObject.config.current_url),
- method: 'post',
- data: Object.assign({}, getExtraFormData(this.container), {
- route: b64_encode_unicode(parent.value),
- field: this.field.data('fieldName'),
- action: 'getLevelListing',
- 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce
- }),
- success: function success(response) {
- _this2.stopLoader();
- if (response.status === 'error') {
- _this2.finder.$emitter.emit('create-column', Parents.createErrorColumn(response.message)[0]);
- return false;
- } // stale request
- if (UUID !== XHRUUID) {
- return false;
- }
- return callback(response.data);
- }
- });
- }
- }, {
- key: "startLoader",
- value: function startLoader() {
- this.loadingIndicator = Parents.createLoadingColumn();
- this.finder.$emitter.emit('create-column', this.loadingIndicator[0]);
- return this.loadingIndicator;
- }
- }, {
- key: "stopLoader",
- value: function stopLoader() {
- return this.loadingIndicator && this.loadingIndicator.remove();
- }
- }], [{
- key: "createItemContent",
- value: function createItemContent(config, item) {
- var frag = document.createDocumentFragment();
- var label = external_jQuery_default()("<span title=\"".concat(item[config.labelKey], "\" />"));
- var infoContainer = external_jQuery_default()('<span class="info-container" />');
- var iconPrepend = external_jQuery_default()('<i />');
- var iconAppend = external_jQuery_default()('<i />');
- var badge = external_jQuery_default()('<span class="badge" />');
- var prependClasses = ['fa'];
- var appendClasses = ['fa']; // prepend icon
- if (item.children || item.type === 'dir') {
- prependClasses.push('fa-folder');
- } else if (item.type === 'root') {
- prependClasses.push('fa-sitemap');
- } else if (item.type === 'file') {
- prependClasses.push('fa-file-o');
- }
- iconPrepend.addClass(prependClasses.join(' ')); // text label
- label.text(item[config.labelKey]).prepend(iconPrepend);
- label.appendTo(frag); // append icon
- if (item.children || item['has-children']) {
- appendClasses.push('fa-caret-right');
- badge.text(item.size || item.count || 0);
- badge.appendTo(infoContainer);
- }
- iconAppend.addClass(appendClasses.join(' '));
- iconAppend.appendTo(infoContainer);
- infoContainer.appendTo(frag);
- return frag;
- }
- }, {
- key: "createLoadingColumn",
- value: function createLoadingColumn() {
- 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 ");
- }
- }, {
- key: "createErrorColumn",
- value: function createErrorColumn(error) {
- 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 "));
- }
- }]);
- return Parents;
- }();
- var b64_encode_unicode = function b64_encode_unicode(str) {
- return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
- return String.fromCharCode('0x' + p1);
- }));
- };
- var b64_decode_unicode = function b64_decode_unicode(str) {
- return decodeURIComponent(atob(str).split('').map(function (c) {
- return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
- }).join(''));
- };
- var getExtraFormData = function getExtraFormData(container) {
- var form = container.closest('form');
- if (container.closest('[data-remodal-id]').length) {
- form = external_jQuery_default()('form#blueprints');
- }
- var data = {};
- var unique_id = form.find('[name="__unique_form_id__"]');
- data['__form-name__'] = form.find('[name="__form-name__"]').val();
- data['form-nonce'] = form.find('[name="form-nonce"]').val();
- if (unique_id.length) {
- data['__unique_form_id__'] = unique_id.val();
- }
- return data;
- };
- external_jQuery_default()(document).on('click', '[data-parents]', function (event) {
- event.preventDefault();
- event.stopPropagation();
- var target = external_jQuery_default()(event.currentTarget);
- var field = target.closest('.parents-wrapper').find('input[name]');
- var fieldName = field.attr('name');
- if (!field.length) {
- fieldName = target.data('parents');
- field = external_jQuery_default()("[name=\"".concat(target.data('parents'), "\"]")).first();
- }
- var modal = external_jQuery_default()("[data-remodal-id=\"".concat(target.data('remodalTarget') || 'parents', "\"]"));
- var loader = modal.find('.grav-loading');
- var content = modal.find('.parents-content');
- loader.css('display', 'block');
- content.html('');
- external_jQuery_default().ajax({
- url: "".concat(external_GravAdmin_namespaceObject.config.current_url),
- method: 'post',
- data: Object.assign({}, getExtraFormData(target), {
- route: b64_encode_unicode(field.val()),
- field: field.data('fieldName'),
- action: 'getLevelListing',
- 'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce,
- initial: true
- }),
- success: function success(response) {
- loader.css('display', 'none');
- if (response.status === 'error') {
- content.html(response.message);
- return true;
- }
- if (!parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))]) {
- parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))] = new Parents(content, field, response.data);
- } else {
- parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))].finder.reload(response.data);
- }
- modal.data('parents', parents_Instances["".concat(fieldName, "-").concat(modal.data('remodalId'))]);
- modal.data('parents-selectedField', field);
- }
- });
- }); // apply finder selection to field
- external_jQuery_default()(document).on('click', '[data-remodal-id].parents-container [data-parents-select]', function (event) {
- var modal = external_jQuery_default()(event.currentTarget).closest('[data-remodal-id]');
- var parents = modal.data('parents');
- var selectedField = modal.data('parentsSelectedField');
- var finder = parents.finder;
- var field = parents.field;
- var parentLabel = parents.parentLabel;
- var parentName = parents.parentName;
- var selection = finder.findLastActive().item[0];
- var value = selection._item[finder.config.valueKey];
- var name = selection._item[finder.config.labelKey];
- if (selectedField.closest('.remodal').length) {
- var index = field.index(selectedField);
- selectedField.val(value);
- external_jQuery_default()(parentLabel[index]).text(value);
- external_jQuery_default()(parentName[index]).text(name);
- } else {
- field.val(value);
- parentLabel.text(value);
- parentName.text(name);
- finder.config.defaultPath = value;
- }
- var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()("[data-remodal-id=\"".concat(modal.data('remodalId'), "\"]")).data('remodal')];
- remodal.close();
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/acl-picker.js
- var acl_picker_body = external_jQuery_default()('body');
- acl_picker_body.on('change', '[data-acl_picker] select', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var value = target.val();
- var item = target.closest('.permissions-item');
- var inputs = item.find('input[type="checkbox"], input[type="radio"]');
- var hidden = item.find('input[type="hidden"][name]');
- var wrapper = target.closest('[data-acl_picker_id]');
- var type = item.data('fieldType');
- if (type === 'access') {
- inputs.each(function (index, input) {
- input = external_jQuery_default()(input);
- var name = input.prop('name');
- input.prop('name', name.replace(/(.*)(\[[^\]]*\])/, "$1[".concat(value, "]")));
- });
- } else if (type === 'permissions') {
- var crudpContainer = item.find('[data-field-name]');
- inputs.each(function (index, input) {
- input = external_jQuery_default()(input);
- var rand = Math.round(Math.random() * 500);
- var name = crudpContainer.data('fieldName');
- var id = input.prop('id').split('_').slice(0, -1).join('_') + "_".concat(value, "+").concat(rand); // const key = input.data('crudpKey');
- hidden.prop('name', name.replace(/(.*)(\[[^\]]*\])/, "$1[".concat(value, "]")));
- input.prop('id', id);
- input.next('label').prop('for', id);
- });
- }
- wrapper.find('.permissions-item .button.add-item')[!value ? 'addClass' : 'removeClass']('disabled').prop('disabled', !value ? 'disabled' : null);
- });
- acl_picker_body.on('input', 'input[data-crudp-key]', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var container = target.closest('.crudp-container');
- var hidden = container.find('input[type="hidden"][name]');
- var key = target.data('crudpKey');
- var json = JSON.parse(hidden.val() || '{}');
- json[key] = target.val();
- hidden.val(JSON.stringify(json));
- });
- acl_picker_body.on('click', '[data-acl_picker] .remove-item', function (event) {
- event.preventDefault();
- var target = external_jQuery_default()(event.currentTarget);
- var container = target.closest('.permissions-item');
- var wrapper = target.closest('[data-acl_picker_id]');
- container.remove();
- var empty = wrapper.find('.permissions-item').length === 1; // show the initial + button
- if (empty) {
- wrapper.find('.permissions-item.empty-list').removeClass('hidden');
- }
- });
- acl_picker_body.on('click', '[data-acl_picker] .add-item', function (event) {
- event.preventDefault();
- var target = external_jQuery_default()(event.currentTarget);
- var item = target.closest('.permissions-item');
- var wrapper = target.closest('[data-acl_picker_id]');
- var ID = wrapper.data('acl_picker_id');
- var template = document.querySelector("template[data-id=\"acl_picker-".concat(ID, "\"]"));
- var clone = external_jQuery_default()(template.content.firstElementChild).clone();
- clone.insertAfter(item); // randomize ids
- clone.find('.switch-toggle input[type="radio"]').each(function (index, input) {
- input = external_jQuery_default()(input);
- var id = input.prop('id');
- var label = input.next('label');
- var rand = (Date.now().toString(36) + Math.random().toString(36).substr(2, 5)).toLowerCase();
- input.prop('id', "".concat(id).concat(rand));
- label.prop('for', "".concat(id).concat(rand));
- }); // hide the initial + button
- wrapper.find('.permissions-item.empty-list').addClass('hidden'); // disable all + buttons until one is selected
- wrapper.find('.permissions-item .button.add-item').addClass('disabled').prop('disabled', 'disabled');
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/permissions.js
- var permissions_body = external_jQuery_default()('body');
- var radioSelector = '.permission-container.parent-section input[type="radio"]';
- var handleParent = function handleParent(event) {
- var target = external_jQuery_default()(event.currentTarget);
- var value = target.val();
- var container = target.closest('.parent-section');
- var fieldset = container.next('fieldset');
- var radios = fieldset.find("input[type=\"radio\"][value=\"".concat(value, "\"]"));
- if (container.data('isLocked') !== false) {
- container.data('isUpdating', true);
- radios.each(function (index, radio) {
- var ID = radio.id;
- external_jQuery_default()(radio).siblings("[for=\"".concat(ID, "\"]")).trigger('click');
- });
- container.data('isUpdating', false);
- }
- };
- var boundHandleParent = handleParent.bind(handleParent);
- permissions_body.on('click', '.permission-container.parent-section label', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var container = target.closest('.parent-section');
- container.data('isLocked', true);
- });
- permissions_body.on('input', radioSelector, boundHandleParent);
- permissions_body.on('input', '.permissions-container input[type="radio"][data-parent-id]', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var parent = external_jQuery_default()("[for=\"".concat(target.data('parentId'), "\"]"));
- var container = target.closest('fieldset').prev('.permission-container.parent-section');
- if (container.data('isUpdating') === true) {
- return true;
- }
- permissions_body.off('input', radioSelector, boundHandleParent);
- container.data('isLocked', false);
- parent.trigger('click');
- permissions_body.on('input', radioSelector, boundHandleParent);
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/indeterminate.js
- document.addEventListener('click', function (event) {
- if (document.querySelector('#pages-filters')) {
- return true;
- }
- var wrapper = event.target.closest('.checkboxes.indeterminate');
- if (wrapper) {
- event.preventDefault();
- var checkbox = wrapper.querySelector('input[type="checkbox"]:not([disabled])');
- var checkStatus = wrapper.dataset._checkStatus;
- wrapper.classList.remove('status-checked', 'status-unchecked', 'status-indeterminate');
- switch (checkStatus) {
- // checked, going indeterminate
- case '1':
- wrapper.dataset._checkStatus = '2';
- checkbox.indeterminate = true;
- checkbox.checked = false;
- checkbox.value = 0;
- wrapper.classList.add('status-indeterminate');
- break;
- // indeterminate, going unchecked
- case '2':
- wrapper.dataset._checkStatus = '0';
- checkbox.indeterminate = false;
- checkbox.checked = false;
- checkbox.value = '';
- wrapper.classList.add('status-unchecked');
- break;
- // unchecked, going checked
- case '0':
- default:
- wrapper.dataset._checkStatus = '1';
- checkbox.indeterminate = false;
- checkbox.checked = true;
- checkbox.value = 1;
- wrapper.classList.add('status-checked');
- break;
- } // const input = new CustomEvent('input', { detail: { target: checkbox }});
- // document.dispatchEvent(input);
- external_jQuery_default()(checkbox).trigger('input');
- }
- });
- (document.querySelectorAll('input[type="checkbox"][indeterminate="true"]') || []).forEach(function (input) {
- input.indeterminate = true;
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/mediapicker.js
- external_jQuery_default()(function () {
- var modal = '';
- var body = external_jQuery_default()('body'); // Thumb Resizer
- external_jQuery_default()(document).on('input change', '.media-container .media-range', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var container = target.closest('.remodal');
- var cards = container.find('.media-container div.card-item');
- var width = target.val() + 'px';
- cards.each(function () {
- external_jQuery_default()(this).css('width', width);
- });
- });
- body.on('click', '[data-mediapicker-modal-trigger]', function (event) {
- var element = external_jQuery_default()(event.currentTarget);
- var modal_identifier = external_jQuery_default()(this).data('grav-mediapicker-unique-identifier');
- var modal_element = body.find("[data-remodal-unique-identifier=\"".concat(modal_identifier, "\"]"));
- modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
- if (!modal) {
- modal_element.remodal();
- modal = (external_jQuery_default()).remodal.lookup[modal_element.data('remodal')];
- }
- modal.open();
- modal.dataField = element.find('input'); // load all media
- modal_element.find('.js__files').trigger('fillView');
- setTimeout(function () {
- return tree_Instance.reload();
- }, 100);
- });
- /* handle media modal click actions */
- body.on('click', '[data-remodal-mediapicker] .media-container.in-modal .admin-media-details a', function (event) {
- event.preventDefault();
- event.stopPropagation();
- var val = external_jQuery_default()(event.target).parents('.js__media-element').data('file-url');
- var string = val.replace(/ /g, '%20');
- modal.dataField.val(string);
- modal.close();
- });
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/multilevel.js
- external_jQuery_default()(function () {
- var getField = function getField(level, name) {
- var levelMargin = level * 50;
- var top = level === 0 ? 'top' : '';
- var the_name = 'name="' + name + '"';
- if (level === 0) {
- // top
- the_name = 'data-attr-name="' + name + '"';
- }
- var marginDir = window.getComputedStyle(document.body).direction === 'ltr' ? 'margin-left' : 'margin-right';
- 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 ");
- return field;
- };
- var hasChildInputs = function hasChildInputs($element) {
- if ($element.attr('name')) {
- return false;
- }
- return true;
- };
- var getTopItems = function getTopItems(element) {
- return external_jQuery_default()(element + ' .js__multilevel-field.top');
- };
- var refreshControls = function refreshControls(unique_identifier) {
- var element = '[data-grav-multilevel-field]';
- if (unique_identifier) {
- element = '[data-grav-multilevel-field][data-id="' + unique_identifier + '"]';
- }
- var hideButtons = function hideButtons() {
- external_jQuery_default()(element + ' .js__add-sibling').addClass('hidden');
- external_jQuery_default()(element + ' .js__add-children').addClass('hidden');
- };
- var restoreAddSiblingButtons = function restoreAddSiblingButtons() {
- external_jQuery_default()(element + ' .children-wrapper').each(function () {
- var elements = external_jQuery_default()(this).children();
- elements.last().each(function () {
- var field = external_jQuery_default()(this);
- if (!external_jQuery_default()(this).hasClass('js__multilevel-field')) {
- field = external_jQuery_default()(this).find('.js__multilevel-field').first();
- }
- field.find('.js__add-sibling').removeClass('hidden');
- });
- }); // add sibling to the last top element
- external_jQuery_default()(element + ' .js__multilevel-field.top').last().find('.js__add-sibling').removeClass('hidden');
- };
- var restoreAddChildrenButtons = function restoreAddChildrenButtons() {
- external_jQuery_default()(element + ' .js__multilevel-field').each(function () {
- if (external_jQuery_default()(this).siblings('.children-wrapper').length === 0 || external_jQuery_default()(this).siblings('.children-wrapper').find('.js__multilevel-field').length === 0) {
- external_jQuery_default()(this).find('.js__add-children').removeClass('hidden');
- }
- });
- };
- var preventRemovingLastTopItem = function preventRemovingLastTopItem() {
- var top_items = getTopItems(element);
- if (top_items.length === 1) {
- top_items.first().find('.js__remove-item').addClass('hidden');
- }
- };
- hideButtons();
- restoreAddSiblingButtons();
- restoreAddChildrenButtons();
- preventRemovingLastTopItem();
- };
- var changeAllOccurrencesInTree = function changeAllOccurrencesInTree($el, current_name, new_name) {
- $el.parents('[data-grav-multilevel-field]').find('input').each(function () {
- var $input = external_jQuery_default()(this);
- if ($input.attr('name')) {
- $input.attr('name', $input.attr('name').replace(current_name, new_name));
- }
- if ($input.attr('data-attr-name')) {
- $input.attr('data-attr-name', $input.attr('data-attr-name').replace(current_name, new_name));
- }
- });
- };
- external_jQuery_default()(document).ready(function () {
- refreshControls();
- });
- external_jQuery_default()(document).on('mouseleave', '[data-grav-multilevel-field]', function (event) {
- var top_items = getTopItems('[data-id="' + external_jQuery_default()(this).data('id') + '"]');
- var has_top_items_without_children = false;
- var element_content = '';
- top_items.each(function () {
- var item = external_jQuery_default()(this);
- if (external_jQuery_default()(item).siblings('.children-wrapper').find('input').length === 0) {
- has_top_items_without_children = true;
- element_content = item.find('input').val();
- }
- });
- if (has_top_items_without_children) {
- if (element_content) {
- alert('Warning: if you save now, the element ' + element_content + ', without children, will be removed, because it\'s invalid YAML');
- } else {
- alert('Warning: if you save now, the top elements without children will be removed, because it\'s invalid YAML');
- }
- }
- });
- external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__add-children', function (event) {
- var element = external_jQuery_default()(this);
- var unique_container_id = element.closest('.js__multilevel-field').data('id');
- var level = element.data('level') + 1;
- var getParentOfElement = function getParentOfElement(element) {
- var parent = element.closest('.js__multilevel-field').parent().first();
- if (parent.find('.children-wrapper').length === 0) {
- external_jQuery_default()(parent).append('<div class="children-wrapper"></div>');
- }
- parent = parent.find('.children-wrapper').first();
- return parent;
- };
- var getNameFromParentInput = function getNameFromParentInput(parentInput, attr) {
- if (parentInput.hasClass('children-wrapper')) {
- parentInput = parentInput.siblings('.js__multilevel-field').first().find('input');
- }
- return parentInput.attr(attr) + '[' + parentInput.val() + ']';
- };
- var getInputFromChildrenWrapper = function getInputFromChildrenWrapper(parentChildrenWrapper) {
- return parentChildrenWrapper.siblings('.js__multilevel-field').first().find('input');
- };
- var parentChildrenWrapper = getParentOfElement(element);
- var parentInput = getInputFromChildrenWrapper(parentChildrenWrapper);
- var attr = 'name';
- if (parentInput.closest('.js__multilevel-field').hasClass('top')) {
- attr = 'data-attr-name';
- }
- parentInput.attr(attr, parentInput.attr(attr).replace('[]', ''));
- var name = getNameFromParentInput(parentInput, attr);
- var field = getField(level, name);
- external_jQuery_default()(parentChildrenWrapper).append(field);
- refreshControls(unique_container_id);
- });
- external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__add-sibling', function (event) {
- var element = external_jQuery_default()(this);
- var unique_container_id = element.closest('.js__multilevel-field').data('id');
- var level = element.data('level');
- element.closest('.children-wrapper').find('.js__add-sibling').addClass('hidden');
- var sibling = null;
- var is_top = false;
- if (element.closest('.js__multilevel-field').hasClass('top')) {
- is_top = true;
- }
- if (is_top) {
- sibling = element.closest('.js__multilevel-field').first().find('input').last();
- } else {
- sibling = element.siblings('input').first();
- if (!sibling) {
- sibling = element.closest('.children-wrapper').first().find('input').last();
- }
- }
- var getParentOfElement = function getParentOfElement(element) {
- var parent = element.closest('.js__multilevel-field').parent().first();
- if (!parent.hasClass('element-wrapper')) {
- if (parent.find('.element-wrapper').length === 0) {
- external_jQuery_default()(parent).append('<div class="element-wrapper"></div>');
- }
- parent = parent.find('.element-wrapper').first();
- }
- return parent;
- };
- var getNameFromSibling = function getNameFromSibling(parent, sibling) {
- var is_top = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- var name = sibling.attr('name');
- if (hasChildInputs(sibling)) {
- var val = sibling.data('attr-name') + '[]';
- sibling.removeAttr('name');
- return val;
- }
- var last_index = name.lastIndexOf('[');
- var almost_there = name.substr(last_index + 1);
- var last_tag = almost_there.substr(0, almost_there.length - 1);
- if (external_jQuery_default().isNumeric(last_tag)) {
- name = name.replace('[' + last_tag + ']', '[' + (parseInt(last_tag, 10) + 1) + ']');
- } else {
- if (is_top) {
- name = name.replace('[' + last_tag + ']', '');
- } else {
- name = name + '[1]'; // change sibling name attr if necessary
- if (sibling.attr('name').slice('-2') !== '[0]') {
- changeAllOccurrencesInTree(sibling, sibling.attr('name'), sibling.attr('name') + '[0]');
- }
- }
- }
- return name;
- };
- var parent = getParentOfElement(element);
- var name = getNameFromSibling(parent, sibling, is_top);
- var field = getField(level, name);
- external_jQuery_default()(field).insertAfter(parent);
- refreshControls(unique_container_id);
- });
- external_jQuery_default()(document).on('click', '[data-grav-multilevel-field] .js__remove-item', function (event) {
- external_jQuery_default()(this).parents('.element-wrapper').first().remove();
- var unique_container_id = external_jQuery_default()(this).closest('.js__multilevel-field').data('id');
- refreshControls(unique_container_id);
- }); // Store old value before editing a field
- external_jQuery_default()(document).on('focusin', '[data-grav-multilevel-field] input', function (event) {
- external_jQuery_default()(this).data('current-value', external_jQuery_default()(this).val());
- }); // Handle field edited event
- external_jQuery_default()(document).on('change', '[data-grav-multilevel-field] input', function (event) {
- var $el = external_jQuery_default()(this);
- var old_value = $el.data('current-value');
- var new_value = $el.val();
- var full_name = $el.attr('name') || $el.attr('data-attr-name'); // first-level items have `data-attr-name` instead of `name`
- var old_name_attr = full_name + '[' + old_value + ']';
- var new_name_attr = full_name + '[' + new_value + ']';
- changeAllOccurrencesInTree($el, old_name_attr, new_name_attr);
- });
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/text.js
- external_jQuery_default()(document).ready(function () {
- external_jQuery_default()('.copy-to-clipboard').click(function (event) {
- var $tempElement = external_jQuery_default()('<input>');
- external_jQuery_default()('body').append($tempElement);
- $tempElement.val(external_jQuery_default()(this).prev('input').val()).select();
- document.execCommand('Copy');
- $tempElement.remove();
- external_jQuery_default()(this).attr('data-hint', 'Copied to clipboard!').addClass('hint--left');
- });
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/range.js
- external_jQuery_default()(document).on('input', '[type="range"].rangefield, [type="number"].rangefield', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var type = target.attr('type').toLowerCase();
- var sibling = type === 'range' ? 'number' : 'range';
- var feedback = target.siblings("[type=\"".concat(sibling, "\"].rangefield"));
- feedback.val(target.val());
- });
- ;// CONCATENATED MODULE: ./app/forms/fields/elements.js
- external_jQuery_default()(document).on('change', '[data-grav-elements] select', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var value = target.val();
- var id = target.closest('[data-grav-elements]').data('gravElements');
- external_jQuery_default()("[id^=\"".concat(id, "_\"]")).css('display', 'none');
- external_jQuery_default()("[id=\"".concat(id, "__").concat(value, "\"]")).css('display', 'inherit');
- });
- external_jQuery_default()('[data-grav-elements] select').trigger('change');
- ;// CONCATENATED MODULE: ./app/forms/fields/index.js
- /* harmony default export */ const fields = ({
- FilepickerField: {
- FilepickerField: FilePickerField,
- Instance: filepicker_Instance
- },
- SelectizeField: {
- SelectizeField: SelectizeField,
- Instance: selectize_Instance
- },
- ArrayField: {
- ArrayField: ArrayField,
- Instance: array_Instance
- },
- CollectionsField: {
- CollectionsField: CollectionsField,
- Instance: collections_Instance
- },
- DateTimeField: {
- DateTimeField: DateTimeField,
- Instance: datetime_Instance
- },
- EditorField: {
- EditorField: EditorField,
- Instance: editor_Instance
- },
- ColorpickerField: {
- ColorpickerField: ColorpickerField,
- Instance: colorpicker_Instance
- },
- FilesField: {
- FilesField: FilesField,
- Instance: Instance
- },
- FolderField: {
- Regenerate: fields_folder
- },
- SelectUniqueField: {
- SelectUniqueField: SelectUniqueField,
- Instance: selectunique_Instance
- },
- IconpickerField: {
- IconpickerField: IconpickerField,
- Instance: iconpicker_Instance
- },
- CronField: {
- CronField: CronField,
- Instance: cron_Instance
- },
- ParentsField: {
- ParentsField: Parents,
- Instance: parents_Instances
- }
- });
- ;// CONCATENATED MODULE: ./app/forms/index.js
- /* harmony default export */ const app_forms = ({
- Form: {
- Form: Form,
- Instance: form_Instance
- },
- Fields: fields,
- FormState: {
- FormState: FormState,
- Instance: state_Instance
- }
- });
- ;// CONCATENATED MODULE: ./app/utils/packages.js
- function packages_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function packages_createClass(Constructor, protoProps, staticProps) { if (protoProps) packages_defineProperties(Constructor.prototype, protoProps); if (staticProps) packages_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var Sorter = /*#__PURE__*/function () {
- function Sorter() {
- packages_classCallCheck(this, Sorter);
- }
- packages_createClass(Sorter, [{
- key: "getElements",
- value: function getElements(elements, container) {
- this.elements = elements || document.querySelectorAll('[data-gpm-plugin], [data-gpm-theme]');
- this.container = container || document.querySelector('.gpm-plugins > table > tbody, .gpm-themes > .themes.card-row');
- return this.elements;
- }
- }, {
- key: "byCommon",
- value: function byCommon() {
- var _this = this;
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- var elements = this.getElements();
- this.removeGumroad();
- Array.from(elements).sort(function (a, b) {
- var A = a.dataset[data].toString().toLowerCase();
- var B = b.dataset[data].toString().toLowerCase();
- return Sorter.sort(A, B, direction);
- }).forEach(function (element) {
- _this.container.appendChild(element);
- });
- this.addGumroad();
- return this.container;
- }
- }, {
- key: "byName",
- value: function byName() {
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmName';
- return this.byCommon(direction, data);
- }
- }, {
- key: "byAuthor",
- value: function byAuthor() {
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmAuthor';
- return this.byCommon(direction, data);
- }
- }, {
- key: "byOfficial",
- value: function byOfficial() {
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmOfficial';
- return this.byCommon(direction, data);
- }
- }, {
- key: "byPremium",
- value: function byPremium() {
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmPremium';
- return this.byCommon(direction, data);
- }
- }, {
- key: "byReleaseDate",
- value: function byReleaseDate() {
- var _this2 = this;
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmReleaseDate';
- var elements = this.getElements();
- this.removeGumroad();
- Array.from(elements).sort(function (a, b) {
- var A = new Date(a.dataset[data]).getTime();
- var B = new Date(b.dataset[data]).getTime();
- return Sorter.sort(A, B, direction === 'asc' ? 'desc' : 'asc');
- }).forEach(function (element) {
- _this2.container.appendChild(element);
- });
- this.addGumroad();
- return this.container;
- }
- }, {
- key: "byUpdatable",
- value: function byUpdatable() {
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmUpdatable';
- return this.byCommon(direction, data);
- }
- }, {
- key: "byEnabled",
- value: function byEnabled() {
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmEnabled';
- return this.byCommon(direction, data);
- }
- }, {
- key: "byTesting",
- value: function byTesting() {
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpmTesting';
- return this.byCommon(direction, data);
- }
- }, {
- key: "addGumroad",
- value: function addGumroad() {
- if (window.GumroadOverlay) {
- window.GumroadOverlay.startNodeAdditionObserver();
- }
- }
- }, {
- key: "removeGumroad",
- value: function removeGumroad() {
- if (window.GumroadOverlay) {
- window.GumroadOverlay.nodeAdditionObserver.disconnect();
- }
- }
- }], [{
- key: "sort",
- value: function sort(A, B) {
- var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'asc';
- if (A > B) {
- return direction === 'asc' ? 1 : -1;
- }
- if (A < B) {
- return direction === 'asc' ? -1 : 1;
- }
- return 0;
- }
- }]);
- return Sorter;
- }();
- var Packages = /*#__PURE__*/function () {
- function Packages() {
- packages_classCallCheck(this, Packages);
- this.Sort = new Sorter();
- }
- packages_createClass(Packages, [{
- key: "addDependenciesToList",
- value: function addDependenciesToList(dependencies) {
- var slug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- dependencies.forEach(function (dependency) {
- Packages.addDependencyToList('plugin', dependency.name || dependency, slug);
- });
- }
- }, {
- key: "removePackage",
- value: function removePackage(type, slug) {
- var _this3 = this;
- var url = Packages.getRemovePackageUrl(type);
- utils_request(url, {
- method: 'post',
- body: {
- "package": slug
- }
- }, function (response) {
- if (response.status === 'success') {
- external_jQuery_default()('.remove-package-confirm').addClass('hidden');
- if (response.dependencies && response.dependencies.length > 0) {
- _this3.addDependenciesToList(response.dependencies);
- external_jQuery_default()('.remove-package-dependencies').removeClass('hidden');
- } else {
- external_jQuery_default()('.remove-package-done').removeClass('hidden');
- } // The package was removed. When the modal closes, move to the packages list
- external_jQuery_default()(document).on('closing', '[data-remodal-id="remove-package"]', function () {
- Packages.getBackToList(type);
- });
- } else {
- external_jQuery_default()('.remove-package-confirm').addClass('hidden');
- external_jQuery_default()('.remove-package-error').removeClass('hidden');
- }
- });
- }
- }, {
- key: "reinstallPackage",
- value: function reinstallPackage(type, slug, package_name, current_version) {
- external_jQuery_default()('.button-bar button').addClass('hidden');
- external_jQuery_default()('.button-bar .spinning-wheel').removeClass('hidden');
- var url = Packages.getReinstallPackageUrl(type);
- utils_request(url, {
- method: 'post',
- body: {
- slug: slug,
- type: type,
- package_name: package_name,
- current_version: current_version
- }
- }, function (response) {
- if (response.status === 'success') {
- external_jQuery_default()('.reinstall-package-confirm').addClass('hidden');
- external_jQuery_default()('.reinstall-package-done').removeClass('hidden');
- } else {
- external_jQuery_default()('.reinstall-package-confirm').addClass('hidden');
- external_jQuery_default()('.reinstall-package-error').removeClass('hidden');
- }
- window.location.reload();
- });
- }
- }, {
- key: "removeDependency",
- value: function removeDependency(type, slug, button) {
- var _this4 = this;
- var url = Packages.getRemovePackageUrl(type);
- utils_request(url, {
- method: 'post',
- body: {
- "package": slug
- }
- }, function (response) {
- if (response.status === 'success') {
- button.removeClass('button');
- button.replaceWith(external_jQuery_default()('<span>Removed successfully</span>'));
- if (response.dependencies && response.dependencies.length > 0) {
- _this4.addDependenciesToList(response.dependencies, slug);
- }
- }
- });
- }
- }, {
- key: "getPackagesDependencies",
- value: function getPackagesDependencies(type, slugs, finishedLoadingCallback) {
- var url = Packages.getGetPackagesDependenciesUrl(type);
- utils_request(url, {
- method: 'post',
- body: {
- packages: slugs
- }
- }, function (response) {
- finishedLoadingCallback();
- if (response.status === 'success') {
- if (response.dependencies) {
- var hasDependencies = false;
- for (var dependency in response.dependencies) {
- if (response.dependencies.hasOwnProperty(dependency)) {
- if (dependency === 'grav') {
- continue;
- }
- hasDependencies = true;
- var dependencyName = dependency;
- var action = response.dependencies[dependency];
- Packages.addNeededDependencyToList(action, dependencyName);
- }
- }
- if (hasDependencies) {
- external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').removeClass('hidden');
- } else {
- external_jQuery_default()('[data-packages-modal] .install-package-container').removeClass('hidden');
- }
- } else {
- external_jQuery_default()('[data-packages-modal] .install-package-container').removeClass('hidden');
- }
- } else {
- external_jQuery_default()('[data-packages-modal] .install-package-error').removeClass('hidden');
- }
- });
- }
- }, {
- key: "installDependenciesOfPackages",
- value: function installDependenciesOfPackages(type, slugs, callbackSuccess, callbackError) {
- var url = Packages.getInstallDependenciesOfPackagesUrl(type);
- utils_request(url, {
- method: 'post',
- body: {
- packages: slugs
- }
- }, callbackSuccess);
- }
- }, {
- key: "installPackages",
- value: function installPackages(type, slugs, callbackSuccess) {
- var url = Packages.getInstallPackageUrl(type);
- __webpack_require__.g.Promise.all(slugs.map(function (slug) {
- return new __webpack_require__.g.Promise(function (resolve, reject) {
- utils_request(url, {
- method: 'post',
- body: {
- "package": slug,
- type: type
- }
- }, function (response) {
- resolve(response);
- });
- });
- })).then(callbackSuccess);
- }
- }, {
- key: "handleGettingPackageDependencies",
- value: function handleGettingPackageDependencies(type, event) {
- var action = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'update';
- var slugs = Packages.getSlugsFromEvent(event);
- if (!slugs) {
- alert('No slug set');
- return;
- } // Cleanup
- external_jQuery_default()('.packages-names-list').html('');
- external_jQuery_default()('.install-dependencies-package-container li').remove();
- slugs.forEach(function (slug) {
- if (action === 'update') {
- var current_version = '';
- var available_version = '';
- var _name = '';
- var resources = gpm_Instance.payload.payload.resources;
- if (resources.plugins[slug]) {
- available_version = resources.plugins[slug].available;
- current_version = resources.plugins[slug].version;
- _name = resources.plugins[slug].name;
- } else if (resources.themes[slug]) {
- available_version = resources.themes[slug].available;
- current_version = resources.themes[slug].version;
- _name = resources.themes[slug].name;
- }
- 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>"));
- } else {
- external_jQuery_default()('.packages-names-list').append("<li>".concat(name ? name : slug, "</li>"));
- }
- });
- event.preventDefault();
- event.stopPropagation(); // fix mismatching types when sharing install modal between plugins/themes
- var query = '[data-packages-modal] [data-theme-action], [data-packages-modal] [data-plugin-action]';
- var data = external_jQuery_default()(query).data('themeAction') || external_jQuery_default()(query).data('pluginAction');
- external_jQuery_default()(query).removeAttr('data-theme-action').removeAttr('data-plugin-action').attr("data-".concat(type, "-action"), data); // Restore original state
- external_jQuery_default()('[data-packages-modal] .loading').removeClass('hidden');
- external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .installing-dependencies').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .installation-complete').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .install-package-error').addClass('hidden');
- this.getPackagesDependencies(type, slugs, function () {
- var slugs_string = slugs.join();
- external_jQuery_default()("[data-packages-modal] [data-".concat(type, "-action=\"install-dependencies-and-package\"]")).attr('data-packages-slugs', slugs_string);
- external_jQuery_default()("[data-packages-modal] [data-".concat(type, "-action=\"install-package\"]")).attr('data-packages-slugs', slugs_string);
- external_jQuery_default()('[data-packages-modal] .loading').addClass('hidden');
- });
- }
- }, {
- key: "handleInstallingDependenciesAndPackage",
- value: function handleInstallingDependenciesAndPackage(type, event) {
- var _this5 = this;
- var slugs = Packages.getSlugsFromEvent(event);
- event.preventDefault();
- event.stopPropagation();
- external_jQuery_default()('[data-packages-modal] .install-dependencies-package-container').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .installing-dependencies').removeClass('hidden');
- this.installDependenciesOfPackages(type, slugs, function (response) {
- external_jQuery_default()('[data-packages-modal] .installing-dependencies').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .installing-package').removeClass('hidden');
- _this5.installPackages(type, slugs, function () {
- external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .installation-complete').removeClass('hidden');
- if (response.status === 'error') {
- var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-packages-modal]').data('remodal')];
- remodal.close();
- return;
- }
- setTimeout(function () {
- if (slugs.length === 1) {
- __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s/").concat(slugs[0]);
- } else {
- __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
- }
- }, 1000);
- });
- });
- }
- }, {
- key: "handleInstallingPackage",
- value: function handleInstallingPackage(type, event) {
- var slugs = Packages.getSlugsFromEvent(event);
- event.preventDefault();
- event.stopPropagation();
- external_jQuery_default()('[data-packages-modal] .install-package-container').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .installing-package').removeClass('hidden');
- this.installPackages(type, slugs, function (response) {
- external_jQuery_default()('[data-packages-modal] .installing-package').addClass('hidden');
- external_jQuery_default()('[data-packages-modal] .installation-complete').removeClass('hidden');
- var errors = Array.from(response).filter(function (r) {
- return r.status === 'error';
- });
- if (errors && errors.length) {
- var remodal = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-packages-modal].remodal-is-opened').data('remodal')];
- remodal.close();
- return;
- }
- if (slugs.length === 1) {
- __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s/").concat(slugs[0]);
- } else {
- __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
- }
- });
- }
- }, {
- key: "handleRemovingPackage",
- value: function handleRemovingPackage(type, event) {
- var slug = external_jQuery_default()(event.target).attr('data-packages-slugs');
- event.preventDefault();
- event.stopPropagation();
- this.removePackage(type, slug);
- }
- }, {
- key: "handleReinstallPackage",
- value: function handleReinstallPackage(type, event) {
- var target = external_jQuery_default()(event.target);
- var slug = target.attr('data-package-slug');
- var package_name = target.attr('data-package-name');
- var current_version = target.attr('data-package-current-version');
- event.preventDefault();
- event.stopPropagation();
- this.reinstallPackage(type, slug, package_name, current_version);
- }
- }, {
- key: "handleRemovingDependency",
- value: function handleRemovingDependency(type, event) {
- var slug = external_jQuery_default()(event.target).attr('data-dependency-slug');
- var button = external_jQuery_default()(event.target);
- event.preventDefault();
- event.stopPropagation();
- this.removeDependency(type, slug, button);
- }
- }], [{
- key: "getBackToList",
- value: function getBackToList(type) {
- __webpack_require__.g.location.href = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/").concat(type, "s");
- }
- }, {
- key: "addDependencyToList",
- value: function addDependencyToList(type, dependency) {
- var slug = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
- if (['admin', 'form', 'login', 'email', 'grav'].indexOf(dependency) !== -1) {
- return;
- }
- var container = external_jQuery_default()('.package-dependencies-container');
- var text = "".concat(dependency, " <a href=\"#\" class=\"button\" data-dependency-slug=\"").concat(dependency, "\" data-").concat(type, "-action=\"remove-dependency-package\">Remove</a>");
- if (slug) {
- text += " (was needed by ".concat(slug, ")");
- }
- container.append("<li>".concat(text, "</li>"));
- }
- }, {
- key: "getTaskUrl",
- value: function getTaskUrl(type, task) {
- var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative);
- url += "/".concat(type, "s.json");
- url += "/task".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(task);
- return url;
- }
- }, {
- key: "getRemovePackageUrl",
- value: function getRemovePackageUrl(type) {
- return "".concat(Packages.getTaskUrl(type, 'removePackage'));
- }
- }, {
- key: "getReinstallPackageUrl",
- value: function getReinstallPackageUrl(type) {
- return "".concat(Packages.getTaskUrl(type, 'reinstallPackage'));
- }
- }, {
- key: "getGetPackagesDependenciesUrl",
- value: function getGetPackagesDependenciesUrl(type) {
- return "".concat(Packages.getTaskUrl(type, 'getPackagesDependencies'));
- }
- }, {
- key: "getInstallDependenciesOfPackagesUrl",
- value: function getInstallDependenciesOfPackagesUrl(type) {
- return "".concat(Packages.getTaskUrl(type, 'installDependenciesOfPackages'));
- }
- }, {
- key: "getInstallPackageUrl",
- value: function getInstallPackageUrl(type) {
- return "".concat(Packages.getTaskUrl(type, 'installPackage'));
- }
- }, {
- key: "addNeededDependencyToList",
- value: function addNeededDependencyToList(action, slug) {
- external_jQuery_default()('.install-dependencies-package-container .type-' + action).removeClass('hidden');
- var list = external_jQuery_default()('.install-dependencies-package-container .type-' + action + ' ul');
- if (action !== 'install') {
- var current_version = '';
- var available_version = '';
- var _name2 = '';
- var resources = gpm_Instance.payload.payload.resources;
- if (resources.plugins[slug]) {
- available_version = resources.plugins[slug].available;
- current_version = resources.plugins[slug].version;
- _name2 = resources.plugins[slug].name;
- } else if (resources.themes[slug]) {
- available_version = resources.themes[slug].available;
- current_version = resources.themes[slug].version;
- _name2 = resources.themes[slug].name;
- }
- 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>"));
- } else {
- list.append("<li>".concat(name ? name : slug, "</li>"));
- }
- }
- }, {
- key: "getSlugsFromEvent",
- value: function getSlugsFromEvent(event) {
- var slugs = '';
- if (external_jQuery_default()(event.target).is('[data-packages-slugs]')) {
- slugs = external_jQuery_default()(event.target).attr('data-packages-slugs');
- } else {
- slugs = external_jQuery_default()(event.target).parent('[data-packages-slugs]').attr('data-packages-slugs');
- }
- if (typeof slugs === 'undefined') {
- return null;
- }
- slugs = slugs.split(',');
- return typeof slugs === 'string' ? [slugs] : slugs;
- }
- }]);
- return Packages;
- }();
- /* harmony default export */ const utils_packages = (new Packages());
- // EXTERNAL MODULE: ./node_modules/mout/string/camelCase.js
- var camelCase = __webpack_require__(71047);
- var camelCase_default = /*#__PURE__*/__webpack_require__.n(camelCase);
- // EXTERNAL MODULE: ./node_modules/mout/string/contains.js
- var contains = __webpack_require__(85286);
- var contains_default = /*#__PURE__*/__webpack_require__.n(contains);
- ;// CONCATENATED MODULE: ./app/plugins/index.js
- // Plugins sliders details
- external_jQuery_default()('.gpm-name, .gpm-actions').on('click', function (e) {
- var element = external_jQuery_default()(this);
- var target = external_jQuery_default()(e.target);
- var tag = target.prop('tagName').toLowerCase();
- if (tag === 'a' || element.parent('a').length || target.parent('a').length) {
- return true;
- }
- var wrapper = element.siblings('.gpm-details').find('.table-wrapper');
- wrapper.slideToggle({
- duration: 350,
- complete: function complete() {
- var visible = wrapper.is(':visible');
- wrapper.closest('tr').find('.gpm-details-expand i').removeClass('fa-chevron-' + (visible ? 'down' : 'up')).addClass('fa-chevron-' + (visible ? 'up' : 'down'));
- }
- });
- }); // Removing plugin
- external_jQuery_default()(document).on('click', '[data-plugin-action="remove-package"]', function (event) {
- utils_packages.handleRemovingPackage('plugin', event);
- }); // Reinstall plugin
- external_jQuery_default()(document).on('click', '[data-plugin-action="reinstall-package"]', function (event) {
- utils_packages.handleReinstallPackage('plugin', event);
- });
- external_jQuery_default()(document).on('click', '[data-plugin-action="remove-dependency-package"]', function (event) {
- utils_packages.handleRemovingDependency('plugin', event);
- }); // Trigger the add new plugin / update plugin modal
- external_jQuery_default()(document).on('click', '[data-plugin-action="start-package-installation"]', function (event) {
- utils_packages.handleGettingPackageDependencies('plugin', event, 'install');
- }); // Trigger the update all plugins modal
- external_jQuery_default()(document).on('click', '[data-plugin-action="start-packages-update"]', function (event) {
- utils_packages.handleGettingPackageDependencies('plugin', event);
- }); // Install a plugin dependencies and the plugin
- external_jQuery_default()(document).on('click', '[data-plugin-action="install-dependencies-and-package"]', function (event) {
- utils_packages.handleInstallingDependenciesAndPackage('plugin', event);
- }); // Install a plugin
- external_jQuery_default()(document).on('click', '[data-plugin-action="install-package"]', function (event) {
- utils_packages.handleInstallingPackage('plugin', event);
- }); // Sort plugins/themes dropdown
- external_jQuery_default()(document).on('change', '.sort-actions select', function (event) {
- var direction = external_jQuery_default()('.sort-actions .sort-icon .fa').hasClass('fa-sort-amount-desc') ? 'desc' : 'asc';
- var sorting = external_jQuery_default()(event.currentTarget).val();
- utils_packages.Sort[camelCase_default()("by-".concat(sorting))](direction);
- }); // Sort plugins/themes icon
- external_jQuery_default()(document).on('click', '.sort-icon', function (event) {
- var icon = external_jQuery_default()(event.currentTarget).find('.fa');
- var current = icon.hasClass('fa-sort-amount-asc') ? 'asc' : 'desc';
- var opposite = current === 'asc' ? 'desc' : 'asc';
- icon.removeClass("fa-sort-amount-".concat(current)).addClass("fa-sort-amount-".concat(opposite));
- external_jQuery_default()('.sort-actions select').trigger('change');
- }); // Filter plugin/theme
- external_jQuery_default()(document).on('input', '[data-gpm-filter]', debounce_default()(function (event) {
- var value = external_jQuery_default()(external_jQuery_default()(event.currentTarget)).val();
- var items = external_jQuery_default()('[data-gpm-plugin], [data-gpm-theme]');
- items.hide().filter(function (index, item) {
- item = external_jQuery_default()(item);
- return contains_default()(item.data('gpm-plugin'), value) || contains_default()(item.data('gpm-theme'), value) || contains_default()(item.data('gpm-name').toLowerCase(), value.toLowerCase());
- }).show();
- }, 250));
- ;// CONCATENATED MODULE: ./app/themes/index.js
- // Themes Switcher Warning
- external_jQuery_default()(document).on('mousedown', '[data-remodal-target="theme-switch-warn"]', function (event) {
- var name = external_jQuery_default()(event.target).closest('[data-gpm-theme]').find('.gpm-name a:first').text();
- var remodal = external_jQuery_default()('.remodal.theme-switcher');
- remodal.find('strong').text(name);
- remodal.find('.button.continue').attr('href', external_jQuery_default()(event.target).attr('href'));
- }); // Removing theme
- external_jQuery_default()(document).on('click', '[data-theme-action="remove-package"]', function (event) {
- utils_packages.handleRemovingPackage('theme', event);
- }); // Reinstall theme
- external_jQuery_default()(document).on('click', '[data-theme-action="reinstall-package"]', function (event) {
- utils_packages.handleReinstallPackage('theme', event);
- });
- external_jQuery_default()(document).on('click', '[data-theme-action="remove-dependency-package"]', function (event) {
- utils_packages.handleRemovingDependency('theme', event);
- }); // Opened the add new theme / update theme modal
- external_jQuery_default()(document).on('click', '[data-theme-action="start-package-installation"]', function (event) {
- utils_packages.handleGettingPackageDependencies('theme', event, 'install');
- }); // Trigger the update all themes modal
- external_jQuery_default()(document).on('click', '[data-theme-action="start-packages-update"]', function (event) {
- utils_packages.handleGettingPackageDependencies('theme', event);
- }); // Install a theme dependencies and the theme
- external_jQuery_default()(document).on('click', '[data-theme-action="install-dependencies-and-package"]', function (event) {
- utils_packages.handleInstallingDependenciesAndPackage('theme', event);
- }); // Install a theme
- external_jQuery_default()(document).on('click', '[data-theme-action="install-package"]', function (event) {
- utils_packages.handleInstallingPackage('theme', event);
- });
- ;// CONCATENATED MODULE: ./app/media/index.js
- function app_media_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function app_media_createClass(Constructor, protoProps, staticProps) { if (protoProps) app_media_defineProperties(Constructor.prototype, protoProps); if (staticProps) app_media_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var Filter = /*#__PURE__*/function () {
- function Filter() {
- app_media_classCallCheck(this, Filter);
- this.URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/media-manager/");
- }
- app_media_createClass(Filter, [{
- key: "filter",
- value: function filter(name, value) {
- var filtered = [];
- var keys = Object.keys(external_GravAdmin_namespaceObject.uri_params);
- if (!~keys.indexOf(name)) {
- keys.push(name);
- }
- keys.forEach(function (key) {
- var filter = Filter.cleanValue(key === name ? value : external_GravAdmin_namespaceObject.uri_params[key]);
- if (filter !== '*') {
- filtered.push("".concat(key).concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filter));
- }
- });
- __webpack_require__.g.location = this.URI + filtered.join('/');
- }
- }], [{
- key: "cleanValue",
- value: function cleanValue(value) {
- return encodeURIComponent(value.replace('/', '\\'));
- }
- }]);
- return Filter;
- }();
- var app_media_Instance = new Filter();
- var isLoading = false;
- var filters = {};
- var global_index = 1;
- var files_ended = false;
- var MEDIA_PAGINATION_INTERVAL = 20;
- /* handle changing file type / date filter */
- external_jQuery_default()('body').on('change', '.thumbs-list-container select.filter', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var filterName = target.data('name');
- var filterValue = target.val();
- if (filterValue) {
- filters[filterName] = filterValue;
- } else {
- delete filters[filterName];
- }
- filterFiles();
- });
- /* initialize media uploader */
- if (external_jQuery_default()('.thumbs-list-container .dropzone')[0]) {
- external_jQuery_default()('.thumbs-list-container .dropzone')[0].dropzone.on('queuecomplete', function () {
- var body = {};
- if (filters.page) {
- body.page = filters.page;
- }
- if (filters.date) {
- body.date = filters.date;
- }
- if (filters.type) {
- body.type = filters.type;
- }
- external_jQuery_default()('.dropzone')[0].dropzone.files.forEach(function (file) {
- file.previewElement.remove();
- });
- external_jQuery_default()('.dropzone').first().removeClass('dz-started');
- utils_request("".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/media-manager.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "clearMediaCache"), {
- method: 'post',
- body: body
- }, function () {
- filterFiles();
- });
- });
- }
- /* handle loading media */
- var loadMedia = function loadMedia(filters, callback) {
- 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);
- if (filters.page) {
- url += "/page".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.page.split('/').join('%5C'));
- }
- if (filters.type && filters.type !== '*') {
- url += "/type".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.type);
- }
- if (filters.date && filters.date !== '*') {
- url += "/date".concat(external_GravAdmin_namespaceObject.config.param_sep).concat(filters.date);
- }
- if (!isLoading) {
- isLoading = true;
- external_jQuery_default()('.spinning-wheel').show();
- external_jQuery_default().get(url, function (content) {
- external_jQuery_default()('.js__files').append(content);
- external_jQuery_default()('.spinning-wheel').hide();
- external_jQuery_default()('.media-container .media-range').trigger('change');
- isLoading = false;
- global_index++;
- callback(content);
- });
- }
- };
- var cleanFilesList = function cleanFilesList() {
- external_jQuery_default()('.js__files .card-item').remove();
- };
- var resetActiveStateInSidebar = function resetActiveStateInSidebar() {
- external_jQuery_default()('.pages-list-container .row').removeClass('active'); // clear active state in sidebar
- };
- var showEmptyState = function showEmptyState() {
- external_jQuery_default()('.thumbs-list-container').append('<p class="card-item empty-space">No media found</p>');
- };
- var filterFiles = function filterFiles() {
- cleanFilesList();
- global_index = 0;
- files_ended = false;
- external_jQuery_default()('.empty-space').remove();
- loadMedia(filters, function (content) {
- if (!content.trim().length) {
- showEmptyState();
- } else {
- if (!filters.page && (!filters.date || filters.date === '*') && (!filters.type || filters.type === '*')) {
- external_jQuery_default()('.js__files').trigger('fillView');
- }
- }
- });
- };
- /* handle changing page */
- external_jQuery_default()('body').on('click', '.pages-list-container .js__page-link', function (event) {
- var page = external_jQuery_default()(event.target).data('page');
- filters['page'] = page;
- external_jQuery_default()('.media-list-title .page-indicator').html(page); // set indication
- external_jQuery_default()('.js__reset-pages-filter').removeClass('hidden'); // activate reset pages icon
- resetActiveStateInSidebar();
- external_jQuery_default()(event.target).parents('.row').addClass('active'); // set active state in sidebar
- external_jQuery_default()('.js__file-uploader').removeClass('hidden'); // customize processing URL, as the page changes dynamically
- if (external_jQuery_default()('.dropzone')[0]) {
- external_jQuery_default()('.dropzone')[0].dropzone.on('processing', function (file) {
- 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");
- });
- }
- external_jQuery_default()('.js__button-clear-media-cache').addClass('hidden');
- filterFiles();
- disableInfiniteScrolling(); // only infinite scroll on main list, not inside single pages
- });
- /* handle clearing page filter */
- external_jQuery_default()('body').on('click', '.js__reset-pages-filter', function (event) {
- external_jQuery_default()('.media-list-title .page-indicator').html('All Pages'); // set indication
- cleanFilesList();
- resetActiveStateInSidebar();
- external_jQuery_default()('.js__reset-pages-filter').addClass('hidden'); // remove reset pages icon
- external_jQuery_default()('.js__file-uploader').addClass('hidden');
- external_jQuery_default()('.js__button-clear-media-cache').removeClass('hidden');
- delete filters['page'];
- filterFiles();
- });
- /* handle infinite loading */
- var enableInfiniteScrolling = function enableInfiniteScrolling() {
- external_jQuery_default()('.spinning-wheel').hide();
- var view = external_jQuery_default()('.mediapicker-scroll').last();
- if (!view.length) {
- return;
- }
- external_jQuery_default()(view).on('scroll', function () {
- if (external_jQuery_default()(this).scrollTop() + external_jQuery_default()(this).innerHeight() + 100 >= external_jQuery_default()(this)[0].scrollHeight) {
- fillView();
- }
- });
- };
- var loadNextBatch = function loadNextBatch(callback) {
- if (files_ended) {
- return;
- }
- loadMedia({}, function (content) {
- if (!external_jQuery_default()(content).length || content.split('card-item').length - 1 < MEDIA_PAGINATION_INTERVAL) {
- files_ended = true;
- } else {
- if (callback) {
- callback();
- }
- }
- external_jQuery_default()('.media-container .media-range').trigger('input');
- });
- };
- var fillView = function fillView() {
- if (!external_jQuery_default()('.js__files').find('.card-item').last().offset()) {
- setTimeout(function () {
- // retry later
- fillView();
- }, 300);
- return;
- }
- if (external_jQuery_default()('.js__files').find('.card-item').last().offset().top - 1 <= external_jQuery_default()('.media-container').height()) {
- loadNextBatch(function () {
- fillView();
- });
- }
- };
- /* disable infinite loading */
- var disableInfiniteScrolling = function disableInfiniteScrolling() {
- external_jQuery_default()('.spinning-wheel').hide();
- external_jQuery_default()('.content-wrapper').unbind('scroll');
- };
- external_jQuery_default()('.js__files').on('fillView', function (event) {
- // the first batch got the max number of media files, try loading more
- if (external_jQuery_default()('.js__files')[0].innerHTML.split('card-item').length - 1 === MEDIA_PAGINATION_INTERVAL) {
- fillView();
- enableInfiniteScrolling();
- }
- });
- ;// CONCATENATED MODULE: ./app/utils/2fa.js
- var _2fa_body = external_jQuery_default()('body'); // Dashboard update and Grav update
- _2fa_body.on('click', '[data-2fa-regenerate]', function (event) {
- event.preventDefault();
- var element = external_jQuery_default()(this);
- var url = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, "/ajax.json/task").concat(external_GravAdmin_namespaceObject.config.param_sep, "regenerate2FASecret");
- element.attr('disabled', 'disabled').find('> .fa').addClass('fa-spin');
- utils_request(url, {
- method: 'post'
- }, function (response) {
- external_jQuery_default()('[data-2fa-image]').attr('src', response.image);
- external_jQuery_default()('[data-2fa-secret]').text(response.secret);
- external_jQuery_default()('[data-2fa-value]').val(response.secret.replace(' ', ''));
- element.removeAttr('disabled').find('> .fa').removeClass('fa-spin');
- });
- });
- var toggleSecret = function toggleSecret() {
- var toggle = external_jQuery_default()('#toggle_twofa_enabled1');
- var secret = external_jQuery_default()('.twofa-secret');
- secret[toggle.is(':checked') ? 'addClass' : 'removeClass']('show');
- };
- _2fa_body.on('click', '.twofa-toggle input', toggleSecret);
- toggleSecret();
- // EXTERNAL MODULE: ./node_modules/mout/queryString.js
- var queryString = __webpack_require__(85407);
- ;// CONCATENATED MODULE: ./app/tools/logs.js
- var prepareQuery = function prepareQuery(key, value) {
- return (0,queryString.setParam)(__webpack_require__.g.location.href, key, value);
- };
- external_jQuery_default()(document).on('change', '.logs-content .block-select select[name]', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var name = target.attr('name');
- var value = target.val();
- __webpack_require__.g.location.href = prepareQuery(name, value);
- });
- ;// CONCATENATED MODULE: ./app/tools/index.js
- ;// CONCATENATED MODULE: ./app/whitelabel/compile.js
- /* harmony default export */ const compile = (function () {
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref$preview = _ref.preview,
- preview = _ref$preview === void 0 ? false : _ref$preview,
- _ref$exportScss = _ref.exportScss,
- exportScss = _ref$exportScss === void 0 ? false : _ref$exportScss,
- _ref$color_scheme = _ref.color_scheme,
- color_scheme = _ref$color_scheme === void 0 ? {} : _ref$color_scheme,
- _ref$fonts = _ref.fonts,
- fonts = _ref$fonts === void 0 ? {} : _ref$fonts,
- _ref$callback = _ref.callback,
- callback = _ref$callback === void 0 ? function () {} : _ref$callback;
- var task = exportScss ? 'exportScss' : 'compileScss'; // console.log(config);
- var URI = "".concat(external_GravAdmin_namespaceObject.config.base_url_relative, ".json/task:").concat(task);
- utils_request(URI, {
- method: 'post',
- body: Object.assign({}, preview ? {
- preview: preview
- } : null, color_scheme)
- }, callback);
- });
- var prepareElement = function prepareElement(element) {
- element.data('busy_right_now', true);
- if (!element.data('current_icon')) {
- element.data('current_icon', element.find('.fa').attr('class'));
- }
- element.find('.fa').attr('class', 'fa fa-fw fa-spin fa-refresh');
- };
- var resetElement = function resetElement(element) {
- element.data('busy_right_now', false);
- element.find('.fa').attr('class', element.data('current_icon'));
- };
- ;// CONCATENATED MODULE: ./app/whitelabel/presets.js
- var presets_body = external_jQuery_default()('body');
- var presets_fields = [];
- var presets_FormState = app_forms.FormState.Instance;
- var setField = function setField(field, value) {
- var name = field.prop('name');
- var tag = field.prop('tagName').toLowerCase();
- var type = field.prop('type');
- presets_fields.push(name);
- switch (tag) {
- case 'select':
- field.val(value);
- field.data('selectize').setValue(value);
- field.trigger('change');
- break;
- case 'input':
- if (type === 'radio') {
- var strValue = value ? '1' : '0';
- field.filter(function (index, radio) {
- return external_jQuery_default()(radio).val() === strValue;
- }).prop('checked', true);
- break;
- }
- if (type === 'checkbox') {
- field.prop('checked', value);
- break;
- }
- field.val(value);
- field.trigger('keyup');
- }
- };
- presets_body.on('click', '[data-preset-values]', function (event) {
- var target = external_jQuery_default()(event.currentTarget);
- var data = target.data('preset-values');
- Object.keys(data).forEach(function (section) {
- if (typeof data[section] === 'string') {
- return;
- }
- Object.keys(data[section]).forEach(function (key) {
- var field = external_jQuery_default()("[name=\"data[whitelabel][color_scheme][".concat(section, "][").concat(key, "]\"], [name=\"data[").concat(section, "][").concat(key, "]\"]"));
- var value = data[section][key];
- setField(field, value);
- });
- });
- });
- presets_body.on('click', '[data-reset-scss]', function (event) {
- event && event.preventDefault();
- var element = external_jQuery_default()(event.currentTarget);
- var links = external_jQuery_default()('link[id^=admin-pro-preview-]');
- element.remove();
- links.remove();
- presets_fields.forEach(function (field) {
- var value = presets_FormState.loadState.get(field);
- setField(external_jQuery_default()("[name=\"".concat(field, "\"]")), value);
- });
- presets_fields = [];
- }); // Horizontal Scroll Functionality
- (external_jQuery_default()).fn.hscrollarrows = function () {
- return this.each(function () {
- var navNext = external_jQuery_default()('<a class="nav-next hide"></a>');
- var navPrev = external_jQuery_default()('<a class="nav-prev hide"></a>');
- var scrollTime = null;
- var resizeTime = null;
- var scrolling = false;
- var elm_w = 0;
- var elem_data_w = 0;
- var max_scroll = 0;
- var inc_scroll = 0;
- var calcData = function calcData() {
- elm_w = elem.width();
- elem_data_w = elem_data.get(0).scrollWidth;
- max_scroll = elem_data_w - elm_w;
- inc_scroll = elm_w * 0.3; // 20%
- };
- var revalidate = function revalidate() {
- calcData();
- stateNavs();
- };
- var run = function run() {
- calcData();
- setupNavs();
- };
- var setupNavs = function setupNavs() {
- elem.parent().prepend(navNext);
- elem.parent().prepend(navPrev);
- navNext.on('click', next);
- navPrev.on('click', prev);
- stateNavs();
- external_jQuery_default()(elem).scroll(function () {
- if (!scrolling) {
- clearTimeout(scrollTime);
- scrollTime = setTimeout(function () {
- stateNavs();
- }, 250);
- }
- });
- external_jQuery_default()(window).resize(function () {
- clearTimeout(resizeTime);
- resizeTime = setTimeout(function () {
- revalidate();
- }, 250);
- });
- };
- var stateNavs = function stateNavs() {
- var current_scroll = elem.scrollLeft();
- if (current_scroll < max_scroll) {
- navNext.removeClass('hide');
- } else {
- navNext.addClass('hide');
- }
- if (current_scroll > 0) {
- navPrev.removeClass('hide');
- } else {
- navPrev.addClass('hide');
- }
- scrolling = false;
- };
- var next = function next() {
- var current_scroll = elem.scrollLeft();
- if (current_scroll < max_scroll) {
- scrolling = true;
- elem.stop().animate({
- scrollLeft: current_scroll + inc_scroll
- }, stateNavs);
- }
- };
- var prev = function prev() {
- var current_scroll = elem.scrollLeft();
- if (current_scroll > 0) {
- scrolling = true;
- elem.stop().animate({
- scrollLeft: current_scroll - inc_scroll
- }, stateNavs);
- }
- };
- var elem = external_jQuery_default()(this);
- var elem_data = external_jQuery_default()(':first-child', elem);
- run();
- });
- };
- external_jQuery_default()(document).ready(function () {
- external_jQuery_default()('.jquery-horizontal-scroll').hscrollarrows();
- });
- ;// CONCATENATED MODULE: ./app/whitelabel/index.js
- var whitelabel_body = external_jQuery_default()('body');
- var whitelabel_FormState = app_forms.FormState.Instance;
- var compiler = function compiler(element) {
- var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- var exportScss = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- var _callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {};
- prepareElement(element);
- var fields = whitelabel_FormState.collect();
- compile({
- preview: preview,
- exportScss: exportScss,
- color_scheme: !fields ? [] : fields.filter(function (value, key) {
- return key.match(/^data\[whitelabel]\[color_scheme]/);
- }).toJS(),
- callback: function callback(response) {
- _callback.call(_callback, response);
- resetElement(element);
- }
- });
- };
- whitelabel_body.on('click', '[data-preview-scss]', function (event) {
- event && event.preventDefault();
- var element = external_jQuery_default()(event.currentTarget);
- if (element.data('busy_right_now')) {
- return false;
- }
- compiler(element, true, false, function (response) {
- if (response.files) {
- Object.keys(response.files).forEach(function (key) {
- var file = external_jQuery_default()("#admin-pro-preview-".concat(key));
- var timestamp = Date.now();
- if (!file.length) {
- file = external_jQuery_default()("<link id=\"admin-pro-preview-".concat(key, "\" type=\"text/css\" rel=\"stylesheet\" />"));
- external_jQuery_default()('head').append(file);
- if (!external_jQuery_default()('[data-reset-scss]').length) {
- 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>');
- reset.insertAfter(element);
- }
- }
- file.attr('href', "".concat(response.files[key], "?").concat(timestamp));
- });
- }
- });
- });
- whitelabel_body.on('click', '[data-recompile-scss]', function (event) {
- event && event.preventDefault();
- var element = external_jQuery_default()(event.currentTarget);
- if (element.data('busy_right_now')) {
- return false;
- }
- compiler(element, true, false);
- });
- whitelabel_body.on('click', '[data-export-scss]', function (event) {
- event && event.preventDefault();
- var element = external_jQuery_default()(event.currentTarget);
- if (element.data('busy_right_now')) {
- return false;
- }
- compiler(element, true, true, function (response) {
- if (response.files) {
- Object.keys(response.files).forEach(function (key) {
- if (key === 'download') {
- var _element = document.createElement('a');
- _element.setAttribute('href', response.files[key]);
- _element.setAttribute('download', '');
- _element.style.display = 'none';
- document.body.appendChild(_element);
- _element.click();
- document.body.removeChild(_element);
- }
- });
- }
- });
- });
- whitelabel_body.on('change._grav_colorpicker', '[data-grav-colorpicker]', function (event, input, hex, opacity) {
- var RGB = hex2rgb(hex);
- var YIQ = (RGB.r * 299 + RGB.g * 587 + RGB.b * 114) / 1000;
- var contrast = YIQ >= 128 || opacity <= 0.50 ? 'dark' : 'light';
- input.parent().removeClass('dark-text light-text').addClass("".concat(contrast, "-text"));
- });
- whitelabel_body.ready(function () {
- external_jQuery_default()('[data-grav-colorpicker]').trigger('keyup');
- });
- ;// CONCATENATED MODULE: ./app/utils/bootstrap-transition.js
- +function ($) {
- 'use strict'; // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
- // ============================================================
- function transitionEnd() {
- var el = document.createElement('bootstrap');
- var transEndEventNames = {
- WebkitTransition: 'webkitTransitionEnd',
- MozTransition: 'transitionend',
- OTransition: 'oTransitionEnd otransitionend',
- transition: 'transitionend'
- };
- for (var name in transEndEventNames) {
- if (el.style[name] !== undefined) {
- return {
- end: transEndEventNames[name]
- };
- }
- }
- return false; // explicit for ie8 ( ._.)
- } // http://blog.alexmaccaw.com/css-transitions
- $.fn.emulateTransitionEnd = function (duration) {
- var called = false;
- var $el = this;
- $(this).one('bsTransitionEnd', function () {
- called = true;
- });
- var callback = function callback() {
- if (!called) $($el).trigger($.support.transition.end);
- };
- setTimeout(callback, duration);
- return this;
- };
- $(function () {
- $.support.transition = transitionEnd();
- if (!$.support.transition) return;
- $.event.special.bsTransitionEnd = {
- bindType: $.support.transition.end,
- delegateType: $.support.transition.end,
- handle: function handle(e) {
- if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments);
- }
- };
- });
- }((external_jQuery_default()));
- ;// CONCATENATED MODULE: ./app/utils/bootstrap-collapse.js
- function bootstrap_collapse_typeof(obj) { "@babel/helpers - typeof"; return bootstrap_collapse_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, bootstrap_collapse_typeof(obj); }
- /* ========================================================================
- * Bootstrap: collapse.js v3.4.0
- * http://getbootstrap.com/javascript/#collapse
- * ========================================================================
- * Copyright 2011-2016 Twitter, Inc.
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * ======================================================================== */
- /* jshint latedef: false */
- +function ($) {
- 'use strict'; // COLLAPSE PUBLIC CLASS DEFINITION
- // ================================
- var Collapse = function Collapse(element, options) {
- this.$element = $(element);
- this.options = $.extend({}, Collapse.DEFAULTS, options);
- this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' + '[data-toggle="collapse"][data-target="#' + element.id + '"]');
- this.transitioning = null;
- if (this.options.parent) {
- this.$parent = this.getParent();
- } else {
- this.addAriaAndCollapsedClass(this.$element, this.$trigger);
- }
- if (this.options.toggle) this.toggle();
- };
- Collapse.VERSION = '3.4.0';
- Collapse.TRANSITION_DURATION = 350;
- Collapse.DEFAULTS = {
- toggle: true
- };
- Collapse.prototype.dimension = function () {
- var hasWidth = this.$element.hasClass('width');
- return hasWidth ? 'width' : 'height';
- };
- Collapse.prototype.show = function () {
- if (this.transitioning || this.$element.hasClass('in')) return;
- var activesData;
- var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing');
- if (actives && actives.length) {
- activesData = actives.data('bs.collapse');
- if (activesData && activesData.transitioning) return;
- }
- var startEvent = $.Event('show.bs.collapse');
- this.$element.trigger(startEvent);
- if (startEvent.isDefaultPrevented()) return;
- if (actives && actives.length) {
- Plugin.call(actives, 'hide');
- activesData || actives.data('bs.collapse', null);
- }
- var dimension = this.dimension();
- this.$element.removeClass('collapse').addClass('collapsing')[dimension](0).attr('aria-expanded', true);
- this.$trigger.removeClass('collapsed').attr('aria-expanded', true);
- this.transitioning = 1;
- var complete = function complete() {
- this.$element.removeClass('collapsing').addClass('collapse in')[dimension]('');
- this.transitioning = 0;
- this.$element.trigger('shown.bs.collapse');
- };
- if (!$.support.transition) return complete.call(this);
- var scrollSize = $.camelCase(['scroll', dimension].join('-'));
- this.$element.one('bsTransitionEnd', $.proxy(complete, this)).emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]);
- };
- Collapse.prototype.hide = function () {
- if (this.transitioning || !this.$element.hasClass('in')) return;
- var startEvent = $.Event('hide.bs.collapse');
- this.$element.trigger(startEvent);
- if (startEvent.isDefaultPrevented()) return;
- var dimension = this.dimension();
- this.$element[dimension](this.$element[dimension]())[0].offsetHeight;
- this.$element.addClass('collapsing').removeClass('collapse in').attr('aria-expanded', false);
- this.$trigger.addClass('collapsed').attr('aria-expanded', false);
- this.transitioning = 1;
- var complete = function complete() {
- this.transitioning = 0;
- this.$element.removeClass('collapsing').addClass('collapse').trigger('hidden.bs.collapse');
- };
- if (!$.support.transition) return complete.call(this);
- this.$element[dimension](0).one('bsTransitionEnd', $.proxy(complete, this)).emulateTransitionEnd(Collapse.TRANSITION_DURATION);
- };
- Collapse.prototype.toggle = function () {
- this[this.$element.hasClass('in') ? 'hide' : 'show']();
- };
- Collapse.prototype.getParent = function () {
- return $(this.options.parent).find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]').each($.proxy(function (i, element) {
- var $element = $(element);
- this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element);
- }, this)).end();
- };
- Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) {
- var isOpen = $element.hasClass('in');
- $element.attr('aria-expanded', isOpen);
- $trigger.toggleClass('collapsed', !isOpen).attr('aria-expanded', isOpen);
- };
- function getTargetFromTrigger($trigger) {
- var href;
- var target = $trigger.attr('data-target') || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''); // strip for ie7
- return $(target);
- } // COLLAPSE PLUGIN DEFINITION
- // ==========================
- function Plugin(option) {
- return this.each(function () {
- var $this = $(this);
- var data = $this.data('bs.collapse');
- var options = $.extend({}, Collapse.DEFAULTS, $this.data(), bootstrap_collapse_typeof(option) === 'object' && option);
- if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false;
- if (!data) $this.data('bs.collapse', data = new Collapse(this, options));
- if (typeof option === 'string') data[option]();
- });
- }
- var old = $.fn.collapse;
- $.fn.collapse = Plugin;
- $.fn.collapse.Constructor = Collapse; // COLLAPSE NO CONFLICT
- // ====================
- $.fn.collapse.noConflict = function () {
- $.fn.collapse = old;
- return this;
- }; // COLLAPSE DATA-API
- // =================
- $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
- var $this = $(this);
- if (!$this.attr('data-target')) e.preventDefault();
- var $target = getTargetFromTrigger($this);
- var data = $target.data('bs.collapse');
- var option = data ? 'toggle' : $this.data();
- Plugin.call($target, option);
- });
- }((external_jQuery_default()));
- ;// CONCATENATED MODULE: ./app/utils/bootstrap-dropdown.js
- /* ========================================================================
- * Bootstrap: dropdown.js v3.4.1
- * https://getbootstrap.com/docs/3.4/javascript/#dropdowns
- * ========================================================================
- * Copyright 2011-2019 Twitter, Inc.
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/v3-dev/LICENSE)
- * ======================================================================== */
- +function ($) {
- 'use strict'; // DROPDOWN CLASS DEFINITION
- // =========================
- var backdrop = '.dropdown-backdrop';
- var toggle = '[data-toggle="dropdown"]';
- var Dropdown = function Dropdown(element) {
- $(element).on('click.bs.dropdown', this.toggle);
- };
- Dropdown.VERSION = '3.4.1';
- function getParent($this) {
- var selector = $this.attr('data-target');
- if (!selector) {
- selector = $this.attr('href');
- selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, ''); // strip for ie7
- }
- var $parent = selector !== '#' ? $(document).find(selector) : null;
- return $parent && $parent.length ? $parent : $this.parent();
- }
- function clearMenus(e) {
- if (e && e.which === 3) {
- return;
- }
- $(backdrop).remove();
- $(toggle).each(function () {
- var $this = $(this);
- var $parent = getParent($this);
- var relatedTarget = {
- relatedTarget: this
- };
- if (!$parent.hasClass('open')) {
- return;
- }
- if (e && e.type === 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) {
- return;
- }
- $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget));
- if (e.isDefaultPrevented()) {
- return;
- }
- $this.attr('aria-expanded', 'false');
- $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget));
- });
- }
- Dropdown.prototype.toggle = function (e) {
- var $this = $(this);
- if ($this.is('.disabled, :disabled')) {
- return;
- }
- var $parent = getParent($this);
- var isActive = $parent.hasClass('open');
- clearMenus();
- if (!isActive) {
- if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
- // if mobile we use a backdrop because click events don't delegate
- $(document.createElement('div')).addClass('dropdown-backdrop').insertAfter($(this)).on('click', clearMenus);
- }
- var relatedTarget = {
- relatedTarget: this
- };
- $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget));
- if (e.isDefaultPrevented()) {
- return;
- }
- $this.trigger('focus').attr('aria-expanded', 'true');
- $parent.toggleClass('open').trigger($.Event('shown.bs.dropdown', relatedTarget));
- }
- return false;
- };
- Dropdown.prototype.keydown = function (e) {
- if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return;
- var $this = $(this);
- e.preventDefault();
- e.stopPropagation();
- if ($this.is('.disabled, :disabled')) {
- return;
- }
- var $parent = getParent($this);
- var isActive = $parent.hasClass('open');
- if (!isActive && e.which !== 27 || isActive && e.which === 27) {
- if (e.which === 27) {
- $parent.find(toggle).trigger('focus');
- }
- return $this.trigger('click');
- }
- var desc = ' li:not(.disabled):visible a';
- var $items = $parent.find('.dropdown-menu' + desc);
- if (!$items.length) {
- return;
- }
- var index = $items.index(e.target);
- if (e.which === 38 && index > 0) {
- index--;
- } // up
- if (e.which === 40 && index < $items.length - 1) {
- index++;
- } // down
- if (!~index) {
- index = 0;
- }
- $items.eq(index).trigger('focus');
- }; // DROPDOWN PLUGIN DEFINITION
- // ==========================
- function Plugin(option) {
- return this.each(function () {
- var $this = $(this);
- var data = $this.data('bs.dropdown');
- if (!data) $this.data('bs.dropdown', data = new Dropdown(this));
- if (typeof option === 'string') data[option].call($this);
- });
- }
- var old = $.fn.dropdown;
- $.fn.dropdown = Plugin;
- $.fn.dropdown.Constructor = Dropdown; // DROPDOWN NO CONFLICT
- // ====================
- $.fn.dropdown.noConflict = function () {
- $.fn.dropdown = old;
- return this;
- }; // APPLY TO STANDARD DROPDOWN ELEMENTS
- // ===================================
- $(document).on('click.bs.dropdown.data-api', clearMenus).on('click.bs.dropdown.data-api', '.dropdown form', function (e) {
- e.stopPropagation();
- }).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);
- }((external_jQuery_default()));
- ;// CONCATENATED MODULE: ./app/utils/tabs-memory.js
- var tabs_memory_Data = JSON.parse(cookies.get('grav-tabs-state') || '{}');
- external_jQuery_default()('body').on('touchstart click', '[data-tabid]', function (event) {
- event && event.stopPropagation();
- var target = external_jQuery_default()(event.currentTarget);
- tabs_memory_Data[target.data('tabkey')] = target.data('scope');
- cookies.set('grav-tabs-state', JSON.stringify(tabs_memory_Data), {
- expires: Infinity
- });
- var panel = external_jQuery_default()("[id=\"".concat(target.data('tabid'), "\"]"));
- target.siblings('[data-tabid]').removeClass('active');
- target.addClass('active');
- panel.siblings('[id]').removeClass('active');
- panel.addClass('active');
- editor_Instance.editors.each(function (index, editor) {
- var codemirror = external_jQuery_default()(editor).data('codemirror');
- if (!codemirror) {
- return;
- }
- if (codemirror.display.lastWrapWidth === 0) {
- codemirror.refresh();
- }
- });
- });
- ;// CONCATENATED MODULE: ./app/utils/changelog.js
- /* eslint-disable */
- var TRIGGER = null;
- external_jQuery_default()(document).on('click', '[data-remodal-changelog]', function (event) {
- TRIGGER = event.currentTarget;
- });
- external_jQuery_default()(document).on('opened', '[data-remodal-id="changelog"]', function () {
- var instance = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id=changelog]').data('remodal')];
- 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>');
- if (!TRIGGER) {
- return true;
- }
- var url = external_jQuery_default()(TRIGGER).data('remodalChangelog');
- external_jQuery_default().ajax({
- url: url
- }).done(function (data) {
- instance.$modal.html(data);
- });
- });
- external_jQuery_default()(document).on('closed', '[data-remodal-id="changelog"]', function () {
- var instance = (external_jQuery_default()).remodal.lookup[external_jQuery_default()('[data-remodal-id=changelog]').data('remodal')];
- instance.$modal.html('');
- });
- ;// CONCATENATED MODULE: ./app/utils/sidebar.js
- function sidebar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function sidebar_createClass(Constructor, protoProps, staticProps) { if (protoProps) sidebar_defineProperties(Constructor.prototype, protoProps); if (staticProps) sidebar_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
- var MOBILE_BREAKPOINT = 48 - 0.062;
- var DESKTOP_BREAKPOINT = 75 + 0.063;
- var EVENTS = 'touchstart._grav click._grav';
- var TARGETS = '[data-sidebar-mobile-toggle], #overlay';
- var MOBILE_QUERY = "(max-width: ".concat(MOBILE_BREAKPOINT, "em)");
- var DESKTOP_QUERY = "(min-width: ".concat(DESKTOP_BREAKPOINT, "em)");
- var map = new __webpack_require__.g.Map();
- var Sidebar = /*#__PURE__*/function () {
- function Sidebar() {
- sidebar_classCallCheck(this, Sidebar);
- this.timeout = null;
- this.isOpen = false;
- this.body = external_jQuery_default()('body');
- this.matchMedia = __webpack_require__.g.matchMedia(MOBILE_QUERY);
- this.enable();
- }
- sidebar_createClass(Sidebar, [{
- key: "enable",
- value: function enable() {
- var sidebar = external_jQuery_default()('#admin-sidebar');
- this.matchMedia.addListener(this._getBound('checkMatch'));
- this.checkMatch(this.matchMedia);
- this.body.on(EVENTS, '[data-sidebar-toggle]', this._getBound('toggleSidebarState'));
- if (sidebar.data('quickopen')) {
- sidebar.hover(this._getBound('quickOpenIn'), this._getBound('quickOpenOut'));
- }
- }
- }, {
- key: "disable",
- value: function disable() {
- var sidebar = external_jQuery_default()('#admin-sidebar');
- this.close();
- this.matchMedia.removeListener(this._getBound('checkMatch'));
- this.body.off(EVENTS, '[data-sidebar-toggle]', this._getBound('toggleSidebarState'));
- if (sidebar.data('quickopen')) {
- sidebar.off('mouseenter mouseleave');
- }
- }
- }, {
- key: "attach",
- value: function attach() {
- this.body.on(EVENTS, TARGETS, this._getBound('toggle'));
- }
- }, {
- key: "detach",
- value: function detach() {
- this.body.off(EVENTS, TARGETS, this._getBound('toggle'));
- }
- }, {
- key: "quickOpenIn",
- value: function
- /* event */
- quickOpenIn() {
- var _this = this;
- var isDesktop = __webpack_require__.g.matchMedia(DESKTOP_QUERY).matches;
- var delay = external_jQuery_default()('#admin-sidebar').data('quickopen-delay') || 500;
- if (this.body.hasClass('sidebar-mobile-open')) {
- return;
- }
- var shouldQuickOpen = isDesktop ? this.body.hasClass('sidebar-closed') : !this.body.hasClass('sidebar-open');
- if (!shouldQuickOpen && !this.body.hasClass('sidebar-quickopen')) {
- return this.quickOpenOut();
- }
- this.timeout = setTimeout(function () {
- _this.body.addClass('sidebar-open sidebar-quickopen');
- external_jQuery_default()(__webpack_require__.g).trigger('sidebar_state._grav', isDesktop);
- }, delay);
- }
- }, {
- key: "quickOpenOut",
- value: function
- /* event */
- quickOpenOut() {
- clearTimeout(this.timeout);
- if (this.body.hasClass('sidebar-quickopen')) {
- this.body.removeClass('sidebar-open sidebar-quickopen');
- }
- return true;
- }
- }, {
- key: "open",
- value: function open(event) {
- var _this2 = this;
- var quick = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- if (event) {
- event.preventDefault();
- }
- var overlay = external_jQuery_default()('#overlay');
- var sidebar = external_jQuery_default()('#admin-sidebar');
- this.body.addClass('sidebar-mobile-open');
- overlay.css('display', 'block');
- if (!quick) {
- sidebar.css('display', 'block').animate({
- opacity: 1
- }, 200, function () {
- _this2.isOpen = true;
- });
- } else {
- sidebar.css({
- display: 'block',
- opacity: 1
- });
- this.isOpen = true;
- }
- }
- }, {
- key: "close",
- value: function close(event) {
- var _this3 = this;
- var quick = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- if (event) {
- event.preventDefault();
- }
- var overlay = external_jQuery_default()('#overlay');
- var sidebar = external_jQuery_default()('#admin-sidebar');
- this.body.removeClass('sidebar-mobile-open');
- overlay.css('display', 'none');
- if (!quick) {
- sidebar.animate({
- opacity: 0
- }, 200, function () {
- sidebar.css('display', 'none');
- _this3.isOpen = false;
- });
- } else {
- sidebar.css({
- opacity: 0,
- display: 'none'
- });
- this.isOpen = false;
- }
- }
- }, {
- key: "toggle",
- value: function toggle(event) {
- if (event) {
- event.preventDefault();
- }
- return this[this.isOpen ? 'close' : 'open'](event);
- }
- }, {
- key: "toggleSidebarState",
- value: function toggleSidebarState(event) {
- if (event) {
- event.preventDefault();
- }
- clearTimeout(this.timeout);
- var isDesktop = __webpack_require__.g.matchMedia(DESKTOP_QUERY).matches;
- var cookie = null;
- if (isDesktop) {
- this.body.removeClass('sidebar-open');
- }
- if (!isDesktop) {
- this.body.removeClass('sidebar-closed');
- this.body.removeClass('sidebar-mobile-open');
- }
- this.body.toggleClass("sidebar-".concat(isDesktop ? 'closed' : 'open'));
- external_jQuery_default()(__webpack_require__.g).trigger('sidebar_state._grav', isDesktop);
- if (isDesktop) {
- cookie = !this.body.hasClass('sidebar-closed');
- } else {
- cookie = this.body.hasClass('sidebar-open');
- }
- cookies.set('grav-admin-sidebar', cookie, {
- expires: Infinity
- });
- }
- }, {
- key: "checkMatch",
- value: function checkMatch(data) {
- var sidebar = external_jQuery_default()('#admin-sidebar');
- var overlay = external_jQuery_default()('#overlay');
- this.isOpen = false;
- overlay.css('display', 'none');
- sidebar.css({
- display: data.matches ? 'none' : 'inherit',
- opacity: data.matches ? 0 : 1
- });
- if (data.matches) {
- this.body.removeClass('sidebar-open sidebar-closed');
- }
- this[data.matches ? 'attach' : 'detach']();
- }
- }, {
- key: "_resetMap",
- value: function _resetMap() {
- return map.clear();
- }
- }, {
- key: "_getBound",
- value: function _getBound(fn) {
- if (map.has(fn)) {
- return map.get(fn);
- }
- return map.set(fn, this[fn].bind(this)).get(fn);
- }
- }]);
- return Sidebar;
- }();
- var sidebar_Instance = new Sidebar();
- ;// CONCATENATED MODULE: ./app/main.js
- // polyfills
- // bootstrap jQuery extensions
- // tabs memory
- // changelog
- // Main Sidebar
- // starts the keep alive, auto runs every X seconds
- keepalive.start(); // global event to catch sidebar_state changes
- external_jQuery_default()(__webpack_require__.g).on('sidebar_state._grav', function () {
- Object.keys(dashboard.Chart.Instances).forEach(function (chart) {
- setTimeout(function () {
- return dashboard.Chart.Instances[chart].chart.update();
- }, 10);
- });
- });
- /* harmony default export */ const main = ({
- GPM: {
- GPM: GPM,
- Instance: gpm_Instance
- },
- KeepAlive: keepalive,
- Dashboard: dashboard,
- Pages: pages,
- Forms: app_forms,
- Updates: {
- Updates: Updates,
- Notifications: updates_notifications,
- Feed: updates_feed,
- Instance: updates_Instance
- },
- Sidebar: {
- Sidebar: Sidebar,
- Instance: sidebar_Instance
- },
- MediaFilter: {
- MediaFilter: Filter,
- Instance: app_media_Instance
- },
- Scrollbar: {
- Scrollbar: {
- deprecated: true
- },
- Instance: {
- deprecated: true
- }
- },
- Utils: {
- request: utils_request,
- toastr: utils_toastr,
- Cookies: cookies,
- UriToMarkdown: UriToMarkdown
- }
- });
- /***/ }),
- /***/ 19912:
- /***/ ((module, exports, __webpack_require__) => {
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
- /*! version : 4.17.47
- =========================================================
- bootstrap-datetimejs
- https://github.com/Eonasdan/bootstrap-datetimepicker
- Copyright (c) 2015 Jonathan Peterson
- =========================================================
- */
- /*
- The MIT License (MIT)
- Copyright (c) 2015 Jonathan Peterson
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- */
- /* global define:false */
- /* global jQuery:false */
- /* global moment:false */
- (function (factory) {
- 'use strict';
- if (true) {
- // AMD is used - Register as an anonymous module.
- !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(65311), __webpack_require__(30381)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else {}
- })(function ($, moment) {
- 'use strict';
- if (!moment) {
- throw new Error('bootstrap-datetimepicker requires Moment.js to be loaded first');
- }
- var dateTimePicker = function dateTimePicker(element, options) {
- var picker = {};
- var date;
- var viewDate;
- var unset = true;
- var input;
- var component = false;
- var widget = false;
- var use24Hours;
- var minViewModeNumber = 0;
- var actualFormat;
- var parseFormats;
- var currentViewMode;
- var datePickerModes = [{
- clsName: 'days',
- navFnc: 'M',
- navStep: 1
- }, {
- clsName: 'months',
- navFnc: 'y',
- navStep: 1
- }, {
- clsName: 'years',
- navFnc: 'y',
- navStep: 10
- }, {
- clsName: 'decades',
- navFnc: 'y',
- navStep: 100
- }];
- var viewModes = ['days', 'months', 'years', 'decades'];
- var verticalModes = ['top', 'bottom', 'auto'];
- var horizontalModes = ['left', 'right', 'auto'];
- var toolbarPlacements = ['default', 'top', 'bottom'];
- var keyMap = {
- 'up': 38,
- 38: 'up',
- 'down': 40,
- 40: 'down',
- 'left': 37,
- 37: 'left',
- 'right': 39,
- 39: 'right',
- 'tab': 9,
- 9: 'tab',
- 'escape': 27,
- 27: 'escape',
- 'enter': 13,
- 13: 'enter',
- 'pageUp': 33,
- 33: 'pageUp',
- 'pageDown': 34,
- 34: 'pageDown',
- 'shift': 16,
- 16: 'shift',
- 'control': 17,
- 17: 'control',
- 'space': 32,
- 32: 'space',
- 't': 84,
- 84: 't',
- 'delete': 46,
- 46: 'delete'
- };
- var keyState = {};
- /** ******************************************************************************
- *
- * Private functions
- *
- ********************************************************************************/
- var hasTimeZone = function hasTimeZone() {
- return moment.tz !== undefined && options.timeZone !== undefined && options.timeZone !== null && options.timeZone !== '';
- };
- var getMoment = function getMoment(d) {
- var returnMoment;
- if (d === undefined || d === null) {
- returnMoment = moment(); // TODO should this use format? and locale?
- } else if (moment.isDate(d) || moment.isMoment(d)) {
- // If the date that is passed in is already a Date() or moment() object,
- // pass it directly to moment.
- returnMoment = moment(d);
- } else if (hasTimeZone()) {
- // There is a string to parse and a default time zone
- // parse with the tz function which takes a default time zone if it is not in the format string
- returnMoment = moment.tz(d, parseFormats, options.useStrict, options.timeZone);
- } else {
- returnMoment = moment(d, parseFormats, options.useStrict);
- }
- if (hasTimeZone()) {
- returnMoment.tz(options.timeZone);
- }
- return returnMoment;
- };
- var isEnabled = function isEnabled(granularity) {
- if (typeof granularity !== 'string' || granularity.length > 1) {
- throw new TypeError('isEnabled expects a single character string parameter');
- }
- switch (granularity) {
- case 'y':
- return actualFormat.indexOf('Y') !== -1;
- case 'M':
- return actualFormat.indexOf('M') !== -1;
- case 'd':
- return actualFormat.toLowerCase().indexOf('d') !== -1;
- case 'h':
- case 'H':
- return actualFormat.toLowerCase().indexOf('h') !== -1;
- case 'm':
- return actualFormat.indexOf('m') !== -1;
- case 's':
- return actualFormat.indexOf('s') !== -1;
- default:
- return false;
- }
- };
- var hasTime = function hasTime() {
- return isEnabled('h') || isEnabled('m') || isEnabled('s');
- };
- var hasDate = function hasDate() {
- return isEnabled('y') || isEnabled('M') || isEnabled('d');
- };
- var getDatePickerTemplate = function getDatePickerTemplate() {
- 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))));
- var contTemplate = $('<tbody>').append($('<tr>').append($('<td>').attr('colspan', options.calendarWeeks ? '8' : '7')));
- 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()))];
- };
- var getTimePickerMainTemplate = function getTimePickerMainTemplate() {
- var topRow = $('<tr>');
- var middleRow = $('<tr>');
- var bottomRow = $('<tr>');
- if (isEnabled('h')) {
- topRow.append($('<td>').append($('<a>').attr({
- href: '#',
- tabindex: '-1',
- 'title': options.tooltips.incrementHour
- }).addClass('btn').attr('data-action', 'incrementHours').append($('<span>').addClass(options.icons.up))));
- middleRow.append($('<td>').append($('<span>').addClass('timepicker-hour').attr({
- 'data-time-component': 'hours',
- 'title': options.tooltips.pickHour
- }).attr('data-action', 'showHours')));
- bottomRow.append($('<td>').append($('<a>').attr({
- href: '#',
- tabindex: '-1',
- 'title': options.tooltips.decrementHour
- }).addClass('btn').attr('data-action', 'decrementHours').append($('<span>').addClass(options.icons.down))));
- }
- if (isEnabled('m')) {
- if (isEnabled('h')) {
- topRow.append($('<td>').addClass('separator'));
- middleRow.append($('<td>').addClass('separator').html(':'));
- bottomRow.append($('<td>').addClass('separator'));
- }
- topRow.append($('<td>').append($('<a>').attr({
- href: '#',
- tabindex: '-1',
- 'title': options.tooltips.incrementMinute
- }).addClass('btn').attr('data-action', 'incrementMinutes').append($('<span>').addClass(options.icons.up))));
- middleRow.append($('<td>').append($('<span>').addClass('timepicker-minute').attr({
- 'data-time-component': 'minutes',
- 'title': options.tooltips.pickMinute
- }).attr('data-action', 'showMinutes')));
- bottomRow.append($('<td>').append($('<a>').attr({
- href: '#',
- tabindex: '-1',
- 'title': options.tooltips.decrementMinute
- }).addClass('btn').attr('data-action', 'decrementMinutes').append($('<span>').addClass(options.icons.down))));
- }
- if (isEnabled('s')) {
- if (isEnabled('m')) {
- topRow.append($('<td>').addClass('separator'));
- middleRow.append($('<td>').addClass('separator').html(':'));
- bottomRow.append($('<td>').addClass('separator'));
- }
- topRow.append($('<td>').append($('<a>').attr({
- href: '#',
- tabindex: '-1',
- 'title': options.tooltips.incrementSecond
- }).addClass('btn').attr('data-action', 'incrementSeconds').append($('<span>').addClass(options.icons.up))));
- middleRow.append($('<td>').append($('<span>').addClass('timepicker-second').attr({
- 'data-time-component': 'seconds',
- 'title': options.tooltips.pickSecond
- }).attr('data-action', 'showSeconds')));
- bottomRow.append($('<td>').append($('<a>').attr({
- href: '#',
- tabindex: '-1',
- 'title': options.tooltips.decrementSecond
- }).addClass('btn').attr('data-action', 'decrementSeconds').append($('<span>').addClass(options.icons.down))));
- }
- if (!use24Hours) {
- topRow.append($('<td>').addClass('separator'));
- middleRow.append($('<td>').append($('<button>').addClass('btn btn-primary').attr({
- 'data-action': 'togglePeriod',
- tabindex: '-1',
- 'title': options.tooltips.togglePeriod
- })));
- bottomRow.append($('<td>').addClass('separator'));
- }
- return $('<div>').addClass('timepicker-picker').append($('<table>').addClass('table-condensed').append([topRow, middleRow, bottomRow]));
- };
- var getTimePickerTemplate = function getTimePickerTemplate() {
- var hoursView = $('<div>').addClass('timepicker-hours').append($('<table>').addClass('table-condensed'));
- var minutesView = $('<div>').addClass('timepicker-minutes').append($('<table>').addClass('table-condensed'));
- var secondsView = $('<div>').addClass('timepicker-seconds').append($('<table>').addClass('table-condensed'));
- var ret = [getTimePickerMainTemplate()];
- if (isEnabled('h')) {
- ret.push(hoursView);
- }
- if (isEnabled('m')) {
- ret.push(minutesView);
- }
- if (isEnabled('s')) {
- ret.push(secondsView);
- }
- return ret;
- };
- var getToolbar = function getToolbar() {
- var row = [];
- if (options.showTodayButton) {
- row.push($('<td>').append($('<a>').attr({
- 'data-action': 'today',
- 'title': options.tooltips.today
- }).append($('<span>').addClass(options.icons.today))));
- }
- if (!options.sideBySide && hasDate() && hasTime()) {
- row.push($('<td>').append($('<a>').attr({
- 'data-action': 'togglePicker',
- 'title': options.tooltips.selectTime
- }).append($('<span>').addClass(options.icons.time))));
- }
- if (options.showClear) {
- row.push($('<td>').append($('<a>').attr({
- 'data-action': 'clear',
- 'title': options.tooltips.clear
- }).append($('<span>').addClass(options.icons.clear))));
- }
- if (options.showClose) {
- row.push($('<td>').append($('<a>').attr({
- 'data-action': 'close',
- 'title': options.tooltips.close
- }).append($('<span>').addClass(options.icons.close))));
- }
- return $('<table>').addClass('table-condensed').append($('<tbody>').append($('<tr>').append(row)));
- };
- var getTemplate = function getTemplate() {
- var template = $('<div>').addClass('bootstrap-datetimepicker-widget dropdown-menu');
- var dateView = $('<div>').addClass('datepicker').append(getDatePickerTemplate());
- var timeView = $('<div>').addClass('timepicker').append(getTimePickerTemplate());
- var content = $('<ul>').addClass('list-unstyled');
- var toolbar = $('<li>').addClass('picker-switch' + (options.collapse ? ' accordion-toggle' : '')).append(getToolbar());
- if (options.inline) {
- template.removeClass('dropdown-menu');
- }
- if (use24Hours) {
- template.addClass('usetwentyfour');
- }
- if (isEnabled('s') && !use24Hours) {
- template.addClass('wider');
- }
- if (options.sideBySide && hasDate() && hasTime()) {
- template.addClass('timepicker-sbs');
- if (options.toolbarPlacement === 'top') {
- template.append(toolbar);
- }
- template.append($('<div>').addClass('row').append(dateView.addClass('col-md-6')).append(timeView.addClass('col-md-6')));
- if (options.toolbarPlacement === 'bottom') {
- template.append(toolbar);
- }
- return template;
- }
- if (options.toolbarPlacement === 'top') {
- content.append(toolbar);
- }
- if (hasDate()) {
- content.append($('<li>').addClass(options.collapse && hasTime() ? 'collapse in' : '').append(dateView));
- }
- if (options.toolbarPlacement === 'default') {
- content.append(toolbar);
- }
- if (hasTime()) {
- content.append($('<li>').addClass(options.collapse && hasDate() ? 'collapse' : '').append(timeView));
- }
- if (options.toolbarPlacement === 'bottom') {
- content.append(toolbar);
- }
- return template.append(content);
- };
- var dataToOptions = function dataToOptions() {
- var eData;
- var dataOptions = {};
- if (element.is('input') || options.inline) {
- eData = element.data();
- } else {
- eData = element.find('input').data();
- }
- if (eData.dateOptions && eData.dateOptions instanceof Object) {
- dataOptions = $.extend(true, dataOptions, eData.dateOptions);
- }
- $.each(options, function (key) {
- var attributeName = 'date' + key.charAt(0).toUpperCase() + key.slice(1);
- if (eData[attributeName] !== undefined) {
- dataOptions[key] = eData[attributeName];
- }
- });
- return dataOptions;
- };
- var place = function place() {
- var position = (component || element).position();
- var offset = (component || element).offset();
- var vertical = options.widgetPositioning.vertical;
- var horizontal = options.widgetPositioning.horizontal;
- var parent;
- if (options.widgetParent) {
- parent = options.widgetParent.append(widget);
- } else if (element.is('input')) {
- parent = element.after(widget).parent();
- } else if (options.inline) {
- parent = element.append(widget);
- return;
- } else {
- parent = element;
- element.children().first().after(widget);
- } // Top and bottom logic
- if (vertical === 'auto') {
- if (offset.top + widget.height() * 1.5 >= $(window).height() + $(window).scrollTop() && widget.height() + element.outerHeight() < offset.top) {
- vertical = 'top';
- } else {
- vertical = 'bottom';
- }
- } // Left and right logic
- if (horizontal === 'auto') {
- if (parent.width() < offset.left + widget.outerWidth() / 2 && offset.left + widget.outerWidth() > $(window).width()) {
- horizontal = 'right';
- } else {
- horizontal = 'left';
- }
- }
- if (vertical === 'top') {
- widget.addClass('top').removeClass('bottom');
- } else {
- widget.addClass('bottom').removeClass('top');
- }
- if (horizontal === 'right') {
- widget.addClass('pull-right');
- } else {
- widget.removeClass('pull-right');
- } // find the first parent element that has a non-static css positioning
- if (parent.css('position') === 'static') {
- parent = parent.parents().filter(function () {
- return $(this).css('position') !== 'static';
- }).first();
- }
- if (parent.length === 0) {
- throw new Error('datetimepicker component should be placed within a non-static positioned container');
- }
- widget.css({
- top: vertical === 'top' ? 'auto' : position.top + element.outerHeight(),
- bottom: vertical === 'top' ? parent.outerHeight() - (parent === element ? 0 : position.top) : 'auto',
- left: horizontal === 'left' ? parent === element ? 0 : position.left : 'auto',
- right: horizontal === 'left' ? 'auto' : parent.outerWidth() - element.outerWidth() - (parent === element ? 0 : position.left)
- });
- };
- var notifyEvent = function notifyEvent(e) {
- if (e.type === 'dp.change' && (e.date && e.date.isSame(e.oldDate) || !e.date && !e.oldDate)) {
- return;
- }
- element.trigger(e);
- };
- var viewUpdate = function viewUpdate(e) {
- if (e === 'y') {
- e = 'YYYY';
- }
- notifyEvent({
- type: 'dp.update',
- change: e,
- viewDate: viewDate.clone()
- });
- };
- var showMode = function showMode(dir) {
- if (!widget) {
- return;
- }
- if (dir) {
- currentViewMode = Math.max(minViewModeNumber, Math.min(3, currentViewMode + dir));
- }
- widget.find('.datepicker > div').hide().filter('.datepicker-' + datePickerModes[currentViewMode].clsName).show();
- };
- var fillDow = function fillDow() {
- var row = $('<tr>');
- var currentDate = viewDate.clone().startOf('w').startOf('d');
- if (options.calendarWeeks === true) {
- row.append($('<th>').addClass('cw').text('#'));
- }
- while (currentDate.isBefore(viewDate.clone().endOf('w'))) {
- row.append($('<th>').addClass('dow').text(currentDate.format('dd')));
- currentDate.add(1, 'd');
- }
- widget.find('.datepicker-days thead').append(row);
- };
- var isInDisabledDates = function isInDisabledDates(testDate) {
- return options.disabledDates[testDate.format('YYYY-MM-DD')] === true;
- };
- var isInEnabledDates = function isInEnabledDates(testDate) {
- return options.enabledDates[testDate.format('YYYY-MM-DD')] === true;
- };
- var isInDisabledHours = function isInDisabledHours(testDate) {
- return options.disabledHours[testDate.format('H')] === true;
- };
- var isInEnabledHours = function isInEnabledHours(testDate) {
- return options.enabledHours[testDate.format('H')] === true;
- };
- var isValid = function isValid(targetMoment, granularity) {
- if (!targetMoment.isValid()) {
- return false;
- }
- if (options.disabledDates && granularity === 'd' && isInDisabledDates(targetMoment)) {
- return false;
- }
- if (options.enabledDates && granularity === 'd' && !isInEnabledDates(targetMoment)) {
- return false;
- }
- if (options.minDate && targetMoment.isBefore(options.minDate, granularity)) {
- return false;
- }
- if (options.maxDate && targetMoment.isAfter(options.maxDate, granularity)) {
- return false;
- }
- if (options.daysOfWeekDisabled && granularity === 'd' && options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) {
- return false;
- }
- if (options.disabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && isInDisabledHours(targetMoment)) {
- return false;
- }
- if (options.enabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && !isInEnabledHours(targetMoment)) {
- return false;
- }
- if (options.disabledTimeIntervals && (granularity === 'h' || granularity === 'm' || granularity === 's')) {
- var found = false;
- $.each(options.disabledTimeIntervals, function () {
- if (targetMoment.isBetween(this[0], this[1])) {
- found = true;
- return false;
- }
- });
- if (found) {
- return false;
- }
- }
- return true;
- };
- var fillMonths = function fillMonths() {
- var spans = [];
- var monthsShort = viewDate.clone().startOf('y').startOf('d');
- while (monthsShort.isSame(viewDate, 'y')) {
- spans.push($('<span>').attr('data-action', 'selectMonth').addClass('month').text(monthsShort.format('MMM')));
- monthsShort.add(1, 'M');
- }
- widget.find('.datepicker-months td').empty().append(spans);
- };
- var updateMonths = function updateMonths() {
- var monthsView = widget.find('.datepicker-months');
- var monthsViewHeader = monthsView.find('th');
- var months = monthsView.find('tbody').find('span');
- monthsViewHeader.eq(0).find('span').attr('title', options.tooltips.prevYear);
- monthsViewHeader.eq(1).attr('title', options.tooltips.selectYear);
- monthsViewHeader.eq(2).find('span').attr('title', options.tooltips.nextYear);
- monthsView.find('.disabled').removeClass('disabled');
- if (!isValid(viewDate.clone().subtract(1, 'y'), 'y')) {
- monthsViewHeader.eq(0).addClass('disabled');
- }
- monthsViewHeader.eq(1).text(viewDate.year());
- if (!isValid(viewDate.clone().add(1, 'y'), 'y')) {
- monthsViewHeader.eq(2).addClass('disabled');
- }
- months.removeClass('active');
- if (date.isSame(viewDate, 'y') && !unset) {
- months.eq(date.month()).addClass('active');
- }
- months.each(function (index) {
- if (!isValid(viewDate.clone().month(index), 'M')) {
- $(this).addClass('disabled');
- }
- });
- };
- var updateYears = function updateYears() {
- var yearsView = widget.find('.datepicker-years');
- var yearsViewHeader = yearsView.find('th');
- var startYear = viewDate.clone().subtract(5, 'y');
- var endYear = viewDate.clone().add(6, 'y');
- var html = '';
- yearsViewHeader.eq(0).find('span').attr('title', options.tooltips.prevDecade);
- yearsViewHeader.eq(1).attr('title', options.tooltips.selectDecade);
- yearsViewHeader.eq(2).find('span').attr('title', options.tooltips.nextDecade);
- yearsView.find('.disabled').removeClass('disabled');
- if (options.minDate && options.minDate.isAfter(startYear, 'y')) {
- yearsViewHeader.eq(0).addClass('disabled');
- }
- yearsViewHeader.eq(1).text(startYear.year() + '-' + endYear.year());
- if (options.maxDate && options.maxDate.isBefore(endYear, 'y')) {
- yearsViewHeader.eq(2).addClass('disabled');
- }
- while (!startYear.isAfter(endYear, 'y')) {
- html += '<span data-action="selectYear" class="year' + (startYear.isSame(date, 'y') && !unset ? ' active' : '') + (!isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
- startYear.add(1, 'y');
- }
- yearsView.find('td').html(html);
- };
- var updateDecades = function updateDecades() {
- var decadesView = widget.find('.datepicker-decades');
- var decadesViewHeader = decadesView.find('th');
- var startDecade = moment({
- y: viewDate.year() - viewDate.year() % 100 - 1
- });
- var endDecade = startDecade.clone().add(100, 'y');
- var startedAt = startDecade.clone();
- var minDateDecade = false;
- var maxDateDecade = false;
- var endDecadeYear;
- var html = '';
- decadesViewHeader.eq(0).find('span').attr('title', options.tooltips.prevCentury);
- decadesViewHeader.eq(2).find('span').attr('title', options.tooltips.nextCentury);
- decadesView.find('.disabled').removeClass('disabled');
- if (startDecade.isSame(moment({
- y: 1900
- })) || options.minDate && options.minDate.isAfter(startDecade, 'y')) {
- decadesViewHeader.eq(0).addClass('disabled');
- }
- decadesViewHeader.eq(1).text(startDecade.year() + '-' + endDecade.year());
- if (startDecade.isSame(moment({
- y: 2000
- })) || options.maxDate && options.maxDate.isBefore(endDecade, 'y')) {
- decadesViewHeader.eq(2).addClass('disabled');
- }
- while (!startDecade.isAfter(endDecade, 'y')) {
- endDecadeYear = startDecade.year() + 12;
- minDateDecade = options.minDate && options.minDate.isAfter(startDecade, 'y') && options.minDate.year() <= endDecadeYear;
- maxDateDecade = options.maxDate && options.maxDate.isAfter(startDecade, 'y') && options.maxDate.year() <= endDecadeYear;
- 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>';
- startDecade.add(12, 'y');
- }
- html += '<span></span><span></span><span></span>'; // push the dangling block over, at least this way it's even
- decadesView.find('td').html(html);
- decadesViewHeader.eq(1).text(startedAt.year() + 1 + '-' + startDecade.year());
- };
- var fillDate = function fillDate() {
- var daysView = widget.find('.datepicker-days');
- var daysViewHeader = daysView.find('th');
- var currentDate;
- var html = [];
- var row;
- var clsNames = [];
- var i;
- if (!hasDate()) {
- return;
- }
- daysViewHeader.eq(0).find('span').attr('title', options.tooltips.prevMonth);
- daysViewHeader.eq(1).attr('title', options.tooltips.selectMonth);
- daysViewHeader.eq(2).find('span').attr('title', options.tooltips.nextMonth);
- daysView.find('.disabled').removeClass('disabled');
- daysViewHeader.eq(1).text(viewDate.format(options.dayViewHeaderFormat));
- if (!isValid(viewDate.clone().subtract(1, 'M'), 'M')) {
- daysViewHeader.eq(0).addClass('disabled');
- }
- if (!isValid(viewDate.clone().add(1, 'M'), 'M')) {
- daysViewHeader.eq(2).addClass('disabled');
- }
- currentDate = viewDate.clone().startOf('M').startOf('w').startOf('d');
- for (i = 0; i < 42; i++) {
- // always display 42 days (should show 6 weeks)
- if (currentDate.weekday() === 0) {
- row = $('<tr>');
- if (options.calendarWeeks) {
- row.append('<td class="cw">' + currentDate.week() + '</td>');
- }
- html.push(row);
- }
- clsNames = ['day'];
- if (currentDate.isBefore(viewDate, 'M')) {
- clsNames.push('old');
- }
- if (currentDate.isAfter(viewDate, 'M')) {
- clsNames.push('new');
- }
- if (currentDate.isSame(date, 'd') && !unset) {
- clsNames.push('active');
- }
- if (!isValid(currentDate, 'd')) {
- clsNames.push('disabled');
- }
- if (currentDate.isSame(getMoment(), 'd')) {
- clsNames.push('today');
- }
- if (currentDate.day() === 0 || currentDate.day() === 6) {
- clsNames.push('weekend');
- }
- notifyEvent({
- type: 'dp.classify',
- date: currentDate,
- classNames: clsNames
- });
- row.append('<td data-action="selectDay" data-day="' + currentDate.format('L') + '" class="' + clsNames.join(' ') + '">' + currentDate.date() + '</td>');
- currentDate.add(1, 'd');
- }
- daysView.find('tbody').empty().append(html);
- updateMonths();
- updateYears();
- updateDecades();
- };
- var fillHours = function fillHours() {
- var table = widget.find('.timepicker-hours table');
- var currentHour = viewDate.clone().startOf('d');
- var html = [];
- var row = $('<tr>');
- if (viewDate.hour() > 11 && !use24Hours) {
- currentHour.hour(12);
- }
- while (currentHour.isSame(viewDate, 'd') && (use24Hours || viewDate.hour() < 12 && currentHour.hour() < 12 || viewDate.hour() > 11)) {
- if (currentHour.hour() % 4 === 0) {
- row = $('<tr>');
- html.push(row);
- }
- row.append('<td data-action="selectHour" class="hour' + (!isValid(currentHour, 'h') ? ' disabled' : '') + '">' + currentHour.format(use24Hours ? 'HH' : 'hh') + '</td>');
- currentHour.add(1, 'h');
- }
- table.empty().append(html);
- };
- var fillMinutes = function fillMinutes() {
- var table = widget.find('.timepicker-minutes table');
- var currentMinute = viewDate.clone().startOf('h');
- var html = [];
- var row = $('<tr>');
- var step = options.stepping === 1 ? 5 : options.stepping;
- while (viewDate.isSame(currentMinute, 'h')) {
- if (currentMinute.minute() % (step * 4) === 0) {
- row = $('<tr>');
- html.push(row);
- }
- row.append('<td data-action="selectMinute" class="minute' + (!isValid(currentMinute, 'm') ? ' disabled' : '') + '">' + currentMinute.format('mm') + '</td>');
- currentMinute.add(step, 'm');
- }
- table.empty().append(html);
- };
- var fillSeconds = function fillSeconds() {
- var table = widget.find('.timepicker-seconds table');
- var currentSecond = viewDate.clone().startOf('m');
- var html = [];
- var row = $('<tr>');
- while (viewDate.isSame(currentSecond, 'm')) {
- if (currentSecond.second() % 20 === 0) {
- row = $('<tr>');
- html.push(row);
- }
- row.append('<td data-action="selectSecond" class="second' + (!isValid(currentSecond, 's') ? ' disabled' : '') + '">' + currentSecond.format('ss') + '</td>');
- currentSecond.add(5, 's');
- }
- table.empty().append(html);
- };
- var fillTime = function fillTime() {
- var toggle;
- var newDate;
- var timeComponents = widget.find('.timepicker span[data-time-component]');
- if (!use24Hours) {
- toggle = widget.find('.timepicker [data-action=togglePeriod]');
- newDate = date.clone().add(date.hours() >= 12 ? -12 : 12, 'h');
- toggle.text(date.format('A'));
- if (isValid(newDate, 'h')) {
- toggle.removeClass('disabled');
- } else {
- toggle.addClass('disabled');
- }
- }
- timeComponents.filter('[data-time-component=hours]').text(date.format(use24Hours ? 'HH' : 'hh'));
- timeComponents.filter('[data-time-component=minutes]').text(date.format('mm'));
- timeComponents.filter('[data-time-component=seconds]').text(date.format('ss'));
- fillHours();
- fillMinutes();
- fillSeconds();
- };
- var update = function update() {
- if (!widget) {
- return;
- }
- fillDate();
- fillTime();
- };
- var setValue = function setValue(targetMoment) {
- var oldDate = unset ? null : date; // case of calling setValue(null or false)
- if (!targetMoment) {
- unset = true;
- input.val('');
- element.data('date', '');
- notifyEvent({
- type: 'dp.change',
- date: false,
- oldDate: oldDate
- });
- update();
- return;
- }
- targetMoment = targetMoment.clone().locale(options.locale);
- if (hasTimeZone()) {
- targetMoment.tz(options.timeZone);
- }
- if (options.stepping !== 1) {
- targetMoment.minutes(Math.round(targetMoment.minutes() / options.stepping) * options.stepping).seconds(0);
- while (options.minDate && targetMoment.isBefore(options.minDate)) {
- targetMoment.add(options.stepping, 'minutes');
- }
- }
- if (isValid(targetMoment)) {
- date = targetMoment;
- viewDate = date.clone();
- input.val(date.format(actualFormat));
- element.data('date', date.format(actualFormat));
- unset = false;
- update();
- notifyEvent({
- type: 'dp.change',
- date: date.clone(),
- oldDate: oldDate
- });
- } else {
- if (!options.keepInvalid) {
- input.val(unset ? '' : date.format(actualFormat));
- } else {
- notifyEvent({
- type: 'dp.change',
- date: targetMoment,
- oldDate: oldDate
- });
- }
- notifyEvent({
- type: 'dp.error',
- date: targetMoment,
- oldDate: oldDate
- });
- }
- };
- /**
- * Hides the widget. Possibly will emit dp.hide
- */
- var hide = function hide() {
- var transitioning = false;
- if (!widget) {
- return picker;
- } // Ignore event if in the middle of a picker transition
- widget.find('.collapse').each(function () {
- var collapseData = $(this).data('collapse');
- if (collapseData && collapseData.transitioning) {
- transitioning = true;
- return false;
- }
- return true;
- });
- if (transitioning) {
- return picker;
- }
- if (component && component.hasClass('btn')) {
- component.toggleClass('active');
- }
- widget.hide();
- $(window).off('resize', place);
- widget.off('click', '[data-action]');
- widget.off('mousedown', false);
- widget.remove();
- widget = false;
- notifyEvent({
- type: 'dp.hide',
- date: date.clone()
- });
- input.blur();
- viewDate = date.clone();
- return picker;
- };
- var clear = function clear() {
- setValue(null);
- };
- var parseInputDate = function parseInputDate(inputDate) {
- if (options.parseInputDate === undefined) {
- if (!moment.isMoment(inputDate) || inputDate instanceof Date) {
- inputDate = getMoment(inputDate);
- }
- } else {
- inputDate = options.parseInputDate(inputDate);
- } // inputDate.locale(options.locale);
- return inputDate;
- };
- /** ******************************************************************************
- *
- * Widget UI interaction functions
- *
- ********************************************************************************/
- var actions = {
- next: function next() {
- var navFnc = datePickerModes[currentViewMode].navFnc;
- viewDate.add(datePickerModes[currentViewMode].navStep, navFnc);
- fillDate();
- viewUpdate(navFnc);
- },
- previous: function previous() {
- var navFnc = datePickerModes[currentViewMode].navFnc;
- viewDate.subtract(datePickerModes[currentViewMode].navStep, navFnc);
- fillDate();
- viewUpdate(navFnc);
- },
- pickerSwitch: function pickerSwitch() {
- showMode(1);
- },
- selectMonth: function selectMonth(e) {
- var month = $(e.target).closest('tbody').find('span').index($(e.target));
- viewDate.month(month);
- if (currentViewMode === minViewModeNumber) {
- setValue(date.clone().year(viewDate.year()).month(viewDate.month()));
- if (!options.inline) {
- hide();
- }
- } else {
- showMode(-1);
- fillDate();
- }
- viewUpdate('M');
- },
- selectYear: function selectYear(e) {
- var year = parseInt($(e.target).text(), 10) || 0;
- viewDate.year(year);
- if (currentViewMode === minViewModeNumber) {
- setValue(date.clone().year(viewDate.year()));
- if (!options.inline) {
- hide();
- }
- } else {
- showMode(-1);
- fillDate();
- }
- viewUpdate('YYYY');
- },
- selectDecade: function selectDecade(e) {
- var year = parseInt($(e.target).data('selection'), 10) || 0;
- viewDate.year(year);
- if (currentViewMode === minViewModeNumber) {
- setValue(date.clone().year(viewDate.year()));
- if (!options.inline) {
- hide();
- }
- } else {
- showMode(-1);
- fillDate();
- }
- viewUpdate('YYYY');
- },
- selectDay: function selectDay(e) {
- var day = viewDate.clone();
- if ($(e.target).is('.old')) {
- day.subtract(1, 'M');
- }
- if ($(e.target).is('.new')) {
- day.add(1, 'M');
- }
- setValue(day.date(parseInt($(e.target).text(), 10)));
- if (!hasTime() && !options.keepOpen && !options.inline) {
- hide();
- }
- },
- incrementHours: function incrementHours() {
- var newDate = date.clone().add(1, 'h');
- if (isValid(newDate, 'h')) {
- setValue(newDate);
- }
- },
- incrementMinutes: function incrementMinutes() {
- var newDate = date.clone().add(options.stepping, 'm');
- if (isValid(newDate, 'm')) {
- setValue(newDate);
- }
- },
- incrementSeconds: function incrementSeconds() {
- var newDate = date.clone().add(1, 's');
- if (isValid(newDate, 's')) {
- setValue(newDate);
- }
- },
- decrementHours: function decrementHours() {
- var newDate = date.clone().subtract(1, 'h');
- if (isValid(newDate, 'h')) {
- setValue(newDate);
- }
- },
- decrementMinutes: function decrementMinutes() {
- var newDate = date.clone().subtract(options.stepping, 'm');
- if (isValid(newDate, 'm')) {
- setValue(newDate);
- }
- },
- decrementSeconds: function decrementSeconds() {
- var newDate = date.clone().subtract(1, 's');
- if (isValid(newDate, 's')) {
- setValue(newDate);
- }
- },
- togglePeriod: function togglePeriod() {
- setValue(date.clone().add(date.hours() >= 12 ? -12 : 12, 'h'));
- },
- togglePicker: function togglePicker(e) {
- var $this = $(e.target);
- var $parent = $this.closest('ul');
- var expanded = $parent.find('.in');
- var closed = $parent.find('.collapse:not(.in)');
- var collapseData;
- if (expanded && expanded.length) {
- collapseData = expanded.data('collapse');
- if (collapseData && collapseData.transitioning) {
- return;
- }
- if (expanded.collapse) {
- // if collapse plugin is available through bootstrap.js then use it
- expanded.collapse('hide');
- closed.collapse('show');
- } else {
- // otherwise just toggle in class on the two views
- expanded.removeClass('in');
- closed.addClass('in');
- }
- if ($this.is('span')) {
- $this.toggleClass(options.icons.time + ' ' + options.icons.date);
- } else {
- $this.find('span').toggleClass(options.icons.time + ' ' + options.icons.date);
- } // NOTE: uncomment if toggled state will be restored in show()
- // if (component) {
- // component.find('span').toggleClass(options.icons.time + ' ' + options.icons.date);
- // }
- }
- },
- showPicker: function showPicker() {
- widget.find('.timepicker > div:not(.timepicker-picker)').hide();
- widget.find('.timepicker .timepicker-picker').show();
- },
- showHours: function showHours() {
- widget.find('.timepicker .timepicker-picker').hide();
- widget.find('.timepicker .timepicker-hours').show();
- },
- showMinutes: function showMinutes() {
- widget.find('.timepicker .timepicker-picker').hide();
- widget.find('.timepicker .timepicker-minutes').show();
- },
- showSeconds: function showSeconds() {
- widget.find('.timepicker .timepicker-picker').hide();
- widget.find('.timepicker .timepicker-seconds').show();
- },
- selectHour: function selectHour(e) {
- var hour = parseInt($(e.target).text(), 10);
- if (!use24Hours) {
- if (date.hours() >= 12) {
- if (hour !== 12) {
- hour += 12;
- }
- } else {
- if (hour === 12) {
- hour = 0;
- }
- }
- }
- setValue(date.clone().hours(hour));
- actions.showPicker.call(picker);
- },
- selectMinute: function selectMinute(e) {
- setValue(date.clone().minutes(parseInt($(e.target).text(), 10)));
- actions.showPicker.call(picker);
- },
- selectSecond: function selectSecond(e) {
- setValue(date.clone().seconds(parseInt($(e.target).text(), 10)));
- actions.showPicker.call(picker);
- },
- clear: clear,
- today: function today() {
- var todaysDate = getMoment();
- if (isValid(todaysDate, 'd')) {
- setValue(todaysDate);
- }
- },
- close: hide
- };
- var doAction = function doAction(e) {
- if ($(e.currentTarget).is('.disabled')) {
- return false;
- }
- actions[$(e.currentTarget).data('action')].apply(picker, arguments);
- return false;
- };
- /**
- * Shows the widget. Possibly will emit dp.show and dp.change
- */
- var show = function show() {
- var currentMoment;
- var useCurrentGranularity = {
- 'year': function year(m) {
- return m.month(0).date(1).hours(0).seconds(0).minutes(0);
- },
- 'month': function month(m) {
- return m.date(1).hours(0).seconds(0).minutes(0);
- },
- 'day': function day(m) {
- return m.hours(0).seconds(0).minutes(0);
- },
- 'hour': function hour(m) {
- return m.seconds(0).minutes(0);
- },
- 'minute': function minute(m) {
- return m.seconds(0);
- }
- };
- if (input.prop('disabled') || !options.ignoreReadonly && input.prop('readonly') || widget) {
- return picker;
- }
- if (input.val() !== undefined && input.val().trim().length !== 0) {
- setValue(parseInputDate(input.val().trim()));
- } else if (unset && options.useCurrent && (options.inline || input.is('input') && input.val().trim().length === 0)) {
- currentMoment = getMoment();
- if (typeof options.useCurrent === 'string') {
- currentMoment = useCurrentGranularity[options.useCurrent](currentMoment);
- }
- setValue(currentMoment);
- }
- widget = getTemplate();
- fillDow();
- fillMonths();
- widget.find('.timepicker-hours').hide();
- widget.find('.timepicker-minutes').hide();
- widget.find('.timepicker-seconds').hide();
- update();
- showMode();
- $(window).on('resize', place);
- widget.on('click', '[data-action]', doAction); // this handles clicks on the widget
- widget.on('mousedown', false);
- if (component && component.hasClass('btn')) {
- component.toggleClass('active');
- }
- place();
- widget.show();
- if (options.focusOnShow && !input.is(':focus')) {
- input.focus();
- }
- notifyEvent({
- type: 'dp.show'
- });
- return picker;
- };
- /**
- * Shows or hides the widget
- */
- var toggle = function toggle() {
- return widget ? hide() : show();
- };
- var keydown = function keydown(e) {
- var handler = null;
- var index;
- var index2;
- var pressedKeys = [];
- var pressedModifiers = {};
- var currentKey = e.which;
- var keyBindKeys;
- var allModifiersPressed;
- var pressed = 'p';
- keyState[currentKey] = pressed;
- for (index in keyState) {
- if (keyState.hasOwnProperty(index) && keyState[index] === pressed) {
- pressedKeys.push(index);
- if (parseInt(index, 10) !== currentKey) {
- pressedModifiers[index] = true;
- }
- }
- }
- for (index in options.keyBinds) {
- if (options.keyBinds.hasOwnProperty(index) && typeof options.keyBinds[index] === 'function') {
- keyBindKeys = index.split(' ');
- if (keyBindKeys.length === pressedKeys.length && keyMap[currentKey] === keyBindKeys[keyBindKeys.length - 1]) {
- allModifiersPressed = true;
- for (index2 = keyBindKeys.length - 2; index2 >= 0; index2--) {
- if (!(keyMap[keyBindKeys[index2]] in pressedModifiers)) {
- allModifiersPressed = false;
- break;
- }
- }
- if (allModifiersPressed) {
- handler = options.keyBinds[index];
- break;
- }
- }
- }
- }
- if (handler) {
- handler.call(picker, widget);
- e.stopPropagation();
- e.preventDefault();
- }
- };
- var keyup = function keyup(e) {
- keyState[e.which] = 'r';
- e.stopPropagation();
- e.preventDefault();
- };
- var change = function change(e) {
- var val = $(e.target).val().trim();
- var parsedDate = val ? parseInputDate(val) : null;
- setValue(parsedDate);
- e.stopImmediatePropagation();
- return false;
- };
- var attachDatePickerElementEvents = function attachDatePickerElementEvents() {
- input.on({
- 'change': change,
- 'blur': options.debug ? '' : hide,
- 'keydown': keydown,
- 'keyup': keyup,
- 'focus': options.allowInputToggle ? show : ''
- });
- if (element.is('input')) {
- input.on({
- 'focus': show
- });
- } else if (component) {
- component.on('click', toggle);
- component.on('mousedown', false);
- }
- };
- var detachDatePickerElementEvents = function detachDatePickerElementEvents() {
- input.off({
- 'change': change,
- 'blur': blur,
- 'keydown': keydown,
- 'keyup': keyup,
- 'focus': options.allowInputToggle ? hide : ''
- });
- if (element.is('input')) {
- input.off({
- 'focus': show
- });
- } else if (component) {
- component.off('click', toggle);
- component.off('mousedown', false);
- }
- };
- var indexGivenDates = function indexGivenDates(givenDatesArray) {
- // Store given enabledDates and disabledDates as keys.
- // This way we can check their existence in O(1) time instead of looping through whole array.
- // (for example: options.enabledDates['2014-02-27'] === true)
- var givenDatesIndexed = {};
- $.each(givenDatesArray, function () {
- var dDate = parseInputDate(this);
- if (dDate.isValid()) {
- givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true;
- }
- });
- return Object.keys(givenDatesIndexed).length ? givenDatesIndexed : false;
- };
- var indexGivenHours = function indexGivenHours(givenHoursArray) {
- // Store given enabledHours and disabledHours as keys.
- // This way we can check their existence in O(1) time instead of looping through whole array.
- // (for example: options.enabledHours['2014-02-27'] === true)
- var givenHoursIndexed = {};
- $.each(givenHoursArray, function () {
- givenHoursIndexed[this] = true;
- });
- return Object.keys(givenHoursIndexed).length ? givenHoursIndexed : false;
- };
- var initFormatting = function initFormatting() {
- var format = options.format || 'L LT';
- actualFormat = format.replace(/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput) {
- var newinput = date.localeData().longDateFormat(formatInput) || formatInput;
- return newinput.replace(/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput2) {
- // temp fix for #740
- return date.localeData().longDateFormat(formatInput2) || formatInput2;
- });
- });
- parseFormats = options.extraFormats ? options.extraFormats.slice() : [];
- if (parseFormats.indexOf(format) < 0 && parseFormats.indexOf(actualFormat) < 0) {
- parseFormats.push(actualFormat);
- }
- use24Hours = actualFormat.toLowerCase().indexOf('a') < 1 && actualFormat.replace(/\[.*?\]/g, '').indexOf('h') < 1;
- if (isEnabled('y')) {
- minViewModeNumber = 2;
- }
- if (isEnabled('M')) {
- minViewModeNumber = 1;
- }
- if (isEnabled('d')) {
- minViewModeNumber = 0;
- }
- currentViewMode = Math.max(minViewModeNumber, currentViewMode);
- if (!unset) {
- setValue(date);
- }
- };
- /** ******************************************************************************
- *
- * Public API functions
- * =====================
- *
- * Important: Do not expose direct references to private objects or the options
- * object to the outer world. Always return a clone when returning values or make
- * a clone when setting a private variable.
- *
- ********************************************************************************/
- picker.destroy = function () {
- // /<summary>Destroys the widget and removes all attached event listeners</summary>
- hide();
- detachDatePickerElementEvents();
- element.removeData('DateTimePicker');
- element.removeData('date');
- };
- picker.toggle = toggle;
- picker.show = show;
- picker.hide = hide;
- picker.disable = function () {
- // /<summary>Disables the input element, the component is attached to, by adding a disabled="true" attribute to it.
- // /If the widget was visible before that call it is hidden. Possibly emits dp.hide</summary>
- hide();
- if (component && component.hasClass('btn')) {
- component.addClass('disabled');
- }
- input.prop('disabled', true);
- return picker;
- };
- picker.enable = function () {
- // /<summary>Enables the input element, the component is attached to, by removing disabled attribute from it.</summary>
- if (component && component.hasClass('btn')) {
- component.removeClass('disabled');
- }
- input.prop('disabled', false);
- return picker;
- };
- picker.ignoreReadonly = function (ignoreReadonly) {
- if (arguments.length === 0) {
- return options.ignoreReadonly;
- }
- if (typeof ignoreReadonly !== 'boolean') {
- throw new TypeError('ignoreReadonly () expects a boolean parameter');
- }
- options.ignoreReadonly = ignoreReadonly;
- return picker;
- };
- picker.options = function (newOptions) {
- if (arguments.length === 0) {
- return $.extend(true, {}, options);
- }
- if (!(newOptions instanceof Object)) {
- throw new TypeError('options() options parameter should be an object');
- }
- $.extend(true, options, newOptions);
- $.each(options, function (key, value) {
- if (picker[key] !== undefined) {
- picker[key](value);
- } else {
- throw new TypeError('option ' + key + ' is not recognized!');
- }
- });
- return picker;
- };
- picker.date = function (newDate) {
- // /<signature helpKeyword="$.fn.datetimepicker.date">
- // /<summary>Returns the component's model current date, a moment object or null if not set.</summary>
- // /<returns type="Moment">date.clone()</returns>
- // /</signature>
- // /<signature>
- // /<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>
- // /<param name="newDate" locid="$.fn.datetimepicker.date_p:newDate">Takes string, Date, moment, null parameter.</param>
- // /</signature>
- if (arguments.length === 0) {
- if (unset) {
- return null;
- }
- return date.clone();
- }
- if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
- throw new TypeError('date() parameter must be one of [null, string, moment or Date]');
- }
- setValue(newDate === null ? null : parseInputDate(newDate));
- return picker;
- };
- picker.format = function (newFormat) {
- // /<summary>test su</summary>
- // /<param name="newFormat">info about para</param>
- // /<returns type="string|boolean">returns foo</returns>
- if (arguments.length === 0) {
- return options.format;
- }
- if (typeof newFormat !== 'string' && (typeof newFormat !== 'boolean' || newFormat !== false)) {
- throw new TypeError('format() expects a string or boolean:false parameter ' + newFormat);
- }
- options.format = newFormat;
- if (actualFormat) {
- initFormatting(); // reinit formatting
- }
- return picker;
- };
- picker.timeZone = function (newZone) {
- if (arguments.length === 0) {
- return options.timeZone;
- }
- if (typeof newZone !== 'string') {
- throw new TypeError('newZone() expects a string parameter');
- }
- options.timeZone = newZone;
- return picker;
- };
- picker.dayViewHeaderFormat = function (newFormat) {
- if (arguments.length === 0) {
- return options.dayViewHeaderFormat;
- }
- if (typeof newFormat !== 'string') {
- throw new TypeError('dayViewHeaderFormat() expects a string parameter');
- }
- options.dayViewHeaderFormat = newFormat;
- return picker;
- };
- picker.extraFormats = function (formats) {
- if (arguments.length === 0) {
- return options.extraFormats;
- }
- if (formats !== false && !(formats instanceof Array)) {
- throw new TypeError('extraFormats() expects an array or false parameter');
- }
- options.extraFormats = formats;
- if (parseFormats) {
- initFormatting(); // reinit formatting
- }
- return picker;
- };
- picker.disabledDates = function (dates) {
- // /<signature helpKeyword="$.fn.datetimepicker.disabledDates">
- // /<summary>Returns an array with the currently set disabled dates on the component.</summary>
- // /<returns type="array">options.disabledDates</returns>
- // /</signature>
- // /<signature>
- // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
- // /options.enabledDates if such exist.</summary>
- // /<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>
- // /</signature>
- if (arguments.length === 0) {
- return options.disabledDates ? $.extend({}, options.disabledDates) : options.disabledDates;
- }
- if (!dates) {
- options.disabledDates = false;
- update();
- return picker;
- }
- if (!(dates instanceof Array)) {
- throw new TypeError('disabledDates() expects an array parameter');
- }
- options.disabledDates = indexGivenDates(dates);
- options.enabledDates = false;
- update();
- return picker;
- };
- picker.enabledDates = function (dates) {
- // /<signature helpKeyword="$.fn.datetimepicker.enabledDates">
- // /<summary>Returns an array with the currently set enabled dates on the component.</summary>
- // /<returns type="array">options.enabledDates</returns>
- // /</signature>
- // /<signature>
- // /<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>
- // /<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>
- // /</signature>
- if (arguments.length === 0) {
- return options.enabledDates ? $.extend({}, options.enabledDates) : options.enabledDates;
- }
- if (!dates) {
- options.enabledDates = false;
- update();
- return picker;
- }
- if (!(dates instanceof Array)) {
- throw new TypeError('enabledDates() expects an array parameter');
- }
- options.enabledDates = indexGivenDates(dates);
- options.disabledDates = false;
- update();
- return picker;
- };
- picker.daysOfWeekDisabled = function (daysOfWeekDisabled) {
- if (arguments.length === 0) {
- return options.daysOfWeekDisabled.splice(0);
- }
- if (typeof daysOfWeekDisabled === 'boolean' && !daysOfWeekDisabled) {
- options.daysOfWeekDisabled = false;
- update();
- return picker;
- }
- if (!(daysOfWeekDisabled instanceof Array)) {
- throw new TypeError('daysOfWeekDisabled() expects an array parameter');
- }
- options.daysOfWeekDisabled = daysOfWeekDisabled.reduce(function (previousValue, currentValue) {
- currentValue = parseInt(currentValue, 10);
- if (currentValue > 6 || currentValue < 0 || isNaN(currentValue)) {
- return previousValue;
- }
- if (previousValue.indexOf(currentValue) === -1) {
- previousValue.push(currentValue);
- }
- return previousValue;
- }, []).sort();
- if (options.useCurrent && !options.keepInvalid) {
- var tries = 0;
- while (!isValid(date, 'd')) {
- date.add(1, 'd');
- if (tries === 31) {
- throw new Error('Tried 31 times to find a valid date');
- }
- tries++;
- }
- setValue(date);
- }
- update();
- return picker;
- };
- picker.maxDate = function (maxDate) {
- if (arguments.length === 0) {
- return options.maxDate ? options.maxDate.clone() : options.maxDate;
- }
- if (typeof maxDate === 'boolean' && maxDate === false) {
- options.maxDate = false;
- update();
- return picker;
- }
- if (typeof maxDate === 'string') {
- if (maxDate === 'now' || maxDate === 'moment') {
- maxDate = getMoment();
- }
- }
- var parsedDate = parseInputDate(maxDate);
- if (!parsedDate.isValid()) {
- throw new TypeError('maxDate() Could not parse date parameter: ' + maxDate);
- }
- if (options.minDate && parsedDate.isBefore(options.minDate)) {
- throw new TypeError('maxDate() date parameter is before options.minDate: ' + parsedDate.format(actualFormat));
- }
- options.maxDate = parsedDate;
- if (options.useCurrent && !options.keepInvalid && date.isAfter(maxDate)) {
- setValue(options.maxDate);
- }
- if (viewDate.isAfter(parsedDate)) {
- viewDate = parsedDate.clone().subtract(options.stepping, 'm');
- }
- update();
- return picker;
- };
- picker.minDate = function (minDate) {
- if (arguments.length === 0) {
- return options.minDate ? options.minDate.clone() : options.minDate;
- }
- if (typeof minDate === 'boolean' && minDate === false) {
- options.minDate = false;
- update();
- return picker;
- }
- if (typeof minDate === 'string') {
- if (minDate === 'now' || minDate === 'moment') {
- minDate = getMoment();
- }
- }
- var parsedDate = parseInputDate(minDate);
- if (!parsedDate.isValid()) {
- throw new TypeError('minDate() Could not parse date parameter: ' + minDate);
- }
- if (options.maxDate && parsedDate.isAfter(options.maxDate)) {
- throw new TypeError('minDate() date parameter is after options.maxDate: ' + parsedDate.format(actualFormat));
- }
- options.minDate = parsedDate;
- if (options.useCurrent && !options.keepInvalid && date.isBefore(minDate)) {
- setValue(options.minDate);
- }
- if (viewDate.isBefore(parsedDate)) {
- viewDate = parsedDate.clone().add(options.stepping, 'm');
- }
- update();
- return picker;
- };
- picker.defaultDate = function (defaultDate) {
- // /<signature helpKeyword="$.fn.datetimepicker.defaultDate">
- // /<summary>Returns a moment with the options.defaultDate option configuration or false if not set</summary>
- // /<returns type="Moment">date.clone()</returns>
- // /</signature>
- // /<signature>
- // /<summary>Will set the picker's inital date. If a boolean:false value is passed the options.defaultDate parameter is cleared.</summary>
- // /<param name="defaultDate" locid="$.fn.datetimepicker.defaultDate_p:defaultDate">Takes a string, Date, moment, boolean:false</param>
- // /</signature>
- if (arguments.length === 0) {
- return options.defaultDate ? options.defaultDate.clone() : options.defaultDate;
- }
- if (!defaultDate) {
- options.defaultDate = false;
- return picker;
- }
- if (typeof defaultDate === 'string') {
- if (defaultDate === 'now' || defaultDate === 'moment') {
- defaultDate = getMoment();
- } else {
- defaultDate = getMoment(defaultDate);
- }
- }
- var parsedDate = parseInputDate(defaultDate);
- if (!parsedDate.isValid()) {
- throw new TypeError('defaultDate() Could not parse date parameter: ' + defaultDate);
- }
- if (!isValid(parsedDate)) {
- throw new TypeError('defaultDate() date passed is invalid according to component setup validations');
- }
- options.defaultDate = parsedDate;
- if (options.defaultDate && options.inline || input.val().trim() === '') {
- setValue(options.defaultDate);
- }
- return picker;
- };
- picker.locale = function (locale) {
- if (arguments.length === 0) {
- return options.locale;
- }
- if (!moment.localeData(locale)) {
- throw new TypeError('locale() locale ' + locale + ' is not loaded from moment locales!');
- }
- options.locale = locale;
- date.locale(options.locale);
- viewDate.locale(options.locale);
- if (actualFormat) {
- initFormatting(); // reinit formatting
- }
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.stepping = function (stepping) {
- if (arguments.length === 0) {
- return options.stepping;
- }
- stepping = parseInt(stepping, 10);
- if (isNaN(stepping) || stepping < 1) {
- stepping = 1;
- }
- options.stepping = stepping;
- return picker;
- };
- picker.useCurrent = function (useCurrent) {
- var useCurrentOptions = ['year', 'month', 'day', 'hour', 'minute'];
- if (arguments.length === 0) {
- return options.useCurrent;
- }
- if (typeof useCurrent !== 'boolean' && typeof useCurrent !== 'string') {
- throw new TypeError('useCurrent() expects a boolean or string parameter');
- }
- if (typeof useCurrent === 'string' && useCurrentOptions.indexOf(useCurrent.toLowerCase()) === -1) {
- throw new TypeError('useCurrent() expects a string parameter of ' + useCurrentOptions.join(', '));
- }
- options.useCurrent = useCurrent;
- return picker;
- };
- picker.collapse = function (collapse) {
- if (arguments.length === 0) {
- return options.collapse;
- }
- if (typeof collapse !== 'boolean') {
- throw new TypeError('collapse() expects a boolean parameter');
- }
- if (options.collapse === collapse) {
- return picker;
- }
- options.collapse = collapse;
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.icons = function (icons) {
- if (arguments.length === 0) {
- return $.extend({}, options.icons);
- }
- if (!(icons instanceof Object)) {
- throw new TypeError('icons() expects parameter to be an Object');
- }
- $.extend(options.icons, icons);
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.tooltips = function (tooltips) {
- if (arguments.length === 0) {
- return $.extend({}, options.tooltips);
- }
- if (!(tooltips instanceof Object)) {
- throw new TypeError('tooltips() expects parameter to be an Object');
- }
- $.extend(options.tooltips, tooltips);
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.useStrict = function (useStrict) {
- if (arguments.length === 0) {
- return options.useStrict;
- }
- if (typeof useStrict !== 'boolean') {
- throw new TypeError('useStrict() expects a boolean parameter');
- }
- options.useStrict = useStrict;
- return picker;
- };
- picker.sideBySide = function (sideBySide) {
- if (arguments.length === 0) {
- return options.sideBySide;
- }
- if (typeof sideBySide !== 'boolean') {
- throw new TypeError('sideBySide() expects a boolean parameter');
- }
- options.sideBySide = sideBySide;
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.viewMode = function (viewMode) {
- if (arguments.length === 0) {
- return options.viewMode;
- }
- if (typeof viewMode !== 'string') {
- throw new TypeError('viewMode() expects a string parameter');
- }
- if (viewModes.indexOf(viewMode) === -1) {
- throw new TypeError('viewMode() parameter must be one of (' + viewModes.join(', ') + ') value');
- }
- options.viewMode = viewMode;
- currentViewMode = Math.max(viewModes.indexOf(viewMode), minViewModeNumber);
- showMode();
- return picker;
- };
- picker.toolbarPlacement = function (toolbarPlacement) {
- if (arguments.length === 0) {
- return options.toolbarPlacement;
- }
- if (typeof toolbarPlacement !== 'string') {
- throw new TypeError('toolbarPlacement() expects a string parameter');
- }
- if (toolbarPlacements.indexOf(toolbarPlacement) === -1) {
- throw new TypeError('toolbarPlacement() parameter must be one of (' + toolbarPlacements.join(', ') + ') value');
- }
- options.toolbarPlacement = toolbarPlacement;
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.widgetPositioning = function (widgetPositioning) {
- if (arguments.length === 0) {
- return $.extend({}, options.widgetPositioning);
- }
- if ({}.toString.call(widgetPositioning) !== '[object Object]') {
- throw new TypeError('widgetPositioning() expects an object variable');
- }
- if (widgetPositioning.horizontal) {
- if (typeof widgetPositioning.horizontal !== 'string') {
- throw new TypeError('widgetPositioning() horizontal variable must be a string');
- }
- widgetPositioning.horizontal = widgetPositioning.horizontal.toLowerCase();
- if (horizontalModes.indexOf(widgetPositioning.horizontal) === -1) {
- throw new TypeError('widgetPositioning() expects horizontal parameter to be one of (' + horizontalModes.join(', ') + ')');
- }
- options.widgetPositioning.horizontal = widgetPositioning.horizontal;
- }
- if (widgetPositioning.vertical) {
- if (typeof widgetPositioning.vertical !== 'string') {
- throw new TypeError('widgetPositioning() vertical variable must be a string');
- }
- widgetPositioning.vertical = widgetPositioning.vertical.toLowerCase();
- if (verticalModes.indexOf(widgetPositioning.vertical) === -1) {
- throw new TypeError('widgetPositioning() expects vertical parameter to be one of (' + verticalModes.join(', ') + ')');
- }
- options.widgetPositioning.vertical = widgetPositioning.vertical;
- }
- update();
- return picker;
- };
- picker.calendarWeeks = function (calendarWeeks) {
- if (arguments.length === 0) {
- return options.calendarWeeks;
- }
- if (typeof calendarWeeks !== 'boolean') {
- throw new TypeError('calendarWeeks() expects parameter to be a boolean value');
- }
- options.calendarWeeks = calendarWeeks;
- update();
- return picker;
- };
- picker.showTodayButton = function (showTodayButton) {
- if (arguments.length === 0) {
- return options.showTodayButton;
- }
- if (typeof showTodayButton !== 'boolean') {
- throw new TypeError('showTodayButton() expects a boolean parameter');
- }
- options.showTodayButton = showTodayButton;
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.showClear = function (showClear) {
- if (arguments.length === 0) {
- return options.showClear;
- }
- if (typeof showClear !== 'boolean') {
- throw new TypeError('showClear() expects a boolean parameter');
- }
- options.showClear = showClear;
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.widgetParent = function (widgetParent) {
- if (arguments.length === 0) {
- return options.widgetParent;
- }
- if (typeof widgetParent === 'string') {
- widgetParent = $(widgetParent);
- }
- if (widgetParent !== null && typeof widgetParent !== 'string' && !(widgetParent instanceof $)) {
- throw new TypeError('widgetParent() expects a string or a jQuery object parameter');
- }
- options.widgetParent = widgetParent;
- if (widget) {
- hide();
- show();
- }
- return picker;
- };
- picker.keepOpen = function (keepOpen) {
- if (arguments.length === 0) {
- return options.keepOpen;
- }
- if (typeof keepOpen !== 'boolean') {
- throw new TypeError('keepOpen() expects a boolean parameter');
- }
- options.keepOpen = keepOpen;
- return picker;
- };
- picker.focusOnShow = function (focusOnShow) {
- if (arguments.length === 0) {
- return options.focusOnShow;
- }
- if (typeof focusOnShow !== 'boolean') {
- throw new TypeError('focusOnShow() expects a boolean parameter');
- }
- options.focusOnShow = focusOnShow;
- return picker;
- };
- picker.inline = function (inline) {
- if (arguments.length === 0) {
- return options.inline;
- }
- if (typeof inline !== 'boolean') {
- throw new TypeError('inline() expects a boolean parameter');
- }
- options.inline = inline;
- return picker;
- };
- picker.clear = function () {
- clear();
- return picker;
- };
- picker.keyBinds = function (keyBinds) {
- if (arguments.length === 0) {
- return options.keyBinds;
- }
- options.keyBinds = keyBinds;
- return picker;
- };
- picker.getMoment = function (d) {
- return getMoment(d);
- };
- picker.debug = function (debug) {
- if (typeof debug !== 'boolean') {
- throw new TypeError('debug() expects a boolean parameter');
- }
- options.debug = debug;
- return picker;
- };
- picker.allowInputToggle = function (allowInputToggle) {
- if (arguments.length === 0) {
- return options.allowInputToggle;
- }
- if (typeof allowInputToggle !== 'boolean') {
- throw new TypeError('allowInputToggle() expects a boolean parameter');
- }
- options.allowInputToggle = allowInputToggle;
- return picker;
- };
- picker.showClose = function (showClose) {
- if (arguments.length === 0) {
- return options.showClose;
- }
- if (typeof showClose !== 'boolean') {
- throw new TypeError('showClose() expects a boolean parameter');
- }
- options.showClose = showClose;
- return picker;
- };
- picker.keepInvalid = function (keepInvalid) {
- if (arguments.length === 0) {
- return options.keepInvalid;
- }
- if (typeof keepInvalid !== 'boolean') {
- throw new TypeError('keepInvalid() expects a boolean parameter');
- }
- options.keepInvalid = keepInvalid;
- return picker;
- };
- picker.datepickerInput = function (datepickerInput) {
- if (arguments.length === 0) {
- return options.datepickerInput;
- }
- if (typeof datepickerInput !== 'string') {
- throw new TypeError('datepickerInput() expects a string parameter');
- }
- options.datepickerInput = datepickerInput;
- return picker;
- };
- picker.parseInputDate = function (parseInputDate) {
- if (arguments.length === 0) {
- return options.parseInputDate;
- }
- if (typeof parseInputDate !== 'function') {
- throw new TypeError('parseInputDate() sholud be as function');
- }
- options.parseInputDate = parseInputDate;
- return picker;
- };
- picker.disabledTimeIntervals = function (disabledTimeIntervals) {
- // /<signature helpKeyword="$.fn.datetimepicker.disabledTimeIntervals">
- // /<summary>Returns an array with the currently set disabled dates on the component.</summary>
- // /<returns type="array">options.disabledTimeIntervals</returns>
- // /</signature>
- // /<signature>
- // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
- // /options.enabledDates if such exist.</summary>
- // /<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>
- // /</signature>
- if (arguments.length === 0) {
- return options.disabledTimeIntervals ? $.extend({}, options.disabledTimeIntervals) : options.disabledTimeIntervals;
- }
- if (!disabledTimeIntervals) {
- options.disabledTimeIntervals = false;
- update();
- return picker;
- }
- if (!(disabledTimeIntervals instanceof Array)) {
- throw new TypeError('disabledTimeIntervals() expects an array parameter');
- }
- options.disabledTimeIntervals = disabledTimeIntervals;
- update();
- return picker;
- };
- picker.disabledHours = function (hours) {
- // /<signature helpKeyword="$.fn.datetimepicker.disabledHours">
- // /<summary>Returns an array with the currently set disabled hours on the component.</summary>
- // /<returns type="array">options.disabledHours</returns>
- // /</signature>
- // /<signature>
- // /<summary>Setting this takes precedence over options.minDate, options.maxDate configuration. Also calling this function removes the configuration of
- // /options.enabledHours if such exist.</summary>
- // /<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>
- // /</signature>
- if (arguments.length === 0) {
- return options.disabledHours ? $.extend({}, options.disabledHours) : options.disabledHours;
- }
- if (!hours) {
- options.disabledHours = false;
- update();
- return picker;
- }
- if (!(hours instanceof Array)) {
- throw new TypeError('disabledHours() expects an array parameter');
- }
- options.disabledHours = indexGivenHours(hours);
- options.enabledHours = false;
- if (options.useCurrent && !options.keepInvalid) {
- var tries = 0;
- while (!isValid(date, 'h')) {
- date.add(1, 'h');
- if (tries === 24) {
- throw new Error('Tried 24 times to find a valid date');
- }
- tries++;
- }
- setValue(date);
- }
- update();
- return picker;
- };
- picker.enabledHours = function (hours) {
- // /<signature helpKeyword="$.fn.datetimepicker.enabledHours">
- // /<summary>Returns an array with the currently set enabled hours on the component.</summary>
- // /<returns type="array">options.enabledHours</returns>
- // /</signature>
- // /<signature>
- // /<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>
- // /<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>
- // /</signature>
- if (arguments.length === 0) {
- return options.enabledHours ? $.extend({}, options.enabledHours) : options.enabledHours;
- }
- if (!hours) {
- options.enabledHours = false;
- update();
- return picker;
- }
- if (!(hours instanceof Array)) {
- throw new TypeError('enabledHours() expects an array parameter');
- }
- options.enabledHours = indexGivenHours(hours);
- options.disabledHours = false;
- if (options.useCurrent && !options.keepInvalid) {
- var tries = 0;
- while (!isValid(date, 'h')) {
- date.add(1, 'h');
- if (tries === 24) {
- throw new Error('Tried 24 times to find a valid date');
- }
- tries++;
- }
- setValue(date);
- }
- update();
- return picker;
- };
- /**
- * 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.
- * @param {Takes string, viewDate, moment, null parameter.} newDate
- * @returns {viewDate.clone()}
- */
- picker.viewDate = function (newDate) {
- if (arguments.length === 0) {
- return viewDate.clone();
- }
- if (!newDate) {
- viewDate = date.clone();
- return picker;
- }
- if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
- throw new TypeError('viewDate() parameter must be one of [string, moment or Date]');
- }
- viewDate = parseInputDate(newDate);
- viewUpdate();
- return picker;
- }; // initializing element and component attributes
- if (element.is('input')) {
- input = element;
- } else {
- input = element.find(options.datepickerInput);
- if (input.length === 0) {
- input = element.find('input');
- } else if (!input.is('input')) {
- throw new Error('CSS class "' + options.datepickerInput + '" cannot be applied to non input element');
- }
- }
- if (element.hasClass('input-group')) {
- // in case there is more then one 'input-group-addon' Issue #48
- if (element.find('.datepickerbutton').length === 0) {
- component = element.find('.input-group-addon');
- } else {
- component = element.find('.datepickerbutton');
- }
- }
- if (!options.inline && !input.is('input')) {
- throw new Error('Could not initialize DateTimePicker without an input element');
- } // Set defaults for date here now instead of in var declaration
- date = getMoment();
- viewDate = date.clone();
- $.extend(true, options, dataToOptions());
- picker.options(options);
- initFormatting();
- attachDatePickerElementEvents();
- if (input.prop('disabled')) {
- picker.disable();
- }
- if (input.is('input') && input.val().trim().length !== 0) {
- setValue(parseInputDate(input.val().trim()));
- } else if (options.defaultDate && input.attr('placeholder') === undefined) {
- setValue(options.defaultDate);
- }
- if (options.inline) {
- show();
- }
- return picker;
- };
- /** ******************************************************************************
- *
- * jQuery plugin constructor and defaults object
- *
- ********************************************************************************/
- /**
- * See (http://jquery.com/).
- * @name jQuery
- * @class
- * See the jQuery Library (http://jquery.com/) for full details. This just
- * documents the function and classes that are added to jQuery by this plug-in.
- */
- /**
- * See (http://jquery.com/)
- * @name fn
- * @class
- * See the jQuery Library (http://jquery.com/) for full details. This just
- * documents the function and classes that are added to jQuery by this plug-in.
- * @memberOf jQuery
- */
- /**
- * Show comments
- * @class datetimepicker
- * @memberOf jQuery.fn
- */
- $.fn.datetimepicker = function (options) {
- options = options || {};
- var args = Array.prototype.slice.call(arguments, 1);
- var isInstance = true;
- var thisMethods = ['destroy', 'hide', 'show', 'toggle'];
- var returnValue;
- if (_typeof(options) === 'object') {
- return this.each(function () {
- var $this = $(this);
- var _options;
- if (!$this.data('DateTimePicker')) {
- // create a private copy of the defaults object
- _options = $.extend(true, {}, $.fn.datetimepicker.defaults, options);
- $this.data('DateTimePicker', dateTimePicker($this, _options));
- }
- });
- } else if (typeof options === 'string') {
- this.each(function () {
- var $this = $(this);
- var instance = $this.data('DateTimePicker');
- if (!instance) {
- throw new Error('bootstrap-datetimepicker("' + options + '") method was called on an element that is not using DateTimePicker');
- }
- returnValue = instance[options].apply(instance, args);
- isInstance = returnValue === instance;
- });
- if (isInstance || $.inArray(options, thisMethods) > -1) {
- return this;
- }
- return returnValue;
- }
- throw new TypeError('Invalid arguments for DateTimePicker: ' + options);
- };
- $.fn.datetimepicker.defaults = {
- timeZone: '',
- format: false,
- dayViewHeaderFormat: 'MMMM YYYY',
- extraFormats: false,
- stepping: 1,
- minDate: false,
- maxDate: false,
- useCurrent: true,
- collapse: true,
- locale: moment.locale(),
- defaultDate: false,
- disabledDates: false,
- enabledDates: false,
- icons: {
- time: 'glyphicon glyphicon-time',
- date: 'glyphicon glyphicon-calendar',
- up: 'glyphicon glyphicon-chevron-up',
- down: 'glyphicon glyphicon-chevron-down',
- previous: 'glyphicon glyphicon-chevron-left',
- next: 'glyphicon glyphicon-chevron-right',
- today: 'glyphicon glyphicon-screenshot',
- clear: 'glyphicon glyphicon-trash',
- close: 'glyphicon glyphicon-remove'
- },
- tooltips: {
- today: 'Go to today',
- clear: 'Clear selection',
- close: 'Close the picker',
- selectMonth: 'Select Month',
- prevMonth: 'Previous Month',
- nextMonth: 'Next Month',
- selectYear: 'Select Year',
- prevYear: 'Previous Year',
- nextYear: 'Next Year',
- selectDecade: 'Select Decade',
- prevDecade: 'Previous Decade',
- nextDecade: 'Next Decade',
- prevCentury: 'Previous Century',
- nextCentury: 'Next Century',
- pickHour: 'Pick Hour',
- incrementHour: 'Increment Hour',
- decrementHour: 'Decrement Hour',
- pickMinute: 'Pick Minute',
- incrementMinute: 'Increment Minute',
- decrementMinute: 'Decrement Minute',
- pickSecond: 'Pick Second',
- incrementSecond: 'Increment Second',
- decrementSecond: 'Decrement Second',
- togglePeriod: 'Toggle Period',
- selectTime: 'Select Time'
- },
- useStrict: false,
- sideBySide: false,
- daysOfWeekDisabled: false,
- calendarWeeks: false,
- viewMode: 'days',
- toolbarPlacement: 'default',
- showTodayButton: false,
- showClear: false,
- showClose: false,
- widgetPositioning: {
- horizontal: 'auto',
- vertical: 'auto'
- },
- widgetParent: null,
- ignoreReadonly: false,
- keepOpen: false,
- focusOnShow: true,
- inline: false,
- keepInvalid: false,
- datepickerInput: '.datepickerinput',
- keyBinds: {
- up: function up(widget) {
- if (!widget) {
- return;
- }
- var d = this.date() || this.getMoment();
- if (widget.find('.datepicker').is(':visible')) {
- this.date(d.clone().subtract(7, 'd'));
- } else {
- this.date(d.clone().add(this.stepping(), 'm'));
- }
- },
- down: function down(widget) {
- if (!widget) {
- this.show();
- return;
- }
- var d = this.date() || this.getMoment();
- if (widget.find('.datepicker').is(':visible')) {
- this.date(d.clone().add(7, 'd'));
- } else {
- this.date(d.clone().subtract(this.stepping(), 'm'));
- }
- },
- 'control up': function controlUp(widget) {
- if (!widget) {
- return;
- }
- var d = this.date() || this.getMoment();
- if (widget.find('.datepicker').is(':visible')) {
- this.date(d.clone().subtract(1, 'y'));
- } else {
- this.date(d.clone().add(1, 'h'));
- }
- },
- 'control down': function controlDown(widget) {
- if (!widget) {
- return;
- }
- var d = this.date() || this.getMoment();
- if (widget.find('.datepicker').is(':visible')) {
- this.date(d.clone().add(1, 'y'));
- } else {
- this.date(d.clone().subtract(1, 'h'));
- }
- },
- left: function left(widget) {
- if (!widget) {
- return;
- }
- var d = this.date() || this.getMoment();
- if (widget.find('.datepicker').is(':visible')) {
- this.date(d.clone().subtract(1, 'd'));
- }
- },
- right: function right(widget) {
- if (!widget) {
- return;
- }
- var d = this.date() || this.getMoment();
- if (widget.find('.datepicker').is(':visible')) {
- this.date(d.clone().add(1, 'd'));
- }
- },
- pageUp: function pageUp(widget) {
- if (!widget) {
- return;
- }
- var d = this.date() || this.getMoment();
- if (widget.find('.datepicker').is(':visible')) {
- this.date(d.clone().subtract(1, 'M'));
- }
- },
- pageDown: function pageDown(widget) {
- if (!widget) {
- return;
- }
- var d = this.date() || this.getMoment();
- if (widget.find('.datepicker').is(':visible')) {
- this.date(d.clone().add(1, 'M'));
- }
- },
- enter: function enter() {
- this.hide();
- },
- escape: function escape() {
- this.hide();
- },
- // tab: function (widget) { //this break the flow of the form. disabling for now
- // var toggle = widget.find('.picker-switch a[data-action="togglePicker"]');
- // if(toggle.length > 0) toggle.click();
- // },
- 'control space': function controlSpace(widget) {
- if (!widget) {
- return;
- }
- if (widget.find('.timepicker').is(':visible')) {
- widget.find('.btn[data-action="togglePeriod"]').click();
- }
- },
- t: function t() {
- this.date(this.getMoment());
- },
- 'delete': function _delete() {
- this.clear();
- }
- },
- debug: false,
- allowInputToggle: false,
- disabledTimeIntervals: false,
- disabledHours: false,
- enabledHours: false,
- viewDate: false
- };
- return $.fn.datetimepicker;
- });
- /***/ }),
- /***/ 31619:
- /***/ (() => {
- // localStorage
- (function () {
- function isSupported() {
- var item = 'localStoragePollyfill';
- try {
- localStorage.setItem(item, item);
- localStorage.removeItem(item);
- sessionStorage.setItem(item, item);
- sessionStorage.removeItem(item);
- return true;
- } catch (e) {
- return false;
- }
- }
- if (!isSupported()) {
- try {
- Storage.prototype._data = {};
- Storage.prototype.setItem = function (id, val) {
- this._data[id] = String(val);
- return this._data[id];
- };
- Storage.prototype.getItem = function (id) {
- return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
- };
- Storage.prototype.removeItem = function (id) {
- return delete this._data[id];
- };
- Storage.prototype.clear = function () {
- this._data = {};
- return this._data;
- };
- } catch (e) {
- console.error('localStorage pollyfill error: ', e);
- }
- }
- })();
- /***/ }),
- /***/ 46700:
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
- var map = {
- "./af": 42786,
- "./af.js": 42786,
- "./ar": 30867,
- "./ar-dz": 14130,
- "./ar-dz.js": 14130,
- "./ar-kw": 96135,
- "./ar-kw.js": 96135,
- "./ar-ly": 56440,
- "./ar-ly.js": 56440,
- "./ar-ma": 47702,
- "./ar-ma.js": 47702,
- "./ar-sa": 16040,
- "./ar-sa.js": 16040,
- "./ar-tn": 37100,
- "./ar-tn.js": 37100,
- "./ar.js": 30867,
- "./az": 31083,
- "./az.js": 31083,
- "./be": 9808,
- "./be.js": 9808,
- "./bg": 68338,
- "./bg.js": 68338,
- "./bm": 67438,
- "./bm.js": 67438,
- "./bn": 8905,
- "./bn-bd": 76225,
- "./bn-bd.js": 76225,
- "./bn.js": 8905,
- "./bo": 11560,
- "./bo.js": 11560,
- "./br": 1278,
- "./br.js": 1278,
- "./bs": 80622,
- "./bs.js": 80622,
- "./ca": 2468,
- "./ca.js": 2468,
- "./cs": 5822,
- "./cs.js": 5822,
- "./cv": 50877,
- "./cv.js": 50877,
- "./cy": 47373,
- "./cy.js": 47373,
- "./da": 24780,
- "./da.js": 24780,
- "./de": 59740,
- "./de-at": 60217,
- "./de-at.js": 60217,
- "./de-ch": 60894,
- "./de-ch.js": 60894,
- "./de.js": 59740,
- "./dv": 5300,
- "./dv.js": 5300,
- "./el": 50837,
- "./el.js": 50837,
- "./en-au": 78348,
- "./en-au.js": 78348,
- "./en-ca": 77925,
- "./en-ca.js": 77925,
- "./en-gb": 22243,
- "./en-gb.js": 22243,
- "./en-ie": 46436,
- "./en-ie.js": 46436,
- "./en-il": 47207,
- "./en-il.js": 47207,
- "./en-in": 44175,
- "./en-in.js": 44175,
- "./en-nz": 76319,
- "./en-nz.js": 76319,
- "./en-sg": 31662,
- "./en-sg.js": 31662,
- "./eo": 92915,
- "./eo.js": 92915,
- "./es": 55655,
- "./es-do": 55251,
- "./es-do.js": 55251,
- "./es-mx": 96112,
- "./es-mx.js": 96112,
- "./es-us": 71146,
- "./es-us.js": 71146,
- "./es.js": 55655,
- "./et": 5603,
- "./et.js": 5603,
- "./eu": 77763,
- "./eu.js": 77763,
- "./fa": 76959,
- "./fa.js": 76959,
- "./fi": 11897,
- "./fi.js": 11897,
- "./fil": 42549,
- "./fil.js": 42549,
- "./fo": 94694,
- "./fo.js": 94694,
- "./fr": 94470,
- "./fr-ca": 63049,
- "./fr-ca.js": 63049,
- "./fr-ch": 52330,
- "./fr-ch.js": 52330,
- "./fr.js": 94470,
- "./fy": 5044,
- "./fy.js": 5044,
- "./ga": 29295,
- "./ga.js": 29295,
- "./gd": 2101,
- "./gd.js": 2101,
- "./gl": 38794,
- "./gl.js": 38794,
- "./gom-deva": 27884,
- "./gom-deva.js": 27884,
- "./gom-latn": 23168,
- "./gom-latn.js": 23168,
- "./gu": 95349,
- "./gu.js": 95349,
- "./he": 24206,
- "./he.js": 24206,
- "./hi": 30094,
- "./hi.js": 30094,
- "./hr": 30316,
- "./hr.js": 30316,
- "./hu": 22138,
- "./hu.js": 22138,
- "./hy-am": 11423,
- "./hy-am.js": 11423,
- "./id": 29218,
- "./id.js": 29218,
- "./is": 90135,
- "./is.js": 90135,
- "./it": 90626,
- "./it-ch": 10150,
- "./it-ch.js": 10150,
- "./it.js": 90626,
- "./ja": 39183,
- "./ja.js": 39183,
- "./jv": 24286,
- "./jv.js": 24286,
- "./ka": 12105,
- "./ka.js": 12105,
- "./kk": 47772,
- "./kk.js": 47772,
- "./km": 18758,
- "./km.js": 18758,
- "./kn": 79282,
- "./kn.js": 79282,
- "./ko": 33730,
- "./ko.js": 33730,
- "./ku": 1408,
- "./ku.js": 1408,
- "./ky": 33291,
- "./ky.js": 33291,
- "./lb": 36841,
- "./lb.js": 36841,
- "./lo": 55466,
- "./lo.js": 55466,
- "./lt": 57010,
- "./lt.js": 57010,
- "./lv": 37595,
- "./lv.js": 37595,
- "./me": 39861,
- "./me.js": 39861,
- "./mi": 35493,
- "./mi.js": 35493,
- "./mk": 95966,
- "./mk.js": 95966,
- "./ml": 87341,
- "./ml.js": 87341,
- "./mn": 5115,
- "./mn.js": 5115,
- "./mr": 10370,
- "./mr.js": 10370,
- "./ms": 9847,
- "./ms-my": 41237,
- "./ms-my.js": 41237,
- "./ms.js": 9847,
- "./mt": 72126,
- "./mt.js": 72126,
- "./my": 56165,
- "./my.js": 56165,
- "./nb": 64924,
- "./nb.js": 64924,
- "./ne": 16744,
- "./ne.js": 16744,
- "./nl": 93901,
- "./nl-be": 59814,
- "./nl-be.js": 59814,
- "./nl.js": 93901,
- "./nn": 83877,
- "./nn.js": 83877,
- "./oc-lnc": 92135,
- "./oc-lnc.js": 92135,
- "./pa-in": 15858,
- "./pa-in.js": 15858,
- "./pl": 64495,
- "./pl.js": 64495,
- "./pt": 89520,
- "./pt-br": 57971,
- "./pt-br.js": 57971,
- "./pt.js": 89520,
- "./ro": 96459,
- "./ro.js": 96459,
- "./ru": 21793,
- "./ru.js": 21793,
- "./sd": 40950,
- "./sd.js": 40950,
- "./se": 10490,
- "./se.js": 10490,
- "./si": 90124,
- "./si.js": 90124,
- "./sk": 64249,
- "./sk.js": 64249,
- "./sl": 14985,
- "./sl.js": 14985,
- "./sq": 51104,
- "./sq.js": 51104,
- "./sr": 49131,
- "./sr-cyrl": 79915,
- "./sr-cyrl.js": 79915,
- "./sr.js": 49131,
- "./ss": 85893,
- "./ss.js": 85893,
- "./sv": 98760,
- "./sv.js": 98760,
- "./sw": 91172,
- "./sw.js": 91172,
- "./ta": 27333,
- "./ta.js": 27333,
- "./te": 23110,
- "./te.js": 23110,
- "./tet": 52095,
- "./tet.js": 52095,
- "./tg": 27321,
- "./tg.js": 27321,
- "./th": 9041,
- "./th.js": 9041,
- "./tk": 19005,
- "./tk.js": 19005,
- "./tl-ph": 75768,
- "./tl-ph.js": 75768,
- "./tlh": 89444,
- "./tlh.js": 89444,
- "./tr": 72397,
- "./tr.js": 72397,
- "./tzl": 28254,
- "./tzl.js": 28254,
- "./tzm": 51106,
- "./tzm-latn": 30699,
- "./tzm-latn.js": 30699,
- "./tzm.js": 51106,
- "./ug-cn": 9288,
- "./ug-cn.js": 9288,
- "./uk": 67691,
- "./uk.js": 67691,
- "./ur": 13795,
- "./ur.js": 13795,
- "./uz": 6791,
- "./uz-latn": 60588,
- "./uz-latn.js": 60588,
- "./uz.js": 6791,
- "./vi": 65666,
- "./vi.js": 65666,
- "./x-pseudo": 14378,
- "./x-pseudo.js": 14378,
- "./yo": 75805,
- "./yo.js": 75805,
- "./zh-cn": 83839,
- "./zh-cn.js": 83839,
- "./zh-hk": 55726,
- "./zh-hk.js": 55726,
- "./zh-mo": 99807,
- "./zh-mo.js": 99807,
- "./zh-tw": 74152,
- "./zh-tw.js": 74152
- };
- function webpackContext(req) {
- var id = webpackContextResolve(req);
- return __webpack_require__(id);
- }
- function webpackContextResolve(req) {
- if(!__webpack_require__.o(map, req)) {
- var e = new Error("Cannot find module '" + req + "'");
- e.code = 'MODULE_NOT_FOUND';
- throw e;
- }
- return map[req];
- }
- webpackContext.keys = function webpackContextKeys() {
- return Object.keys(map);
- };
- webpackContext.resolve = webpackContextResolve;
- module.exports = webpackContext;
- webpackContext.id = 46700;
- /***/ }),
- /***/ 56089:
- /***/ ((module) => {
- "use strict";
- module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==";
- /***/ }),
- /***/ 17735:
- /***/ ((module) => {
- "use strict";
- module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=";
- /***/ }),
- /***/ 96192:
- /***/ ((module) => {
- "use strict";
- module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC";
- /***/ }),
- /***/ 71090:
- /***/ ((module) => {
- "use strict";
- module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=";
- /***/ }),
- /***/ 46050:
- /***/ ((module) => {
- "use strict";
- module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=";
- /***/ }),
- /***/ 65311:
- /***/ ((module) => {
- "use strict";
- module.exports = jQuery;
- /***/ })
- /******/ });
- /************************************************************************/
- /******/ // The module cache
- /******/ var __webpack_module_cache__ = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/ // Check if module is in cache
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
- /******/ if (cachedModule !== undefined) {
- /******/ return cachedModule.exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = __webpack_module_cache__[moduleId] = {
- /******/ id: moduleId,
- /******/ loaded: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.loaded = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = __webpack_modules__;
- /******/
- /************************************************************************/
- /******/ /* webpack/runtime/amd define */
- /******/ (() => {
- /******/ __webpack_require__.amdD = function () {
- /******/ throw new Error('define cannot be used indirect');
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/chunk loaded */
- /******/ (() => {
- /******/ var deferred = [];
- /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
- /******/ if(chunkIds) {
- /******/ priority = priority || 0;
- /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
- /******/ deferred[i] = [chunkIds, fn, priority];
- /******/ return;
- /******/ }
- /******/ var notFulfilled = Infinity;
- /******/ for (var i = 0; i < deferred.length; i++) {
- /******/ var [chunkIds, fn, priority] = deferred[i];
- /******/ var fulfilled = true;
- /******/ for (var j = 0; j < chunkIds.length; j++) {
- /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
- /******/ chunkIds.splice(j--, 1);
- /******/ } else {
- /******/ fulfilled = false;
- /******/ if(priority < notFulfilled) notFulfilled = priority;
- /******/ }
- /******/ }
- /******/ if(fulfilled) {
- /******/ deferred.splice(i--, 1)
- /******/ var r = fn();
- /******/ if (r !== undefined) result = r;
- /******/ }
- /******/ }
- /******/ return result;
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/compat get default export */
- /******/ (() => {
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = (module) => {
- /******/ var getter = module && module.__esModule ?
- /******/ () => (module['default']) :
- /******/ () => (module);
- /******/ __webpack_require__.d(getter, { a: getter });
- /******/ return getter;
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/define property getters */
- /******/ (() => {
- /******/ // define getter functions for harmony exports
- /******/ __webpack_require__.d = (exports, definition) => {
- /******/ for(var key in definition) {
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
- /******/ }
- /******/ }
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/global */
- /******/ (() => {
- /******/ __webpack_require__.g = (function() {
- /******/ if (typeof globalThis === 'object') return globalThis;
- /******/ try {
- /******/ return this || new Function('return this')();
- /******/ } catch (e) {
- /******/ if (typeof window === 'object') return window;
- /******/ }
- /******/ })();
- /******/ })();
- /******/
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
- /******/ (() => {
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
- /******/ })();
- /******/
- /******/ /* webpack/runtime/make namespace object */
- /******/ (() => {
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = (exports) => {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/node module decorator */
- /******/ (() => {
- /******/ __webpack_require__.nmd = (module) => {
- /******/ module.paths = [];
- /******/ if (!module.children) module.children = [];
- /******/ return module;
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/jsonp chunk loading */
- /******/ (() => {
- /******/ __webpack_require__.b = document.baseURI || self.location.href;
- /******/
- /******/ // object to store loaded and loading chunks
- /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
- /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
- /******/ var installedChunks = {
- /******/ 328: 0
- /******/ };
- /******/
- /******/ // no chunk on demand loading
- /******/
- /******/ // no prefetching
- /******/
- /******/ // no preloaded
- /******/
- /******/ // no HMR
- /******/
- /******/ // no HMR manifest
- /******/
- /******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
- /******/
- /******/ // install a JSONP callback for chunk loading
- /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
- /******/ var [chunkIds, moreModules, runtime] = data;
- /******/ // add "moreModules" to the modules object,
- /******/ // then flag all "chunkIds" as loaded and fire callback
- /******/ var moduleId, chunkId, i = 0;
- /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
- /******/ for(moduleId in moreModules) {
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
- /******/ }
- /******/ }
- /******/ if(runtime) var result = runtime(__webpack_require__);
- /******/ }
- /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
- /******/ for(;i < chunkIds.length; i++) {
- /******/ chunkId = chunkIds[i];
- /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
- /******/ installedChunks[chunkId][0]();
- /******/ }
- /******/ installedChunks[chunkId] = 0;
- /******/ }
- /******/ return __webpack_require__.O(result);
- /******/ }
- /******/
- /******/ var chunkLoadingGlobal = self["webpackChunkGrav"] = self["webpackChunkGrav"] || [];
- /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
- /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
- /******/ })();
- /******/
- /************************************************************************/
- /******/
- /******/ // startup
- /******/ // Load entry module and return exports
- /******/ // This entry module depends on other loaded chunks and execution need to be delayed
- /******/ var __webpack_exports__ = __webpack_require__.O(undefined, [736], () => (__webpack_require__(56299)))
- /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
- /******/ Grav = __webpack_exports__;
- /******/
- /******/ })()
- ;
|