mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-17 05:46:39 +02:00
226 lines
8 KiB
HTML
226 lines
8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<base data-ice="baseUrl" href="../../">
|
|
<title data-ice="title">src/dom.js | TableFilter v0.0.0 API Document</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>
|
|
|
|
|
|
</head>
|
|
<body class="layout-container">
|
|
|
|
<header>
|
|
<a href="./">Home</a>
|
|
<a href="identifiers.html">Identifier</a>
|
|
<a href="source.html">Source</a>
|
|
|
|
<a data-ice="repoURL" href="https://github.com/koalyptus/TableFilter.git" class="repo-url-github">Repository</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>
|
|
</header>
|
|
|
|
<nav class="navigation" data-ice="nav"><div data-ice="classWrap">
|
|
<h2>Class</h2>
|
|
<ul>
|
|
|
|
<li data-ice="classDoc"><span><a href="class/src/extensions/advancedGrid/adapterEzEditTable.js~AdapterEzEditTable.html">AdapterEzEditTable</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/extensions/sort/adapterSortabletable.js~AdapterSortableTable.html">AdapterSortableTable</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/alternateRows.js~AlternateRows.html">AlternateRows</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/checkList.js~CheckList.html">CheckList</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/clearButton.js~ClearButton.html">ClearButton</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/extensions/colOps/colOps.js~ColOps.html">ColOps</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/extensions/colsVisibility/colsVisibility.js~ColsVisibility.html">ColsVisibility</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/dropdown.js~Dropdown.html">Dropdown</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/extensions/filtersVisibility/filtersVisibility.js~FiltersVisibility.html">FiltersVisibility</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/gridLayout.js~GridLayout.html">GridLayout</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/help.js~Help.html">Help</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/highlightKeywords.js~HighlightKeyword.html">HighlightKeyword</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/loader.js~Loader.html">Loader</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/paging.js~Paging.html">Paging</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/popupFilter.js~PopupFilter.html">PopupFilter</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/rowsCounter.js~RowsCounter.html">RowsCounter</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/statusBar.js~StatusBar.html">StatusBar</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/modules/store.js~Store.html">Store</a></span></li>
|
|
<li data-ice="classDoc"><span><a href="class/src/tablefilter.js~TableFilter.html">TableFilter</a></span></li>
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</nav>
|
|
|
|
<div class="content" data-ice="content"><h1 data-ice="title">src/dom.js</h1>
|
|
<pre class="source-code line-number"><code class="prettyprint linenums" data-ice="content">/**
|
|
* DOM utilities
|
|
*/
|
|
|
|
export default {
|
|
|
|
/**
|
|
* Returns text + text of children of given node
|
|
* @param {NodeElement} node
|
|
* @return {String}
|
|
*/
|
|
getText(node){
|
|
let s = node.textContent || node.innerText ||
|
|
node.innerHTML.replace(/<[^<>]+>/g, '');
|
|
s = s.replace(/^\s+/, '').replace(/\s+$/, '');
|
|
return s;
|
|
},
|
|
|
|
/**
|
|
* Creates an html element with given collection of attributes
|
|
* @param {String} tag a string of the html tag to create
|
|
* @param {Array} an undetermined number of arrays containing the with 2
|
|
* items, the attribute name and its value ['id','myId']
|
|
* @return {Object} created element
|
|
*/
|
|
create(tag){
|
|
if(!tag || tag===''){
|
|
return;
|
|
}
|
|
|
|
let el = document.createElement(tag),
|
|
args = arguments;
|
|
|
|
if(args.length > 1){
|
|
for(let i=0; i<args.length; i++){
|
|
let argtype = typeof args[i];
|
|
if(argtype.toLowerCase() === 'object' && args[i].length === 2){
|
|
el.setAttribute(args[i][0], args[i][1]);
|
|
}
|
|
}
|
|
}
|
|
return el;
|
|
},
|
|
|
|
/**
|
|
* Returns a text node with given text
|
|
* @param {String} txt
|
|
* @return {Object}
|
|
*/
|
|
text(txt){
|
|
return document.createTextNode(txt);
|
|
},
|
|
|
|
hasClass(ele, cls){
|
|
if(!ele){ return false; }
|
|
|
|
if(supportsClassList()){
|
|
return ele.classList.contains(cls);
|
|
}
|
|
return ele.className.match(new RegExp('(\\s|^)'+ cls +'(\\s|$)'));
|
|
},
|
|
|
|
addClass(ele, cls){
|
|
if(!ele){ return; }
|
|
|
|
if(supportsClassList()){
|
|
ele.classList.add(cls);
|
|
return;
|
|
}
|
|
|
|
if(ele.className === ''){
|
|
ele.className = cls;
|
|
}
|
|
else if(!this.hasClass(ele, cls)){
|
|
ele.className += ' ' + cls;
|
|
}
|
|
},
|
|
|
|
removeClass(ele, cls){
|
|
if(!ele){ return; }
|
|
|
|
if(supportsClassList()){
|
|
ele.classList.remove(cls);
|
|
return;
|
|
}
|
|
let reg = new RegExp('(\\s|^)'+ cls +'(\\s|$)', 'g');
|
|
ele.className = ele.className.replace(reg, '');
|
|
},
|
|
|
|
/**
|
|
* Creates and returns an option element
|
|
* @param {String} text option text
|
|
* @param {String} value option value
|
|
* @param {Boolean} isSel whether option is selected
|
|
* @return {Object} option element
|
|
*/
|
|
createOpt(text, value, isSel){
|
|
let isSelected = isSel ? true : false,
|
|
opt = isSelected ?
|
|
this.create('option', ['value',value], ['selected','true']) :
|
|
this.create('option', ['value',value]);
|
|
opt.appendChild(this.text(text));
|
|
return opt;
|
|
},
|
|
|
|
/**
|
|
* Creates and returns a checklist item
|
|
* @param {Number} chkIndex index of check item
|
|
* @param {String} chkValue check item value
|
|
* @param {String} labelText check item label text
|
|
* @return {Object} li DOM element
|
|
*/
|
|
createCheckItem(chkIndex, chkValue, labelText){
|
|
let li = this.create('li'),
|
|
label = this.create('label', ['for', chkIndex]),
|
|
check = this.create('input',
|
|
['id', chkIndex],
|
|
['name', chkIndex],
|
|
['type', 'checkbox'],
|
|
['value', chkValue]
|
|
);
|
|
label.appendChild(check);
|
|
label.appendChild(this.text(labelText));
|
|
li.appendChild(label);
|
|
li.label = label;
|
|
li.check = check;
|
|
return li;
|
|
},
|
|
|
|
id(_id){
|
|
return document.getElementById(_id);
|
|
},
|
|
|
|
tag(o, tagname){
|
|
return o.getElementsByTagName(tagname);
|
|
}
|
|
};
|
|
|
|
// HTML5 classList API
|
|
function supportsClassList(){
|
|
return document.documentElement.classList;
|
|
}
|
|
</code></pre>
|
|
</div>
|
|
|
|
<footer class="footer">
|
|
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(0.1.4)</span></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>
|