New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

choosery

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choosery

A jQuery plugin to activate certains element based on the current URL.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-55.56%
Maintainers
1
Weekly downloads
 
Created
Source

Choosery

A jQuery plugin to activate certains element based on the current URL.

Building

Use gulp and just type gulp to build the source. The output will be placed in the dist directory. The dist directory is tracked, you may also skip the building steps and just use the js in the dist directory.

Quick Example

<ul class="list-group" id="navs">
    <li data-choosery-url="my/home$" class="list-group-item">Home Sweet Home</li>
    <li data-choosery-url="my/open$" class="list-group-item">Open the Door</li>
    <li data-choosery-url="my/save$" class="list-group-item">Save the World</li>
    <li data-choosery-url="my/ok$" class="list-group-item">OK vs KO</li>
    <li data-choosery-url="my/cancel$" class="list-group-item">Cancel the Dinner</li>
    <li data-choosery-url="my/abort$" class="list-group-item">Abort World.exe</li>
</ul>
 $('#navs').choosery({
            target: 'li'
        });
    });

It means all li inside #navs will be activated if the current URL match with its data-choosery-url attributes.

References

Available Attributes
  1. data-choosery-url Accepts a regex that later will be compared with window.location.pathname.
  2. data-chooser-trigger Accepts everything, as long as it is defined, when the element with this attribute is clicked, it will starts the choosery engine to find which element need to be activated based on the current URL. Useful for ajax or history.pushState situation.
Available Options
  1. target The targets for the choosery engine to activate.
  2. activeClass (default: active) The class that will be set to the element that have its data-choosery-url matched with the current URL.

Examples

Open example/index.html to see it in action and see the source code to see how it is implemented.

Contributing

Just fork and add any extra features you wanted, if you want to share that feature, feel free to submit a pull request.

Credits

Aditya Purwa @ Myriatek

Keywords

FAQs

Package last updated on 17 Feb 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc