Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ajax_filter.js.map « plugins « droplab « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1e1b0003de66d8d031966b4864ffac91fd72d1c4 (plain)
1
{"version":3,"sources":["webpack:///dist/plugins/ajax_filter.js","webpack:///webpack/bootstrap 595d943f775089263f5d?9279*","webpack:///./src/plugins/ajax_filter.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","11","droplabAjaxFilter","init","hook","this","destroyed","notLoading","eventWrapper","debounceTrigger","bind","trigger","addEventListener","loading","e","NON_CHARACTER_KEYS","invalidKeyPressed","indexOf","detail","which","keyCode","focusEvent","type","timeout","clearTimeout","setTimeout","getEntireList","config","searchValue","endpoint","searchKey","searchValueFunction","loadingTemplate","undefined","list","data","length","dynamicList","querySelector","document","createElement","innerHTML","setAttribute","listTemplate","outerHTML","show","params","self","cache","url","buildParams","urlCachedData","_loadData","_loadUrlData","then","Promise","resolve","reject","xhr","XMLHttpRequest","open","onreadystatechange","readyState","DONE","status","JSON","parse","responseText","send","dataLoadingTemplate","hookListChildren","children","hasAttribute","hide","setData","currentIndex","keys","map","param","join","destroy","removeEventListener","window","default"],"mappings":"CAAS,SAAUA,GCInB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAI,EAAAJ,EACAK,GAAA,EACAH,WAUA,OANAJ,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,GAAA,EAGAF,EAAAD,QAvBA,GAAAD,KA4BAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAK,EAAA,SAAAK,GAA2C,MAAAA,IAG3CV,EAAAW,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IAAQC,EAAIS,aAAcT,EAAIM,WAI3CN,EAAIU,UAIRhB,UAAW,SAAmBjB,EAAMR,EAAQoB,GAC1C,GAAMb,GAAOa,EAAK3C,KAAK8B,IACvB,IAAIP,EAAOK,iBAAiCC,SAAdC,EAAKC,MACZ,IAArBD,EAAKC,KAAKC,OAAc,CACxB,GAAMiC,GAAsBnC,EAAKA,KAAKI,cAAc,0BAChD+B,KACFA,EAAoBzB,UAAYG,EAAKJ,cAGzC,IAAKI,EAAKzC,UAAW,CACnB,GAAIgE,GAAmBpC,EAAKA,KAAKqC,QACiB,KAA5BD,EAAiBlC,QAAgBkC,EAAiB,GAAGE,aAAa,iBACjD,IAAhBrC,EAAKC,QAC1BF,EAAKuC,OAEPvC,EAAKwC,QAAQ9F,KAAKsD,EAAMC,GAE1BY,EAAKxC,aACL2B,EAAKyC,aAAe,GAGtBzB,YAAa,SAASJ,GACpB,MAAKA,GAIE,IAHW1D,OAAOwF,KAAK9B,GAAQ+B,IAAI,SAASC,GACjD,MAAOA,GAAQ,KAAOhC,EAAOgC,IAAU,MAEhBC,KAAK,KAJV,IAOtBC,QAAS,WACH3E,KAAKkB,SACPC,aAAanB,KAAKkB,SAGpBlB,KAAKC,WAAY,EACjBD,KAAKD,KAAKO,QAAQsE,oBAAoB,aAAc5E,KAAKG,aAAaC,iBACtEJ,KAAKD,KAAKO,QAAQsE,oBAAoB,QAAS5E,KAAKG,aAAaC,kBAIrEyE,QAAOhF,kBAAoBA,EF8E3B1B,EAAQ2G,QE5EOjF","file":"./dist/plugins/ajax_filter.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 11);\n/******/ })\n/************************************************************************/\n/******/ ({\n\n/***/ 11:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nvar droplabAjaxFilter = {\n  init: function init(hook) {\n    this.destroyed = false;\n    this.hook = hook;\n    this.notLoading();\n\n    this.eventWrapper = {};\n    this.eventWrapper.debounceTrigger = this.debounceTrigger.bind(this);\n    this.hook.trigger.addEventListener('keydown.dl', this.eventWrapper.debounceTrigger);\n    this.hook.trigger.addEventListener('focus', this.eventWrapper.debounceTrigger);\n\n    this.trigger(true);\n  },\n\n  notLoading: function notLoading() {\n    this.loading = false;\n  },\n\n  debounceTrigger: function debounceTrigger(e) {\n    var NON_CHARACTER_KEYS = [16, 17, 18, 20, 37, 38, 39, 40, 91, 93];\n    var invalidKeyPressed = NON_CHARACTER_KEYS.indexOf(e.detail.which || e.detail.keyCode) > -1;\n    var focusEvent = e.type === 'focus';\n    if (invalidKeyPressed || this.loading) {\n      return;\n    }\n    if (this.timeout) {\n      clearTimeout(this.timeout);\n    }\n    this.timeout = setTimeout(this.trigger.bind(this, focusEvent), 200);\n  },\n\n  trigger: function trigger(getEntireList) {\n    var config = this.hook.config.droplabAjaxFilter;\n    var searchValue = this.trigger.value;\n    if (!config || !config.endpoint || !config.searchKey) {\n      return;\n    }\n    if (config.searchValueFunction) {\n      searchValue = config.searchValueFunction();\n    }\n    if (config.loadingTemplate && this.hook.list.data === undefined || this.hook.list.data.length === 0) {\n      var dynamicList = this.hook.list.list.querySelector('[data-dynamic]');\n      var loadingTemplate = document.createElement('div');\n      loadingTemplate.innerHTML = config.loadingTemplate;\n      loadingTemplate.setAttribute('data-loading-template', true);\n      this.listTemplate = dynamicList.outerHTML;\n      dynamicList.outerHTML = loadingTemplate.outerHTML;\n    }\n    if (getEntireList) {\n      searchValue = '';\n    }\n    if (config.searchKey === searchValue) {\n      return this.list.show();\n    }\n    this.loading = true;\n    var params = config.params || {};\n    params[config.searchKey] = searchValue;\n    var self = this;\n    self.cache = self.cache || {};\n    var url = config.endpoint + this.buildParams(params);\n    var urlCachedData = self.cache[url];\n    if (urlCachedData) {\n      self._loadData(urlCachedData, config, self);\n    } else {\n      this._loadUrlData(url).then(function (data) {\n        self._loadData(data, config, self);\n      });\n    }\n  },\n\n  _loadUrlData: function _loadUrlData(url) {\n    var self = this;\n    return new Promise(function (resolve, reject) {\n      var xhr = new XMLHttpRequest();\n      xhr.open('GET', url, true);\n      xhr.onreadystatechange = function () {\n        if (xhr.readyState === XMLHttpRequest.DONE) {\n          if (xhr.status === 200) {\n            var data = JSON.parse(xhr.responseText);\n            self.cache[url] = data;\n            return resolve(data);\n          } else {\n            return reject([xhr.responseText, xhr.status]);\n          }\n        }\n      };\n      xhr.send();\n    });\n  },\n\n  _loadData: function _loadData(data, config, self) {\n    var list = self.hook.list;\n    if (config.loadingTemplate && list.data === undefined || list.data.length === 0) {\n      var dataLoadingTemplate = list.list.querySelector('[data-loading-template]');\n      if (dataLoadingTemplate) {\n        dataLoadingTemplate.outerHTML = self.listTemplate;\n      }\n    }\n    if (!self.destroyed) {\n      var hookListChildren = list.list.children;\n      var onlyDynamicList = hookListChildren.length === 1 && hookListChildren[0].hasAttribute('data-dynamic');\n      if (onlyDynamicList && data.length === 0) {\n        list.hide();\n      }\n      list.setData.call(list, data);\n    }\n    self.notLoading();\n    list.currentIndex = 0;\n  },\n\n  buildParams: function buildParams(params) {\n    if (!params) return '';\n    var paramsArray = Object.keys(params).map(function (param) {\n      return param + '=' + (params[param] || '');\n    });\n    return '?' + paramsArray.join('&');\n  },\n\n  destroy: function destroy() {\n    if (this.timeout) {\n      clearTimeout(this.timeout);\n    }\n\n    this.destroyed = true;\n    this.hook.trigger.removeEventListener('keydown.dl', this.eventWrapper.debounceTrigger);\n    this.hook.trigger.removeEventListener('focus', this.eventWrapper.debounceTrigger);\n  }\n};\n\nwindow.droplabAjaxFilter = droplabAjaxFilter;\n\nexports.default = droplabAjaxFilter;\n\n/***/ })\n\n/******/ });\n\n\n// WEBPACK FOOTER //\n// dist/plugins/ajax_filter.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 11);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 595d943f775089263f5d","const droplabAjaxFilter = {\n  init: function(hook) {\n    this.destroyed = false;\n    this.hook = hook;\n    this.notLoading();\n\n    this.eventWrapper = {};\n    this.eventWrapper.debounceTrigger = this.debounceTrigger.bind(this);\n    this.hook.trigger.addEventListener('keydown.dl', this.eventWrapper.debounceTrigger);\n    this.hook.trigger.addEventListener('focus', this.eventWrapper.debounceTrigger);\n\n    this.trigger(true);\n  },\n\n  notLoading: function notLoading() {\n    this.loading = false;\n  },\n\n  debounceTrigger: function debounceTrigger(e) {\n    var NON_CHARACTER_KEYS = [16, 17, 18, 20, 37, 38, 39, 40, 91, 93];\n    var invalidKeyPressed = NON_CHARACTER_KEYS.indexOf(e.detail.which || e.detail.keyCode) > -1;\n    var focusEvent = e.type === 'focus';\n    if (invalidKeyPressed || this.loading) {\n      return;\n    }\n    if (this.timeout) {\n      clearTimeout(this.timeout);\n    }\n    this.timeout = setTimeout(this.trigger.bind(this, focusEvent), 200);\n  },\n\n  trigger: function trigger(getEntireList) {\n    var config = this.hook.config.droplabAjaxFilter;\n    var searchValue = this.trigger.value;\n    if (!config || !config.endpoint || !config.searchKey) {\n      return;\n    }\n    if (config.searchValueFunction) {\n      searchValue = config.searchValueFunction();\n    }\n    if (config.loadingTemplate && this.hook.list.data === undefined ||\n      this.hook.list.data.length === 0) {\n      var dynamicList = this.hook.list.list.querySelector('[data-dynamic]');\n      var loadingTemplate = document.createElement('div');\n      loadingTemplate.innerHTML = config.loadingTemplate;\n      loadingTemplate.setAttribute('data-loading-template', true);\n      this.listTemplate = dynamicList.outerHTML;\n      dynamicList.outerHTML = loadingTemplate.outerHTML;\n    }\n    if (getEntireList) {\n      searchValue = '';\n    }\n    if (config.searchKey === searchValue) {\n      return this.list.show();\n    }\n    this.loading = true;\n    var params = config.params || {};\n    params[config.searchKey] = searchValue;\n    var self = this;\n    self.cache = self.cache || {};\n    var url = config.endpoint + this.buildParams(params);\n    var urlCachedData = self.cache[url];\n    if (urlCachedData) {\n      self._loadData(urlCachedData, config, self);\n    } else {\n      this._loadUrlData(url)\n        .then(function(data) {\n          self._loadData(data, config, self);\n        });\n    }\n  },\n\n  _loadUrlData: function _loadUrlData(url) {\n    var self = this;\n    return new Promise(function(resolve, reject) {\n      var xhr = new XMLHttpRequest;\n      xhr.open('GET', url, true);\n      xhr.onreadystatechange = function () {\n        if(xhr.readyState === XMLHttpRequest.DONE) {\n          if (xhr.status === 200) {\n            var data = JSON.parse(xhr.responseText);\n            self.cache[url] = data;\n            return resolve(data);\n          } else {\n            return reject([xhr.responseText, xhr.status]);\n          }\n        }\n      };\n      xhr.send();\n    });\n  },\n\n  _loadData: function _loadData(data, config, self) {\n    const list = self.hook.list;\n    if (config.loadingTemplate && list.data === undefined ||\n      list.data.length === 0) {\n      const dataLoadingTemplate = list.list.querySelector('[data-loading-template]');\n      if (dataLoadingTemplate) {\n        dataLoadingTemplate.outerHTML = self.listTemplate;\n      }\n    }\n    if (!self.destroyed) {\n      var hookListChildren = list.list.children;\n      var onlyDynamicList = hookListChildren.length === 1 && hookListChildren[0].hasAttribute('data-dynamic');\n      if (onlyDynamicList && data.length === 0) {\n        list.hide();\n      }\n      list.setData.call(list, data);\n    }\n    self.notLoading();\n    list.currentIndex = 0;\n  },\n\n  buildParams: function(params) {\n    if (!params) return '';\n    var paramsArray = Object.keys(params).map(function(param) {\n      return param + '=' + (params[param] || '');\n    });\n    return '?' + paramsArray.join('&');\n  },\n\n  destroy: function destroy() {\n    if (this.timeout) {\n      clearTimeout(this.timeout);\n    }\n\n    this.destroyed = true;\n    this.hook.trigger.removeEventListener('keydown.dl', this.eventWrapper.debounceTrigger);\n    this.hook.trigger.removeEventListener('focus', this.eventWrapper.debounceTrigger);\n  }\n};\n\nwindow.droplabAjaxFilter = droplabAjaxFilter;\n\nexport default droplabAjaxFilter;\n\n\n\n// WEBPACK FOOTER //\n// ./src/plugins/ajax_filter.js"],"sourceRoot":""}