{"_id":"@adminarchitect/jquery-toggles","_rev":"2-00aa9859990c2953149a443611cf35d8","name":"@adminarchitect/jquery-toggles","dist-tags":{"latest":"4.0.0"},"versions":{"4.0.0":{"name":"@adminarchitect/jquery-toggles","version":"4.0.0","description":"Toggles is a lightweight jQuery plugin that creates easily-styleable toggle buttons.","main":"toggles.min.js","author":{"name":"Simon Tabor","email":"me@simontabor.com","url":"http://simontabor.com/"},"homepage":"http://simontabor.com/labs/toggles/","license":"MIT","repository":{"type":"git","url":"git+https://github.com/simontabor/jquery-toggles.git"},"keywords":["toggles","checkbox","jquery-plugin","ecosystem:jquery"],"bugs":{"url":"https://github.com/simontabor/jquery-toggles/issues"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"dependencies":{},"devDependencies":{"autoprefixer":"^6.0.3","js-beautify":"^1.5.10","less":"^2.5.3","postcss-cli":"^2.3.2"},"gitHead":"7d1c5c0df2a0ad2043fcff4605f67180bc383fb8","_id":"@adminarchitect/jquery-toggles@4.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.1.2","_npmUser":{"name":"endihunter","email":"endi1982@gmail.com"},"dist":{"integrity":"sha512-okYb1nU7dKzQbjbOR8puTW3iCu3zk8njowU1tGl/WQWLlg41zp+eQweYhwPLGf5DBE8jt91FBkoDEc5WVAXfiQ==","shasum":"1b973463608900511337348896438667b6841b41","tarball":"https://registry.npmjs.org/@adminarchitect/jquery-toggles/-/jquery-toggles-4.0.0.tgz","fileCount":23,"unpackedSize":50522,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEI4jskY6MsEriFe2T5QWDsvOX3umI23R5G4i9gZt76wAiEA5j+qD013qvtV/8fVt2DqNAzVJkBANGhc6Oi+5u2kTTQ="}]},"maintainers":[{"name":"endihunter","email":"endi1982@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jquery-toggles_4.0.0_1522242304483_0.6813112371608763"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-28T13:05:04.418Z","4.0.0":"2018-03-28T13:05:04.547Z","modified":"2022-04-04T11:32:11.964Z"},"maintainers":[{"name":"endihunter","email":"endi1982@gmail.com"}],"description":"Toggles is a lightweight jQuery plugin that creates easily-styleable toggle buttons.","homepage":"http://simontabor.com/labs/toggles/","keywords":["toggles","checkbox","jquery-plugin","ecosystem:jquery"],"repository":{"type":"git","url":"git+https://github.com/simontabor/jquery-toggles.git"},"author":{"name":"Simon Tabor","email":"me@simontabor.com","url":"http://simontabor.com/"},"bugs":{"url":"https://github.com/simontabor/jquery-toggles/issues"},"license":"MIT","readme":"# jQuery Toggles\n\n[![Dependencies](https://david-dm.org/simontabor/jquery-toggles.svg)](https://david-dm.org/simontabor/jquery-toggles)\n[![Dev Dependencies](https://david-dm.org/simontabor/jquery-toggles/dev-status.svg)](https://david-dm.org/simontabor/jquery-toggles)\n![Bower](https://img.shields.io/bower/v/jquery-toggles.svg)\n[![Join the chat at https://gitter.im/simontabor/jquery-toggles](https://img.shields.io/badge/gitter-join%20chat-blue.svg)](https://gitter.im/simontabor/jquery-toggles)\n\n[![NPM](https://nodei.co/npm/jquery-toggles.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/jquery-toggles)\n\nWant to create easy toggle buttons that you can click, drag, animate, use to toggle checkboxes and more? Yeah.\n\nExamples can be seen [here](http://simontabor.com/toggles/).\n\n## Usage\n\n### Step 1: Include it in your page\n\nInclude the CSS at the start:\n\n```html\n  <head>\n    <title>My cool page</title>\n  \n    <link rel=\"stylesheet\" href=\"css/toggles.css\">\n    <link rel=\"stylesheet\" href=\"css/toggles-modern.css\">\n    \n    <!-- ALL OF THE THEMES -->\n    <!-- <link rel=\"stylesheet\" href=\"css/toggles-all.css\"> -->\n    \n    <!-- ALL OF THE CSS AND THEMES IN ONE FILE -->\n    <!-- <link rel=\"stylesheet\" href=\"css/toggles-full.css\"> -->\n```\n\nAnd the JS at the end:\n\n```html\n    <script src=\"js/toggles.js\" type=\"text/javascript\"></script>\n    <!-- MINIFIED JS - recommended for production -->\n    <!-- <script src=\"js/toggles.min.js\" type=\"text/javascript\"></script> -->\n  </body>\n</html>\n```\n\n### Step 2: Create your element\n\nYou need to specify the class for the specific theme you want to use.  In this case we are using `toggle-modern`.  The `toggle` class is simply what we will use as our selector to initialize it.\n\n```html\n<div class=\"toggle toggle-modern\">\n```\n\nThe themes we could have used are:\n\n* soft\n* light\n* dark\n* iphone\n* modern\n\nOf course, you can write your own themes/tweak the styling.\n\n### Step 3: Initialize!\n\nNow we just need to initialize the element we made to make it toggleable!\n\n```javascript\n\n// Simplest way:\n$('.toggle').toggles();\n\n\n// With options (defaults shown below)\n$('.toggle').toggles({\n  drag: true, // allow dragging the toggle between positions\n  click: true, // allow clicking on the toggle\n  text: {\n    on: 'ON', // text for the ON position\n    off: 'OFF' // and off\n  },\n  on: true, // is the toggle ON on init\n  animate: 250, // animation time (ms)\n  easing: 'swing', // animation transition easing function\n  checkbox: null, // the checkbox to toggle (for use in forms)\n  clicker: null, // element that can be clicked on to toggle. removes binding from the toggle itself (use nesting)\n  width: 50, // width used if not set in css\n  height: 20, // height if not set in css\n  type: 'compact' // if this is set to 'select' then the select style toggle will be used\n});\n\n\n// Getting notified of changes, and the new state:\n$('.toggle').on('toggle', function(e, active) {\n  if (active) {\n    console.log('Toggle is now ON!');\n  } else {\n    console.log('Toggle is now OFF!');\n  }\n});\n\n```\n\n## Advanced Usage\n\n### Setting toggle states\n\n```javascript\n// initiate a new Toggles class\n$('.toggles').toggles({\n  on: true\n});\n\n// the underlying Toggles class can be accessed\nvar myToggle = $('.toggles').data('toggles');\n\nconsole.log(myToggle.active); // true\nmyToggle.toggle();\nconsole.log(myToggle.active); // false\n\n// set the state to 'false'\n// will not do anything if the state is already false\nmyToggle.toggle(false);\nconsole.log(myToggle.active); // false\n\n// passing a boolean in place of options on an active toggle element\n// will set the state\n$('.toggles').toggles(true);\nconsole.log(myToggle.active); // true\n\n// the toggle-active data attribute stores the state too\nconsole.log($('.toggles').data('toggle-active')); // true\n\n// myToggle.toggle(state, noAnimate, noEvent)\n\n// don't animate the change\nmyToggle.toggle(false, true);\n\n// change the state without triggering an event\nmyToggle.toggle(true, false, true);\n```\n\n### Using data-toggle-\\* attributes on the element\n\nAny of the following options can be set using data-toggle attributes: `on`, `drag`, `click`, `width`, `height`, `animate`, `easing`, `type`, `checkbox`\n```html\n<div class=\"toggles\" data-toggle-on=\"true\" data-toggle-height=\"20\" data-toggle-width=\"60\"></div>\n```\n```javascript\n$('.toggles').toggles();\n```\n\n### Disabling user interaction\n\nIt can be useful to disable the toggle to stop users from changing the state. Set the `disabled` attribute on the toggle element to do this. Alternatively, you could use CSS to set `pointer-events: none`\n\n```js\n// your toggle element\nvar toggle = $('.toggle');\n\n// initialise it\ntoggle.toggles();\n\n// disable the toggle element (click + drag will no longer work)\ntoggle.toggleClass('disabled', true);\n\n// setting the state via JS is NOT disabled, only user input\n// toggle the toggle on\ntoggle.toggles(true);\n\n// re-enable the toggle\ntoggle.toggleClass('disabled', false);\n```\n\n## Contributing\n\nMake your JavaScript edits to `js/Toggles.js`. Any styling edits should be made to the relevent files in the `less` folder. JS edits must be compatible with Closure Compiler advanced optimisations - if you aren't able to code in this style then I'll happily tweak any pull requests/help out.\n\nTo build the files for release, run `make`. Again, if you struggle then I'll be able to build the files for you. (Note: use node v5)\n","readmeFilename":"README.md"}