1.0.8 • Published 8 years ago

chepollo v1.0.8

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

Che Pollo!

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)

Install

$ npm install chepollo

Usage

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)();
});

API reference

chepollo~oo

Class oo.

Kind: inner class of chepollo

oo.ready(_callback)

on DOM ready

Kind: instance method of oo

ParamType
_callbackfunction

oo.getAll(_selector) ⇒ NodeList

return an array of DOM nodes using querySelectorAll()

Kind: instance method of oo

ParamType
_selectorstring

oo.getOne(_selector) ⇒ Element

return a dom Element using querySelector()

Kind: instance method of oo

Param
_selector

oo.getById(_id) ⇒ Element

return a DOM node using getElementById

Kind: instance method of oo

ParamType
_idstring

oo.fadeIn(_el, _duration)

fadeIn a DOM element

Kind: instance method of oo

ParamType
_elElement
_durationint

oo.fadeOut(_el, _duration)

fadeOut a DOM element

Kind: instance method of oo

ParamType
_elElement
_durationint

oo.addClass(_el, _classes)

add a class to a DOM element

Kind: instance method of oo

ParamType
_elElement
_classesstring

oo.removeClass(_el, _classes)

remove a class from a DOM element

Kind: instance method of oo

ParamType
_elElement
_classesstring

oo.hasClass(_el, _class) ⇒ boolean

checks if the given DOM element has a class

Kind: instance method of oo

ParamType
_elElement
_classstring

oo.toggleClass(_el, _class)

toggle a DOM element class

Kind: instance method of oo

ParamType
_elElement
_classstring

oo.addData(_el, _key, _data)

add content to a DOM element dataList

Kind: instance method of oo

ParamType
_elElement
_keystring
_datastring

oo.getData(_el, _key) ⇒ string | undefined

return the content of the given dataList key

Kind: instance method of oo

Param
_el
_key

oo.storageGet(_key)

get data from localStorage (with cookie fallback)

Kind: instance method of oo

Param
_key

oo.storageSet(_key, _data)

set data in localStorage (with cookie fallback)

Kind: instance method of oo

Param
_key
_data

oo.storageRemove(_key)

removes a key from localStorage (with cookie fallback)

Kind: instance method of oo

Param
_key

oo.storageClear()

clear localStorage (with cookie fallback)

Kind: instance method of oo

oo.cookieSet(cname, cvalue, exdays)

set a cookie

Kind: instance method of oo

Param
cname
cvalue
exdays

oo.cookieGet(cname) ⇒ *

get a cookie

Kind: instance method of oo

Param
cname

oo.debounce(func, wait, immediate) ⇒ function

debounce a function

Kind: instance method of oo

ParamType
funcfunction
waitint
immediateboolean
1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago