npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

items-dialog

v1.1.1

Published

[ABANDONED] Modal dialog for set items by type

Downloads

14

Readme

Items dialog

Modal dialog for writing items in groups (eg. contacts). Using modal-dialog package and is dependent on jquery. This dialog is also instance of EventEmitter.

This dialog is completely without styles, so for styling you have to read more about modal-dialog package.

Abandoned

Unfortunately I don't have any more time to maintain this repository :-(

sad cat

Usage

var Items = require('items-dialog');
var items = new Items;

items.types = {
	facebook: 'Facebook',
	google: 'Google plus',
	skype: 'Skype'
};

items.open();

You have to set just object with list of types. This can be for example from your database, where keys are IDs and values are publicly visible names.

Thane call the open method which can be added to some event handler (eg. click on some button).

Default values

items.defaults = {
	facebook: ['david', 'george']
}

Get selected data

var data = items.getValues();

This will return object which has got the same structure like defaults property.

Use it in form

You can add text input into your form and connect it with items-dialog. Then after every change, data from getValues method will be added into your input. These data are "stringified".

This works also in opposite direction. When this result input contains some data, they will be added into defaults property.

items.setResultElement($('#myInputInForm'));

Showing summary of items

This feature is like the previous one, except one thing. You are connecting div element not text input and data are rendered into this element.

items.setSummaryElement($('mySummaryElement'));

Prepare component

If you want to render for example summary immediately after some setup, you have to call method prepare.

items.prepare();

Own labels and texts

There is variable labels which holds all labels.

The simplest option is to set own labels globally.

var Items = require('items-dialog');

Items.labels.title = 'Add contacts';

or you can set it for each dialog

var Items = require('items-dialog');
var items = new Items;

items.labels.title = 'Add contacts';

List of labels

  • title: Title of modal dialog
  • okButton: Button in the bottom of the modal dialog
  • addTypeHint: "prompt" text of first text in select input (eg. Please select something)
  • help: Text in the top of modal dialog content
  • removeType: Title of link for removing whole type
  • writeItem: Text in prompt dialog for writing new item in type. There you can use %s "variable" which will be replaced with selected type (eg. Please enter new item into %s type)
  • addItem: Title of link for adding new item into type
  • editItem: Title of link for editing item
  • removeItem: Title of link for removing one item

You can of course use for example images instead of titles.

Events

  • beforeRender (items): Called right before first main render method is called
  • afterRender (items): Called right after first main render method is called
  • registerType (name, items): Called when there is new type added into select list
  • addType: (name, items): Called after person select new type and it is added into result
  • removeType: (name, items): Called after person remove type from result
  • addItem: (type, value, items): Called after person add new value into some type
  • beforeRefresh: (items): Called before summary refresh is called (eg. after adding new type)
  • afterRefresh: (items): Called after summary refresh is called (eg. after adding new type)

Example:

items.on('addItem', function(type, value, items) {
	console.log("Item '" + value + "' was added into '" + type + "' group.");
});

There are also events for modal dialog itself. This dialog object is accessible via dialog variable (documentation).

Example

dialog

Changelog

  • 1.1.1

    • Abandon package
    • Move under Carrooi organization
  • 1.1.0

    • Switched edit and remove buttons
    • Adding new value is automatically called after new type is added
    • More options for setup labels (+ doc)
    • Items dialog is instance of EventEmitter
    • Added events
  • 1.0.2 - 1.0.3

    • Bug in rendering summary
    • Defaults from resume element
  • 1.0.1

    • Added missing example
  • 1.0.0

    • Initial version