Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Pillbox.js is a UI container for your (optionally pill-styled) tag labels. The pillbox contains pills (tags), and each pill is aware of its state. Events are emitted whenever something interesting happens.
Pillbox.js is available as a CommonJS module. Soon, it will be available via npm, like so:
npm install --save pillbox
And you can require it in your project:
var Pillbox = require('pillbox');
The Pillbox
variable above is a constructor that takes an object with the following properties:
container
-- The parent DOM element that will contain each "pill"pills
-- An optional array containing the initial collection of pillsPills are created with the following options:
key
-- String, used to identify the pill, must be uniquevalue
-- String that will be displayed on the rendered pillremove
-- Optional boolean, determines if pills should have close buttons when no template is present.template
-- An optional function, should return a string of HTML given an object parameter with a value
property.states
-- An optional array of strings to be used as initial statesvar pb = new Pillbox({
container: document.querySelector('.pill-container'),
pills: [{/* see pill options above */}]
});
You don't have to add pills initially, though. You can easily add them after creating pb
.
pb.addPill({
key: 'roots',
value: 'Root Vegetables',
template: require('tag.jade'),
states: ['disabled']
});
You can also remove a pill if you know its key
:
pb.removePill('roots');
You can retrieve an instance of a pill if you know its key. This allows you to check or set a pill's state.
pb.getPill('roots').removeState('disabled');
You can also request an array of all keys, which would allow you to iterate over each pill and remove it or modify its state:
var pillKeys = pb.keys();
_.each(pillKeys, function (key) {
pb.removePill(key);
});
Each pill has an array of states. States translate to classes in the DOM, and they can be modified and queried with the following methods.
setState(state)
-- Adds a new state based on the given stringremoveState(state)
-- Removes an existing statehasState(state)
-- returns true
or false
depending on the existence of a given statecleanState()
-- removes all states from the pilldraw(parent)
-- Appends an element representing the pill into the given parenterase()
-- Removes the pill's element from the DOMPills emit several events:
"click"
-- When a pill is clicked"state:add"
-- When a state is added to a pill"state:remove"
-- When a state is removed from a pill"request:remove"
-- When a pill requests to be removed (e.g. when the x
is clicked)However, getting pill instances is a hassle, so all pill events are also forwarded through Pillbox with a "pill:"
prefix. Instead of listening for "request:remove"
on each pill instance:
_.each(pb.keys(), function (key) {
pb.getPill(key).on('request:remove', function () {
pb.removePill(key);
});
});
You can instead listen for the event on pb
directly, which is more concise:
pb.on('pill:request:remove', function (pill) {
pb.removePill(pill.key);
});
In addition to forwarding Pill events, Pillbox emits two events of its own:
"pill:add"
-- Emitted after a new pill is added. The pill object is passed to the callback."pill:remove"
-- Emitted after a pill is removed. The pill's key is passed to the callback.With npm
and gulp
installed globally, you can run a development build (which includes file watching) by running the following in the project directory:
npm install
gulp
FAQs
Small library for creating lists of tags in containers.
We found that pillbox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.