Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bootstrap-slider

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bootstrap-slider

Slider view component for Twitter Bootstrap.

  • 4.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bootstrap-slider Build Status

Originally began as a loose "fork" of bootstrap-slider found on http://www.eyecon.ro/ by Stefan Petre.

Over time, this project has diverged sigfinicantly from Stefan Petre's version and is now almost completly different.

Please ensure that you are using this library instead of the Petre version before creating issues in the repository Issue tracker!!

Installation

Clone the repository, then run npm install

Want to use bower? bower install seiyria-bootstrap-slider

Want to use npm? npm install bootstrap-slider

Then load the plugin CSS and JavaScript into your web page, and everything should work!

Remember to load the plugin code after loading the Bootstrap CSS and JQuery.

JQuery is optional and the plugin can operate with or without it.

Look below to see an example of how to interact with the non-JQuery interface.

Supported Browsers

We only support modern browsers!!! Basically, anything below IE9 is not compatible with this plugin!

Examples

You can see all of our API examples here.

Using bootstrap-slider (with JQuery)

Create an input element and call .slider() on it:

// Instantiate a slider
var mySlider = $("input.slider").slider();

// Call a method on the slider
var value = mySlider.slider('getValue');

// For non-getter methods, you can chain together commands
	mySlider
		.slider('setValue', 5)
		.slider('setValue', 7);

If there is already a JQuery plugin named slider bound to the namespace, then this plugin will take on the alternate namespace bootstrapSlider.

// Instantiate a slider
var mySlider = $("input.slider").bootstrapSlider();

// Call a method on the slider
var value = mySlider.bootstrapSlider('getValue');

// For non-getter methods, you can chain together commands
	mySlider
		.bootstrapSlider('setValue', 5)
		.bootstrapSlider('setValue', 7);

Using bootstrap-slider (without JQuery)

Create an input element in the DOM, and then create an instance of Slider, passing it a selector string referencing the input element.

// Instantiate a slider
var mySlider = new Slider("input.slider", {
	// initial options object
});

// Call a method on the slider
var value = mySlider.getValue();

// For non-getter methods, you can chain together commands
mySlider
	.setValue(5)
	.setValue(7);

Loading as CommonJS module

bootstrap-slider can be loaded as a CommonJS module via Browserify, Webpack, or some other library.

var Slider = require("bootstrap-slider");

var mySlider = new Slider();

Note that the JQuery dependency is considered to be optional. For example, to exclude JQuery from being part of your Browserify build, you would call something like the following (assuming main.js is requiring bootstrap-slider as a dependency):

browserify -u jquery main.js > bundle.js

Please see the documentation for the specific CommonJS loader you are using to find out how to exclude dependencies.

Options

Options can be passed either as a data (data-slider-foo) attribute, or as part of an object in the slider call. The only exception here is the formatter argument - that can not be passed as a data- attribute.

NameTypeDefaultDescription
idstring''set the id of the slider element when it's created
minfloat0minimum possible value
maxfloat10maximum possible value
stepfloat1increment step
precisionfloatnumber of digits after the decimal of step valueThe number of digits shown after the decimal. Defaults to the number of digits after the decimal of step value.
orientationstring'horizontal'set the orientation. Accepts 'vertical' or 'horizontal'
valuefloat,array5initial value. Use array to have a range slider.
rangeboolfalsemake range slider. Optional if initial value is an array. If initial value is scalar, max will be used for second value.
selectionstring'before'selection placement. Accepts: 'before', 'after' or 'none'. In case of a range slider, the selection will be placed between the handles
tooltipstring'show'whether to show the tooltip on drag, hide the tooltip, or always show the tooltip. Accepts: 'show', 'hide', or 'always'
tooltip_separatorstring':'tooltip separator
tooltip_splitboolfalseif false show one tootip if true show two tooltips one for each handler
handlestring'round'handle shape. Accepts: 'round', 'square', 'triangle' or 'custom'
reversedboolfalsewhether or not the slider should be reversed
enabledbooltruewhether or not the slider is initially enabled
formatterfunctionreturns the plain valueformatter callback. Return the value wanted to be displayed in the tooltip
natural_arrow_keysboolfalseThe natural order is used for the arrow keys. Arrow up select the upper slider value for vertical sliders, arrow right the righter slider value for a horizontal slider - no matter if the slider was reversed or not. By default the arrow keys are oriented by arrow up/right to the higher slider value, arrow down/left to the lower slider value.

Functions

NOTE: Optional parameters are italicized.

FunctionParametersDescription
getValue---Get the current value from the slider
setValuenewValue, triggerSlideEventSet a new value for the slider. If optional triggerSlideEvent parameter is true, the 'slide' event will be triggered.
destroy---Properly clean up and remove the slider instance
disable---Disables the slider and prevents the user from changing the value
enable---Enables the slider
toggle---Toggles the slider between enabled and disabled
isEnabled---Returns true if enabled, false if disabled
setAttributeattribute, valueUpdates the slider's attributes
getAttributeattributeGet the slider's attributes
refresh---Refreshes the current slider
oneventType, callbackWhen the slider event eventType is triggered, the callback function will be invoked

Events

EventDescription
slideThis event fires when the slider is dragged
slideStartThis event fires when dragging starts
slideStopThis event fires when the dragging stops
slideEnabledThis event fires when the slider is enabled
slideDisabledThis event fires when the slider is disabled

Version Bumping (Maintainers Only)

To bump the version number across all the various packagement systems the plugin is registered with, please use the grunt bump plugin.

  • grunt bump:patch - patch version bump, 0.0.0 -> 0.0.1
  • grunt bump:minor - minor version bump, 0.0.0 -> 0.1.0
  • grunt bump:major - major version bump, 0.0.0 -> 1.0.0

Other Platforms & Libraries

Maintainers

FAQs

Package last updated on 14 Nov 2014

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