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

image-areas-tag

v1.0.5

Published

jQuery plugin for tagging areas for images

Downloads

6

Readme

image-areas-tag

A jQuery plugin for selecting and tagging areas for images (https://github.com/IrinaSmirnova/image-areas-tag).

Getting started

Installation

npm install image-areas-tag

Include files:

<script src="/path/to/jquery.js"></script><!-- jQuery is required -->
<script src="/path/to/bootstrap.min.js"></script><!-- Bootstrap is required -->
<link  href="/path/to/bootstrap.css" rel="stylesheet">
<script src="/path/to/jquery.selectareas.js"></script><!-- jquery.selectareas is required -->
<link  href="/path/to/jquery.selectareas.css" rel="stylesheet">
<script src="/path/to/select2.full.js"></script><!-- select2.js is required -->
<link  href="/path/to/select2.css" rel="stylesheet">
<link  href="/path/to/dist/css/image-areas-tag.css" rel="stylesheet">

Usage

Initialize with $.fn.imageAreasTag method.

<!-- Container where carousel with images will be placed -->
<div id="container">

</div>
// Define your array of images with id and url fields
const imagesArr = [
	{
		id: 1,
		url: '...'
	},
	{
		id: 2,
		url: '...'
	}
];
// Define your callback function that will called with selected areas data after proceeding to the next slide.
let cb = function(dataObj) {
	...
};
$('#container').imageAreasTag(imagesArr, cb, options)

API Doc

dataObj

Object containing data with all selected areas. It will be passed to callback function

	{
		imageId,
		imageWidth,
		imageHeight,
		boundingBoxes: [
			{
				id, // ID identifying the area in the plugin
				x,  // X coordinate (in percents from image width)
				y,  // Y coordinate (in percents from image height)
				z,  // Z-index (0 when inactive or 100 when focused)
				width,  // Width of the area (in percents from image width)
				height,  // Height of the area (in percents from image height)
				label  // Array of tags (strings)
			}
		]
	}

Options

Here is a list of available options for imageAreasTag, with their default value:

  • allowEdit (true) : When set to false, unset allowMove, allowResize, allowSelect and allowDelete
  • allowMove (true) : When set to false, Areas can not be moved with a drag & drop.
  • allowResize (true) : When set to false, Areas can not be resized.
  • allowSelect (true) : When set to false, Areas can not be created.
  • allowDelete (true) : When set to false, Areas can not be deleted.
  • allowNudge (true) : When set to false, Areas can not be moved with arrow keys.
  • aspectRatio (0) : When not 0, force a ratio between height and width for the selections.
  • minSize ([30, 30]) : When not 0, set the minimum size for a selection [width, height]
  • maxSize ([0, 0]) : When not 0, set the maximum size for a selection [width, height]
  • maxAreas (0) : When not 0, set the maximum number of area that can be drawn.
  • outlineOpacity (0.5) : opacity of the moving dotted outline around a selection.
  • overlayOpacity (0) : opacity of the overlay layer over the image
  • areas ([]) : list of areas to add to the image from the beginning (id will be ignored)
  • onChanging (null) : triggered when the event "changing" is fired
  • onChanged (null) : triggered when the event "changed" is fired
  • onLoaded (null) : triggered when the event "loaded" is fired
  • width (0) : When not 0, scale the image to this width (px). The coordinates of the areas on the full image can be retrieved with method relativeAreas()
  • enableLabels (true) : When set to false, setting tags for ares is unavailable
  • tags ([]) : List of predefined tags
  • allowOwnTags (true) : When set to false, user can not enter own tags
  • isLabelsRequired (false) : When set to true, user can not proceed to the next image while there are some areas without tags
  • errorTextOnMissingLabel ('Each area must have at least one tag') : Error text which user sees in alert window when he tries to proceed to the next image without tagging all areas on the image (when isLabelsRequired option set to true)

No conflict

If you have to use other plugin with the same namespace, just call the $.fn.imageAreasTag.noConflict method to revert to it.

<script src="other-plugin.js"></script>
<script src="image-areas-tag.js"></script>
<script>
  $.fn.imageAreasTag.noConflict();
  // Code that uses other plugin's "$().imageAreasTag" can follow here.
</script>

License

MIT © [Irina Smirnova]