mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-03 14:32:21 +02:00
4481fbe361
branch: master
SHA: c7d6de72f7
range SHA: 81f31a3106fb...c7d6de72f785
build id: 375208741
build number: 1103
667 lines
38 KiB
HTML
667 lines
38 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<base data-ice="baseUrl" href="../../../">
|
|
<title data-ice="title">src/modules/checkList.js | tablefilter</title>
|
|
<link type="text/css" rel="stylesheet" href="css/style.css">
|
|
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
|
|
<script src="script/prettify/prettify.js"></script>
|
|
<script src="script/manual.js"></script>
|
|
<meta name="description" content="A Javascript library making HTML tables filterable and a bit more"><meta property="twitter:card" content="summary"><meta property="twitter:title" content="tablefilter"><meta property="twitter:description" content="A Javascript library making HTML tables filterable and a bit more"></head>
|
|
<body class="layout-container" data-ice="rootContainer">
|
|
|
|
<header>
|
|
<a href="./">Home</a>
|
|
|
|
<a href="identifiers.html">Reference</a>
|
|
<a href="source.html">Source</a>
|
|
|
|
<div class="search-box">
|
|
<span>
|
|
<img src="./image/search.png">
|
|
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
|
|
</span>
|
|
<ul class="search-result"></ul>
|
|
</div>
|
|
<a style="position:relative; top:3px;" href="https://github.com/koalyptus/TableFilter.git"><img width="20px" src="./image/github.png"></a></header>
|
|
|
|
<nav class="navigation" data-ice="nav"><div>
|
|
<ul>
|
|
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/emitter.js~Emitter.html">Emitter</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/feature.js~Feature.html">Feature</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/tablefilter.js~TableFilter.html">TableFilter</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-has">has</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-addClass">addClass</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCheckItem">createCheckItem</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createElm">createElm</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOpt">createOpt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createText">createText</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-elm">elm</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getFirstTextNode">getFirstTextNode</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getText">getText</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-hasClass">hasClass</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-removeClass">removeClass</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-removeElm">removeElm</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-tag">tag</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-addEvt">addEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-cancelEvt">cancelEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isKeyPressed">isKeyPressed</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-keyCode">keyCode</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-removeEvt">removeEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-stopEvt">stopEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-targetEvt">targetEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-parse">parse</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsArr">defaultsArr</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsBool">defaultsBool</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsFn">defaultsFn</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsNb">defaultsNb</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsStr">defaultsStr</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-dateSortAsc">dateSortAsc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-dateSortDesc">dateSortDesc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ignoreCase">ignoreCase</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-numSortAsc">numSortAsc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-numSortDesc">numSortDesc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-sortDateStr">sortDateStr</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-sortNumberStr">sortNumberStr</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-contains">contains</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isEmpty">isEmpty</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-matchCase">matchCase</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-rgxEsc">rgxEsc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-trim">trim</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-EMPTY_FN">EMPTY_FN</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isArray">isArray</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isBoolean">isBoolean</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isEmpty">isEmpty</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isFn">isFn</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isNull">isNull</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isNumber">isNumber</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isObj">isObj</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isString">isString</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isUndef">isUndef</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-AUTO_FILTER_DELAY">AUTO_FILTER_DELAY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-CELL_TAG">CELL_TAG</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-CHECKLIST">CHECKLIST</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-DATE">DATE</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-DOWN_ARROW_KEY">DOWN_ARROW_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-ENTER_KEY">ENTER_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-ESC_KEY">ESC_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-FEATURES">FEATURES</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-FORMATTED_NUMBER">FORMATTED_NUMBER</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-HEADER_TAG">HEADER_TAG</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-INPUT">INPUT</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-IP_ADDRESS">IP_ADDRESS</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-MULTIPLE">MULTIPLE</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-NONE">NONE</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-NUMBER">NUMBER</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-SELECT">SELECT</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-STRING">STRING</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-TAB_KEY">TAB_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-UP_ARROW_KEY">UP_ARROW_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-root">root</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-advancedgrid">extensions/advancedGrid</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/advancedGrid/adapterEzEditTable.js~AdapterEzEditTable.html">AdapterEzEditTable</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-colops">extensions/colOps</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/colOps/colOps.js~ColOps.html">ColOps</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-colsvisibility">extensions/colsVisibility</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/colsVisibility/colsVisibility.js~ColsVisibility.html">ColsVisibility</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-filtersvisibility">extensions/filtersVisibility</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/filtersVisibility/filtersVisibility.js~FiltersVisibility.html">FiltersVisibility</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-sort">extensions/sort</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/sort/adapterSortabletable.js~AdapterSortableTable.html">AdapterSortableTable</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#modules">modules</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/alternateRows.js~AlternateRows.html">AlternateRows</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/baseDropdown.js~BaseDropdown.html">BaseDropdown</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/checkList.js~CheckList.html">CheckList</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/clearButton.js~ClearButton.html">ClearButton</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/dateType.js~DateType.html">DateType</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/dropdown.js~Dropdown.html">Dropdown</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/gridLayout.js~GridLayout.html">GridLayout</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/hash.js~Hash.html">Hash</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/help.js~Help.html">Help</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/highlightKeywords.js~HighlightKeyword.html">HighlightKeyword</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/loader.js~Loader.html">Loader</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/markActiveColumns.js~MarkActiveColumns.html">MarkActiveColumns</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/noResults.js~NoResults.html">NoResults</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/paging.js~Paging.html">Paging</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/popupFilter.js~PopupFilter.html">PopupFilter</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/rowsCounter.js~RowsCounter.html">RowsCounter</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/state.js~State.html">State</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/statusBar.js~StatusBar.html">StatusBar</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/storage.js~Storage.html">Storage</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/toolbar.js~Toolbar.html">Toolbar</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-hasHashChange">hasHashChange</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-hasStorage">hasStorage</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-CENTER">CENTER</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-LEFT">LEFT</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-RIGHT">RIGHT</a></span></span></li>
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="content" data-ice="content"><h1 data-ice="title">src/modules/checkList.js</h1>
|
|
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import {BaseDropdown} from './baseDropdown';
|
|
import {
|
|
addClass, createCheckItem, createText, createElm, elm, removeClass, tag
|
|
} from '../dom';
|
|
import {has} from '../array';
|
|
import {matchCase, trim, rgxEsc} from '../string';
|
|
import {addEvt, removeEvt, targetEvt} from '../event';
|
|
import {isEmpty} from '../types';
|
|
import {CHECKLIST, NONE} from '../const';
|
|
import {defaultsStr, defaultsBool} from '../settings';
|
|
|
|
/**
|
|
* Checklist filter UI component
|
|
* @export
|
|
* @class CheckList
|
|
* @extends {BaseDropdown}
|
|
*/
|
|
export class CheckList extends BaseDropdown {
|
|
|
|
/**
|
|
* Creates an instance of CheckList
|
|
* @param {TableFilter} tf TableFilter instance
|
|
*/
|
|
constructor(tf) {
|
|
super(tf, 'checkList');
|
|
|
|
let f = this.config;
|
|
|
|
/**
|
|
* List of container DOM elements
|
|
* @type {Array}
|
|
*/
|
|
this.containers = [];
|
|
|
|
/**
|
|
* Css class for the container of the checklist filter (div)
|
|
* @type {String}
|
|
*/
|
|
this.containerCssClass = defaultsStr(f.div_checklist_css_class,
|
|
'div_checklist');
|
|
|
|
/**
|
|
* Css class for the checklist filter element (ul)
|
|
* @type {String}
|
|
*/
|
|
this.filterCssClass = defaultsStr(f.checklist_css_class,
|
|
'flt_checklist');
|
|
|
|
/**
|
|
* Css class for the item of a checklist (li)
|
|
* @type {String}
|
|
*/
|
|
this.itemCssClass = defaultsStr(f.checklist_item_css_class,
|
|
'flt_checklist_item');
|
|
|
|
/**
|
|
* Css class for a selected item of a checklist (li)
|
|
* @type {String}
|
|
*/
|
|
this.selectedItemCssClass = defaultsStr(
|
|
f.checklist_selected_item_css_class,
|
|
'flt_checklist_slc_item'
|
|
);
|
|
|
|
/**
|
|
* Text placed in the filter's container when load filter on demand
|
|
* feature is enabled
|
|
* @type {String}
|
|
*/
|
|
this.activateText = defaultsStr(
|
|
f.activate_checklist_text,
|
|
'Click to load filter data'
|
|
);
|
|
|
|
/**
|
|
* Css class for a disabled item of a checklist (li)
|
|
* @type {String}
|
|
*/
|
|
this.disabledItemCssClass = defaultsStr(
|
|
f.checklist_item_disabled_css_class,
|
|
'flt_checklist_item_disabled'
|
|
);
|
|
|
|
/**
|
|
* Enable the reset filter option as first item
|
|
* @type {Boolean}
|
|
*/
|
|
this.enableResetOption = defaultsBool(f.enable_checklist_reset_filter,
|
|
true);
|
|
|
|
/**
|
|
* Prefix for container element ID
|
|
* @type {String}
|
|
* @private
|
|
*/
|
|
this.prfx = 'chkdiv_';
|
|
}
|
|
|
|
/**
|
|
* Checklist option click event handler
|
|
* @param {Event} evt
|
|
* @private
|
|
*/
|
|
optionClick(evt) {
|
|
let elm = targetEvt(evt);
|
|
let tf = this.tf;
|
|
|
|
this.emitter.emit('filter-focus', tf, elm);
|
|
this.setItemOption(elm);
|
|
tf.filter();
|
|
}
|
|
|
|
/**
|
|
* Checklist container click event handler for load-on-demand feature
|
|
* @param {Event} evt
|
|
* @private
|
|
*/
|
|
onCheckListClick(evt) {
|
|
let elm = targetEvt(evt);
|
|
if (this.tf.loadFltOnDemand && elm.getAttribute('filled') === '0') {
|
|
let ct = elm.getAttribute('ct');
|
|
let div = this.containers[ct];
|
|
this.build(ct);
|
|
removeEvt(div, 'click', (evt) => this.onCheckListClick(evt));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Refresh all checklist filters
|
|
*/
|
|
refreshAll() {
|
|
let colIdxs = this.tf.getFiltersByType(CHECKLIST, true);
|
|
this.refreshFilters(colIdxs);
|
|
}
|
|
|
|
/**
|
|
* Initialize checklist filter
|
|
* @param {Number} colIndex Column index
|
|
* @param {Boolean} isExternal External filter flag
|
|
* @param {DOMElement} container Dom element containing the filter
|
|
*/
|
|
init(colIndex, isExternal, container) {
|
|
let tf = this.tf;
|
|
let externalFltTgtId = isExternal ?
|
|
tf.externalFltIds[colIndex] : null;
|
|
|
|
let divCont = createElm('div',
|
|
['id', `${this.prfx}${colIndex}_${tf.id}`],
|
|
['ct', colIndex], ['filled', '0']);
|
|
divCont.className = this.containerCssClass;
|
|
|
|
//filter is appended in desired element
|
|
if (externalFltTgtId) {
|
|
elm(externalFltTgtId).appendChild(divCont);
|
|
} else {
|
|
container.appendChild(divCont);
|
|
}
|
|
|
|
this.containers[colIndex] = divCont;
|
|
tf.fltIds.push(tf.buildFilterId(colIndex));
|
|
|
|
if (!tf.loadFltOnDemand) {
|
|
this.build(colIndex);
|
|
} else {
|
|
addEvt(divCont, 'click', (evt) => this.onCheckListClick(evt));
|
|
divCont.appendChild(createText(this.activateText));
|
|
}
|
|
|
|
this.emitter.on(
|
|
['build-checklist-filter'],
|
|
(tf, colIndex, isLinked) => this.build(colIndex, isLinked)
|
|
);
|
|
|
|
this.emitter.on(
|
|
['select-checklist-options'],
|
|
(tf, colIndex, values) => this.selectOptions(colIndex, values)
|
|
);
|
|
|
|
this.emitter.on(['rows-changed'], () => this.refreshAll());
|
|
|
|
/** @inherited */
|
|
this.initialized = true;
|
|
}
|
|
|
|
/**
|
|
* Build checklist UI
|
|
* @param {Number} colIndex Column index
|
|
* @param {Boolean} isLinked Enable linked filters behaviour
|
|
*/
|
|
build(colIndex, isLinked = false) {
|
|
let tf = this.tf;
|
|
colIndex = Number(colIndex);
|
|
|
|
this.emitter.emit('before-populating-filter', tf, colIndex);
|
|
|
|
/** @inherited */
|
|
this.opts = [];
|
|
/** @inherited */
|
|
this.optsTxt = [];
|
|
|
|
let flt = this.containers[colIndex];
|
|
let ul = createElm('ul',
|
|
['id', tf.fltIds[colIndex]],
|
|
['colIndex', colIndex]);
|
|
ul.className = this.filterCssClass;
|
|
|
|
let caseSensitive = tf.caseSensitive;
|
|
/** @inherited */
|
|
this.isCustom = tf.isCustomOptions(colIndex);
|
|
|
|
//Retrieves custom values
|
|
if (this.isCustom) {
|
|
let customValues = tf.getCustomOptions(colIndex);
|
|
this.opts = customValues[0];
|
|
this.optsTxt = customValues[1];
|
|
}
|
|
|
|
let activeIdx;
|
|
let activeFilterId = tf.getActiveFilterId();
|
|
|
|
if (isLinked && activeFilterId) {
|
|
activeIdx = tf.getColumnIndexFromFilterId(activeFilterId);
|
|
}
|
|
|
|
let filteredDataCol = [];
|
|
if (isLinked && tf.disableExcludedOptions) {
|
|
/** @inherited */
|
|
this.excludedOpts = [];
|
|
}
|
|
|
|
flt.innerHTML = '';
|
|
|
|
let eachRow = tf.eachRow();
|
|
eachRow(
|
|
(row) => {
|
|
let cellValue = tf.getCellValue(row.cells[colIndex]);
|
|
//Vary Peter's patch
|
|
let cellString = matchCase(cellValue, caseSensitive);
|
|
// checks if celldata is already in array
|
|
if (!has(this.opts, cellString, caseSensitive)) {
|
|
this.opts.push(cellValue);
|
|
}
|
|
let filteredCol = filteredDataCol[colIndex];
|
|
if (isLinked && tf.disableExcludedOptions) {
|
|
if (!filteredCol) {
|
|
filteredCol = tf.getVisibleColumnValues(colIndex);
|
|
}
|
|
if (!has(filteredCol, cellString, caseSensitive) &&
|
|
!has(this.excludedOpts, cellString, caseSensitive)) {
|
|
this.excludedOpts.push(cellValue);
|
|
}
|
|
}
|
|
},
|
|
// continue conditions function
|
|
(row, k) => {
|
|
// excluded rows don't need to appear on selects as always valid
|
|
if (tf.excludeRows.indexOf(k) !== -1) {
|
|
return true;
|
|
}
|
|
|
|
// checks if row has expected number of cells
|
|
if (row.cells.length !== tf.nbCells || this.isCustom) {
|
|
return true;
|
|
}
|
|
|
|
if (isLinked && !this.isValidLinkedValue(k, activeIdx)) {
|
|
return true;
|
|
}
|
|
}
|
|
);
|
|
|
|
//sort options
|
|
this.opts = this.sortOptions(colIndex, this.opts);
|
|
if (this.excludedOpts) {
|
|
this.excludedOpts = this.sortOptions(colIndex, this.excludedOpts);
|
|
}
|
|
|
|
this.addChecks(colIndex, ul);
|
|
|
|
if (tf.loadFltOnDemand) {
|
|
flt.innerHTML = '';
|
|
}
|
|
flt.appendChild(ul);
|
|
flt.setAttribute('filled', '1');
|
|
|
|
this.emitter.emit('after-populating-filter', tf, colIndex, flt);
|
|
}
|
|
|
|
/**
|
|
* Add checklist options
|
|
* @param {Number} colIndex Column index
|
|
* @param {Object} ul Ul element
|
|
* @private
|
|
*/
|
|
addChecks(colIndex, ul) {
|
|
let tf = this.tf;
|
|
let chkCt = this.addTChecks(colIndex, ul);
|
|
|
|
for (let y = 0; y < this.opts.length; y++) {
|
|
let val = this.opts[y]; //item value
|
|
let lbl = this.isCustom ? this.optsTxt[y] : val; //item text
|
|
let fltId = tf.fltIds[colIndex];
|
|
let lblIdx = y + chkCt;
|
|
let li = createCheckItem(`${fltId}_${lblIdx}`, val, lbl,
|
|
['data-idx', lblIdx]);
|
|
li.className = this.itemCssClass;
|
|
|
|
if (tf.linkedFilters && tf.disableExcludedOptions &&
|
|
has(this.excludedOpts, matchCase(val, tf.caseSensitive),
|
|
tf.caseSensitive)) {
|
|
addClass(li, this.disabledItemCssClass);
|
|
li.check.disabled = true;
|
|
li.disabled = true;
|
|
} else {
|
|
addEvt(li.check, 'click', evt => this.optionClick(evt));
|
|
}
|
|
ul.appendChild(li);
|
|
|
|
if (val === '') {
|
|
//item is hidden
|
|
li.style.display = NONE;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Add checklist header option
|
|
* @param {Number} colIndex Column index
|
|
* @param {Object} ul Ul element
|
|
* @private
|
|
*/
|
|
addTChecks(colIndex, ul) {
|
|
let tf = this.tf;
|
|
let chkCt = 1;
|
|
let fltId = tf.fltIds[colIndex];
|
|
let li0 = createCheckItem(`${fltId}_0`, '',
|
|
tf.getClearFilterText(colIndex), ['data-idx', 0]);
|
|
li0.className = this.itemCssClass;
|
|
ul.appendChild(li0);
|
|
|
|
addEvt(li0.check, 'click', evt => this.optionClick(evt));
|
|
|
|
if (!this.enableResetOption) {
|
|
li0.style.display = NONE;
|
|
}
|
|
|
|
if (tf.enableEmptyOption) {
|
|
let li1 = createCheckItem(`${fltId}_1`, tf.emOperator,
|
|
tf.emptyText, ['data-idx', 1]);
|
|
li1.className = this.itemCssClass;
|
|
ul.appendChild(li1);
|
|
addEvt(li1.check, 'click', evt => this.optionClick(evt));
|
|
chkCt++;
|
|
}
|
|
|
|
if (tf.enableNonEmptyOption) {
|
|
let li2 = createCheckItem(`${fltId}_2`, tf.nmOperator,
|
|
tf.nonEmptyText, ['data-idx', 2]);
|
|
li2.className = this.itemCssClass;
|
|
ul.appendChild(li2);
|
|
addEvt(li2.check, 'click', evt => this.optionClick(evt));
|
|
chkCt++;
|
|
}
|
|
return chkCt;
|
|
}
|
|
|
|
/**
|
|
* Set/unset value of passed item option in filter's DOM element attribute
|
|
* @param {Object} o checklist option DOM element
|
|
* @private
|
|
*/
|
|
setItemOption(o) {
|
|
if (!o) {
|
|
return;
|
|
}
|
|
|
|
let tf = this.tf;
|
|
let chkValue = o.value; //checked item value
|
|
let chkIndex = o.dataset.idx;
|
|
let colIdx = tf.getColumnIndexFromFilterId(o.id);
|
|
let n = tf.getFilterElement(parseInt(colIdx, 10));
|
|
let items = n.childNodes;
|
|
let li = items[chkIndex];
|
|
//selected values (ul tag)
|
|
let slcValues = n.getAttribute('value') || '';
|
|
//selected items indexes (ul tag)
|
|
let slcIndexes = n.getAttribute('indexes') || '';
|
|
|
|
if (o.checked) {
|
|
//show all item
|
|
if (chkValue === '') {
|
|
//items indexes
|
|
let indexes = slcIndexes.split(tf.separator);
|
|
indexes.forEach(idx => {
|
|
idx = Number(idx);
|
|
let li = items[idx];
|
|
let chx = tag(li, 'input')[0];
|
|
if (chx && idx > 0) {
|
|
chx.checked = false;
|
|
removeClass(li, this.selectedItemCssClass);
|
|
}
|
|
});
|
|
|
|
n.setAttribute('value', '');
|
|
n.setAttribute('indexes', '');
|
|
|
|
} else {
|
|
let indexes = slcIndexes + chkIndex + tf.separator;
|
|
let values =
|
|
trim(slcValues + ' ' + chkValue + ' ' + tf.orOperator);
|
|
|
|
n.setAttribute('value', values);
|
|
n.setAttribute('indexes', indexes);
|
|
|
|
//uncheck first option
|
|
let chx0 = tag(items[0], 'input')[0];
|
|
if (chx0) {
|
|
chx0.checked = false;
|
|
}
|
|
}
|
|
|
|
removeClass(items[0], this.selectedItemCssClass);
|
|
addClass(li, this.selectedItemCssClass);
|
|
} else { //removes values and indexes
|
|
let replaceValue =
|
|
new RegExp(rgxEsc(chkValue + ' ' + tf.orOperator));
|
|
let values = slcValues.replace(replaceValue, '');
|
|
let replaceIndex = new RegExp(rgxEsc(chkIndex + tf.separator));
|
|
let indexes = slcIndexes.replace(replaceIndex, '');
|
|
|
|
n.setAttribute('value', trim(values));
|
|
n.setAttribute('indexes', indexes);
|
|
|
|
removeClass(li, this.selectedItemCssClass);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Select filter options programmatically
|
|
* @param {Number} colIndex Column index
|
|
* @param {Array} values Array of option values to select
|
|
*/
|
|
selectOptions(colIndex, values = []) {
|
|
let tf = this.tf;
|
|
let flt = tf.getFilterElement(colIndex);
|
|
if (!flt || values.length === 0) {
|
|
return;
|
|
}
|
|
|
|
let lis = tag(flt, 'li');
|
|
|
|
flt.setAttribute('value', '');
|
|
flt.setAttribute('indexes', '');
|
|
|
|
[].forEach.call(lis, (li) => {
|
|
let chk = tag(li, 'input')[0];
|
|
let chkVal = matchCase(chk.value, tf.caseSensitive);
|
|
|
|
if (chkVal !== '' && has(values, chkVal, tf.caseSensitive)) {
|
|
chk.checked = true;
|
|
} else {
|
|
// Check non-empty-text or empty-text option
|
|
if (values.indexOf(tf.nmOperator) !== -1 &&
|
|
chkVal === matchCase(tf.nonEmptyText, tf.caseSensitive)) {
|
|
chk.checked = true;
|
|
}
|
|
else if (values.indexOf(tf.emOperator) !== -1 &&
|
|
chkVal === matchCase(tf.emptyText, tf.caseSensitive)) {
|
|
chk.checked = true;
|
|
} else {
|
|
chk.checked = false;
|
|
}
|
|
}
|
|
this.setItemOption(chk);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get filter values for a given column index
|
|
* @param {Number} colIndex Column index
|
|
* @returns {Array} values Collection of selected values
|
|
*/
|
|
getValues(colIndex) {
|
|
let tf = this.tf;
|
|
let flt = tf.getFilterElement(colIndex);
|
|
let fltAttr = flt.getAttribute('value');
|
|
let values = isEmpty(fltAttr) ? '' : fltAttr;
|
|
//removes last operator ||
|
|
values = values.substr(0, values.length - 3);
|
|
//turn || separated values into array
|
|
values = values.split(' ' + tf.orOperator + ' ');
|
|
|
|
return values;
|
|
}
|
|
|
|
/**
|
|
* Destroy CheckList instance
|
|
*/
|
|
destroy() {
|
|
this.emitter.off(
|
|
['build-checklist-filter'],
|
|
(tf, colIndex, isLinked) => this.build(colIndex, isLinked)
|
|
);
|
|
this.emitter.off(
|
|
['select-checklist-options'],
|
|
(tf, colIndex, values) => this.selectOptions(colIndex, values)
|
|
);
|
|
this.emitter.off(['rows-changed'], () => this.refreshAll());
|
|
|
|
this.initialized = false;
|
|
}
|
|
}
|
|
</code></pre>
|
|
|
|
</div>
|
|
|
|
<footer class="footer">
|
|
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
|
|
</footer>
|
|
|
|
<script src="script/search_index.js"></script>
|
|
<script src="script/search.js"></script>
|
|
<script src="script/pretty-print.js"></script>
|
|
<script src="script/inherited-summary.js"></script>
|
|
<script src="script/test-summary.js"></script>
|
|
<script src="script/inner-link.js"></script>
|
|
<script src="script/patch-for-local.js"></script>
|
|
</body>
|
|
</html>
|