12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055 |
- var Grav;
- /******/ (() => { // webpackBootstrap
- /******/ var __webpack_modules__ = ({
- /***/ 40535:
- /***/ ((__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__(73609);
- 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.esm.js + 1 modules
- var simplebar_esm = __webpack_require__(56884);
- // 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;
- });
- // 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"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
- 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); 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 } }); 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; } 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';
- _classCallCheck(this, GPM);
- _this = _super.call(this);
- _this.payload = {};
- _this.raw = {};
- _this.action = action;
- return _this;
- }
- _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 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); 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/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/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); 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); 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');
- 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); 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;
- 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
- 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') {
- 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"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { chart_typeof = function _typeof(obj) { return typeof obj; }; } else { chart_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return chart_typeof(obj); }
- function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
- 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 } }); 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; } 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); 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);
- });
- 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); 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__(92511);
- ;// 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); 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"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { filter_typeof = function _typeof(obj) { return typeof obj; }; } else { filter_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return filter_typeof(obj); }
- 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); 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) {
- return getFields('title', event.currentTarget).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');
- });
- // EXTERNAL MODULE: ./node_modules/dropzone/dist/dropzone.js
- var dist_dropzone = __webpack_require__(32025);
- var dropzone_default = /*#__PURE__*/__webpack_require__.n(dist_dropzone);
- ;// CONCATENATED MODULE: ./app/forms/fields/files.js
- function files_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function files_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function files_createClass(Constructor, protoProps, staticProps) { if (protoProps) files_defineProperties(Constructor.prototype, protoProps); if (staticProps) files_defineProperties(Constructor, staticProps); 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) {
- 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;
- files_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('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));
- });
- }
- files_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>").concat(file.name, "</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>").concat(file.name, "</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: "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"]');
- modal.find('.error-content').html(msg);
- (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 files_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;
- }();
- ;// 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__(47180);
- // 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); 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"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { media_typeof = function _typeof(obj) { return typeof obj; }; } else { media_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return media_typeof(obj); }
- 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); return Constructor; }
- function media_get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { media_get = Reflect.get; } else { media_get = function _get(target, property, receiver) { var base = media_superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return media_get(target, property, receiver || target); }
- 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 } }); 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; } 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.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
- external_jQuery_default()('.dz-preview').prop('draggable', 'true');
- }
- }, {
- key: "onDropzoneRemovedFile",
- value: function onDropzoneRemovedFile(file) {
- var _get2;
- for (var _len = arguments.length, extra = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- extra[_key - 1] = arguments[_key];
- }
- (_get2 = media_get(media_getPrototypeOf(PageMedia.prototype), "onDropzoneRemovedFile", this)).call.apply(_get2, [this, file].concat(extra));
- if (this.sortable) {
- this.sortable.options.onSort();
- }
- }
- }, {
- 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 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(__webpack_require__.g.decodeURI(filename), ".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(filename);
- 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) {
- container.append("<li><strong>".concat(meta ? meta + ':' : '', "</strong> ").concat(fileObj.metadata[meta], "</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 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.js
- var immutable = __webpack_require__(43393);
- var immutable_default = /*#__PURE__*/__webpack_require__.n(immutable);
- // 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); 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_default().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_default().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); 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); 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 onLoad()
- /* data */
- {
- 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); 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); 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); return Constructor; }
- var CollectionsField = /*#__PURE__*/function () {
- function CollectionsField() {
- var _this = this;
- collections_classCallCheck(this, CollectionsField);
- this.lists = external_jQuery_default()();
- external_jQuery_default()('[data-type="collection"]').each(function (index, list) {
- return _this.addList(list);
- });
- external_jQuery_default()('body').on('mutation._grav', this._onAddedNodes.bind(this));
- }
- 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="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: "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'].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);
- }
- }
- }]);
- return CollectionsField;
- }();
- var collections_Instance = new CollectionsField();
- // EXTERNAL MODULE: ./app/utils/bootstrap-datetimepicker.js
- var bootstrap_datetimepicker = __webpack_require__(36531);
- ;// 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); 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); 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); 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); 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"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { cron_ui_typeof = function _typeof(obj) { return typeof obj; }; } else { cron_ui_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return cron_ui_typeof(obj); }
- /* 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); 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"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { finderjs_typeof = function _typeof(obj) { return typeof obj; }; } else { finderjs_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return finderjs_typeof(obj); }
- 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); 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); 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/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: files_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/cookies.js
- function cookies_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { cookies_typeof = function _typeof(obj) { return typeof obj; }; } else { cookies_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return cookies_typeof(obj); }
- /*
- * 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) {
- alert('a');
- 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);
- // EXTERNAL MODULE: ./node_modules/es6-promise/dist/es6-promise.js
- var es6_promise = __webpack_require__(82702);
- ;// 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); 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 || external_jQuery_default()('[data-gpm-plugin], [data-gpm-theme]');
- this.container = container || external_jQuery_default()('.gpm-plugins > table > tbody, .gpm-themes > .themes.card-row');
- return this.elements;
- }
- }, {
- key: "byCommon",
- value: function byCommon() {
- 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().sort(function (a, b) {
- var A = external_jQuery_default()(a).data(data).toString().toLowerCase();
- var B = external_jQuery_default()(b).data(data).toString().toLowerCase();
- return Sorter.sort(A, B, direction);
- });
- return elements.appendTo(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] : 'gpm-name';
- 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] : 'gpm-author';
- 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] : 'gpm-official';
- return this.byCommon(direction, data);
- }
- }, {
- key: "byReleaseDate",
- value: function byReleaseDate() {
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asc';
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gpm-release-date';
- var elements = this.getElements().sort(function (a, b) {
- var A = new Date(external_jQuery_default()(a).data(data)).getTime();
- var B = new Date(external_jQuery_default()(b).data(data)).getTime();
- return Sorter.sort(A, B, direction === 'asc' ? 'desc' : 'asc');
- });
- elements.appendTo(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] : 'gpm-updatable';
- 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] : 'gpm-enabled';
- 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] : 'gpm-testing';
- return this.byCommon(direction, data);
- }
- }], [{
- 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 _this = 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) {
- _this.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 _this2 = 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) {
- _this2.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);
- es6_promise.Promise.all(slugs.map(function (slug) {
- return new es6_promise.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 = 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 _this3 = 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');
- _this3.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 = 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); 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"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { bootstrap_collapse_typeof = function _typeof(obj) { return typeof obj; }; } else { bootstrap_collapse_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return bootstrap_collapse_typeof(obj); }
- /* ========================================================================
- * 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('');
- });
- // EXTERNAL MODULE: ./node_modules/es6-map/index.js
- var es6_map = __webpack_require__(1520);
- var es6_map_default = /*#__PURE__*/__webpack_require__.n(es6_map);
- ;// 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); 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 (es6_map_default())();
- 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 quickOpenIn()
- /* event */
- {
- 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 quickOpenOut()
- /* event */
- {
- 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: 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
- }
- });
- /***/ }),
- /***/ 36531:
- /***/ ((module, exports, __webpack_require__) => {
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
- /*! 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__(73609), __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;
- });
- /***/ }),
- /***/ 92511:
- /***/ (() => {
- // 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": 34082,
- "./sl.js": 34082,
- "./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": 44257,
- "./tg.js": 44257,
- "./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;
- /***/ }),
- /***/ 73609:
- /***/ ((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)
- /******/ result = fn();
- /******/ }
- /******/ }
- /******/ 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 */
- /******/ (() => {
- /******/ // no baseURI
- /******/
- /******/ // 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;
- /******/ 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[chunkIds[i]] = 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__(40535)))
- /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
- /******/ Grav = __webpack_exports__;
- /******/
- /******/ })()
- ;
|