ChePollo is an ultra-simple framework for common javascript client tasks, such as:
- Manipulating the DOM
- Debouncing functions
- Saving data on localStorage (falling back to cookies)
ChePollo is:
- super-light (<4kb)
- written in pure Vanilla javascript using ES6 syntax.
- transpiled to ES5 using babel and gulp
- packed in a CommonJS module or available in global scope (window.oo)
- compatible with IE > 7 (it has polyfill included)
$ npm install chepollo
oo.ready(function(){
var foo = oo.getById('foo');
oo.addClass(foo, 'pollastro');
oo.addData(foo, 'somekey', 'somedata');
oo.getData(foo, 'somekey'); // "somedata"
oo.debounce(function(){
foo.removeClass(foo, 'pollastro');
}, 1000)();
});Class oo.
Kind: inner class of chepollo
- ~oo
- .ready(_callback)
- .getAll(_selector) β
NodeList - .getOne(_selector) β
Element - .getById(_id) β
Element - .fadeIn(_el, _duration)
- .fadeOut(_el, _duration)
- .addClass(_el, _classes)
- .removeClass(_el, _classes)
- .hasClass(_el, _class) β
boolean - .toggleClass(_el, _class)
- .addData(_el, _key, _data)
- .getData(_el, _key) β
string|undefined - .storageGet(_key)
- .storageSet(_key, _data)
- .storageRemove(_key)
- .storageClear()
- .cookieSet(cname, cvalue, exdays)
- .cookieGet(cname) β
* - .debounce(func, wait, immediate) β
function
on DOM ready
Kind: instance method of oo
| Param | Type |
|---|---|
| _callback | function |
return an array of DOM nodes using querySelectorAll()
Kind: instance method of oo
| Param | Type |
|---|---|
| _selector | string |
return a dom Element using querySelector()
Kind: instance method of oo
| Param |
|---|
| _selector |
return a DOM node using getElementById
Kind: instance method of oo
| Param | Type |
|---|---|
| _id | string |
fadeIn a DOM element
Kind: instance method of oo
| Param | Type |
|---|---|
| _el | Element |
| _duration | int |
fadeOut a DOM element
Kind: instance method of oo
| Param | Type |
|---|---|
| _el | Element |
| _duration | int |
add a class to a DOM element
Kind: instance method of oo
| Param | Type |
|---|---|
| _el | Element |
| _classes | string |
remove a class from a DOM element
Kind: instance method of oo
| Param | Type |
|---|---|
| _el | Element |
| _classes | string |
checks if the given DOM element has a class
Kind: instance method of oo
| Param | Type |
|---|---|
| _el | Element |
| _class | string |
toggle a DOM element class
Kind: instance method of oo
| Param | Type |
|---|---|
| _el | Element |
| _class | string |
add content to a DOM element dataList
Kind: instance method of oo
| Param | Type |
|---|---|
| _el | Element |
| _key | string |
| _data | string |
return the content of the given dataList key
Kind: instance method of oo
| Param |
|---|
| _el |
| _key |
get data from localStorage (with cookie fallback)
Kind: instance method of oo
| Param |
|---|
| _key |
set data in localStorage (with cookie fallback)
Kind: instance method of oo
| Param |
|---|
| _key |
| _data |
removes a key from localStorage (with cookie fallback)
Kind: instance method of oo
| Param |
|---|
| _key |
clear localStorage (with cookie fallback)
Kind: instance method of oo
set a cookie
Kind: instance method of oo
| Param |
|---|
| cname |
| cvalue |
| exdays |
get a cookie
Kind: instance method of oo
| Param |
|---|
| cname |
debounce a function
Kind: instance method of oo
| Param | Type |
|---|---|
| func | function |
| wait | int |
| immediate | boolean |