1.0.3 • Published 10 years ago

z-modifier v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

z-modifier

Build Status npm version

This module was written to handle modifier classes inspired by the BEM methodology.

Since it's a CommonJS module, it must be used alongside with Browserify, or something similar, like WebPacker.

Example, explanation

<div id="module"></div>
var Modifier = require('z-modifier');

var mod = new Modifier(
    $('#module'),
    'module'. // The base class the modifier string will be attached to
    '--', // Modifier separator, optional
    '_' // Value separator, optional
);

mod.on('modifier');
// -> Adds the "module--modifier" class
mod.get('modifier');
// -> true

mod.set('modifier', 'value');
// -> Replaces the "module--modifier" class with "module--modifier_value".
mod.get('modifier');
// -> 'value'

mod.off('modifier');
// Removes the "module--modifier_value" class.
mod.get('modifier');
// -> false

mod.toggle('modifier');
// -> Adds the "module--modifier" class.
mod.toggle('modifier');
// -> Removes the "module--modifier" class.

License

MIT

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

0.1.0

10 years ago