File "control.js.map"

Full Path: /home/pumpbmko/public_html/wp-content/plugins/kirki/kirki-packages/module-field-dependencies/dist/control.js.map
File size: 12.5 KB
MIME-type: application/json
Charset: utf-8

{"mappings":"YAAA,IAAIA,EAAoB,CACtBC,mBAAoB,GAEpBC,KAAM,WACJ,IAAIC,EAAOC,KAEXC,EAAEC,KACAC,OAAOC,0BACP,SAAUC,EAAcC,GACtB,IAAIC,EAAUC,GAAGC,UAAUF,QAAQD,GAE/BC,IACFF,EAAeN,EAAKW,eAAeL,GAEnCG,GAAGC,UAAUF,QAAQD,GAAaK,OAAOC,SAAWP,EACpDN,EAAKc,iBAAiBN,OAK5BN,EAAEC,KAAKH,EAAKF,oBAAoB,SAAUiB,EAAYC,GACpDd,EAAEC,KAAKY,EAAWE,WAAW,SAAUC,GACrCT,GAAGC,UAAUK,EAAWI,aAAa,SAAUC,GAqB7CX,GAAGC,UAAUF,QAAQU,GApBF,SAAUV,GAC3B,IAAIa,EACAC,EAEJA,EAAc,WACZ,OAAOtB,EAAKc,iBACVL,GAAGC,UAAUF,QAAQU,MAIzBG,EAAiB,WACfb,EAAQe,OAAOC,IAAIF,SAIrBF,EAAQK,KAAKJ,GAEbb,EAAQe,OAAOG,SAAWJ,eAgBpCK,eAAgB,SAAUC,GACxB,IAAIpB,EAAUqB,SAASC,cACrB,wBAA0BF,EAAY,MAEpCR,EAAUQ,EAQd,OANIpB,GACEoB,IAAcpB,EAAQuB,QAAQC,mBAChCZ,EAAUZ,EAAQuB,QAAQC,kBAIvBZ,GAGTT,eAAgB,SAAUL,GAC1B,IAAMN,EAAOC,KAiBX,OAfAK,EAAa2B,SAAQ,SAAUC,EAAaC,GACtCD,EAAYd,QACdd,EAAa6B,GAAkBhB,YAAcnB,EAAK2B,eAChDO,EAAYd,SAIVc,EAAYE,SACd9B,EAAa6B,GAAoBnC,EAAKW,eACpCL,EAAa6B,QAMd7B,GAUTQ,iBAAkB,SAAUN,GAC1B,IAGI6B,EAFAC,GAAO,EASX,GALI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KAAKsD,SAASG,EAAQC,EAAQ,WAAYF,GAG7CC,GAAUC,IAIrBM,OAAOpC,UAAUqC,OAAM,WACrBrE,EAAkBE","sources":["src/control.js"],"sourcesContent":["var kirkiDependencies = {\n  dependencyControls: {},\n\n  init: function () {\n    var self = this;\n\n    _.each(\n      window.kirkiControlDependencies,\n      function (requirements, dependantID) {\n        var control = wp.customize.control(dependantID);\n\n        if (control) {\n          requirements = self.addSettingLink(requirements);\n\n          wp.customize.control(dependantID).params.required = requirements;\n          self.showKirkiControl(control);\n        }\n      }\n    );\n\n    _.each(self.dependencyControls, function (dependency, dependencySetting) {\n      _.each(dependency.childrens, function (childrenSetting) {\n        wp.customize(dependency.settingLink, function (setting) {\n          var setupControl = function (control) {\n            var setActiveState;\n            var isDisplayed;\n\n            isDisplayed = function () {\n              return self.showKirkiControl(\n                wp.customize.control(childrenSetting)\n              );\n            };\n\n            setActiveState = function () {\n              control.active.set(isDisplayed());\n            };\n\n            setActiveState();\n            setting.bind(setActiveState);\n\n            control.active.validate = isDisplayed;\n          };\n\n          wp.customize.control(childrenSetting, setupControl);\n        });\n      });\n    });\n  },\n\n  /**\n   * Get the actual customize setting link of a control.\n   *\n   * @since 1.0.3\n   * @param {string} controlID The ID of the control.\n   * @return {string} The setting link.\n   */\n  getSettingLink: function (controlID) {\n    var control = document.querySelector(\n      '[data-kirki-setting=\"' + controlID + '\"]'\n    );\n    var setting = controlID;\n\n    if (control) {\n      if (controlID !== control.dataset.kirkiSettingLink) {\n        setting = control.dataset.kirkiSettingLink;\n      }\n    }\n\n    return setting;\n  },\n\n  addSettingLink: function (requirements) {\n\t\tconst self = this;\n\n    requirements.forEach(function (requirement, requirementIndex) {\n      if (requirement.setting) {\n        requirements[requirementIndex].settingLink = self.getSettingLink(\n          requirement.setting\n        );\n      } else {\n        // If `requirement` is an array, then it has nested dependencies, so let's loop it.\n        if (requirement.length) {\n          requirements[requirementIndex] = self.addSettingLink(\n            requirements[requirementIndex]\n          );\n        }\n      }\n    });\n\n    return requirements;\n  },\n\n  /**\n   * Should we show the control?\n   *\n   * @since 3.0.17\n   * @param {string|object} control - The control-id or the control object.\n   * @returns {bool} - Whether the control should be shown or not.\n   */\n  showKirkiControl: function (control) {\n    const self = this;\n    let show = true;\n\n    let i;\n\n    if (_.isString(control)) {\n      control = wp.customize.control(control);\n    }\n\n    // Exit early if control not found or if \"required\" argument is not defined.\n    if (\n      \"undefined\" === typeof control ||\n      (control.params && _.isEmpty(control.params.required))\n    ) {\n      return true;\n    }\n\n    // Loop control requirements.\n    for (i = 0; i < control.params.required.length; i++) {\n      if (!self.checkCondition(control.params.required[i], control, \"AND\")) {\n        show = false;\n      }\n    }\n\n    return show;\n  },\n\n  /**\n   * Check a condition.\n   *\n   * @param {Object} dependency - The dependency, inherited from showKirkiControl.\n   * @param {Object} dependantControl - The dependant control object.\n   * @param {string} relation - Can be one of 'AND' or 'OR'.\n   * @returns {bool} - Returns the results of the condition checks.\n   */\n  checkCondition: function (dependency, dependantControl, relation) {\n    let self = this;\n    let childRelation = \"AND\" === relation ? \"OR\" : \"AND\";\n    let nestedItems;\n    let value;\n    let i;\n\n    // If dependency has nested dependants, we need to process them separately.\n    if (\n      \"undefined\" !== typeof dependency[0] &&\n      \"undefined\" === typeof dependency.setting\n    ) {\n      nestedItems = [];\n\n      // Loop sub-dependencies.\n      for (i = 0; i < dependency.length; i++) {\n        nestedItems.push(\n          self.checkCondition(dependency[i], dependantControl, childRelation)\n        );\n      }\n\n      // OR relation. Check that true is part of the array.\n      if (\"OR\" === childRelation) {\n        return -1 !== nestedItems.indexOf(true);\n      }\n\n      // AND relation. Check that false is not part of the array.\n      return -1 === nestedItems.indexOf(false);\n    } // End of nested dependants processing.\n\n    if (\"undefined\" === typeof wp.customize.control(dependency.setting)) {\n      // Early exit if setting is not defined.\n      return true;\n    }\n\n    if (!self.dependencyControls[dependency.setting]) {\n      self.dependencyControls[dependency.setting] = {\n        settingLink: dependency.settingLink,\n        childrens: [],\n      };\n    }\n\n    if (\n      !self.dependencyControls[dependency.setting].childrens.includes(\n        dependantControl.id\n      )\n    ) {\n      self.dependencyControls[dependency.setting].childrens.push(\n        dependantControl.id\n      );\n    }\n\n    if (!dependency.settingLink) {\n      // console.log(dependency);\n      // console.log(dependantControl);\n      console.log(self.dependencyControls);\n      console.log(\"--------\");\n    }\n\n    value = wp.customize(dependency.settingLink).get();\n\n    if (wp.customize.control(dependency.setting).setting) {\n      value = wp.customize.control(dependency.setting).setting._value;\n    }\n\n    return self.evaluate(\n      dependency.value,\n      value,\n      dependency.operator,\n      dependency.choice\n    );\n  },\n\n  /**\n   * Figure out if the 2 values have the relation we want.\n   *\n   * @since 3.0.17\n   * @param {mixed} value1 - The 1st value.\n   * @param {mixed} value2 - The 2nd value.\n   * @param {string} operator - The comparison to use.\n   * @param {string} choice - If we want to check an item in an object value.\n   * @returns {bool} - Returns the evaluation result.\n   */\n  evaluate: function (value1, value2, operator, choice) {\n    var found = false;\n\n    if (choice && \"object\" === typeof value2) {\n      value2 = value2[choice];\n    }\n\n    if (\"===\" === operator) {\n      return value1 === value2;\n    }\n\n    if (\n      \"==\" === operator ||\n      \"=\" === operator ||\n      \"equals\" === operator ||\n      \"equal\" === operator\n    ) {\n      return value1 == value2;\n    }\n\n    if (\"!==\" === operator) {\n      return value1 !== value2;\n    }\n\n    if (\"!=\" === operator || \"not equal\" === operator) {\n      return value1 != value2;\n    }\n\n    if (\n      \">=\" === operator ||\n      \"greater or equal\" === operator ||\n      \"equal or greater\" === operator\n    ) {\n      return value2 >= value1;\n    }\n\n    if (\n      \"<=\" === operator ||\n      \"smaller or equal\" === operator ||\n      \"equal or smaller\" === operator\n    ) {\n      return value2 <= value1;\n    }\n\n    if (\">\" === operator || \"greater\" === operator) {\n      return value2 > value1;\n    }\n\n    if (\"<\" === operator || \"smaller\" === operator) {\n      return value2 < value1;\n    }\n\n    if (\"contains\" === operator || \"in\" === operator) {\n      if (_.isArray(value1) && _.isArray(value2)) {\n        _.each(value2, function (value) {\n          if (value1.includes(value)) {\n            found = true;\n            return false;\n          }\n        });\n\n        return found;\n      }\n\n      if (_.isArray(value2)) {\n        _.each(value2, function (value) {\n          if (value == value1) {\n            // jshint ignore:line\n            found = true;\n          }\n        });\n        return found;\n      }\n\n      if (_.isObject(value2)) {\n        if (!_.isUndefined(value2[value1])) {\n          found = true;\n        }\n        _.each(value2, function (subValue) {\n          if (value1 === subValue) {\n            found = true;\n          }\n        });\n        return found;\n      }\n\n      if (_.isString(value2)) {\n        if (_.isString(value1)) {\n          return -1 < value1.indexOf(value2) && -1 < value2.indexOf(value1);\n        }\n        return -1 < value1.indexOf(value2);\n      }\n    }\n\n    if (\"does not contain\" === operator || \"not in\" === operator) {\n      return !this.evaluate(value1, value2, \"contains\", choice);\n    }\n\n    return value1 == value2;\n  },\n};\n\njQuery(document).ready(function () {\n  kirkiDependencies.init();\n});\n"],"names":["$1abc80d3e2df1201$var$kirkiDependencies","dependencyControls","init","self","this","_","each","window","kirkiControlDependencies","requirements","dependantID","control","wp","customize","addSettingLink","params","required","showKirkiControl","dependency","dependencySetting","childrens","childrenSetting","settingLink","setting","setActiveState","isDisplayed","active","set","bind","validate","getSettingLink","controlID","document","querySelector","dataset","kirkiSettingLink","forEach","requirement","requirementIndex","length","i","show","isString","isEmpty","checkCondition","dependantControl","relation","nestedItems","value","childRelation","push","indexOf","includes","id","console","log","get","_value","evaluate","operator","choice","value1","value2","found","isArray","isObject","isUndefined","subValue","jQuery","ready"],"version":3,"file":"control.js.map"}