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

filter.js « plugins « droplab « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9401c047a8782b1af6d64e9781ae29884b9e32b (plain)
1
!function(n){function e(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return n[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var t={};e.m=n,e.c=t,e.i=function(n){return n},e.d=function(n,t,o){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:o})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="",e(e.s=12)}({12:function(module,exports,__webpack_require__){"use strict";eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nvar droplabFilter = {\n  keydown: function keydown(e) {\n    var hiddenCount = 0;\n    var dataHiddenCount = 0;\n\n    var list = e.detail.hook.list;\n    var data = list.data;\n    var value = e.detail.hook.trigger.value.toLowerCase();\n    var config = e.detail.hook.config.droplabFilter;\n    var matches = [];\n    var filterFunction;\n    // will only work on dynamically set data\n    if (!data) {\n      return;\n    }\n\n    if (config && config.filterFunction && typeof config.filterFunction === 'function') {\n      filterFunction = config.filterFunction;\n    } else {\n      filterFunction = function filterFunction(o) {\n        // cheap string search\n        o.droplab_hidden = o[config.template].toLowerCase().indexOf(value) === -1;\n        return o;\n      };\n    }\n\n    dataHiddenCount = data.filter(function (o) {\n      return !o.droplab_hidden;\n    }).length;\n\n    matches = data.map(function (o) {\n      return filterFunction(o, value);\n    });\n\n    hiddenCount = matches.filter(function (o) {\n      return !o.droplab_hidden;\n    }).length;\n\n    if (dataHiddenCount !== hiddenCount) {\n      list.render(matches);\n      list.currentIndex = 0;\n    }\n  },\n\n  debounceKeydown: function debounceKeydown(e) {\n    if ([13, // enter\n    16, // shift\n    17, // ctrl\n    18, // alt\n    20, // caps lock\n    37, // left arrow\n    38, // up arrow\n    39, // right arrow\n    40, // down arrow\n    91, // left window\n    92, // right window\n    93].indexOf(e.detail.which || e.detail.keyCode) > -1) return;\n\n    if (this.timeout) clearTimeout(this.timeout);\n    this.timeout = setTimeout(this.keydown.bind(this, e), 200);\n  },\n\n  init: function init(hook) {\n    var config = hook.config.droplabFilter;\n\n    if (!config || !config.template) return;\n\n    this.hook = hook;\n\n    this.eventWrapper = {};\n    this.eventWrapper.debounceKeydown = this.debounceKeydown.bind(this);\n\n    this.hook.trigger.addEventListener('keydown.dl', this.eventWrapper.debounceKeydown);\n  },\n\n  destroy: function destroy() {\n    this.hook.trigger.removeEventListener('keydown.dl', this.eventWrapper.debounceKeydown);\n\n    var dynamicList = this.hook.list.list.querySelector('[data-dynamic]');\n    if (this.listTemplate && dynamicList) {\n      dynamicList.outerHTML = this.listTemplate;\n    }\n  }\n};\n\nwindow.droplabFilter = droplabFilter;\n\nexports.default = droplabFilter;\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/plugins/filter.js\n// module id = 12\n// module chunks = 1\n\n//# sourceURL=webpack:///./src/plugins/filter.js?")}});