No Description

acf.js 97KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ "./src/advanced-custom-fields-pro/assets/src/js/_acf-hooks.js":
  4. /*!********************************************************************!*\
  5. !*** ./src/advanced-custom-fields-pro/assets/src/js/_acf-hooks.js ***!
  6. \********************************************************************/
  7. /***/ (function() {
  8. (function (window, undefined) {
  9. 'use strict';
  10. /**
  11. * Handles managing all events for whatever you plug it into. Priorities for hooks are based on lowest to highest in
  12. * that, lowest priority hooks are fired first.
  13. */
  14. var EventManager = function () {
  15. /**
  16. * Maintain a reference to the object scope so our public methods never get confusing.
  17. */
  18. var MethodsAvailable = {
  19. removeFilter: removeFilter,
  20. applyFilters: applyFilters,
  21. addFilter: addFilter,
  22. removeAction: removeAction,
  23. doAction: doAction,
  24. addAction: addAction,
  25. storage: getStorage
  26. };
  27. /**
  28. * Contains the hooks that get registered with this EventManager. The array for storage utilizes a "flat"
  29. * object literal such that looking up the hook utilizes the native object literal hash.
  30. */
  31. var STORAGE = {
  32. actions: {},
  33. filters: {}
  34. };
  35. function getStorage() {
  36. return STORAGE;
  37. }
  38. /**
  39. * Adds an action to the event manager.
  40. *
  41. * @param action Must contain namespace.identifier
  42. * @param callback Must be a valid callback function before this action is added
  43. * @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
  44. * @param [context] Supply a value to be used for this
  45. */
  46. function addAction(action, callback, priority, context) {
  47. if (typeof action === 'string' && typeof callback === 'function') {
  48. priority = parseInt(priority || 10, 10);
  49. _addHook('actions', action, callback, priority, context);
  50. }
  51. return MethodsAvailable;
  52. }
  53. /**
  54. * Performs an action if it exists. You can pass as many arguments as you want to this function; the only rule is
  55. * that the first argument must always be the action.
  56. */
  57. function doAction() {
  58. var args = Array.prototype.slice.call(arguments);
  59. var action = args.shift();
  60. if (typeof action === 'string') {
  61. _runHook('actions', action, args);
  62. }
  63. return MethodsAvailable;
  64. }
  65. /**
  66. * Removes the specified action if it contains a namespace.identifier & exists.
  67. *
  68. * @param action The action to remove
  69. * @param [callback] Callback function to remove
  70. */
  71. function removeAction(action, callback) {
  72. if (typeof action === 'string') {
  73. _removeHook('actions', action, callback);
  74. }
  75. return MethodsAvailable;
  76. }
  77. /**
  78. * Adds a filter to the event manager.
  79. *
  80. * @param filter Must contain namespace.identifier
  81. * @param callback Must be a valid callback function before this action is added
  82. * @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
  83. * @param [context] Supply a value to be used for this
  84. */
  85. function addFilter(filter, callback, priority, context) {
  86. if (typeof filter === 'string' && typeof callback === 'function') {
  87. priority = parseInt(priority || 10, 10);
  88. _addHook('filters', filter, callback, priority, context);
  89. }
  90. return MethodsAvailable;
  91. }
  92. /**
  93. * Performs a filter if it exists. You should only ever pass 1 argument to be filtered. The only rule is that
  94. * the first argument must always be the filter.
  95. */
  96. function applyFilters() {
  97. var args = Array.prototype.slice.call(arguments);
  98. var filter = args.shift();
  99. if (typeof filter === 'string') {
  100. return _runHook('filters', filter, args);
  101. }
  102. return MethodsAvailable;
  103. }
  104. /**
  105. * Removes the specified filter if it contains a namespace.identifier & exists.
  106. *
  107. * @param filter The action to remove
  108. * @param [callback] Callback function to remove
  109. */
  110. function removeFilter(filter, callback) {
  111. if (typeof filter === 'string') {
  112. _removeHook('filters', filter, callback);
  113. }
  114. return MethodsAvailable;
  115. }
  116. /**
  117. * Removes the specified hook by resetting the value of it.
  118. *
  119. * @param type Type of hook, either 'actions' or 'filters'
  120. * @param hook The hook (namespace.identifier) to remove
  121. * @private
  122. */
  123. function _removeHook(type, hook, callback, context) {
  124. if (!STORAGE[type][hook]) {
  125. return;
  126. }
  127. if (!callback) {
  128. STORAGE[type][hook] = [];
  129. } else {
  130. var handlers = STORAGE[type][hook];
  131. var i;
  132. if (!context) {
  133. for (i = handlers.length; i--;) {
  134. if (handlers[i].callback === callback) {
  135. handlers.splice(i, 1);
  136. }
  137. }
  138. } else {
  139. for (i = handlers.length; i--;) {
  140. var handler = handlers[i];
  141. if (handler.callback === callback && handler.context === context) {
  142. handlers.splice(i, 1);
  143. }
  144. }
  145. }
  146. }
  147. }
  148. /**
  149. * Adds the hook to the appropriate storage container
  150. *
  151. * @param type 'actions' or 'filters'
  152. * @param hook The hook (namespace.identifier) to add to our event manager
  153. * @param callback The function that will be called when the hook is executed.
  154. * @param priority The priority of this hook. Must be an integer.
  155. * @param [context] A value to be used for this
  156. * @private
  157. */
  158. function _addHook(type, hook, callback, priority, context) {
  159. var hookObject = {
  160. callback: callback,
  161. priority: priority,
  162. context: context
  163. }; // Utilize 'prop itself' : http://jsperf.com/hasownproperty-vs-in-vs-undefined/19
  164. var hooks = STORAGE[type][hook];
  165. if (hooks) {
  166. hooks.push(hookObject);
  167. hooks = _hookInsertSort(hooks);
  168. } else {
  169. hooks = [hookObject];
  170. }
  171. STORAGE[type][hook] = hooks;
  172. }
  173. /**
  174. * Use an insert sort for keeping our hooks organized based on priority. This function is ridiculously faster
  175. * than bubble sort, etc: http://jsperf.com/javascript-sort
  176. *
  177. * @param hooks The custom array containing all of the appropriate hooks to perform an insert sort on.
  178. * @private
  179. */
  180. function _hookInsertSort(hooks) {
  181. var tmpHook, j, prevHook;
  182. for (var i = 1, len = hooks.length; i < len; i++) {
  183. tmpHook = hooks[i];
  184. j = i;
  185. while ((prevHook = hooks[j - 1]) && prevHook.priority > tmpHook.priority) {
  186. hooks[j] = hooks[j - 1];
  187. --j;
  188. }
  189. hooks[j] = tmpHook;
  190. }
  191. return hooks;
  192. }
  193. /**
  194. * Runs the specified hook. If it is an action, the value is not modified but if it is a filter, it is.
  195. *
  196. * @param type 'actions' or 'filters'
  197. * @param hook The hook ( namespace.identifier ) to be ran.
  198. * @param args Arguments to pass to the action/filter. If it's a filter, args is actually a single parameter.
  199. * @private
  200. */
  201. function _runHook(type, hook, args) {
  202. var handlers = STORAGE[type][hook];
  203. if (!handlers) {
  204. return type === 'filters' ? args[0] : false;
  205. }
  206. var i = 0,
  207. len = handlers.length;
  208. if (type === 'filters') {
  209. for (; i < len; i++) {
  210. args[0] = handlers[i].callback.apply(handlers[i].context, args);
  211. }
  212. } else {
  213. for (; i < len; i++) {
  214. handlers[i].callback.apply(handlers[i].context, args);
  215. }
  216. }
  217. return type === 'filters' ? args[0] : true;
  218. } // return all of the publicly available methods
  219. return MethodsAvailable;
  220. }; // instantiate
  221. acf.hooks = new EventManager();
  222. })(window);
  223. /***/ }),
  224. /***/ "./src/advanced-custom-fields-pro/assets/src/js/_acf-modal.js":
  225. /*!********************************************************************!*\
  226. !*** ./src/advanced-custom-fields-pro/assets/src/js/_acf-modal.js ***!
  227. \********************************************************************/
  228. /***/ (function() {
  229. (function ($, undefined) {
  230. acf.models.Modal = acf.Model.extend({
  231. data: {
  232. title: '',
  233. content: '',
  234. toolbar: ''
  235. },
  236. events: {
  237. 'click .acf-modal-close': 'onClickClose'
  238. },
  239. setup: function (props) {
  240. $.extend(this.data, props);
  241. this.$el = $();
  242. this.render();
  243. },
  244. initialize: function () {
  245. this.open();
  246. },
  247. render: function () {
  248. // Extract vars.
  249. var title = this.get('title');
  250. var content = this.get('content');
  251. var toolbar = this.get('toolbar'); // Create element.
  252. var $el = $(['<div>', '<div class="acf-modal">', '<div class="acf-modal-title">', '<h2>' + title + '</h2>', '<button class="acf-modal-close" type="button"><span class="dashicons dashicons-no"></span></button>', '</div>', '<div class="acf-modal-content">' + content + '</div>', '<div class="acf-modal-toolbar">' + toolbar + '</div>', '</div>', '<div class="acf-modal-backdrop acf-modal-close"></div>', '</div>'].join('')); // Update DOM.
  253. if (this.$el) {
  254. this.$el.replaceWith($el);
  255. }
  256. this.$el = $el; // Trigger action.
  257. acf.doAction('append', $el);
  258. },
  259. update: function (props) {
  260. this.data = acf.parseArgs(props, this.data);
  261. this.render();
  262. },
  263. title: function (title) {
  264. this.$('.acf-modal-title h2').html(title);
  265. },
  266. content: function (content) {
  267. this.$('.acf-modal-content').html(content);
  268. },
  269. toolbar: function (toolbar) {
  270. this.$('.acf-modal-toolbar').html(toolbar);
  271. },
  272. open: function () {
  273. $('body').append(this.$el);
  274. },
  275. close: function () {
  276. this.remove();
  277. },
  278. onClickClose: function (e, $el) {
  279. e.preventDefault();
  280. this.close();
  281. }
  282. });
  283. /**
  284. * Returns a new modal.
  285. *
  286. * @date 21/4/20
  287. * @since 5.9.0
  288. *
  289. * @param object props The modal props.
  290. * @return object
  291. */
  292. acf.newModal = function (props) {
  293. return new acf.models.Modal(props);
  294. };
  295. })(jQuery);
  296. /***/ }),
  297. /***/ "./src/advanced-custom-fields-pro/assets/src/js/_acf-model.js":
  298. /*!********************************************************************!*\
  299. !*** ./src/advanced-custom-fields-pro/assets/src/js/_acf-model.js ***!
  300. \********************************************************************/
  301. /***/ (function() {
  302. (function ($, undefined) {
  303. // Cached regex to split keys for `addEvent`.
  304. var delegateEventSplitter = /^(\S+)\s*(.*)$/;
  305. /**
  306. * extend
  307. *
  308. * Helper function to correctly set up the prototype chain for subclasses
  309. * Heavily inspired by backbone.js
  310. *
  311. * @date 14/12/17
  312. * @since 5.6.5
  313. *
  314. * @param object protoProps New properties for this object.
  315. * @return function.
  316. */
  317. var extend = function (protoProps) {
  318. // vars
  319. var Parent = this;
  320. var Child; // The constructor function for the new subclass is either defined by you
  321. // (the "constructor" property in your `extend` definition), or defaulted
  322. // by us to simply call the parent constructor.
  323. if (protoProps && protoProps.hasOwnProperty('constructor')) {
  324. Child = protoProps.constructor;
  325. } else {
  326. Child = function () {
  327. return Parent.apply(this, arguments);
  328. };
  329. } // Add static properties to the constructor function, if supplied.
  330. $.extend(Child, Parent); // Set the prototype chain to inherit from `parent`, without calling
  331. // `parent`'s constructor function and add the prototype properties.
  332. Child.prototype = Object.create(Parent.prototype);
  333. $.extend(Child.prototype, protoProps);
  334. Child.prototype.constructor = Child; // Set a convenience property in case the parent's prototype is needed later.
  335. //Child.prototype.__parent__ = Parent.prototype;
  336. // return
  337. return Child;
  338. };
  339. /**
  340. * Model
  341. *
  342. * Base class for all inheritence
  343. *
  344. * @date 14/12/17
  345. * @since 5.6.5
  346. *
  347. * @param object props
  348. * @return function.
  349. */
  350. var Model = acf.Model = function () {
  351. // generate uique client id
  352. this.cid = acf.uniqueId('acf'); // set vars to avoid modifying prototype
  353. this.data = $.extend(true, {}, this.data); // pass props to setup function
  354. this.setup.apply(this, arguments); // store on element (allow this.setup to create this.$el)
  355. if (this.$el && !this.$el.data('acf')) {
  356. this.$el.data('acf', this);
  357. } // initialize
  358. var initialize = function () {
  359. this.initialize();
  360. this.addEvents();
  361. this.addActions();
  362. this.addFilters();
  363. }; // initialize on action
  364. if (this.wait && !acf.didAction(this.wait)) {
  365. this.addAction(this.wait, initialize); // initialize now
  366. } else {
  367. initialize.apply(this);
  368. }
  369. }; // Attach all inheritable methods to the Model prototype.
  370. $.extend(Model.prototype, {
  371. // Unique model id
  372. id: '',
  373. // Unique client id
  374. cid: '',
  375. // jQuery element
  376. $el: null,
  377. // Data specific to this instance
  378. data: {},
  379. // toggle used when changing data
  380. busy: false,
  381. changed: false,
  382. // Setup events hooks
  383. events: {},
  384. actions: {},
  385. filters: {},
  386. // class used to avoid nested event triggers
  387. eventScope: '',
  388. // action to wait until initialize
  389. wait: false,
  390. // action priority default
  391. priority: 10,
  392. /**
  393. * get
  394. *
  395. * Gets a specific data value
  396. *
  397. * @date 14/12/17
  398. * @since 5.6.5
  399. *
  400. * @param string name
  401. * @return mixed
  402. */
  403. get: function (name) {
  404. return this.data[name];
  405. },
  406. /**
  407. * has
  408. *
  409. * Returns `true` if the data exists and is not null
  410. *
  411. * @date 14/12/17
  412. * @since 5.6.5
  413. *
  414. * @param string name
  415. * @return boolean
  416. */
  417. has: function (name) {
  418. return this.get(name) != null;
  419. },
  420. /**
  421. * set
  422. *
  423. * Sets a specific data value
  424. *
  425. * @date 14/12/17
  426. * @since 5.6.5
  427. *
  428. * @param string name
  429. * @param mixed value
  430. * @return this
  431. */
  432. set: function (name, value, silent) {
  433. // bail if unchanged
  434. var prevValue = this.get(name);
  435. if (prevValue == value) {
  436. return this;
  437. } // set data
  438. this.data[name] = value; // trigger events
  439. if (!silent) {
  440. this.changed = true;
  441. this.trigger('changed:' + name, [value, prevValue]);
  442. this.trigger('changed', [name, value, prevValue]);
  443. } // return
  444. return this;
  445. },
  446. /**
  447. * inherit
  448. *
  449. * Inherits the data from a jQuery element
  450. *
  451. * @date 14/12/17
  452. * @since 5.6.5
  453. *
  454. * @param jQuery $el
  455. * @return this
  456. */
  457. inherit: function (data) {
  458. // allow jQuery
  459. if (data instanceof jQuery) {
  460. data = data.data();
  461. } // extend
  462. $.extend(this.data, data); // return
  463. return this;
  464. },
  465. /**
  466. * prop
  467. *
  468. * mimics the jQuery prop function
  469. *
  470. * @date 4/6/18
  471. * @since 5.6.9
  472. *
  473. * @param type $var Description. Default.
  474. * @return type Description.
  475. */
  476. prop: function () {
  477. return this.$el.prop.apply(this.$el, arguments);
  478. },
  479. /**
  480. * setup
  481. *
  482. * Run during constructor function
  483. *
  484. * @date 14/12/17
  485. * @since 5.6.5
  486. *
  487. * @param n/a
  488. * @return n/a
  489. */
  490. setup: function (props) {
  491. $.extend(this, props);
  492. },
  493. /**
  494. * initialize
  495. *
  496. * Also run during constructor function
  497. *
  498. * @date 14/12/17
  499. * @since 5.6.5
  500. *
  501. * @param n/a
  502. * @return n/a
  503. */
  504. initialize: function () {},
  505. /**
  506. * addElements
  507. *
  508. * Adds multiple jQuery elements to this object
  509. *
  510. * @date 9/5/18
  511. * @since 5.6.9
  512. *
  513. * @param type $var Description. Default.
  514. * @return type Description.
  515. */
  516. addElements: function (elements) {
  517. elements = elements || this.elements || null;
  518. if (!elements || !Object.keys(elements).length) return false;
  519. for (var i in elements) {
  520. this.addElement(i, elements[i]);
  521. }
  522. },
  523. /**
  524. * addElement
  525. *
  526. * description
  527. *
  528. * @date 9/5/18
  529. * @since 5.6.9
  530. *
  531. * @param type $var Description. Default.
  532. * @return type Description.
  533. */
  534. addElement: function (name, selector) {
  535. this['$' + name] = this.$(selector);
  536. },
  537. /**
  538. * addEvents
  539. *
  540. * Adds multiple event handlers
  541. *
  542. * @date 14/12/17
  543. * @since 5.6.5
  544. *
  545. * @param object events {event1 : callback, event2 : callback, etc }
  546. * @return n/a
  547. */
  548. addEvents: function (events) {
  549. events = events || this.events || null;
  550. if (!events) return false;
  551. for (var key in events) {
  552. var match = key.match(delegateEventSplitter);
  553. this.on(match[1], match[2], events[key]);
  554. }
  555. },
  556. /**
  557. * removeEvents
  558. *
  559. * Removes multiple event handlers
  560. *
  561. * @date 14/12/17
  562. * @since 5.6.5
  563. *
  564. * @param object events {event1 : callback, event2 : callback, etc }
  565. * @return n/a
  566. */
  567. removeEvents: function (events) {
  568. events = events || this.events || null;
  569. if (!events) return false;
  570. for (var key in events) {
  571. var match = key.match(delegateEventSplitter);
  572. this.off(match[1], match[2], events[key]);
  573. }
  574. },
  575. /**
  576. * getEventTarget
  577. *
  578. * Returns a jQUery element to tigger an event on
  579. *
  580. * @date 5/6/18
  581. * @since 5.6.9
  582. *
  583. * @param jQuery $el The default jQuery element. Optional.
  584. * @param string event The event name. Optional.
  585. * @return jQuery
  586. */
  587. getEventTarget: function ($el, event) {
  588. return $el || this.$el || $(document);
  589. },
  590. /**
  591. * validateEvent
  592. *
  593. * Returns true if the event target's closest $el is the same as this.$el
  594. * Requires both this.el and this.$el to be defined
  595. *
  596. * @date 5/6/18
  597. * @since 5.6.9
  598. *
  599. * @param type $var Description. Default.
  600. * @return type Description.
  601. */
  602. validateEvent: function (e) {
  603. if (this.eventScope) {
  604. return $(e.target).closest(this.eventScope).is(this.$el);
  605. } else {
  606. return true;
  607. }
  608. },
  609. /**
  610. * proxyEvent
  611. *
  612. * Returns a new event callback function scoped to this model
  613. *
  614. * @date 29/3/18
  615. * @since 5.6.9
  616. *
  617. * @param function callback
  618. * @return function
  619. */
  620. proxyEvent: function (callback) {
  621. return this.proxy(function (e) {
  622. // validate
  623. if (!this.validateEvent(e)) {
  624. return;
  625. } // construct args
  626. var args = acf.arrayArgs(arguments);
  627. var extraArgs = args.slice(1);
  628. var eventArgs = [e, $(e.currentTarget)].concat(extraArgs); // callback
  629. callback.apply(this, eventArgs);
  630. });
  631. },
  632. /**
  633. * on
  634. *
  635. * Adds an event handler similar to jQuery
  636. * Uses the instance 'cid' to namespace event
  637. *
  638. * @date 14/12/17
  639. * @since 5.6.5
  640. *
  641. * @param string name
  642. * @param string callback
  643. * @return n/a
  644. */
  645. on: function (a1, a2, a3, a4) {
  646. // vars
  647. var $el, event, selector, callback, args; // find args
  648. if (a1 instanceof jQuery) {
  649. // 1. args( $el, event, selector, callback )
  650. if (a4) {
  651. $el = a1;
  652. event = a2;
  653. selector = a3;
  654. callback = a4; // 2. args( $el, event, callback )
  655. } else {
  656. $el = a1;
  657. event = a2;
  658. callback = a3;
  659. }
  660. } else {
  661. // 3. args( event, selector, callback )
  662. if (a3) {
  663. event = a1;
  664. selector = a2;
  665. callback = a3; // 4. args( event, callback )
  666. } else {
  667. event = a1;
  668. callback = a2;
  669. }
  670. } // element
  671. $el = this.getEventTarget($el); // modify callback
  672. if (typeof callback === 'string') {
  673. callback = this.proxyEvent(this[callback]);
  674. } // modify event
  675. event = event + '.' + this.cid; // args
  676. if (selector) {
  677. args = [event, selector, callback];
  678. } else {
  679. args = [event, callback];
  680. } // on()
  681. $el.on.apply($el, args);
  682. },
  683. /**
  684. * off
  685. *
  686. * Removes an event handler similar to jQuery
  687. *
  688. * @date 14/12/17
  689. * @since 5.6.5
  690. *
  691. * @param string name
  692. * @param string callback
  693. * @return n/a
  694. */
  695. off: function (a1, a2, a3) {
  696. // vars
  697. var $el, event, selector, args; // find args
  698. if (a1 instanceof jQuery) {
  699. // 1. args( $el, event, selector )
  700. if (a3) {
  701. $el = a1;
  702. event = a2;
  703. selector = a3; // 2. args( $el, event )
  704. } else {
  705. $el = a1;
  706. event = a2;
  707. }
  708. } else {
  709. // 3. args( event, selector )
  710. if (a2) {
  711. event = a1;
  712. selector = a2; // 4. args( event )
  713. } else {
  714. event = a1;
  715. }
  716. } // element
  717. $el = this.getEventTarget($el); // modify event
  718. event = event + '.' + this.cid; // args
  719. if (selector) {
  720. args = [event, selector];
  721. } else {
  722. args = [event];
  723. } // off()
  724. $el.off.apply($el, args);
  725. },
  726. /**
  727. * trigger
  728. *
  729. * Triggers an event similar to jQuery
  730. *
  731. * @date 14/12/17
  732. * @since 5.6.5
  733. *
  734. * @param string name
  735. * @param string callback
  736. * @return n/a
  737. */
  738. trigger: function (name, args, bubbles) {
  739. var $el = this.getEventTarget();
  740. if (bubbles) {
  741. $el.trigger.apply($el, arguments);
  742. } else {
  743. $el.triggerHandler.apply($el, arguments);
  744. }
  745. return this;
  746. },
  747. /**
  748. * addActions
  749. *
  750. * Adds multiple action handlers
  751. *
  752. * @date 14/12/17
  753. * @since 5.6.5
  754. *
  755. * @param object actions {action1 : callback, action2 : callback, etc }
  756. * @return n/a
  757. */
  758. addActions: function (actions) {
  759. actions = actions || this.actions || null;
  760. if (!actions) return false;
  761. for (var i in actions) {
  762. this.addAction(i, actions[i]);
  763. }
  764. },
  765. /**
  766. * removeActions
  767. *
  768. * Removes multiple action handlers
  769. *
  770. * @date 14/12/17
  771. * @since 5.6.5
  772. *
  773. * @param object actions {action1 : callback, action2 : callback, etc }
  774. * @return n/a
  775. */
  776. removeActions: function (actions) {
  777. actions = actions || this.actions || null;
  778. if (!actions) return false;
  779. for (var i in actions) {
  780. this.removeAction(i, actions[i]);
  781. }
  782. },
  783. /**
  784. * addAction
  785. *
  786. * Adds an action using the wp.hooks library
  787. *
  788. * @date 14/12/17
  789. * @since 5.6.5
  790. *
  791. * @param string name
  792. * @param string callback
  793. * @return n/a
  794. */
  795. addAction: function (name, callback, priority) {
  796. //console.log('addAction', name, priority);
  797. // defaults
  798. priority = priority || this.priority; // modify callback
  799. if (typeof callback === 'string') {
  800. callback = this[callback];
  801. } // add
  802. acf.addAction(name, callback, priority, this);
  803. },
  804. /**
  805. * removeAction
  806. *
  807. * Remove an action using the wp.hooks library
  808. *
  809. * @date 14/12/17
  810. * @since 5.6.5
  811. *
  812. * @param string name
  813. * @param string callback
  814. * @return n/a
  815. */
  816. removeAction: function (name, callback) {
  817. acf.removeAction(name, this[callback]);
  818. },
  819. /**
  820. * addFilters
  821. *
  822. * Adds multiple filter handlers
  823. *
  824. * @date 14/12/17
  825. * @since 5.6.5
  826. *
  827. * @param object filters {filter1 : callback, filter2 : callback, etc }
  828. * @return n/a
  829. */
  830. addFilters: function (filters) {
  831. filters = filters || this.filters || null;
  832. if (!filters) return false;
  833. for (var i in filters) {
  834. this.addFilter(i, filters[i]);
  835. }
  836. },
  837. /**
  838. * addFilter
  839. *
  840. * Adds a filter using the wp.hooks library
  841. *
  842. * @date 14/12/17
  843. * @since 5.6.5
  844. *
  845. * @param string name
  846. * @param string callback
  847. * @return n/a
  848. */
  849. addFilter: function (name, callback, priority) {
  850. // defaults
  851. priority = priority || this.priority; // modify callback
  852. if (typeof callback === 'string') {
  853. callback = this[callback];
  854. } // add
  855. acf.addFilter(name, callback, priority, this);
  856. },
  857. /**
  858. * removeFilters
  859. *
  860. * Removes multiple filter handlers
  861. *
  862. * @date 14/12/17
  863. * @since 5.6.5
  864. *
  865. * @param object filters {filter1 : callback, filter2 : callback, etc }
  866. * @return n/a
  867. */
  868. removeFilters: function (filters) {
  869. filters = filters || this.filters || null;
  870. if (!filters) return false;
  871. for (var i in filters) {
  872. this.removeFilter(i, filters[i]);
  873. }
  874. },
  875. /**
  876. * removeFilter
  877. *
  878. * Remove a filter using the wp.hooks library
  879. *
  880. * @date 14/12/17
  881. * @since 5.6.5
  882. *
  883. * @param string name
  884. * @param string callback
  885. * @return n/a
  886. */
  887. removeFilter: function (name, callback) {
  888. acf.removeFilter(name, this[callback]);
  889. },
  890. /**
  891. * $
  892. *
  893. * description
  894. *
  895. * @date 16/12/17
  896. * @since 5.6.5
  897. *
  898. * @param type $var Description. Default.
  899. * @return type Description.
  900. */
  901. $: function (selector) {
  902. return this.$el.find(selector);
  903. },
  904. /**
  905. * remove
  906. *
  907. * Removes the element and listenters
  908. *
  909. * @date 19/12/17
  910. * @since 5.6.5
  911. *
  912. * @param type $var Description. Default.
  913. * @return type Description.
  914. */
  915. remove: function () {
  916. this.removeEvents();
  917. this.removeActions();
  918. this.removeFilters();
  919. this.$el.remove();
  920. },
  921. /**
  922. * setTimeout
  923. *
  924. * description
  925. *
  926. * @date 16/1/18
  927. * @since 5.6.5
  928. *
  929. * @param type $var Description. Default.
  930. * @return type Description.
  931. */
  932. setTimeout: function (callback, milliseconds) {
  933. return setTimeout(this.proxy(callback), milliseconds);
  934. },
  935. /**
  936. * time
  937. *
  938. * used for debugging
  939. *
  940. * @date 7/3/18
  941. * @since 5.6.9
  942. *
  943. * @param type $var Description. Default.
  944. * @return type Description.
  945. */
  946. time: function () {
  947. console.time(this.id || this.cid);
  948. },
  949. /**
  950. * timeEnd
  951. *
  952. * used for debugging
  953. *
  954. * @date 7/3/18
  955. * @since 5.6.9
  956. *
  957. * @param type $var Description. Default.
  958. * @return type Description.
  959. */
  960. timeEnd: function () {
  961. console.timeEnd(this.id || this.cid);
  962. },
  963. /**
  964. * show
  965. *
  966. * description
  967. *
  968. * @date 15/3/18
  969. * @since 5.6.9
  970. *
  971. * @param type $var Description. Default.
  972. * @return type Description.
  973. */
  974. show: function () {
  975. acf.show(this.$el);
  976. },
  977. /**
  978. * hide
  979. *
  980. * description
  981. *
  982. * @date 15/3/18
  983. * @since 5.6.9
  984. *
  985. * @param type $var Description. Default.
  986. * @return type Description.
  987. */
  988. hide: function () {
  989. acf.hide(this.$el);
  990. },
  991. /**
  992. * proxy
  993. *
  994. * Returns a new function scoped to this model
  995. *
  996. * @date 29/3/18
  997. * @since 5.6.9
  998. *
  999. * @param function callback
  1000. * @return function
  1001. */
  1002. proxy: function (callback) {
  1003. return $.proxy(callback, this);
  1004. }
  1005. }); // Set up inheritance for the model
  1006. Model.extend = extend; // Global model storage
  1007. acf.models = {};
  1008. /**
  1009. * acf.getInstance
  1010. *
  1011. * This function will get an instance from an element
  1012. *
  1013. * @date 5/3/18
  1014. * @since 5.6.9
  1015. *
  1016. * @param type $var Description. Default.
  1017. * @return type Description.
  1018. */
  1019. acf.getInstance = function ($el) {
  1020. return $el.data('acf');
  1021. };
  1022. /**
  1023. * acf.getInstances
  1024. *
  1025. * This function will get an array of instances from multiple elements
  1026. *
  1027. * @date 5/3/18
  1028. * @since 5.6.9
  1029. *
  1030. * @param type $var Description. Default.
  1031. * @return type Description.
  1032. */
  1033. acf.getInstances = function ($el) {
  1034. var instances = [];
  1035. $el.each(function () {
  1036. instances.push(acf.getInstance($(this)));
  1037. });
  1038. return instances;
  1039. };
  1040. })(jQuery);
  1041. /***/ }),
  1042. /***/ "./src/advanced-custom-fields-pro/assets/src/js/_acf-notice.js":
  1043. /*!*********************************************************************!*\
  1044. !*** ./src/advanced-custom-fields-pro/assets/src/js/_acf-notice.js ***!
  1045. \*********************************************************************/
  1046. /***/ (function() {
  1047. (function ($, undefined) {
  1048. var Notice = acf.Model.extend({
  1049. data: {
  1050. text: '',
  1051. type: '',
  1052. timeout: 0,
  1053. dismiss: true,
  1054. target: false,
  1055. close: function () {}
  1056. },
  1057. events: {
  1058. 'click .acf-notice-dismiss': 'onClickClose'
  1059. },
  1060. tmpl: function () {
  1061. return '<div class="acf-notice"></div>';
  1062. },
  1063. setup: function (props) {
  1064. $.extend(this.data, props);
  1065. this.$el = $(this.tmpl());
  1066. },
  1067. initialize: function () {
  1068. // render
  1069. this.render(); // show
  1070. this.show();
  1071. },
  1072. render: function () {
  1073. // class
  1074. this.type(this.get('type')); // text
  1075. this.html('<p>' + this.get('text') + '</p>'); // close
  1076. if (this.get('dismiss')) {
  1077. this.$el.append('<a href="#" class="acf-notice-dismiss acf-icon -cancel small"></a>');
  1078. this.$el.addClass('-dismiss');
  1079. } // timeout
  1080. var timeout = this.get('timeout');
  1081. if (timeout) {
  1082. this.away(timeout);
  1083. }
  1084. },
  1085. update: function (props) {
  1086. // update
  1087. $.extend(this.data, props); // re-initialize
  1088. this.initialize(); // refresh events
  1089. this.removeEvents();
  1090. this.addEvents();
  1091. },
  1092. show: function () {
  1093. var $target = this.get('target');
  1094. if ($target) {
  1095. $target.prepend(this.$el);
  1096. }
  1097. },
  1098. hide: function () {
  1099. this.$el.remove();
  1100. },
  1101. away: function (timeout) {
  1102. this.setTimeout(function () {
  1103. acf.remove(this.$el);
  1104. }, timeout);
  1105. },
  1106. type: function (type) {
  1107. // remove prev type
  1108. var prevType = this.get('type');
  1109. if (prevType) {
  1110. this.$el.removeClass('-' + prevType);
  1111. } // add new type
  1112. this.$el.addClass('-' + type); // backwards compatibility
  1113. if (type == 'error') {
  1114. this.$el.addClass('acf-error-message');
  1115. }
  1116. },
  1117. html: function (html) {
  1118. this.$el.html(acf.escHtml(html));
  1119. },
  1120. text: function (text) {
  1121. this.$('p').html(acf.escHtml(text));
  1122. },
  1123. onClickClose: function (e, $el) {
  1124. e.preventDefault();
  1125. this.get('close').apply(this, arguments);
  1126. this.remove();
  1127. }
  1128. });
  1129. acf.newNotice = function (props) {
  1130. // ensure object
  1131. if (typeof props !== 'object') {
  1132. props = {
  1133. text: props
  1134. };
  1135. } // instantiate
  1136. return new Notice(props);
  1137. };
  1138. var noticeManager = new acf.Model({
  1139. wait: 'prepare',
  1140. priority: 1,
  1141. initialize: function () {
  1142. // vars
  1143. var $notice = $('.acf-admin-notice'); // move to avoid WP flicker
  1144. if ($notice.length) {
  1145. $('h1:first').after($notice);
  1146. }
  1147. }
  1148. });
  1149. })(jQuery);
  1150. /***/ }),
  1151. /***/ "./src/advanced-custom-fields-pro/assets/src/js/_acf-panel.js":
  1152. /*!********************************************************************!*\
  1153. !*** ./src/advanced-custom-fields-pro/assets/src/js/_acf-panel.js ***!
  1154. \********************************************************************/
  1155. /***/ (function() {
  1156. (function ($, undefined) {
  1157. var panel = new acf.Model({
  1158. events: {
  1159. 'click .acf-panel-title': 'onClick'
  1160. },
  1161. onClick: function (e, $el) {
  1162. e.preventDefault();
  1163. this.toggle($el.parent());
  1164. },
  1165. isOpen: function ($el) {
  1166. return $el.hasClass('-open');
  1167. },
  1168. toggle: function ($el) {
  1169. this.isOpen($el) ? this.close($el) : this.open($el);
  1170. },
  1171. open: function ($el) {
  1172. $el.addClass('-open');
  1173. $el.find('.acf-panel-title i').attr('class', 'dashicons dashicons-arrow-down');
  1174. },
  1175. close: function ($el) {
  1176. $el.removeClass('-open');
  1177. $el.find('.acf-panel-title i').attr('class', 'dashicons dashicons-arrow-right');
  1178. }
  1179. });
  1180. })(jQuery);
  1181. /***/ }),
  1182. /***/ "./src/advanced-custom-fields-pro/assets/src/js/_acf-popup.js":
  1183. /*!********************************************************************!*\
  1184. !*** ./src/advanced-custom-fields-pro/assets/src/js/_acf-popup.js ***!
  1185. \********************************************************************/
  1186. /***/ (function() {
  1187. (function ($, undefined) {
  1188. acf.models.Popup = acf.Model.extend({
  1189. data: {
  1190. title: '',
  1191. content: '',
  1192. width: 0,
  1193. height: 0,
  1194. loading: false
  1195. },
  1196. events: {
  1197. 'click [data-event="close"]': 'onClickClose',
  1198. 'click .acf-close-popup': 'onClickClose'
  1199. },
  1200. setup: function (props) {
  1201. $.extend(this.data, props);
  1202. this.$el = $(this.tmpl());
  1203. },
  1204. initialize: function () {
  1205. this.render();
  1206. this.open();
  1207. },
  1208. tmpl: function () {
  1209. return ['<div id="acf-popup">', '<div class="acf-popup-box acf-box">', '<div class="title"><h3></h3><a href="#" class="acf-icon -cancel grey" data-event="close"></a></div>', '<div class="inner"></div>', '<div class="loading"><i class="acf-loading"></i></div>', '</div>', '<div class="bg" data-event="close"></div>', '</div>'].join('');
  1210. },
  1211. render: function () {
  1212. // Extract Vars.
  1213. var title = this.get('title');
  1214. var content = this.get('content');
  1215. var loading = this.get('loading');
  1216. var width = this.get('width');
  1217. var height = this.get('height'); // Update.
  1218. this.title(title);
  1219. this.content(content);
  1220. if (width) {
  1221. this.$('.acf-popup-box').css('width', width);
  1222. }
  1223. if (height) {
  1224. this.$('.acf-popup-box').css('min-height', height);
  1225. }
  1226. this.loading(loading); // Trigger action.
  1227. acf.doAction('append', this.$el);
  1228. },
  1229. update: function (props) {
  1230. this.data = acf.parseArgs(props, this.data);
  1231. this.render();
  1232. },
  1233. title: function (title) {
  1234. this.$('.title:first h3').html(title);
  1235. },
  1236. content: function (content) {
  1237. this.$('.inner:first').html(content);
  1238. },
  1239. loading: function (show) {
  1240. var $loading = this.$('.loading:first');
  1241. show ? $loading.show() : $loading.hide();
  1242. },
  1243. open: function () {
  1244. $('body').append(this.$el);
  1245. },
  1246. close: function () {
  1247. this.remove();
  1248. },
  1249. onClickClose: function (e, $el) {
  1250. e.preventDefault();
  1251. this.close();
  1252. }
  1253. });
  1254. /**
  1255. * newPopup
  1256. *
  1257. * Creates a new Popup with the supplied props
  1258. *
  1259. * @date 17/12/17
  1260. * @since 5.6.5
  1261. *
  1262. * @param object props
  1263. * @return object
  1264. */
  1265. acf.newPopup = function (props) {
  1266. return new acf.models.Popup(props);
  1267. };
  1268. })(jQuery);
  1269. /***/ }),
  1270. /***/ "./src/advanced-custom-fields-pro/assets/src/js/_acf-tooltip.js":
  1271. /*!**********************************************************************!*\
  1272. !*** ./src/advanced-custom-fields-pro/assets/src/js/_acf-tooltip.js ***!
  1273. \**********************************************************************/
  1274. /***/ (function() {
  1275. (function ($, undefined) {
  1276. acf.newTooltip = function (props) {
  1277. // ensure object
  1278. if (typeof props !== 'object') {
  1279. props = {
  1280. text: props
  1281. };
  1282. } // confirmRemove
  1283. if (props.confirmRemove !== undefined) {
  1284. props.textConfirm = acf.__('Remove');
  1285. props.textCancel = acf.__('Cancel');
  1286. return new TooltipConfirm(props); // confirm
  1287. } else if (props.confirm !== undefined) {
  1288. return new TooltipConfirm(props); // default
  1289. } else {
  1290. return new Tooltip(props);
  1291. }
  1292. };
  1293. var Tooltip = acf.Model.extend({
  1294. data: {
  1295. text: '',
  1296. timeout: 0,
  1297. target: null
  1298. },
  1299. tmpl: function () {
  1300. return '<div class="acf-tooltip"></div>';
  1301. },
  1302. setup: function (props) {
  1303. $.extend(this.data, props);
  1304. this.$el = $(this.tmpl());
  1305. },
  1306. initialize: function () {
  1307. // render
  1308. this.render(); // append
  1309. this.show(); // position
  1310. this.position(); // timeout
  1311. var timeout = this.get('timeout');
  1312. if (timeout) {
  1313. setTimeout($.proxy(this.fade, this), timeout);
  1314. }
  1315. },
  1316. update: function (props) {
  1317. $.extend(this.data, props);
  1318. this.initialize();
  1319. },
  1320. render: function () {
  1321. this.html(this.get('text'));
  1322. },
  1323. show: function () {
  1324. $('body').append(this.$el);
  1325. },
  1326. hide: function () {
  1327. this.$el.remove();
  1328. },
  1329. fade: function () {
  1330. // add class
  1331. this.$el.addClass('acf-fade-up'); // remove
  1332. this.setTimeout(function () {
  1333. this.remove();
  1334. }, 250);
  1335. },
  1336. html: function (html) {
  1337. this.$el.html(html);
  1338. },
  1339. position: function () {
  1340. // vars
  1341. var $tooltip = this.$el;
  1342. var $target = this.get('target');
  1343. if (!$target) return; // Reset position.
  1344. $tooltip.removeClass('right left bottom top').css({
  1345. top: 0,
  1346. left: 0
  1347. }); // Declare tollerance to edge of screen.
  1348. var tolerance = 10; // Find target position.
  1349. var targetWidth = $target.outerWidth();
  1350. var targetHeight = $target.outerHeight();
  1351. var targetTop = $target.offset().top;
  1352. var targetLeft = $target.offset().left; // Find tooltip position.
  1353. var tooltipWidth = $tooltip.outerWidth();
  1354. var tooltipHeight = $tooltip.outerHeight();
  1355. var tooltipTop = $tooltip.offset().top; // Should be 0, but WP media grid causes this to be 32 (toolbar padding).
  1356. // Assume default top alignment.
  1357. var top = targetTop - tooltipHeight - tooltipTop;
  1358. var left = targetLeft + targetWidth / 2 - tooltipWidth / 2; // Check if too far left.
  1359. if (left < tolerance) {
  1360. $tooltip.addClass('right');
  1361. left = targetLeft + targetWidth;
  1362. top = targetTop + targetHeight / 2 - tooltipHeight / 2 - tooltipTop; // Check if too far right.
  1363. } else if (left + tooltipWidth + tolerance > $(window).width()) {
  1364. $tooltip.addClass('left');
  1365. left = targetLeft - tooltipWidth;
  1366. top = targetTop + targetHeight / 2 - tooltipHeight / 2 - tooltipTop; // Check if too far up.
  1367. } else if (top - $(window).scrollTop() < tolerance) {
  1368. $tooltip.addClass('bottom');
  1369. top = targetTop + targetHeight - tooltipTop; // No colision with edges.
  1370. } else {
  1371. $tooltip.addClass('top');
  1372. } // update css
  1373. $tooltip.css({
  1374. top: top,
  1375. left: left
  1376. });
  1377. }
  1378. });
  1379. var TooltipConfirm = Tooltip.extend({
  1380. data: {
  1381. text: '',
  1382. textConfirm: '',
  1383. textCancel: '',
  1384. target: null,
  1385. targetConfirm: true,
  1386. confirm: function () {},
  1387. cancel: function () {},
  1388. context: false
  1389. },
  1390. events: {
  1391. 'click [data-event="cancel"]': 'onCancel',
  1392. 'click [data-event="confirm"]': 'onConfirm'
  1393. },
  1394. addEvents: function () {
  1395. // add events
  1396. acf.Model.prototype.addEvents.apply(this); // vars
  1397. var $document = $(document);
  1398. var $target = this.get('target'); // add global 'cancel' click event
  1399. // - use timeout to avoid the current 'click' event triggering the onCancel function
  1400. this.setTimeout(function () {
  1401. this.on($document, 'click', 'onCancel');
  1402. }); // add target 'confirm' click event
  1403. // - allow setting to control this feature
  1404. if (this.get('targetConfirm')) {
  1405. this.on($target, 'click', 'onConfirm');
  1406. }
  1407. },
  1408. removeEvents: function () {
  1409. // remove events
  1410. acf.Model.prototype.removeEvents.apply(this); // vars
  1411. var $document = $(document);
  1412. var $target = this.get('target'); // remove custom events
  1413. this.off($document, 'click');
  1414. this.off($target, 'click');
  1415. },
  1416. render: function () {
  1417. // defaults
  1418. var text = this.get('text') || acf.__('Are you sure?');
  1419. var textConfirm = this.get('textConfirm') || acf.__('Yes');
  1420. var textCancel = this.get('textCancel') || acf.__('No'); // html
  1421. var html = [text, '<a href="#" data-event="confirm">' + textConfirm + '</a>', '<a href="#" data-event="cancel">' + textCancel + '</a>'].join(' '); // html
  1422. this.html(html); // class
  1423. this.$el.addClass('-confirm');
  1424. },
  1425. onCancel: function (e, $el) {
  1426. // prevent default
  1427. e.preventDefault();
  1428. e.stopImmediatePropagation(); // callback
  1429. var callback = this.get('cancel');
  1430. var context = this.get('context') || this;
  1431. callback.apply(context, arguments); //remove
  1432. this.remove();
  1433. },
  1434. onConfirm: function (e, $el) {
  1435. // Prevent event from propagating completely to allow "targetConfirm" to be clicked.
  1436. e.preventDefault();
  1437. e.stopImmediatePropagation(); // callback
  1438. var callback = this.get('confirm');
  1439. var context = this.get('context') || this;
  1440. callback.apply(context, arguments); //remove
  1441. this.remove();
  1442. }
  1443. }); // storage
  1444. acf.models.Tooltip = Tooltip;
  1445. acf.models.TooltipConfirm = TooltipConfirm;
  1446. /**
  1447. * tooltipManager
  1448. *
  1449. * description
  1450. *
  1451. * @date 17/4/18
  1452. * @since 5.6.9
  1453. *
  1454. * @param type $var Description. Default.
  1455. * @return type Description.
  1456. */
  1457. var tooltipHoverHelper = new acf.Model({
  1458. tooltip: false,
  1459. events: {
  1460. 'mouseenter .acf-js-tooltip': 'showTitle',
  1461. 'mouseup .acf-js-tooltip': 'hideTitle',
  1462. 'mouseleave .acf-js-tooltip': 'hideTitle'
  1463. },
  1464. showTitle: function (e, $el) {
  1465. // vars
  1466. var title = $el.attr('title'); // bail ealry if no title
  1467. if (!title) {
  1468. return;
  1469. } // clear title to avoid default browser tooltip
  1470. $el.attr('title', ''); // create
  1471. if (!this.tooltip) {
  1472. this.tooltip = acf.newTooltip({
  1473. text: title,
  1474. target: $el
  1475. }); // update
  1476. } else {
  1477. this.tooltip.update({
  1478. text: title,
  1479. target: $el
  1480. });
  1481. }
  1482. },
  1483. hideTitle: function (e, $el) {
  1484. // hide tooltip
  1485. this.tooltip.hide(); // restore title
  1486. $el.attr('title', this.tooltip.get('text'));
  1487. }
  1488. });
  1489. })(jQuery);
  1490. /***/ }),
  1491. /***/ "./src/advanced-custom-fields-pro/assets/src/js/_acf.js":
  1492. /*!**************************************************************!*\
  1493. !*** ./src/advanced-custom-fields-pro/assets/src/js/_acf.js ***!
  1494. \**************************************************************/
  1495. /***/ (function() {
  1496. (function ($, undefined) {
  1497. /**
  1498. * acf
  1499. *
  1500. * description
  1501. *
  1502. * @date 14/12/17
  1503. * @since 5.6.5
  1504. *
  1505. * @param type $var Description. Default.
  1506. * @return type Description.
  1507. */
  1508. // The global acf object
  1509. var acf = {}; // Set as a browser global
  1510. window.acf = acf;
  1511. /** @var object Data sent from PHP */
  1512. acf.data = {};
  1513. /**
  1514. * get
  1515. *
  1516. * Gets a specific data value
  1517. *
  1518. * @date 14/12/17
  1519. * @since 5.6.5
  1520. *
  1521. * @param string name
  1522. * @return mixed
  1523. */
  1524. acf.get = function (name) {
  1525. return this.data[name] || null;
  1526. };
  1527. /**
  1528. * has
  1529. *
  1530. * Returns `true` if the data exists and is not null
  1531. *
  1532. * @date 14/12/17
  1533. * @since 5.6.5
  1534. *
  1535. * @param string name
  1536. * @return boolean
  1537. */
  1538. acf.has = function (name) {
  1539. return this.get(name) !== null;
  1540. };
  1541. /**
  1542. * set
  1543. *
  1544. * Sets a specific data value
  1545. *
  1546. * @date 14/12/17
  1547. * @since 5.6.5
  1548. *
  1549. * @param string name
  1550. * @param mixed value
  1551. * @return this
  1552. */
  1553. acf.set = function (name, value) {
  1554. this.data[name] = value;
  1555. return this;
  1556. };
  1557. /**
  1558. * uniqueId
  1559. *
  1560. * Returns a unique ID
  1561. *
  1562. * @date 9/11/17
  1563. * @since 5.6.3
  1564. *
  1565. * @param string prefix Optional prefix.
  1566. * @return string
  1567. */
  1568. var idCounter = 0;
  1569. acf.uniqueId = function (prefix) {
  1570. var id = ++idCounter + '';
  1571. return prefix ? prefix + id : id;
  1572. };
  1573. /**
  1574. * acf.uniqueArray
  1575. *
  1576. * Returns a new array with only unique values
  1577. * Credit: https://stackoverflow.com/questions/1960473/get-all-unique-values-in-an-array-remove-duplicates
  1578. *
  1579. * @date 23/3/18
  1580. * @since 5.6.9
  1581. *
  1582. * @param type $var Description. Default.
  1583. * @return type Description.
  1584. */
  1585. acf.uniqueArray = function (array) {
  1586. function onlyUnique(value, index, self) {
  1587. return self.indexOf(value) === index;
  1588. }
  1589. return array.filter(onlyUnique);
  1590. };
  1591. /**
  1592. * uniqid
  1593. *
  1594. * Returns a unique ID (PHP version)
  1595. *
  1596. * @date 9/11/17
  1597. * @since 5.6.3
  1598. * @source http://locutus.io/php/misc/uniqid/
  1599. *
  1600. * @param string prefix Optional prefix.
  1601. * @return string
  1602. */
  1603. var uniqidSeed = '';
  1604. acf.uniqid = function (prefix, moreEntropy) {
  1605. // discuss at: http://locutus.io/php/uniqid/
  1606. // original by: Kevin van Zonneveld (http://kvz.io)
  1607. // revised by: Kankrelune (http://www.webfaktory.info/)
  1608. // note 1: Uses an internal counter (in locutus global) to avoid collision
  1609. // example 1: var $id = uniqid()
  1610. // example 1: var $result = $id.length === 13
  1611. // returns 1: true
  1612. // example 2: var $id = uniqid('foo')
  1613. // example 2: var $result = $id.length === (13 + 'foo'.length)
  1614. // returns 2: true
  1615. // example 3: var $id = uniqid('bar', true)
  1616. // example 3: var $result = $id.length === (23 + 'bar'.length)
  1617. // returns 3: true
  1618. if (typeof prefix === 'undefined') {
  1619. prefix = '';
  1620. }
  1621. var retId;
  1622. var formatSeed = function (seed, reqWidth) {
  1623. seed = parseInt(seed, 10).toString(16); // to hex str
  1624. if (reqWidth < seed.length) {
  1625. // so long we split
  1626. return seed.slice(seed.length - reqWidth);
  1627. }
  1628. if (reqWidth > seed.length) {
  1629. // so short we pad
  1630. return Array(1 + (reqWidth - seed.length)).join('0') + seed;
  1631. }
  1632. return seed;
  1633. };
  1634. if (!uniqidSeed) {
  1635. // init seed with big random int
  1636. uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
  1637. }
  1638. uniqidSeed++;
  1639. retId = prefix; // start with prefix, add current milliseconds hex string
  1640. retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
  1641. retId += formatSeed(uniqidSeed, 5); // add seed hex string
  1642. if (moreEntropy) {
  1643. // for more entropy we add a float lower to 10
  1644. retId += (Math.random() * 10).toFixed(8).toString();
  1645. }
  1646. return retId;
  1647. };
  1648. /**
  1649. * strReplace
  1650. *
  1651. * Performs a string replace
  1652. *
  1653. * @date 14/12/17
  1654. * @since 5.6.5
  1655. *
  1656. * @param string search
  1657. * @param string replace
  1658. * @param string subject
  1659. * @return string
  1660. */
  1661. acf.strReplace = function (search, replace, subject) {
  1662. return subject.split(search).join(replace);
  1663. };
  1664. /**
  1665. * strCamelCase
  1666. *
  1667. * Converts a string into camelCase
  1668. * Thanks to https://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case
  1669. *
  1670. * @date 14/12/17
  1671. * @since 5.6.5
  1672. *
  1673. * @param string str
  1674. * @return string
  1675. */
  1676. acf.strCamelCase = function (str) {
  1677. var matches = str.match(/([a-zA-Z0-9]+)/g);
  1678. return matches ? matches.map(function (s, i) {
  1679. var c = s.charAt(0);
  1680. return (i === 0 ? c.toLowerCase() : c.toUpperCase()) + s.slice(1);
  1681. }).join('') : '';
  1682. };
  1683. /**
  1684. * strPascalCase
  1685. *
  1686. * Converts a string into PascalCase
  1687. * Thanks to https://stackoverflow.com/questions/1026069/how-do-i-make-the-first-letter-of-a-string-uppercase-in-javascript
  1688. *
  1689. * @date 14/12/17
  1690. * @since 5.6.5
  1691. *
  1692. * @param string str
  1693. * @return string
  1694. */
  1695. acf.strPascalCase = function (str) {
  1696. var camel = acf.strCamelCase(str);
  1697. return camel.charAt(0).toUpperCase() + camel.slice(1);
  1698. };
  1699. /**
  1700. * acf.strSlugify
  1701. *
  1702. * Converts a string into a HTML class friendly slug
  1703. *
  1704. * @date 21/3/18
  1705. * @since 5.6.9
  1706. *
  1707. * @param string str
  1708. * @return string
  1709. */
  1710. acf.strSlugify = function (str) {
  1711. return acf.strReplace('_', '-', str.toLowerCase());
  1712. };
  1713. acf.strSanitize = function (str) {
  1714. // chars (https://jsperf.com/replace-foreign-characters)
  1715. var map = {
  1716. À: 'A',
  1717. Á: 'A',
  1718. Â: 'A',
  1719. Ã: 'A',
  1720. Ä: 'A',
  1721. Å: 'A',
  1722. Æ: 'AE',
  1723. Ç: 'C',
  1724. È: 'E',
  1725. É: 'E',
  1726. Ê: 'E',
  1727. Ë: 'E',
  1728. Ì: 'I',
  1729. Í: 'I',
  1730. Î: 'I',
  1731. Ï: 'I',
  1732. Ð: 'D',
  1733. Ñ: 'N',
  1734. Ò: 'O',
  1735. Ó: 'O',
  1736. Ô: 'O',
  1737. Õ: 'O',
  1738. Ö: 'O',
  1739. Ø: 'O',
  1740. Ù: 'U',
  1741. Ú: 'U',
  1742. Û: 'U',
  1743. Ü: 'U',
  1744. Ý: 'Y',
  1745. ß: 's',
  1746. à: 'a',
  1747. á: 'a',
  1748. â: 'a',
  1749. ã: 'a',
  1750. ä: 'a',
  1751. å: 'a',
  1752. æ: 'ae',
  1753. ç: 'c',
  1754. è: 'e',
  1755. é: 'e',
  1756. ê: 'e',
  1757. ë: 'e',
  1758. ì: 'i',
  1759. í: 'i',
  1760. î: 'i',
  1761. ï: 'i',
  1762. ñ: 'n',
  1763. ò: 'o',
  1764. ó: 'o',
  1765. ô: 'o',
  1766. õ: 'o',
  1767. ö: 'o',
  1768. ø: 'o',
  1769. ù: 'u',
  1770. ú: 'u',
  1771. û: 'u',
  1772. ü: 'u',
  1773. ý: 'y',
  1774. ÿ: 'y',
  1775. Ā: 'A',
  1776. ā: 'a',
  1777. Ă: 'A',
  1778. ă: 'a',
  1779. Ą: 'A',
  1780. ą: 'a',
  1781. Ć: 'C',
  1782. ć: 'c',
  1783. Ĉ: 'C',
  1784. ĉ: 'c',
  1785. Ċ: 'C',
  1786. ċ: 'c',
  1787. Č: 'C',
  1788. č: 'c',
  1789. Ď: 'D',
  1790. ď: 'd',
  1791. Đ: 'D',
  1792. đ: 'd',
  1793. Ē: 'E',
  1794. ē: 'e',
  1795. Ĕ: 'E',
  1796. ĕ: 'e',
  1797. Ė: 'E',
  1798. ė: 'e',
  1799. Ę: 'E',
  1800. ę: 'e',
  1801. Ě: 'E',
  1802. ě: 'e',
  1803. Ĝ: 'G',
  1804. ĝ: 'g',
  1805. Ğ: 'G',
  1806. ğ: 'g',
  1807. Ġ: 'G',
  1808. ġ: 'g',
  1809. Ģ: 'G',
  1810. ģ: 'g',
  1811. Ĥ: 'H',
  1812. ĥ: 'h',
  1813. Ħ: 'H',
  1814. ħ: 'h',
  1815. Ĩ: 'I',
  1816. ĩ: 'i',
  1817. Ī: 'I',
  1818. ī: 'i',
  1819. Ĭ: 'I',
  1820. ĭ: 'i',
  1821. Į: 'I',
  1822. į: 'i',
  1823. İ: 'I',
  1824. ı: 'i',
  1825. IJ: 'IJ',
  1826. ij: 'ij',
  1827. Ĵ: 'J',
  1828. ĵ: 'j',
  1829. Ķ: 'K',
  1830. ķ: 'k',
  1831. Ĺ: 'L',
  1832. ĺ: 'l',
  1833. Ļ: 'L',
  1834. ļ: 'l',
  1835. Ľ: 'L',
  1836. ľ: 'l',
  1837. Ŀ: 'L',
  1838. ŀ: 'l',
  1839. Ł: 'l',
  1840. ł: 'l',
  1841. Ń: 'N',
  1842. ń: 'n',
  1843. Ņ: 'N',
  1844. ņ: 'n',
  1845. Ň: 'N',
  1846. ň: 'n',
  1847. ʼn: 'n',
  1848. Ō: 'O',
  1849. ō: 'o',
  1850. Ŏ: 'O',
  1851. ŏ: 'o',
  1852. Ő: 'O',
  1853. ő: 'o',
  1854. Œ: 'OE',
  1855. œ: 'oe',
  1856. Ŕ: 'R',
  1857. ŕ: 'r',
  1858. Ŗ: 'R',
  1859. ŗ: 'r',
  1860. Ř: 'R',
  1861. ř: 'r',
  1862. Ś: 'S',
  1863. ś: 's',
  1864. Ŝ: 'S',
  1865. ŝ: 's',
  1866. Ş: 'S',
  1867. ş: 's',
  1868. Š: 'S',
  1869. š: 's',
  1870. Ţ: 'T',
  1871. ţ: 't',
  1872. Ť: 'T',
  1873. ť: 't',
  1874. Ŧ: 'T',
  1875. ŧ: 't',
  1876. Ũ: 'U',
  1877. ũ: 'u',
  1878. Ū: 'U',
  1879. ū: 'u',
  1880. Ŭ: 'U',
  1881. ŭ: 'u',
  1882. Ů: 'U',
  1883. ů: 'u',
  1884. Ű: 'U',
  1885. ű: 'u',
  1886. Ų: 'U',
  1887. ų: 'u',
  1888. Ŵ: 'W',
  1889. ŵ: 'w',
  1890. Ŷ: 'Y',
  1891. ŷ: 'y',
  1892. Ÿ: 'Y',
  1893. Ź: 'Z',
  1894. ź: 'z',
  1895. Ż: 'Z',
  1896. ż: 'z',
  1897. Ž: 'Z',
  1898. ž: 'z',
  1899. ſ: 's',
  1900. ƒ: 'f',
  1901. Ơ: 'O',
  1902. ơ: 'o',
  1903. Ư: 'U',
  1904. ư: 'u',
  1905. Ǎ: 'A',
  1906. ǎ: 'a',
  1907. Ǐ: 'I',
  1908. ǐ: 'i',
  1909. Ǒ: 'O',
  1910. ǒ: 'o',
  1911. Ǔ: 'U',
  1912. ǔ: 'u',
  1913. Ǖ: 'U',
  1914. ǖ: 'u',
  1915. Ǘ: 'U',
  1916. ǘ: 'u',
  1917. Ǚ: 'U',
  1918. ǚ: 'u',
  1919. Ǜ: 'U',
  1920. ǜ: 'u',
  1921. Ǻ: 'A',
  1922. ǻ: 'a',
  1923. Ǽ: 'AE',
  1924. ǽ: 'ae',
  1925. Ǿ: 'O',
  1926. ǿ: 'o',
  1927. // extra
  1928. ' ': '_',
  1929. "'": '',
  1930. '?': '',
  1931. '/': '',
  1932. '\\': '',
  1933. '.': '',
  1934. ',': '',
  1935. '`': '',
  1936. '>': '',
  1937. '<': '',
  1938. '"': '',
  1939. '[': '',
  1940. ']': '',
  1941. '|': '',
  1942. '{': '',
  1943. '}': '',
  1944. '(': '',
  1945. ')': ''
  1946. }; // vars
  1947. var nonWord = /\W/g;
  1948. var mapping = function (c) {
  1949. return map[c] !== undefined ? map[c] : c;
  1950. }; // replace
  1951. str = str.replace(nonWord, mapping); // lowercase
  1952. str = str.toLowerCase(); // return
  1953. return str;
  1954. };
  1955. /**
  1956. * acf.strMatch
  1957. *
  1958. * Returns the number of characters that match between two strings
  1959. *
  1960. * @date 1/2/18
  1961. * @since 5.6.5
  1962. *
  1963. * @param type $var Description. Default.
  1964. * @return type Description.
  1965. */
  1966. acf.strMatch = function (s1, s2) {
  1967. // vars
  1968. var val = 0;
  1969. var min = Math.min(s1.length, s2.length); // loop
  1970. for (var i = 0; i < min; i++) {
  1971. if (s1[i] !== s2[i]) {
  1972. break;
  1973. }
  1974. val++;
  1975. } // return
  1976. return val;
  1977. };
  1978. /**
  1979. * Escapes HTML entities from a string.
  1980. *
  1981. * @date 08/06/2020
  1982. * @since 5.9.0
  1983. *
  1984. * @param string string The input string.
  1985. * @return string
  1986. */
  1987. acf.strEscape = function (string) {
  1988. var htmlEscapes = {
  1989. '&': '&amp;',
  1990. '<': '&lt;',
  1991. '>': '&gt;',
  1992. '"': '&quot;',
  1993. "'": '&#39;'
  1994. };
  1995. return ('' + string).replace(/[&<>"']/g, function (chr) {
  1996. return htmlEscapes[chr];
  1997. });
  1998. }; // Tests.
  1999. //console.log( acf.strEscape('Test 1') );
  2000. //console.log( acf.strEscape('Test & 1') );
  2001. //console.log( acf.strEscape('Test\'s &amp; 1') );
  2002. //console.log( acf.strEscape('<script>js</script>') );
  2003. /**
  2004. * Unescapes HTML entities from a string.
  2005. *
  2006. * @date 08/06/2020
  2007. * @since 5.9.0
  2008. *
  2009. * @param string string The input string.
  2010. * @return string
  2011. */
  2012. acf.strUnescape = function (string) {
  2013. var htmlUnescapes = {
  2014. '&amp;': '&',
  2015. '&lt;': '<',
  2016. '&gt;': '>',
  2017. '&quot;': '"',
  2018. '&#39;': "'"
  2019. };
  2020. return ('' + string).replace(/&amp;|&lt;|&gt;|&quot;|&#39;/g, function (entity) {
  2021. return htmlUnescapes[entity];
  2022. });
  2023. }; // Tests.
  2024. //console.log( acf.strUnescape( acf.strEscape('Test 1') ) );
  2025. //console.log( acf.strUnescape( acf.strEscape('Test & 1') ) );
  2026. //console.log( acf.strUnescape( acf.strEscape('Test\'s &amp; 1') ) );
  2027. //console.log( acf.strUnescape( acf.strEscape('<script>js</script>') ) );
  2028. /**
  2029. * Escapes HTML entities from a string.
  2030. *
  2031. * @date 08/06/2020
  2032. * @since 5.9.0
  2033. *
  2034. * @param string string The input string.
  2035. * @return string
  2036. */
  2037. acf.escAttr = acf.strEscape;
  2038. /**
  2039. * Encodes <script> tags for safe HTML output.
  2040. *
  2041. * @date 08/06/2020
  2042. * @since 5.9.0
  2043. *
  2044. * @param string string The input string.
  2045. * @return string
  2046. */
  2047. acf.escHtml = function (string) {
  2048. return ('' + string).replace(/<script|<\/script/g, function (html) {
  2049. return acf.strEscape(html);
  2050. });
  2051. }; // Tests.
  2052. //console.log( acf.escHtml('<script>js</script>') );
  2053. //console.log( acf.escHtml( acf.strEscape('<script>js</script>') ) );
  2054. //console.log( acf.escHtml( '<script>js1</script><script>js2</script>' ) );
  2055. /**
  2056. * acf.decode
  2057. *
  2058. * description
  2059. *
  2060. * @date 13/1/18
  2061. * @since 5.6.5
  2062. *
  2063. * @param type $var Description. Default.
  2064. * @return type Description.
  2065. */
  2066. acf.decode = function (string) {
  2067. return $('<textarea/>').html(string).text();
  2068. };
  2069. /**
  2070. * parseArgs
  2071. *
  2072. * Merges together defaults and args much like the WP wp_parse_args function
  2073. *
  2074. * @date 14/12/17
  2075. * @since 5.6.5
  2076. *
  2077. * @param object args
  2078. * @param object defaults
  2079. * @return object
  2080. */
  2081. acf.parseArgs = function (args, defaults) {
  2082. if (typeof args !== 'object') args = {};
  2083. if (typeof defaults !== 'object') defaults = {};
  2084. return $.extend({}, defaults, args);
  2085. };
  2086. /**
  2087. * __
  2088. *
  2089. * Retrieve the translation of $text.
  2090. *
  2091. * @date 16/4/18
  2092. * @since 5.6.9
  2093. *
  2094. * @param string text Text to translate.
  2095. * @return string Translated text.
  2096. */
  2097. if (window.acfL10n == undefined) {
  2098. acfL10n = {};
  2099. }
  2100. acf.__ = function (text) {
  2101. return acfL10n[text] || text;
  2102. };
  2103. /**
  2104. * _x
  2105. *
  2106. * Retrieve translated string with gettext context.
  2107. *
  2108. * @date 16/4/18
  2109. * @since 5.6.9
  2110. *
  2111. * @param string text Text to translate.
  2112. * @param string context Context information for the translators.
  2113. * @return string Translated text.
  2114. */
  2115. acf._x = function (text, context) {
  2116. return acfL10n[text + '.' + context] || acfL10n[text] || text;
  2117. };
  2118. /**
  2119. * _n
  2120. *
  2121. * Retrieve the plural or single form based on the amount.
  2122. *
  2123. * @date 16/4/18
  2124. * @since 5.6.9
  2125. *
  2126. * @param string single Single text to translate.
  2127. * @param string plural Plural text to translate.
  2128. * @param int number The number to compare against.
  2129. * @return string Translated text.
  2130. */
  2131. acf._n = function (single, plural, number) {
  2132. if (number == 1) {
  2133. return acf.__(single);
  2134. } else {
  2135. return acf.__(plural);
  2136. }
  2137. };
  2138. acf.isArray = function (a) {
  2139. return Array.isArray(a);
  2140. };
  2141. acf.isObject = function (a) {
  2142. return typeof a === 'object';
  2143. };
  2144. /**
  2145. * serialize
  2146. *
  2147. * description
  2148. *
  2149. * @date 24/12/17
  2150. * @since 5.6.5
  2151. *
  2152. * @param type $var Description. Default.
  2153. * @return type Description.
  2154. */
  2155. var buildObject = function (obj, name, value) {
  2156. // replace [] with placeholder
  2157. name = name.replace('[]', '[%%index%%]'); // vars
  2158. var keys = name.match(/([^\[\]])+/g);
  2159. if (!keys) return;
  2160. var length = keys.length;
  2161. var ref = obj; // loop
  2162. for (var i = 0; i < length; i++) {
  2163. // vars
  2164. var key = String(keys[i]); // value
  2165. if (i == length - 1) {
  2166. // %%index%%
  2167. if (key === '%%index%%') {
  2168. ref.push(value); // default
  2169. } else {
  2170. ref[key] = value;
  2171. } // path
  2172. } else {
  2173. // array
  2174. if (keys[i + 1] === '%%index%%') {
  2175. if (!acf.isArray(ref[key])) {
  2176. ref[key] = [];
  2177. } // object
  2178. } else {
  2179. if (!acf.isObject(ref[key])) {
  2180. ref[key] = {};
  2181. }
  2182. } // crawl
  2183. ref = ref[key];
  2184. }
  2185. }
  2186. };
  2187. acf.serialize = function ($el, prefix) {
  2188. // vars
  2189. var obj = {};
  2190. var inputs = acf.serializeArray($el); // prefix
  2191. if (prefix !== undefined) {
  2192. // filter and modify
  2193. inputs = inputs.filter(function (item) {
  2194. return item.name.indexOf(prefix) === 0;
  2195. }).map(function (item) {
  2196. item.name = item.name.slice(prefix.length);
  2197. return item;
  2198. });
  2199. } // loop
  2200. for (var i = 0; i < inputs.length; i++) {
  2201. buildObject(obj, inputs[i].name, inputs[i].value);
  2202. } // return
  2203. return obj;
  2204. };
  2205. /**
  2206. * acf.serializeArray
  2207. *
  2208. * Similar to $.serializeArray() but works with a parent wrapping element.
  2209. *
  2210. * @date 19/8/18
  2211. * @since 5.7.3
  2212. *
  2213. * @param jQuery $el The element or form to serialize.
  2214. * @return array
  2215. */
  2216. acf.serializeArray = function ($el) {
  2217. return $el.find('select, textarea, input').serializeArray();
  2218. };
  2219. /**
  2220. * acf.serializeForAjax
  2221. *
  2222. * Returns an object containing name => value data ready to be encoded for Ajax.
  2223. *
  2224. * @date 17/12/18
  2225. * @since 5.8.0
  2226. *
  2227. * @param jQUery $el The element or form to serialize.
  2228. * @return object
  2229. */
  2230. acf.serializeForAjax = function ($el) {
  2231. // vars
  2232. var data = {};
  2233. var index = {}; // Serialize inputs.
  2234. var inputs = acf.serializeArray($el); // Loop over inputs and build data.
  2235. inputs.map(function (item) {
  2236. // Append to array.
  2237. if (item.name.slice(-2) === '[]') {
  2238. data[item.name] = data[item.name] || [];
  2239. data[item.name].push(item.value); // Append
  2240. } else {
  2241. data[item.name] = item.value;
  2242. }
  2243. }); // return
  2244. return data;
  2245. };
  2246. /**
  2247. * addAction
  2248. *
  2249. * Wrapper for acf.hooks.addAction
  2250. *
  2251. * @date 14/12/17
  2252. * @since 5.6.5
  2253. *
  2254. * @param n/a
  2255. * @return this
  2256. */
  2257. /*
  2258. var prefixAction = function( action ){
  2259. return 'acf_' + action;
  2260. }
  2261. */
  2262. acf.addAction = function (action, callback, priority, context) {
  2263. //action = prefixAction(action);
  2264. acf.hooks.addAction.apply(this, arguments);
  2265. return this;
  2266. };
  2267. /**
  2268. * removeAction
  2269. *
  2270. * Wrapper for acf.hooks.removeAction
  2271. *
  2272. * @date 14/12/17
  2273. * @since 5.6.5
  2274. *
  2275. * @param n/a
  2276. * @return this
  2277. */
  2278. acf.removeAction = function (action, callback) {
  2279. //action = prefixAction(action);
  2280. acf.hooks.removeAction.apply(this, arguments);
  2281. return this;
  2282. };
  2283. /**
  2284. * doAction
  2285. *
  2286. * Wrapper for acf.hooks.doAction
  2287. *
  2288. * @date 14/12/17
  2289. * @since 5.6.5
  2290. *
  2291. * @param n/a
  2292. * @return this
  2293. */
  2294. var actionHistory = {}; //var currentAction = false;
  2295. acf.doAction = function (action) {
  2296. //action = prefixAction(action);
  2297. //currentAction = action;
  2298. actionHistory[action] = 1;
  2299. acf.hooks.doAction.apply(this, arguments);
  2300. actionHistory[action] = 0;
  2301. return this;
  2302. };
  2303. /**
  2304. * doingAction
  2305. *
  2306. * Return true if doing action
  2307. *
  2308. * @date 14/12/17
  2309. * @since 5.6.5
  2310. *
  2311. * @param n/a
  2312. * @return this
  2313. */
  2314. acf.doingAction = function (action) {
  2315. //action = prefixAction(action);
  2316. return actionHistory[action] === 1;
  2317. };
  2318. /**
  2319. * didAction
  2320. *
  2321. * Wrapper for acf.hooks.doAction
  2322. *
  2323. * @date 14/12/17
  2324. * @since 5.6.5
  2325. *
  2326. * @param n/a
  2327. * @return this
  2328. */
  2329. acf.didAction = function (action) {
  2330. //action = prefixAction(action);
  2331. return actionHistory[action] !== undefined;
  2332. };
  2333. /**
  2334. * currentAction
  2335. *
  2336. * Wrapper for acf.hooks.doAction
  2337. *
  2338. * @date 14/12/17
  2339. * @since 5.6.5
  2340. *
  2341. * @param n/a
  2342. * @return this
  2343. */
  2344. acf.currentAction = function () {
  2345. for (var k in actionHistory) {
  2346. if (actionHistory[k]) {
  2347. return k;
  2348. }
  2349. }
  2350. return false;
  2351. };
  2352. /**
  2353. * addFilter
  2354. *
  2355. * Wrapper for acf.hooks.addFilter
  2356. *
  2357. * @date 14/12/17
  2358. * @since 5.6.5
  2359. *
  2360. * @param n/a
  2361. * @return this
  2362. */
  2363. acf.addFilter = function (action) {
  2364. //action = prefixAction(action);
  2365. acf.hooks.addFilter.apply(this, arguments);
  2366. return this;
  2367. };
  2368. /**
  2369. * removeFilter
  2370. *
  2371. * Wrapper for acf.hooks.removeFilter
  2372. *
  2373. * @date 14/12/17
  2374. * @since 5.6.5
  2375. *
  2376. * @param n/a
  2377. * @return this
  2378. */
  2379. acf.removeFilter = function (action) {
  2380. //action = prefixAction(action);
  2381. acf.hooks.removeFilter.apply(this, arguments);
  2382. return this;
  2383. };
  2384. /**
  2385. * applyFilters
  2386. *
  2387. * Wrapper for acf.hooks.applyFilters
  2388. *
  2389. * @date 14/12/17
  2390. * @since 5.6.5
  2391. *
  2392. * @param n/a
  2393. * @return this
  2394. */
  2395. acf.applyFilters = function (action) {
  2396. //action = prefixAction(action);
  2397. return acf.hooks.applyFilters.apply(this, arguments);
  2398. };
  2399. /**
  2400. * getArgs
  2401. *
  2402. * description
  2403. *
  2404. * @date 15/12/17
  2405. * @since 5.6.5
  2406. *
  2407. * @param type $var Description. Default.
  2408. * @return type Description.
  2409. */
  2410. acf.arrayArgs = function (args) {
  2411. return Array.prototype.slice.call(args);
  2412. };
  2413. /**
  2414. * extendArgs
  2415. *
  2416. * description
  2417. *
  2418. * @date 15/12/17
  2419. * @since 5.6.5
  2420. *
  2421. * @param type $var Description. Default.
  2422. * @return type Description.
  2423. */
  2424. /*
  2425. acf.extendArgs = function( ){
  2426. var args = Array.prototype.slice.call( arguments );
  2427. var realArgs = args.shift();
  2428. Array.prototype.push.call(arguments, 'bar')
  2429. return Array.prototype.push.apply( args, arguments );
  2430. };
  2431. */
  2432. // Preferences
  2433. // - use try/catch to avoid JS error if cookies are disabled on front-end form
  2434. try {
  2435. var preferences = JSON.parse(localStorage.getItem('acf')) || {};
  2436. } catch (e) {
  2437. var preferences = {};
  2438. }
  2439. /**
  2440. * getPreferenceName
  2441. *
  2442. * Gets the true preference name.
  2443. * Converts "this.thing" to "thing-123" if editing post 123.
  2444. *
  2445. * @date 11/11/17
  2446. * @since 5.6.5
  2447. *
  2448. * @param string name
  2449. * @return string
  2450. */
  2451. var getPreferenceName = function (name) {
  2452. if (name.substr(0, 5) === 'this.') {
  2453. name = name.substr(5) + '-' + acf.get('post_id');
  2454. }
  2455. return name;
  2456. };
  2457. /**
  2458. * acf.getPreference
  2459. *
  2460. * Gets a preference setting or null if not set.
  2461. *
  2462. * @date 11/11/17
  2463. * @since 5.6.5
  2464. *
  2465. * @param string name
  2466. * @return mixed
  2467. */
  2468. acf.getPreference = function (name) {
  2469. name = getPreferenceName(name);
  2470. return preferences[name] || null;
  2471. };
  2472. /**
  2473. * acf.setPreference
  2474. *
  2475. * Sets a preference setting.
  2476. *
  2477. * @date 11/11/17
  2478. * @since 5.6.5
  2479. *
  2480. * @param string name
  2481. * @param mixed value
  2482. * @return n/a
  2483. */
  2484. acf.setPreference = function (name, value) {
  2485. name = getPreferenceName(name);
  2486. if (value === null) {
  2487. delete preferences[name];
  2488. } else {
  2489. preferences[name] = value;
  2490. }
  2491. localStorage.setItem('acf', JSON.stringify(preferences));
  2492. };
  2493. /**
  2494. * acf.removePreference
  2495. *
  2496. * Removes a preference setting.
  2497. *
  2498. * @date 11/11/17
  2499. * @since 5.6.5
  2500. *
  2501. * @param string name
  2502. * @return n/a
  2503. */
  2504. acf.removePreference = function (name) {
  2505. acf.setPreference(name, null);
  2506. };
  2507. /**
  2508. * remove
  2509. *
  2510. * Removes an element with fade effect
  2511. *
  2512. * @date 1/1/18
  2513. * @since 5.6.5
  2514. *
  2515. * @param type $var Description. Default.
  2516. * @return type Description.
  2517. */
  2518. acf.remove = function (props) {
  2519. // allow jQuery
  2520. if (props instanceof jQuery) {
  2521. props = {
  2522. target: props
  2523. };
  2524. } // defaults
  2525. props = acf.parseArgs(props, {
  2526. target: false,
  2527. endHeight: 0,
  2528. complete: function () {}
  2529. }); // action
  2530. acf.doAction('remove', props.target); // tr
  2531. if (props.target.is('tr')) {
  2532. removeTr(props); // div
  2533. } else {
  2534. removeDiv(props);
  2535. }
  2536. };
  2537. /**
  2538. * removeDiv
  2539. *
  2540. * description
  2541. *
  2542. * @date 16/2/18
  2543. * @since 5.6.9
  2544. *
  2545. * @param type $var Description. Default.
  2546. * @return type Description.
  2547. */
  2548. var removeDiv = function (props) {
  2549. // vars
  2550. var $el = props.target;
  2551. var height = $el.height();
  2552. var width = $el.width();
  2553. var margin = $el.css('margin');
  2554. var outerHeight = $el.outerHeight(true);
  2555. var style = $el.attr('style') + ''; // needed to copy
  2556. // wrap
  2557. $el.wrap('<div class="acf-temp-remove" style="height:' + outerHeight + 'px"></div>');
  2558. var $wrap = $el.parent(); // set pos
  2559. $el.css({
  2560. height: height,
  2561. width: width,
  2562. margin: margin,
  2563. position: 'absolute'
  2564. }); // fade wrap
  2565. setTimeout(function () {
  2566. $wrap.css({
  2567. opacity: 0,
  2568. height: props.endHeight
  2569. });
  2570. }, 50); // remove
  2571. setTimeout(function () {
  2572. $el.attr('style', style);
  2573. $wrap.remove();
  2574. props.complete();
  2575. }, 301);
  2576. };
  2577. /**
  2578. * removeTr
  2579. *
  2580. * description
  2581. *
  2582. * @date 16/2/18
  2583. * @since 5.6.9
  2584. *
  2585. * @param type $var Description. Default.
  2586. * @return type Description.
  2587. */
  2588. var removeTr = function (props) {
  2589. // vars
  2590. var $tr = props.target;
  2591. var height = $tr.height();
  2592. var children = $tr.children().length; // create dummy td
  2593. var $td = $('<td class="acf-temp-remove" style="padding:0; height:' + height + 'px" colspan="' + children + '"></td>'); // fade away tr
  2594. $tr.addClass('acf-remove-element'); // update HTML after fade animation
  2595. setTimeout(function () {
  2596. $tr.html($td);
  2597. }, 251); // allow .acf-temp-remove to exist before changing CSS
  2598. setTimeout(function () {
  2599. // remove class
  2600. $tr.removeClass('acf-remove-element'); // collapse
  2601. $td.css({
  2602. height: props.endHeight
  2603. });
  2604. }, 300); // remove
  2605. setTimeout(function () {
  2606. $tr.remove();
  2607. props.complete();
  2608. }, 451);
  2609. };
  2610. /**
  2611. * duplicate
  2612. *
  2613. * description
  2614. *
  2615. * @date 3/1/18
  2616. * @since 5.6.5
  2617. *
  2618. * @param type $var Description. Default.
  2619. * @return type Description.
  2620. */
  2621. acf.duplicate = function (args) {
  2622. // allow jQuery
  2623. if (args instanceof jQuery) {
  2624. args = {
  2625. target: args
  2626. };
  2627. } // defaults
  2628. args = acf.parseArgs(args, {
  2629. target: false,
  2630. search: '',
  2631. replace: '',
  2632. rename: true,
  2633. before: function ($el) {},
  2634. after: function ($el, $el2) {},
  2635. append: function ($el, $el2) {
  2636. $el.after($el2);
  2637. }
  2638. }); // compatibility
  2639. args.target = args.target || args.$el; // vars
  2640. var $el = args.target; // search
  2641. args.search = args.search || $el.attr('data-id');
  2642. args.replace = args.replace || acf.uniqid(); // before
  2643. // - allow acf to modify DOM
  2644. // - fixes bug where select field option is not selected
  2645. args.before($el);
  2646. acf.doAction('before_duplicate', $el); // clone
  2647. var $el2 = $el.clone(); // rename
  2648. if (args.rename) {
  2649. acf.rename({
  2650. target: $el2,
  2651. search: args.search,
  2652. replace: args.replace,
  2653. replacer: typeof args.rename === 'function' ? args.rename : null
  2654. });
  2655. } // remove classes
  2656. $el2.removeClass('acf-clone');
  2657. $el2.find('.ui-sortable').removeClass('ui-sortable'); // after
  2658. // - allow acf to modify DOM
  2659. args.after($el, $el2);
  2660. acf.doAction('after_duplicate', $el, $el2); // append
  2661. args.append($el, $el2);
  2662. /**
  2663. * Fires after an element has been duplicated and appended to the DOM.
  2664. *
  2665. * @date 30/10/19
  2666. * @since 5.8.7
  2667. *
  2668. * @param jQuery $el The original element.
  2669. * @param jQuery $el2 The duplicated element.
  2670. */
  2671. acf.doAction('duplicate', $el, $el2); // append
  2672. acf.doAction('append', $el2); // return
  2673. return $el2;
  2674. };
  2675. /**
  2676. * rename
  2677. *
  2678. * description
  2679. *
  2680. * @date 7/1/18
  2681. * @since 5.6.5
  2682. *
  2683. * @param type $var Description. Default.
  2684. * @return type Description.
  2685. */
  2686. acf.rename = function (args) {
  2687. // Allow jQuery param.
  2688. if (args instanceof jQuery) {
  2689. args = {
  2690. target: args
  2691. };
  2692. } // Apply default args.
  2693. args = acf.parseArgs(args, {
  2694. target: false,
  2695. destructive: false,
  2696. search: '',
  2697. replace: '',
  2698. replacer: null
  2699. }); // Extract args.
  2700. var $el = args.target; // Provide backup for empty args.
  2701. if (!args.search) {
  2702. args.search = $el.attr('data-id');
  2703. }
  2704. if (!args.replace) {
  2705. args.replace = acf.uniqid('acf');
  2706. }
  2707. if (!args.replacer) {
  2708. args.replacer = function (name, value, search, replace) {
  2709. return value.replace(search, replace);
  2710. };
  2711. } // Callback function for jQuery replacing.
  2712. var withReplacer = function (name) {
  2713. return function (i, value) {
  2714. return args.replacer(name, value, args.search, args.replace);
  2715. };
  2716. }; // Destructive Replace.
  2717. if (args.destructive) {
  2718. var html = acf.strReplace(args.search, args.replace, $el.outerHTML());
  2719. $el.replaceWith(html); // Standard Replace.
  2720. } else {
  2721. $el.attr('data-id', args.replace);
  2722. $el.find('[id*="' + args.search + '"]').attr('id', withReplacer('id'));
  2723. $el.find('[for*="' + args.search + '"]').attr('for', withReplacer('for'));
  2724. $el.find('[name*="' + args.search + '"]').attr('name', withReplacer('name'));
  2725. } // return
  2726. return $el;
  2727. };
  2728. /**
  2729. * acf.prepareForAjax
  2730. *
  2731. * description
  2732. *
  2733. * @date 4/1/18
  2734. * @since 5.6.5
  2735. *
  2736. * @param type $var Description. Default.
  2737. * @return type Description.
  2738. */
  2739. acf.prepareForAjax = function (data) {
  2740. // required
  2741. data.nonce = acf.get('nonce');
  2742. data.post_id = acf.get('post_id'); // language
  2743. if (acf.has('language')) {
  2744. data.lang = acf.get('language');
  2745. } // filter for 3rd party customization
  2746. data = acf.applyFilters('prepare_for_ajax', data); // return
  2747. return data;
  2748. };
  2749. /**
  2750. * acf.startButtonLoading
  2751. *
  2752. * description
  2753. *
  2754. * @date 5/1/18
  2755. * @since 5.6.5
  2756. *
  2757. * @param type $var Description. Default.
  2758. * @return type Description.
  2759. */
  2760. acf.startButtonLoading = function ($el) {
  2761. $el.prop('disabled', true);
  2762. $el.after(' <i class="acf-loading"></i>');
  2763. };
  2764. acf.stopButtonLoading = function ($el) {
  2765. $el.prop('disabled', false);
  2766. $el.next('.acf-loading').remove();
  2767. };
  2768. /**
  2769. * acf.showLoading
  2770. *
  2771. * description
  2772. *
  2773. * @date 12/1/18
  2774. * @since 5.6.5
  2775. *
  2776. * @param type $var Description. Default.
  2777. * @return type Description.
  2778. */
  2779. acf.showLoading = function ($el) {
  2780. $el.append('<div class="acf-loading-overlay"><i class="acf-loading"></i></div>');
  2781. };
  2782. acf.hideLoading = function ($el) {
  2783. $el.children('.acf-loading-overlay').remove();
  2784. };
  2785. /**
  2786. * acf.updateUserSetting
  2787. *
  2788. * description
  2789. *
  2790. * @date 5/1/18
  2791. * @since 5.6.5
  2792. *
  2793. * @param type $var Description. Default.
  2794. * @return type Description.
  2795. */
  2796. acf.updateUserSetting = function (name, value) {
  2797. var ajaxData = {
  2798. action: 'acf/ajax/user_setting',
  2799. name: name,
  2800. value: value
  2801. };
  2802. $.ajax({
  2803. url: acf.get('ajaxurl'),
  2804. data: acf.prepareForAjax(ajaxData),
  2805. type: 'post',
  2806. dataType: 'html'
  2807. });
  2808. };
  2809. /**
  2810. * acf.val
  2811. *
  2812. * description
  2813. *
  2814. * @date 8/1/18
  2815. * @since 5.6.5
  2816. *
  2817. * @param type $var Description. Default.
  2818. * @return type Description.
  2819. */
  2820. acf.val = function ($input, value, silent) {
  2821. // vars
  2822. var prevValue = $input.val(); // bail if no change
  2823. if (value === prevValue) {
  2824. return false;
  2825. } // update value
  2826. $input.val(value); // prevent select elements displaying blank value if option doesn't exist
  2827. if ($input.is('select') && $input.val() === null) {
  2828. $input.val(prevValue);
  2829. return false;
  2830. } // update with trigger
  2831. if (silent !== true) {
  2832. $input.trigger('change');
  2833. } // return
  2834. return true;
  2835. };
  2836. /**
  2837. * acf.show
  2838. *
  2839. * description
  2840. *
  2841. * @date 9/2/18
  2842. * @since 5.6.5
  2843. *
  2844. * @param type $var Description. Default.
  2845. * @return type Description.
  2846. */
  2847. acf.show = function ($el, lockKey) {
  2848. // unlock
  2849. if (lockKey) {
  2850. acf.unlock($el, 'hidden', lockKey);
  2851. } // bail early if $el is still locked
  2852. if (acf.isLocked($el, 'hidden')) {
  2853. //console.log( 'still locked', getLocks( $el, 'hidden' ));
  2854. return false;
  2855. } // $el is hidden, remove class and return true due to change in visibility
  2856. if ($el.hasClass('acf-hidden')) {
  2857. $el.removeClass('acf-hidden');
  2858. return true; // $el is visible, return false due to no change in visibility
  2859. } else {
  2860. return false;
  2861. }
  2862. };
  2863. /**
  2864. * acf.hide
  2865. *
  2866. * description
  2867. *
  2868. * @date 9/2/18
  2869. * @since 5.6.5
  2870. *
  2871. * @param type $var Description. Default.
  2872. * @return type Description.
  2873. */
  2874. acf.hide = function ($el, lockKey) {
  2875. // lock
  2876. if (lockKey) {
  2877. acf.lock($el, 'hidden', lockKey);
  2878. } // $el is hidden, return false due to no change in visibility
  2879. if ($el.hasClass('acf-hidden')) {
  2880. return false; // $el is visible, add class and return true due to change in visibility
  2881. } else {
  2882. $el.addClass('acf-hidden');
  2883. return true;
  2884. }
  2885. };
  2886. /**
  2887. * acf.isHidden
  2888. *
  2889. * description
  2890. *
  2891. * @date 9/2/18
  2892. * @since 5.6.5
  2893. *
  2894. * @param type $var Description. Default.
  2895. * @return type Description.
  2896. */
  2897. acf.isHidden = function ($el) {
  2898. return $el.hasClass('acf-hidden');
  2899. };
  2900. /**
  2901. * acf.isVisible
  2902. *
  2903. * description
  2904. *
  2905. * @date 9/2/18
  2906. * @since 5.6.5
  2907. *
  2908. * @param type $var Description. Default.
  2909. * @return type Description.
  2910. */
  2911. acf.isVisible = function ($el) {
  2912. return !acf.isHidden($el);
  2913. };
  2914. /**
  2915. * enable
  2916. *
  2917. * description
  2918. *
  2919. * @date 12/3/18
  2920. * @since 5.6.9
  2921. *
  2922. * @param type $var Description. Default.
  2923. * @return type Description.
  2924. */
  2925. var enable = function ($el, lockKey) {
  2926. // check class. Allow .acf-disabled to overrule all JS
  2927. if ($el.hasClass('acf-disabled')) {
  2928. return false;
  2929. } // unlock
  2930. if (lockKey) {
  2931. acf.unlock($el, 'disabled', lockKey);
  2932. } // bail early if $el is still locked
  2933. if (acf.isLocked($el, 'disabled')) {
  2934. return false;
  2935. } // $el is disabled, remove prop and return true due to change
  2936. if ($el.prop('disabled')) {
  2937. $el.prop('disabled', false);
  2938. return true; // $el is enabled, return false due to no change
  2939. } else {
  2940. return false;
  2941. }
  2942. };
  2943. /**
  2944. * acf.enable
  2945. *
  2946. * description
  2947. *
  2948. * @date 9/2/18
  2949. * @since 5.6.5
  2950. *
  2951. * @param type $var Description. Default.
  2952. * @return type Description.
  2953. */
  2954. acf.enable = function ($el, lockKey) {
  2955. // enable single input
  2956. if ($el.attr('name')) {
  2957. return enable($el, lockKey);
  2958. } // find and enable child inputs
  2959. // return true if any inputs have changed
  2960. var results = false;
  2961. $el.find('[name]').each(function () {
  2962. var result = enable($(this), lockKey);
  2963. if (result) {
  2964. results = true;
  2965. }
  2966. });
  2967. return results;
  2968. };
  2969. /**
  2970. * disable
  2971. *
  2972. * description
  2973. *
  2974. * @date 12/3/18
  2975. * @since 5.6.9
  2976. *
  2977. * @param type $var Description. Default.
  2978. * @return type Description.
  2979. */
  2980. var disable = function ($el, lockKey) {
  2981. // lock
  2982. if (lockKey) {
  2983. acf.lock($el, 'disabled', lockKey);
  2984. } // $el is disabled, return false due to no change
  2985. if ($el.prop('disabled')) {
  2986. return false; // $el is enabled, add prop and return true due to change
  2987. } else {
  2988. $el.prop('disabled', true);
  2989. return true;
  2990. }
  2991. };
  2992. /**
  2993. * acf.disable
  2994. *
  2995. * description
  2996. *
  2997. * @date 9/2/18
  2998. * @since 5.6.5
  2999. *
  3000. * @param type $var Description. Default.
  3001. * @return type Description.
  3002. */
  3003. acf.disable = function ($el, lockKey) {
  3004. // disable single input
  3005. if ($el.attr('name')) {
  3006. return disable($el, lockKey);
  3007. } // find and enable child inputs
  3008. // return true if any inputs have changed
  3009. var results = false;
  3010. $el.find('[name]').each(function () {
  3011. var result = disable($(this), lockKey);
  3012. if (result) {
  3013. results = true;
  3014. }
  3015. });
  3016. return results;
  3017. };
  3018. /**
  3019. * acf.isset
  3020. *
  3021. * description
  3022. *
  3023. * @date 10/1/18
  3024. * @since 5.6.5
  3025. *
  3026. * @param type $var Description. Default.
  3027. * @return type Description.
  3028. */
  3029. acf.isset = function (obj
  3030. /*, level1, level2, ... */
  3031. ) {
  3032. for (var i = 1; i < arguments.length; i++) {
  3033. if (!obj || !obj.hasOwnProperty(arguments[i])) {
  3034. return false;
  3035. }
  3036. obj = obj[arguments[i]];
  3037. }
  3038. return true;
  3039. };
  3040. /**
  3041. * acf.isget
  3042. *
  3043. * description
  3044. *
  3045. * @date 10/1/18
  3046. * @since 5.6.5
  3047. *
  3048. * @param type $var Description. Default.
  3049. * @return type Description.
  3050. */
  3051. acf.isget = function (obj
  3052. /*, level1, level2, ... */
  3053. ) {
  3054. for (var i = 1; i < arguments.length; i++) {
  3055. if (!obj || !obj.hasOwnProperty(arguments[i])) {
  3056. return null;
  3057. }
  3058. obj = obj[arguments[i]];
  3059. }
  3060. return obj;
  3061. };
  3062. /**
  3063. * acf.getFileInputData
  3064. *
  3065. * description
  3066. *
  3067. * @date 10/1/18
  3068. * @since 5.6.5
  3069. *
  3070. * @param type $var Description. Default.
  3071. * @return type Description.
  3072. */
  3073. acf.getFileInputData = function ($input, callback) {
  3074. // vars
  3075. var value = $input.val(); // bail early if no value
  3076. if (!value) {
  3077. return false;
  3078. } // data
  3079. var data = {
  3080. url: value
  3081. }; // modern browsers
  3082. var file = $input[0].files.length ? acf.isget($input[0].files, 0) : false;
  3083. if (file) {
  3084. // update data
  3085. data.size = file.size;
  3086. data.type = file.type; // image
  3087. if (file.type.indexOf('image') > -1) {
  3088. // vars
  3089. var windowURL = window.URL || window.webkitURL;
  3090. var img = new Image();
  3091. img.onload = function () {
  3092. // update
  3093. data.width = this.width;
  3094. data.height = this.height;
  3095. callback(data);
  3096. };
  3097. img.src = windowURL.createObjectURL(file);
  3098. } else {
  3099. callback(data);
  3100. }
  3101. } else {
  3102. callback(data);
  3103. }
  3104. };
  3105. /**
  3106. * acf.isAjaxSuccess
  3107. *
  3108. * description
  3109. *
  3110. * @date 18/1/18
  3111. * @since 5.6.5
  3112. *
  3113. * @param type $var Description. Default.
  3114. * @return type Description.
  3115. */
  3116. acf.isAjaxSuccess = function (json) {
  3117. return json && json.success;
  3118. };
  3119. /**
  3120. * acf.getAjaxMessage
  3121. *
  3122. * description
  3123. *
  3124. * @date 18/1/18
  3125. * @since 5.6.5
  3126. *
  3127. * @param type $var Description. Default.
  3128. * @return type Description.
  3129. */
  3130. acf.getAjaxMessage = function (json) {
  3131. return acf.isget(json, 'data', 'message');
  3132. };
  3133. /**
  3134. * acf.getAjaxError
  3135. *
  3136. * description
  3137. *
  3138. * @date 18/1/18
  3139. * @since 5.6.5
  3140. *
  3141. * @param type $var Description. Default.
  3142. * @return type Description.
  3143. */
  3144. acf.getAjaxError = function (json) {
  3145. return acf.isget(json, 'data', 'error');
  3146. };
  3147. /**
  3148. * Returns the error message from an XHR object.
  3149. *
  3150. * @date 17/3/20
  3151. * @since 5.8.9
  3152. *
  3153. * @param object xhr The XHR object.
  3154. * @return (string)
  3155. */
  3156. acf.getXhrError = function (xhr) {
  3157. if (xhr.responseJSON && xhr.responseJSON.message) {
  3158. return xhr.responseJSON.message;
  3159. } else if (xhr.statusText) {
  3160. return xhr.statusText;
  3161. }
  3162. return '';
  3163. };
  3164. /**
  3165. * acf.renderSelect
  3166. *
  3167. * Renders the innter html for a select field.
  3168. *
  3169. * @date 19/2/18
  3170. * @since 5.6.9
  3171. *
  3172. * @param jQuery $select The select element.
  3173. * @param array choices An array of choices.
  3174. * @return void
  3175. */
  3176. acf.renderSelect = function ($select, choices) {
  3177. // vars
  3178. var value = $select.val();
  3179. var values = []; // callback
  3180. var crawl = function (items) {
  3181. // vars
  3182. var itemsHtml = ''; // loop
  3183. items.map(function (item) {
  3184. // vars
  3185. var text = item.text || item.label || '';
  3186. var id = item.id || item.value || ''; // append
  3187. values.push(id); // optgroup
  3188. if (item.children) {
  3189. itemsHtml += '<optgroup label="' + acf.escAttr(text) + '">' + crawl(item.children) + '</optgroup>'; // option
  3190. } else {
  3191. itemsHtml += '<option value="' + acf.escAttr(id) + '"' + (item.disabled ? ' disabled="disabled"' : '') + '>' + acf.strEscape(text) + '</option>';
  3192. }
  3193. }); // return
  3194. return itemsHtml;
  3195. }; // update HTML
  3196. $select.html(crawl(choices)); // update value
  3197. if (values.indexOf(value) > -1) {
  3198. $select.val(value);
  3199. } // return selected value
  3200. return $select.val();
  3201. };
  3202. /**
  3203. * acf.lock
  3204. *
  3205. * Creates a "lock" on an element for a given type and key
  3206. *
  3207. * @date 22/2/18
  3208. * @since 5.6.9
  3209. *
  3210. * @param jQuery $el The element to lock.
  3211. * @param string type The type of lock such as "condition" or "visibility".
  3212. * @param string key The key that will be used to unlock.
  3213. * @return void
  3214. */
  3215. var getLocks = function ($el, type) {
  3216. return $el.data('acf-lock-' + type) || [];
  3217. };
  3218. var setLocks = function ($el, type, locks) {
  3219. $el.data('acf-lock-' + type, locks);
  3220. };
  3221. acf.lock = function ($el, type, key) {
  3222. var locks = getLocks($el, type);
  3223. var i = locks.indexOf(key);
  3224. if (i < 0) {
  3225. locks.push(key);
  3226. setLocks($el, type, locks);
  3227. }
  3228. };
  3229. /**
  3230. * acf.unlock
  3231. *
  3232. * Unlocks a "lock" on an element for a given type and key
  3233. *
  3234. * @date 22/2/18
  3235. * @since 5.6.9
  3236. *
  3237. * @param jQuery $el The element to lock.
  3238. * @param string type The type of lock such as "condition" or "visibility".
  3239. * @param string key The key that will be used to unlock.
  3240. * @return void
  3241. */
  3242. acf.unlock = function ($el, type, key) {
  3243. var locks = getLocks($el, type);
  3244. var i = locks.indexOf(key);
  3245. if (i > -1) {
  3246. locks.splice(i, 1);
  3247. setLocks($el, type, locks);
  3248. } // return true if is unlocked (no locks)
  3249. return locks.length === 0;
  3250. };
  3251. /**
  3252. * acf.isLocked
  3253. *
  3254. * Returns true if a lock exists for a given type
  3255. *
  3256. * @date 22/2/18
  3257. * @since 5.6.9
  3258. *
  3259. * @param jQuery $el The element to lock.
  3260. * @param string type The type of lock such as "condition" or "visibility".
  3261. * @return void
  3262. */
  3263. acf.isLocked = function ($el, type) {
  3264. return getLocks($el, type).length > 0;
  3265. };
  3266. /**
  3267. * acf.isGutenberg
  3268. *
  3269. * Returns true if the Gutenberg editor is being used.
  3270. *
  3271. * @date 14/11/18
  3272. * @since 5.8.0
  3273. *
  3274. * @param vois
  3275. * @return bool
  3276. */
  3277. acf.isGutenberg = function () {
  3278. return !!(window.wp && wp.data && wp.data.select && wp.data.select('core/editor'));
  3279. };
  3280. /**
  3281. * acf.objectToArray
  3282. *
  3283. * Returns an array of items from the given object.
  3284. *
  3285. * @date 20/11/18
  3286. * @since 5.8.0
  3287. *
  3288. * @param object obj The object of items.
  3289. * @return array
  3290. */
  3291. acf.objectToArray = function (obj) {
  3292. return Object.keys(obj).map(function (key) {
  3293. return obj[key];
  3294. });
  3295. };
  3296. /**
  3297. * acf.debounce
  3298. *
  3299. * Returns a debounced version of the passed function which will postpone its execution until after `wait` milliseconds have elapsed since the last time it was invoked.
  3300. *
  3301. * @date 28/8/19
  3302. * @since 5.8.1
  3303. *
  3304. * @param function callback The callback function.
  3305. * @return int wait The number of milliseconds to wait.
  3306. */
  3307. acf.debounce = function (callback, wait) {
  3308. var timeout;
  3309. return function () {
  3310. var context = this;
  3311. var args = arguments;
  3312. var later = function () {
  3313. callback.apply(context, args);
  3314. };
  3315. clearTimeout(timeout);
  3316. timeout = setTimeout(later, wait);
  3317. };
  3318. };
  3319. /**
  3320. * acf.throttle
  3321. *
  3322. * Returns a throttled version of the passed function which will allow only one execution per `limit` time period.
  3323. *
  3324. * @date 28/8/19
  3325. * @since 5.8.1
  3326. *
  3327. * @param function callback The callback function.
  3328. * @return int wait The number of milliseconds to wait.
  3329. */
  3330. acf.throttle = function (callback, limit) {
  3331. var busy = false;
  3332. return function () {
  3333. if (busy) return;
  3334. busy = true;
  3335. setTimeout(function () {
  3336. busy = false;
  3337. }, limit);
  3338. callback.apply(this, arguments);
  3339. };
  3340. };
  3341. /**
  3342. * acf.isInView
  3343. *
  3344. * Returns true if the given element is in view.
  3345. *
  3346. * @date 29/8/19
  3347. * @since 5.8.1
  3348. *
  3349. * @param elem el The dom element to inspect.
  3350. * @return bool
  3351. */
  3352. acf.isInView = function (el) {
  3353. if (el instanceof jQuery) {
  3354. el = el[0];
  3355. }
  3356. var rect = el.getBoundingClientRect();
  3357. return rect.top !== rect.bottom && rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
  3358. };
  3359. /**
  3360. * acf.onceInView
  3361. *
  3362. * Watches for a dom element to become visible in the browser and then excecutes the passed callback.
  3363. *
  3364. * @date 28/8/19
  3365. * @since 5.8.1
  3366. *
  3367. * @param dom el The dom element to inspect.
  3368. * @param function callback The callback function.
  3369. */
  3370. acf.onceInView = function () {
  3371. // Define list.
  3372. var items = [];
  3373. var id = 0; // Define check function.
  3374. var check = function () {
  3375. items.forEach(function (item) {
  3376. if (acf.isInView(item.el)) {
  3377. item.callback.apply(this);
  3378. pop(item.id);
  3379. }
  3380. });
  3381. }; // And create a debounced version.
  3382. var debounced = acf.debounce(check, 300); // Define add function.
  3383. var push = function (el, callback) {
  3384. // Add event listener.
  3385. if (!items.length) {
  3386. $(window).on('scroll resize', debounced).on('acfrefresh orientationchange', check);
  3387. } // Append to list.
  3388. items.push({
  3389. id: id++,
  3390. el: el,
  3391. callback: callback
  3392. });
  3393. }; // Define remove function.
  3394. var pop = function (id) {
  3395. // Remove from list.
  3396. items = items.filter(function (item) {
  3397. return item.id !== id;
  3398. }); // Clean up listener.
  3399. if (!items.length) {
  3400. $(window).off('scroll resize', debounced).off('acfrefresh orientationchange', check);
  3401. }
  3402. }; // Define returned function.
  3403. return function (el, callback) {
  3404. // Allow jQuery object.
  3405. if (el instanceof jQuery) el = el[0]; // Execute callback if already in view or add to watch list.
  3406. if (acf.isInView(el)) {
  3407. callback.apply(this);
  3408. } else {
  3409. push(el, callback);
  3410. }
  3411. };
  3412. }();
  3413. /**
  3414. * acf.once
  3415. *
  3416. * Creates a function that is restricted to invoking `func` once.
  3417. *
  3418. * @date 2/9/19
  3419. * @since 5.8.1
  3420. *
  3421. * @param function func The function to restrict.
  3422. * @return function
  3423. */
  3424. acf.once = function (func) {
  3425. var i = 0;
  3426. return function () {
  3427. if (i++ > 0) {
  3428. return func = undefined;
  3429. }
  3430. return func.apply(this, arguments);
  3431. };
  3432. };
  3433. /**
  3434. * Focuses attention to a specific element.
  3435. *
  3436. * @date 05/05/2020
  3437. * @since 5.9.0
  3438. *
  3439. * @param jQuery $el The jQuery element to focus.
  3440. * @return void
  3441. */
  3442. acf.focusAttention = function ($el) {
  3443. var wait = 1000; // Apply class to focus attention.
  3444. $el.addClass('acf-attention -focused'); // Scroll to element if needed.
  3445. var scrollTime = 500;
  3446. if (!acf.isInView($el)) {
  3447. $('body, html').animate({
  3448. scrollTop: $el.offset().top - $(window).height() / 2
  3449. }, scrollTime);
  3450. wait += scrollTime;
  3451. } // Remove class after $wait amount of time.
  3452. var fadeTime = 250;
  3453. setTimeout(function () {
  3454. $el.removeClass('-focused');
  3455. setTimeout(function () {
  3456. $el.removeClass('acf-attention');
  3457. }, fadeTime);
  3458. }, wait);
  3459. };
  3460. /**
  3461. * Description
  3462. *
  3463. * @date 05/05/2020
  3464. * @since 5.9.0
  3465. *
  3466. * @param type Var Description.
  3467. * @return type Description.
  3468. */
  3469. acf.onFocus = function ($el, callback) {
  3470. // Only run once per element.
  3471. // if( $el.data('acf.onFocus') ) {
  3472. // return false;
  3473. // }
  3474. // Vars.
  3475. var ignoreBlur = false;
  3476. var focus = false; // Functions.
  3477. var onFocus = function () {
  3478. ignoreBlur = true;
  3479. setTimeout(function () {
  3480. ignoreBlur = false;
  3481. }, 1);
  3482. setFocus(true);
  3483. };
  3484. var onBlur = function () {
  3485. if (!ignoreBlur) {
  3486. setFocus(false);
  3487. }
  3488. };
  3489. var addEvents = function () {
  3490. $(document).on('click', onBlur); //$el.on('acfBlur', onBlur);
  3491. $el.on('blur', 'input, select, textarea', onBlur);
  3492. };
  3493. var removeEvents = function () {
  3494. $(document).off('click', onBlur); //$el.off('acfBlur', onBlur);
  3495. $el.off('blur', 'input, select, textarea', onBlur);
  3496. };
  3497. var setFocus = function (value) {
  3498. if (focus === value) {
  3499. return;
  3500. }
  3501. if (value) {
  3502. addEvents();
  3503. } else {
  3504. removeEvents();
  3505. }
  3506. focus = value;
  3507. callback(value);
  3508. }; // Add events and set data.
  3509. $el.on('click', onFocus); //$el.on('acfFocus', onFocus);
  3510. $el.on('focus', 'input, select, textarea', onFocus); //$el.data('acf.onFocus', true);
  3511. };
  3512. /*
  3513. * exists
  3514. *
  3515. * This function will return true if a jQuery selection exists
  3516. *
  3517. * @type function
  3518. * @date 8/09/2014
  3519. * @since 5.0.0
  3520. *
  3521. * @param n/a
  3522. * @return (boolean)
  3523. */
  3524. $.fn.exists = function () {
  3525. return $(this).length > 0;
  3526. };
  3527. /*
  3528. * outerHTML
  3529. *
  3530. * This function will return a string containing the HTML of the selected element
  3531. *
  3532. * @type function
  3533. * @date 19/11/2013
  3534. * @since 5.0.0
  3535. *
  3536. * @param $.fn
  3537. * @return (string)
  3538. */
  3539. $.fn.outerHTML = function () {
  3540. return $(this).get(0).outerHTML;
  3541. };
  3542. /*
  3543. * indexOf
  3544. *
  3545. * This function will provide compatibility for ie8
  3546. *
  3547. * @type function
  3548. * @date 5/3/17
  3549. * @since 5.5.10
  3550. *
  3551. * @param n/a
  3552. * @return n/a
  3553. */
  3554. if (!Array.prototype.indexOf) {
  3555. Array.prototype.indexOf = function (val) {
  3556. return $.inArray(val, this);
  3557. };
  3558. }
  3559. /**
  3560. * Returns true if value is a number or a numeric string.
  3561. *
  3562. * @date 30/11/20
  3563. * @since 5.9.4
  3564. * @link https://stackoverflow.com/questions/9716468/pure-javascript-a-function-like-jquerys-isnumeric/9716488#9716488
  3565. *
  3566. * @param mixed n The variable being evaluated.
  3567. * @return bool.
  3568. */
  3569. acf.isNumeric = function (n) {
  3570. return !isNaN(parseFloat(n)) && isFinite(n);
  3571. };
  3572. /**
  3573. * Triggers a "refresh" action used by various Components to redraw the DOM.
  3574. *
  3575. * @date 26/05/2020
  3576. * @since 5.9.0
  3577. *
  3578. * @param void
  3579. * @return void
  3580. */
  3581. acf.refresh = acf.debounce(function () {
  3582. $(window).trigger('acfrefresh');
  3583. acf.doAction('refresh');
  3584. }, 0); // Set up actions from events
  3585. $(document).ready(function () {
  3586. acf.doAction('ready');
  3587. });
  3588. $(window).on('load', function () {
  3589. // Use timeout to ensure action runs after Gutenberg has modified DOM elements during "DOMContentLoaded".
  3590. setTimeout(function () {
  3591. acf.doAction('load');
  3592. });
  3593. });
  3594. $(window).on('beforeunload', function () {
  3595. acf.doAction('unload');
  3596. });
  3597. $(window).on('resize', function () {
  3598. acf.doAction('resize');
  3599. });
  3600. $(document).on('sortstart', function (event, ui) {
  3601. acf.doAction('sortstart', ui.item, ui.placeholder);
  3602. });
  3603. $(document).on('sortstop', function (event, ui) {
  3604. acf.doAction('sortstop', ui.item, ui.placeholder);
  3605. });
  3606. })(jQuery);
  3607. /***/ })
  3608. /******/ });
  3609. /************************************************************************/
  3610. /******/ // The module cache
  3611. /******/ var __webpack_module_cache__ = {};
  3612. /******/
  3613. /******/ // The require function
  3614. /******/ function __webpack_require__(moduleId) {
  3615. /******/ // Check if module is in cache
  3616. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  3617. /******/ if (cachedModule !== undefined) {
  3618. /******/ return cachedModule.exports;
  3619. /******/ }
  3620. /******/ // Create a new module (and put it into the cache)
  3621. /******/ var module = __webpack_module_cache__[moduleId] = {
  3622. /******/ // no module.id needed
  3623. /******/ // no module.loaded needed
  3624. /******/ exports: {}
  3625. /******/ };
  3626. /******/
  3627. /******/ // Execute the module function
  3628. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  3629. /******/
  3630. /******/ // Return the exports of the module
  3631. /******/ return module.exports;
  3632. /******/ }
  3633. /******/
  3634. /************************************************************************/
  3635. /******/ /* webpack/runtime/compat get default export */
  3636. /******/ !function() {
  3637. /******/ // getDefaultExport function for compatibility with non-harmony modules
  3638. /******/ __webpack_require__.n = function(module) {
  3639. /******/ var getter = module && module.__esModule ?
  3640. /******/ function() { return module['default']; } :
  3641. /******/ function() { return module; };
  3642. /******/ __webpack_require__.d(getter, { a: getter });
  3643. /******/ return getter;
  3644. /******/ };
  3645. /******/ }();
  3646. /******/
  3647. /******/ /* webpack/runtime/define property getters */
  3648. /******/ !function() {
  3649. /******/ // define getter functions for harmony exports
  3650. /******/ __webpack_require__.d = function(exports, definition) {
  3651. /******/ for(var key in definition) {
  3652. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  3653. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  3654. /******/ }
  3655. /******/ }
  3656. /******/ };
  3657. /******/ }();
  3658. /******/
  3659. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  3660. /******/ !function() {
  3661. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  3662. /******/ }();
  3663. /******/
  3664. /******/ /* webpack/runtime/make namespace object */
  3665. /******/ !function() {
  3666. /******/ // define __esModule on exports
  3667. /******/ __webpack_require__.r = function(exports) {
  3668. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  3669. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  3670. /******/ }
  3671. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  3672. /******/ };
  3673. /******/ }();
  3674. /******/
  3675. /************************************************************************/
  3676. var __webpack_exports__ = {};
  3677. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  3678. !function() {
  3679. "use strict";
  3680. /*!*************************************************************!*\
  3681. !*** ./src/advanced-custom-fields-pro/assets/src/js/acf.js ***!
  3682. \*************************************************************/
  3683. __webpack_require__.r(__webpack_exports__);
  3684. /* harmony import */ var _acf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_acf.js */ "./src/advanced-custom-fields-pro/assets/src/js/_acf.js");
  3685. /* harmony import */ var _acf_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_acf_js__WEBPACK_IMPORTED_MODULE_0__);
  3686. /* harmony import */ var _acf_hooks_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./_acf-hooks.js */ "./src/advanced-custom-fields-pro/assets/src/js/_acf-hooks.js");
  3687. /* harmony import */ var _acf_hooks_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_acf_hooks_js__WEBPACK_IMPORTED_MODULE_1__);
  3688. /* harmony import */ var _acf_model_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_acf-model.js */ "./src/advanced-custom-fields-pro/assets/src/js/_acf-model.js");
  3689. /* harmony import */ var _acf_model_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_acf_model_js__WEBPACK_IMPORTED_MODULE_2__);
  3690. /* harmony import */ var _acf_popup_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./_acf-popup.js */ "./src/advanced-custom-fields-pro/assets/src/js/_acf-popup.js");
  3691. /* harmony import */ var _acf_popup_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_acf_popup_js__WEBPACK_IMPORTED_MODULE_3__);
  3692. /* harmony import */ var _acf_modal_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./_acf-modal.js */ "./src/advanced-custom-fields-pro/assets/src/js/_acf-modal.js");
  3693. /* harmony import */ var _acf_modal_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_acf_modal_js__WEBPACK_IMPORTED_MODULE_4__);
  3694. /* harmony import */ var _acf_panel_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./_acf-panel.js */ "./src/advanced-custom-fields-pro/assets/src/js/_acf-panel.js");
  3695. /* harmony import */ var _acf_panel_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_acf_panel_js__WEBPACK_IMPORTED_MODULE_5__);
  3696. /* harmony import */ var _acf_notice_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./_acf-notice.js */ "./src/advanced-custom-fields-pro/assets/src/js/_acf-notice.js");
  3697. /* harmony import */ var _acf_notice_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_acf_notice_js__WEBPACK_IMPORTED_MODULE_6__);
  3698. /* harmony import */ var _acf_tooltip_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./_acf-tooltip.js */ "./src/advanced-custom-fields-pro/assets/src/js/_acf-tooltip.js");
  3699. /* harmony import */ var _acf_tooltip_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_acf_tooltip_js__WEBPACK_IMPORTED_MODULE_7__);
  3700. }();
  3701. /******/ })()
  3702. ;
  3703. //# sourceMappingURL=acf.js.map