index.tpl 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta name="description" content="Examples for bootstrap-slider plugin">
  7. <meta name="author" content="">
  8. <title>Slider for Bootstrap Examples Page</title>
  9. <!-- core CSS -->
  10. <link href="<%= css.bootstrap %>" rel="stylesheet">
  11. <link href="<%= css.slider %>" rel="stylesheet">
  12. <!-- Hightlight.js Theme Styles -->
  13. <link href="<%= css.highlightjs %>" rel="stylesheet">
  14. <!-- Custom styles for this template -->
  15. <style type='text/css'>
  16. /* Space out content a bit */
  17. body {
  18. padding-top: 20px;
  19. padding-bottom: 20px;
  20. }
  21. h1 small {
  22. font-size: 51%;
  23. }
  24. table {
  25. border-collapse: collapse;
  26. width: 100%;
  27. }
  28. th, td {
  29. text-align: left;
  30. padding: 5px;
  31. }
  32. tr:nth-child(even){background-color: #e5e5e5}
  33. th {
  34. background-color: #00008B;
  35. color: white;
  36. }
  37. /* Everything but the jumbotron gets side spacing for mobile first views */
  38. .header,
  39. .marketing,
  40. .footer {
  41. padding-left: 15px;
  42. padding-right: 15px;
  43. }
  44. /* Custom page header */
  45. .header {
  46. border-bottom: 1px solid #e5e5e5;
  47. }
  48. /* Make the masthead heading the same height as the navigation */
  49. .header h3 {
  50. margin-top: 0;
  51. margin-bottom: 0;
  52. line-height: 40px;
  53. padding-bottom: 19px;
  54. }
  55. /* Custom page footer */
  56. .footer {
  57. padding-top: 19px;
  58. color: #777;
  59. border-top: 1px solid #e5e5e5;
  60. }
  61. /* Customize container */
  62. .container {
  63. min-width: 640px;
  64. }
  65. @media (min-width: 768px) {
  66. .container {
  67. max-width: 1000px;
  68. }
  69. }
  70. .container-narrow > hr {
  71. margin: 30px 0;
  72. }
  73. /* Main marketing message and sign up button */
  74. .title {
  75. text-align: center;
  76. border-bottom: 1px solid #e5e5e5;
  77. }
  78. /* Responsive: Portrait tablets and up */
  79. @media screen and (min-width: 768px) {
  80. /* Remove the padding we set earlier */
  81. .header,
  82. .footer {
  83. padding-left: 0;
  84. padding-right: 0;
  85. }
  86. /* Space out the masthead */
  87. .header {
  88. margin-bottom: 30px;
  89. }
  90. /* Remove the bottom border on the jumbotron for visual effect */
  91. .title {
  92. border-bottom: 0;
  93. }
  94. }
  95. .well {
  96. background-color: #E0E0E0;
  97. }
  98. .slider-example {
  99. padding-top: 10px;
  100. padding-bottom: 55px;
  101. margin: 35px 0;
  102. }
  103. #destroyEx5Slider, #ex6CurrentSliderValLabel, #ex7-enabled {
  104. margin-left: 45px;
  105. }
  106. #ex6SliderVal {
  107. color: green;
  108. }
  109. #slider12a .slider-track-high, #slider12c .slider-track-high {
  110. background: green;
  111. }
  112. #slider12b .slider-track-low, #slider12c .slider-track-low {
  113. background: red;
  114. }
  115. #slider12c .slider-selection {
  116. background: yellow;
  117. }
  118. #slider22 .slider-selection {
  119. background: #2196f3;
  120. }
  121. #slider22 .slider-rangeHighlight {
  122. background: #f70616;
  123. }
  124. #slider22 .slider-rangeHighlight.category1 {
  125. background: #FF9900;
  126. }
  127. #slider22 .slider-rangeHighlight.category2 {
  128. background: #99CC00;
  129. }
  130. </style>
  131. <style type='text/css'>
  132. /* Example 1 custom styles */
  133. #ex1Slider .slider-selection {
  134. background: #BABABA;
  135. }
  136. /* Example 3 custom styles */
  137. #RGB {
  138. height: 20px;
  139. background: rgb(128, 128, 128);
  140. }
  141. #RC .slider-selection {
  142. background: #FF8282;
  143. }
  144. #RC .slider-handle {
  145. background: red;
  146. }
  147. #GC .slider-selection {
  148. background: #428041;
  149. }
  150. #GC .slider-handle {
  151. background: green;
  152. }
  153. #BC .slider-selection {
  154. background: #8283FF;
  155. }
  156. #BC .slider-handle {
  157. border-bottom-color: blue;
  158. }
  159. #R, #G, #B {
  160. width: 300px;
  161. }
  162. </style>
  163. <script type='text/javascript' src="<%= js.modernizr %>"></script>
  164. <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  165. <!--[if lt IE 9]>
  166. <script src="../../assets/js/html5shiv.js"></script>
  167. <script src="../../assets/js/respond.min.js"></script>
  168. <![endif]-->
  169. <!-- Highlight.js Styles -->
  170. </head>
  171. <body>
  172. <div class="container">
  173. <div id="top" class="jumbotron">
  174. <h1>Slider for Bootstrap <small>bootstrap-slider.js</small></h1>
  175. <p class="lead">Examples for the <a target="_blank" href="https://github.com/seiyria/bootstrap-slider">bootstrap-slider</a> component.<p>
  176. </div>
  177. <table>
  178. <tr>
  179. <th>Example Link</th>
  180. <th>Example Description</th>
  181. </tr>
  182. <tr>
  183. <td><a href="#example-1">Example 1</a></td>
  184. <td>Basic example with custom formatter and colored selected region via CSS</td>
  185. </tr>
  186. <tr>
  187. <td><a href="#example-2">Example 2</a></td>
  188. <td>Range selector, options specified via data attribute</td>
  189. </tr>
  190. <tr>
  191. <td><a href="#example-3">Example 3</a></td>
  192. <td>Using events to work with the values and style the selection and handles via CSS. The tooltip is disabled and diferent shapes for the handles</td>
  193. </tr>
  194. <tr>
  195. <td><a href="#example-4">Example 4</a></td>
  196. <td>Vertical Slider with reversed values (largest to smallest)</td>
  197. </tr>
  198. <tr>
  199. <td><a href="#example-5">Example 5</a></td>
  200. <td>Destroy instance of slider by calling destroy() method on slider instance via JavaScript</td>
  201. </tr>
  202. <tr>
  203. <td><a href="#example-6">Example 6</a></td>
  204. <td>Able to bind to 'slide' JQuery event on slider, which is triggered whenever the slider is used</td>
  205. </tr>
  206. <tr>
  207. <td><a href="#example-7">Example 7</a></td>
  208. <td>Sliders can be enabled and disabled</td>
  209. </tr>
  210. <tr>
  211. <td><a href="#example-8">Example 8</a></td>
  212. <td>Tooltip can always be displayed</td>
  213. </tr>
  214. <tr>
  215. <td><a href="#example-9">Example 9</a></td>
  216. <td>Precision (number of places after the decimal) can be specified</td>
  217. </tr>
  218. <tr>
  219. <td><a href="#example-10">Example 10</a></td>
  220. <td>Setting custom handlers</td>
  221. </tr>
  222. <tr>
  223. <td><a href="#example-11">Example 11</a></td>
  224. <td>Using a custom step interval</td>
  225. </tr>
  226. <tr>
  227. <td><a href="#example-12">Example 12</a></td>
  228. <td>Coloring the low and high track segments</td>
  229. </tr>
  230. <tr>
  231. <td><a href="#example-13">Example 13</a></td>
  232. <td>Using tick marks and labels</td>
  233. </tr>
  234. <tr>
  235. <td><a href="#example-14">Example 14</a></td>
  236. <td>Using tick marks at specific positions</td>
  237. </tr>
  238. <tr>
  239. <td><a href="#example-15">Example 15</a></td>
  240. <td>With a logarithmic scale</td>
  241. </tr>
  242. <tr>
  243. <td><a href="#example-16">Example 16</a></td>
  244. <td>Focus the slider handle after a value changes</td>
  245. </tr>
  246. <tr>
  247. <td><a href="#example-17">Example 17</a></td>
  248. <td>Unusual tooltip positions</td>
  249. </tr>
  250. <tr>
  251. <td><a href="#example-18">Example 18</a></td>
  252. <td>Accessibility with ARIA labels</td>
  253. </tr>
  254. <tr>
  255. <td><a href="#example-19">Example 19</a></td>
  256. <td>Auto-Register data-provide="slider" Elements</td>
  257. </tr>
  258. <tr>
  259. <td><a href="#example-20">Example 20</a></td>
  260. <td>Slider-Elements initially hidden</td>
  261. </tr>
  262. <tr>
  263. <td><a href="#example-21">Example 21</a></td>
  264. <td>Create an input element with the <strong>data-provide="slider"</strong> attribute automatically turns it into a slider. Options can be supplied via <strong>data-slider-</strong> attributes</td>
  265. </tr>
  266. <tr>
  267. <td><a href="#example-22">Example 22</a></td>
  268. <td>Highlight ranges on slider with <strong>rangeHighlights</strong> attribute</td>
  269. </tr>
  270. <tr>
  271. <td><a href="#example-23">Example 23</a></td>
  272. <td>Using tick marks at specific positions</td>
  273. </tr>
  274. <tr>
  275. <td><a href="#example-24">Example 24</a></td>
  276. <td>rtl mode (auto)</td>
  277. </tr>
  278. <tr>
  279. <td><a href="#example-25">Example 25</a></td>
  280. <td>Lock selection to ticks</td>
  281. </tr>
  282. <tr>
  283. <td><a href="#example-26">Example 26</a></td>
  284. <td>Refresh method with optional `options` object</td>
  285. </tr>
  286. </table>
  287. <div class="examples">
  288. <div id="example-1" class='slider-example'>
  289. <h3>Example 1: <a href="#top"><small>Back to Top</small></a></h3>
  290. <p>Basic example with custom formatter and colored selected region via CSS.</p>
  291. <div class="well">
  292. <input id="ex1" data-slider-id='ex1Slider' type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="14"/>
  293. </div>
  294. <h5>HTML</h5>
  295. <pre><code class="html">
  296. &ltinput id="ex1" data-slider-id='ex1Slider' type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="14"/&gt
  297. </code></pre>
  298. <h5>JavaScript</h5>
  299. <pre><code class="js">
  300. // With JQuery
  301. $('#ex1').slider({
  302. formatter: function(value) {
  303. return 'Current value: ' + value;
  304. }
  305. });
  306. // Without JQuery
  307. var slider = new Slider('#ex1', {
  308. formatter: function(value) {
  309. return 'Current value: ' + value;
  310. }
  311. });
  312. </code></pre>
  313. <h5>CSS</h5>
  314. <pre><code class="css">
  315. #ex1Slider .slider-selection {
  316. background: #BABABA;
  317. }
  318. </code></pre>
  319. </div>
  320. <div id="example-2" class='slider-example'>
  321. <h3>Example 2: <a href="#top"><small>Back to Top</small></a></h3>
  322. <p>Range selector, options specified via data attribute.</p>
  323. <div class="well">
  324. Filter by price interval: <b>€ 10</b> <input id="ex2" type="text" class="span2" value="" data-slider-min="10" data-slider-max="1000" data-slider-step="5" data-slider-value="[250,450]"/> <b>€ 1000</b>
  325. </div>
  326. <h5>HTML</h5>
  327. <pre><code class="html">
  328. Filter by price interval: &ltb&gt€ 10&lt/b&gt &ltinput id="ex2" type="text" class="span2" value="" data-slider-min="10" data-slider-max="1000" data-slider-step="5" data-slider-value="[250,450]"/&gt &ltb&gt€ 1000&lt/b&gt
  329. </code></pre>
  330. <h5>JavaScript</h5>
  331. <pre><code class="js">
  332. // With JQuery
  333. $("#ex2").slider({});
  334. // Without JQuery
  335. var slider = new Slider('#ex2', {});
  336. </code></pre>
  337. </div>
  338. <div id="example-3" class='slider-example'>
  339. <h3>Example 3: <a href="#top"><small>Back to Top</small></a></h3>
  340. <p>Using events to work with the values and style the selection and handles via CSS. The tooltip is disabled and diferent shapes for the handles.</p>
  341. <div class="well">
  342. <p>
  343. <b>R</b> <input type="text" class="span2" value="" data-slider-min="0" data-slider-max="255" data-slider-step="1" data-slider-value="128" data-slider-id="RC" id="R" data-slider-tooltip="hide" data-slider-handle="square" />
  344. </p>
  345. <p>
  346. <b>G</b> <input type="text" class="span2" value="" data-slider-min="0" data-slider-max="255" data-slider-step="1" data-slider-value="128" data-slider-id="GC" id="G" data-slider-tooltip="hide" data-slider-handle="round" />
  347. </p>
  348. <p>
  349. <b>B</b> <input type="text" class="span2" value="" data-slider-min="0" data-slider-max="255" data-slider-step="1" data-slider-value="128" data-slider-id="BC" id="B" data-slider-tooltip="hide" data-slider-handle="triangle" />
  350. </p>
  351. <div id="RGB"></div>
  352. </div>
  353. <h5>HTML</h5>
  354. <pre><code class="html">
  355. &ltp&gt
  356. &ltb&gtR&lt/b&gt &ltinput type="text" class="span2" value="" data-slider-min="0" data-slider-max="255" data-slider-step="1" data-slider-value="128" data-slider-id="RC" id="R" data-slider-tooltip="hide" data-slider-handle="square" /&gt
  357. &lt/p&gt
  358. &ltp&gt
  359. &ltb&gtG&lt/b&gt &ltinput type="text" class="span2" value="" data-slider-min="0" data-slider-max="255" data-slider-step="1" data-slider-value="128" data-slider-id="GC" id="G" data-slider-tooltip="hide" data-slider-handle="round" /&gt
  360. &lt/p&gt
  361. &ltp&gt
  362. &ltb&gtB&lt/b&gt &ltinput type="text" class="span2" value="" data-slider-min="0" data-slider-max="255" data-slider-step="1" data-slider-value="128" data-slider-id="BC" id="B" data-slider-tooltip="hide" data-slider-handle="triangle" /&gt
  363. &lt/p&gt
  364. &ltdiv id="RGB"&gt&lt/div&gt
  365. </code></pre>
  366. <h5>JavaScript</h5>
  367. <pre><code class="js">
  368. var RGBChange = function() {
  369. $('#RGB').css('background', 'rgb('+r.getValue()+','+g.getValue()+','+b.getValue()+')')
  370. };
  371. var r = $('#R').slider()
  372. .on('slide', RGBChange)
  373. .data('slider');
  374. var g = $('#G').slider()
  375. .on('slide', RGBChange)
  376. .data('slider');
  377. var b = $('#B').slider()
  378. .on('slide', RGBChange)
  379. .data('slider');
  380. </code></pre>
  381. <h5>CSS</h5>
  382. <pre><code class="css">
  383. #RGB {
  384. height: 20px;
  385. background: rgb(128, 128, 128);
  386. }
  387. #RC .slider-selection {
  388. background: #FF8282;
  389. }
  390. #RC .slider-handle {
  391. background: red;
  392. }
  393. #GC .slider-selection {
  394. background: #428041;
  395. }
  396. #GC .slider-handle {
  397. background: green;
  398. }
  399. #BC .slider-selection {
  400. background: #8283FF;
  401. }
  402. #BC .slider-handle {
  403. border-bottom-color: blue;
  404. }
  405. #R, #G, #B {
  406. width: 300px;
  407. }
  408. </code></pre>
  409. </div>
  410. <div id="example-4" class='slider-example'>
  411. <h3>Example 4: <a href="#top"><small>Back to Top</small></a></h3>
  412. <p>Vertical Slider with reversed values (largest to smallest).</p>
  413. <div class="well">
  414. <input id="ex4" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="-3" data-slider-orientation="vertical"/>
  415. </div>
  416. <h5>HTML</h5>
  417. <pre><code class="html">
  418. &ltinput id="ex4" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="-3" data-slider-orientation="vertical"/&gt
  419. </code></pre>
  420. <h5>JavaScript</h5>
  421. <pre><code class="js">
  422. // With JQuery
  423. $("#ex4").slider({
  424. reversed : true
  425. });
  426. // Without JQuery
  427. var slider = new Slider("#ex4", {
  428. reversed : true
  429. });
  430. </code></pre>
  431. </div>
  432. <div id="example-5" class='slider-example'>
  433. <h3>Example 5: <a href="#top"><small>Back to Top</small></a></h3>
  434. <p>Destroy instance of slider by calling destroy() method on slider instance via JavaScript.</p>
  435. <div class="well">
  436. <input id="ex5" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="0"/>
  437. <button id="destroyEx5Slider" class='btn btn-danger'>Click to Destroy</button>
  438. </div>
  439. <h5>HTML</h5>
  440. <pre><code class="html">
  441. &ltinput id="ex5" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="0"/&gt
  442. &ltbutton id="destroyEx5Slider" class='btn btn-danger'>Click to Destroy&lt/button&gt
  443. </code></pre>
  444. <h5>JavaScript</h5>
  445. <pre><code class="js">
  446. // With JQuery
  447. $("#ex5").slider();
  448. // Without JQuery
  449. var slider = new Slider('#ex5');
  450. $("#destroyEx5Slider").click(function() {
  451. // With JQuery
  452. $("#ex5").slider('destroy');
  453. // Without JQuery
  454. slider.destroy();
  455. });
  456. </code></pre>
  457. </div>
  458. <div id="example-6" class='slider-example'>
  459. <h3>Example 6: <a href="#top"><small>Back to Top</small></a></h3>
  460. <p>Able to bind to 'slide' JQuery event on slider, which is triggered whenever the slider is used.</p>
  461. <div class="well">
  462. <input id="ex6" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="3"/>
  463. <span id="ex6CurrentSliderValLabel">Current Slider Value: <span id="ex6SliderVal">3</span></span>
  464. </div>
  465. <h5>HTML</h5>
  466. <pre><code class="html">
  467. &ltinput id="ex6" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="3"/&gt
  468. &ltspan id="ex6CurrentSliderValLabel">Current Slider Value: &ltspan id="ex6SliderVal"&gt3&lt/span&gt&lt/span&gt
  469. </code></pre>
  470. <h5>JavaScript</h5>
  471. <pre><code class="js">
  472. // With JQuery
  473. $("#ex6").slider();
  474. $("#ex6").on("slide", function(slideEvt) {
  475. $("#ex6SliderVal").text(slideEvt.value);
  476. });
  477. // Without JQuery
  478. var slider = new Slider("#ex6");
  479. slider.on("slide", function(sliderValue) {
  480. document.getElementById("ex6SliderVal").textContent = sliderValue;
  481. });
  482. </code></pre>
  483. </code></pre>
  484. </div>
  485. <div id="example-7" class='slider-example'>
  486. <h3>Example 7: <a href="#top"><small>Back to Top</small></a></h3>
  487. <p>Sliders can be enabled and disabled.</p>
  488. <div class="well">
  489. <input id="ex7" type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="5" data-slider-enabled="false"/>
  490. <input id="ex7-enabled" type="checkbox"/> Enabled
  491. </div>
  492. <h5>HTML</h5>
  493. <pre><code class="html">
  494. &ltinput id="ex7" type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="5" data-slider-enabled="false"/&gt
  495. &ltinput id="ex7-enabled" type="checkbox"/&gt Enabled
  496. </code></pre>
  497. <h5>JavaScript</h5>
  498. <pre><code class="js">
  499. // With JQuery
  500. $("#ex7").slider();
  501. // Without JQuery
  502. var slider = new Slider("#ex7");
  503. $("#ex7-enabled").click(function() {
  504. if(this.checked) {
  505. // With JQuery
  506. $("#ex7").slider("enable");
  507. // Without JQuery
  508. slider.enable();
  509. }
  510. else {
  511. // With JQuery
  512. $("#ex7").slider("disable");
  513. // Without JQuery
  514. slider.disable();
  515. }
  516. });
  517. </code></pre>
  518. </div>
  519. <div id="example-8" class='slider-example'>
  520. <h3>Example 8: <a href="#top"><small>Back to Top</small></a></h3>
  521. <p>Tooltip can always be displayed.</p>
  522. <div class="well">
  523. <input id="ex8" data-slider-id='ex1Slider' type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="14"/>
  524. </div>
  525. <h5>HTML</h5>
  526. <pre><code class="html">
  527. &ltinput id="ex8" data-slider-id='ex1Slider' type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="14"/&gt
  528. </code></pre>
  529. <h5>JavaScript</h5>
  530. <pre><code class="js">
  531. // With JQuery
  532. $("#ex8").slider({
  533. tooltip: 'always'
  534. });
  535. // Without JQuery
  536. var slider = new Slider("#ex8", {
  537. tooltip: 'always'
  538. });
  539. </code></pre>
  540. </div>
  541. <div id="example-9" class='slider-example'>
  542. <h3>Example 9: <a href="#top"><small>Back to Top</small></a></h3>
  543. <p>Precision (number of places after the decimal) can be specified.</p>
  544. <div class="well">
  545. <input id="ex9" type="text"/>
  546. </div>
  547. <h5>HTML</h5>
  548. <pre><code class="html">
  549. &ltinput id="ex9" type="text"/&gt
  550. </code></pre>
  551. <h5>JavaScript</h5>
  552. <pre><code class="js">
  553. // With JQuery
  554. $("#ex9").slider({
  555. precision: 2,
  556. value: 8.115 // Slider will instantiate showing 8.12 due to specified precision
  557. });
  558. // Without JQuery
  559. var slider = new Slider("#ex9", {
  560. precision: 2,
  561. value: 8.115 // Slider will instantiate showing 8.12 due to specified precision
  562. });
  563. </code></pre>
  564. </div>
  565. <div id="example-10" class='slider-example'>
  566. <h3>Example 10: <a href="#top"><small>Back to Top</small></a></h3>
  567. <p>Setting custom handlers.</p>
  568. <div class="well">
  569. <input id="ex10" type="text" data-slider-handle="custom"/>
  570. </div>
  571. <h5>HTML</h5>
  572. <pre><code class="html">
  573. &ltinput id="ex10" type="text" data-slider-handle="custom"/&gt
  574. </code></pre>
  575. <h5>JavaScript</h5>
  576. <pre><code class="js">
  577. // With JQuery
  578. $("#ex10").slider({});
  579. // Without JQuery
  580. var slider = new Slider("#ex10", {});
  581. </code></pre>
  582. <h5>CSS</h5>
  583. <pre><code class="css">
  584. .slider-handle.custom {
  585. background: transparent none;
  586. /* You can customize the handle and set a background image */
  587. }
  588. /* Or display content like unicode characters or fontawesome icons */
  589. .slider-handle.custom::before {
  590. line-height: 20px;
  591. font-size: 20px;
  592. content: '\2605'; /*unicode star character*/
  593. color: #726204;
  594. }
  595. </code></pre>
  596. </div>
  597. <div id="example-11" class='slider-example'>
  598. <h3>Example 11: <a href="#top"><small>Back to Top</small></a></h3>
  599. <p>Using a custom step interval.</p>
  600. <div class="well">
  601. <input id="ex11" type="text" data-slider-handle="custom"/>
  602. </div>
  603. <h5>HTML</h5>
  604. <pre><code class="html">
  605. &ltinput id="ex11" type="text" data-slider-handle="custom"/&gt
  606. </code></pre>
  607. <h5>JavaScript</h5>
  608. <pre><code class="js">
  609. // With JQuery
  610. $("#ex11").slider({step: 20000, min: 0, max: 200000});
  611. // Without JQuery
  612. var slider = new Slider("#ex11", {
  613. step: 20000,
  614. min: 0,
  615. max: 200000
  616. });
  617. </code></pre>
  618. </div>
  619. <div id="example-12" class='slider-example'>
  620. <h3>Example 12: <a href="#top"><small>Back to Top</small></a></h3>
  621. <p>Coloring the low and high track segments.</p>
  622. <div class="well">
  623. Single-value slider, high track:<br/>
  624. <input id="ex12a" type="text"/><br/>
  625. Note that there is no low track on the single-value slider. The
  626. area lesser than the value of the handle is the selection.
  627. <br/><br/>
  628. Range slider, low track:<br/>
  629. <input id="ex12b" type="text"/>
  630. <br/><br/>
  631. Range slider, low and high tracks, and selection:<br/>
  632. <input id="ex12c" type="text"/>
  633. </div>
  634. <h5>HTML</h5>
  635. <pre><code class="html">
  636. &lt;!-- Single-value slider, high track: --&gt;
  637. &ltinput id="ex12a" type="text"/&gt&ltbr/&gt
  638. Note that there is no low track on the single-value slider. The area to lesser than the value of the handle is the selection.
  639. &lt;!-- Range slider, low track: --&gt;
  640. &ltinput id="ex12b" type="text"/&gt&ltbr/&gt
  641. &lt;!-- Range slider, low and high tracks, and selection: --&gt;
  642. &ltinput id="ex12c" type="text"/&gt&ltbr/&gt
  643. </code></pre>
  644. <h5>JavaScript</h5>
  645. <pre><code class="js">
  646. // With JQuery
  647. $("#ex12a").slider({ id: "slider12a", min: 0, max: 10, value: 5 });
  648. $("#ex12b").slider({ id: "slider12b", min: 0, max: 10, range: true, value: [3, 7] });
  649. $("#ex12c").slider({ id: "slider12c", min: 0, max: 10, range: true, value: [3, 7] });
  650. // Without JQuery
  651. var sliderA = new Slider("#ex12a", { id: "slider12a", min: 0, max: 10, value: 5 });
  652. var sliderB = new Slider("#ex12b", { id: "slider12b", min: 0, max: 10, range: true, value: [3, 7] });
  653. var sliderC = new Slider("#ex12c", { id: "slider12c", min: 0, max: 10, range: true, value: [3, 7] });
  654. </code></pre>
  655. <h5>CSS</h5>
  656. <pre><code class="css">
  657. #slider12a .slider-track-high, #slider12c .slider-track-high {
  658. background: green;
  659. }
  660. #slider12b .slider-track-low, #slider12c .slider-track-low {
  661. background: red;
  662. }
  663. #slider12c .slider-selection {
  664. background: yellow;
  665. }
  666. </code></pre>
  667. </div>
  668. <div id="example-13" class='slider-example'>
  669. <h3>Example 13: <a href="#top"><small>Back to Top</small></a></h3>
  670. <p>Using tick marks and labels.</p>
  671. <div class="well">
  672. <input id="ex13" type="text"/>
  673. </div>
  674. <h5>HTML</h5>
  675. <pre><code class="html">
  676. &lt;input id="ex13" type="text" data-slider-ticks="[0, 100, 200, 300, 400]" data-slider-ticks-snap-bounds="30" data-slider-ticks-labels='["$0", "$100", "$200", "$300", "$400"]'/&gt;
  677. </code></pre>
  678. <h5>JavaScript</h5>
  679. <pre><code class="js">
  680. // With JQuery
  681. $("#ex13").slider({
  682. ticks: [0, 100, 200, 300, 400],
  683. ticks_labels: ['$0', '$100', '$200', '$300', '$400'],
  684. ticks_snap_bounds: 30
  685. });
  686. // Without JQuery
  687. var slider = new Slider("#ex13", {
  688. ticks: [0, 100, 200, 300, 400],
  689. ticks_labels: ['$0', '$100', '$200', '$300', '$400'],
  690. ticks_snap_bounds: 30
  691. });
  692. </code></pre>
  693. </div>
  694. <div id="example-14" class='slider-example'>
  695. <h3>Example 14: <a href="#top"><small>Back to Top</small></a></h3>
  696. <p>Using tick marks at specific positions.</p>
  697. <div class="well">
  698. <input id="ex14" type="text"/>
  699. </div>
  700. <h5>HTML</h5>
  701. <pre><code class="html">
  702. &ltinput id="ex14" type="text" data-slider-ticks="[0, 100, 200, 300, 400]" data-slider-ticks-snap-bounds="30" data-slider-ticks-labels='["$0", "$100", "$200", "$300", "$400"]' data-slider-ticks-positions="[0, 30, 70, 90, 100]" /&gt
  703. </code></pre>
  704. <h5>JavaScript</h5>
  705. <pre><code class="js">
  706. // With JQuery
  707. $("#ex14").slider({
  708. ticks: [0, 100, 200, 300, 400],
  709. ticks_positions: [0, 30, 70, 90, 100],
  710. ticks_labels: ['$0', '$100', '$200', '$300', '$400'],
  711. ticks_snap_bounds: 30
  712. });
  713. // Without JQuery
  714. var slider = new Slider("#ex14", {
  715. ticks: [0, 100, 200, 300, 400],
  716. ticks_positions: [0, 30, 70, 90, 100],
  717. ticks_labels: ['$0', '$100', '$200', '$300', '$400'],
  718. ticks_snap_bounds: 30
  719. });
  720. </code></pre>
  721. </div>
  722. <div id="example-15" class='slider-example'>
  723. <h3>Example 15: <a href="#top"><small>Back to Top</small></a></h3>
  724. <p>With a logarithmic scale.</p>
  725. <div class="well">
  726. <input id="ex15" type="text" data-slider-min="1000" data-slider-max="10000000" data-slider-step="5" />
  727. </div>
  728. <h5>HTML</h5>
  729. <pre><code class="html">
  730. &lt;input id="ex15" type="text" data-slider-min="1000" data-slider-max="10000000" data-slider-step="5" /&gt;
  731. </code></pre>
  732. <h5>JavaScript</h5>
  733. <pre><code class="js">
  734. // With JQuery
  735. $("#ex15").slider({
  736. min: 1000,
  737. max: 10000000,
  738. scale: 'logarithmic',
  739. step: 10
  740. });
  741. // Without JQuery
  742. var slider = new Slider('#ex15', {
  743. min: 1000,
  744. max: 10000000,
  745. scale: 'logarithmic',
  746. step: 10
  747. });
  748. </code></pre>
  749. </div>
  750. <div id="example-16" class="slider-example">
  751. <h3>Example 16: <a href="#top"><small>Back to Top</small></a></h3>
  752. <p>Focus the slider handle after a value change.</p>
  753. <div class="well">
  754. Single-value slider:<br/>
  755. <input id="ex16a" type="text"/><br/>
  756. <br/><br/>
  757. Range slider:<br/>
  758. <input id="ex16b" type="text"/>
  759. </div>
  760. <h5>HTML</h5>
  761. <pre><code class="html">
  762. &lt;!-- Single-value slider: --&gt;
  763. &ltinput id="ex16a" type="text"/&gt&ltbr/&gt
  764. &lt;!-- Range slider: --&gt;
  765. &ltinput id="ex16b" type="text"/&gt&ltbr/&gt
  766. Note that the slider handle that caused the value change is focused.
  767. </code></pre>
  768. <h5>JavaScript</h5>
  769. <pre><code class="js">
  770. // With JQuery
  771. $("#ex16a").slider({ min: 0, max: 10, value: 0, focus: true });
  772. $("#ex16b").slider({ min: 0, max: 10, value: [0, 10], focus: true });
  773. // Without JQuery
  774. var sliderA = new Slider("#ex16a", { min: 0, max: 10, value: 0, focus: true });
  775. var sliderB = new Slider("#ex16b", { min: 0, max: 10, value: [0, 10], focus: true });
  776. </code></pre>
  777. </div>
  778. <div id="example-17" class="slider-example">
  779. <h3>Example 17: <a href="#top"><small>Back to Top</small></a></h3>
  780. <p>Unusual tooltip positions.</p>
  781. <div class="well">
  782. Horizontal slider with tooltip on the bottom<br/><br/>
  783. <input id="ex17a" type="text"/><br/><br/><br/>
  784. Vertical slider with tooltip on the left<br/><br/>
  785. <input id="ex17b" type="text"/>
  786. </div>
  787. <h5>HTML</h5>
  788. <pre><code class="html">
  789. &ltinput id="ex17a" type="text"/&gt
  790. &ltinput id="ex17b" type="text"/&gt
  791. </code></pre>
  792. <h5>JS</h5>
  793. <pre><code class="js">
  794. // With JQuery
  795. $("#ex17a").slider({
  796. min: 0,
  797. max: 10,
  798. value: 0,
  799. tooltip_position:'bottom'
  800. });
  801. $("#ex17b").slider({
  802. min: 0,
  803. max: 10,
  804. value: 0,
  805. orientation: 'vertical',
  806. tooltip_position:'left'
  807. });
  808. // Without JQuery
  809. var sliderA = new Slider("#ex17a", {
  810. min: 0,
  811. max: 10,
  812. value: 0,
  813. tooltip_position:'bottom'
  814. });
  815. var sliderB = new Slider("#ex17b", {
  816. min: 0,
  817. max: 10,
  818. value: 0,
  819. orientation: 'vertical',
  820. tooltip_position:'left'
  821. });
  822. </code></pre>
  823. </div>
  824. <div id="example-18" class="slider-example">
  825. <h3>Example 18: <a href="#top"><small>Back to Top</small></a></h3>
  826. <p>Accessibility with ARIA labels.</p>
  827. <div class="well">
  828. Slider with single value and label:<br/><br/>
  829. <span id="ex18-label-1" class="hidden">
  830. Example slider label
  831. </span>
  832. <input id="ex18a" type="text" /><br/><br/><br/>
  833. Range slider with multiple labels:<br/><br/>
  834. <span id="ex18-label-2a" class="hidden">
  835. Example low value
  836. </span>
  837. <span id="ex18-label-2b" class="hidden">
  838. Example high value
  839. </span>
  840. <input id="ex18b" type="text" />
  841. </div>
  842. <h5>HTML</h5>
  843. <pre><code class="html">
  844. &lt;span id="ex18-label-1" class="hidden"&gt;Example slider label&lt;/span&gt;
  845. &lt;input id="ex18a" type="text"/&gt;
  846. &lt;span id="ex18-label-2a" class="hidden"&gt;Example low value&lt;/span&gt;
  847. &lt;span id="ex18-label-2b" class="hidden"&gt;Example high value&lt;/span&gt;
  848. &lt;input id="ex18b" type="text"/&gt;
  849. </pre></code>
  850. <h5>JavaScript</h5>
  851. <pre><code class="js">
  852. // With JQuery
  853. $("#ex18a").slider({
  854. min: 0,
  855. max: 10,
  856. value: 5,
  857. labelledby: 'ex18-label-1'
  858. });
  859. $("#ex18b").slider({
  860. min: 0,
  861. max: 10,
  862. value: [3, 6],
  863. labelledby: ['ex18-label-2a', 'ex18-label-2b']
  864. });
  865. // Without JQuery
  866. var sliderA = new Slider("#ex18a", {
  867. min: 0,
  868. max: 10,
  869. value: 5,
  870. labelledby: 'ex18-label-1'
  871. });
  872. var sliderB = new Slider("#ex18b", {
  873. min: 0,
  874. max: 10,
  875. value: [3, 6],
  876. labelledby: ['ex18-label-2a', 'ex18-label-2b']
  877. });
  878. </pre></code>
  879. </div>
  880. <div id="example-19" class="slider-example">
  881. <h3>Example 19: <a href="#top"><small>Back to Top</small></a></h3>
  882. <p>Auto-Register data-provide="slider" Elements.</p>
  883. <div class="well">
  884. Slider-Element not accompanied by any custom Javascript:<br/><br/>
  885. <span id="ex18-label-1" class="hidden">
  886. Example slider label
  887. </span>
  888. <input id="ex19" type="text"
  889. data-provide="slider"
  890. data-slider-ticks="[1, 2, 3]"
  891. data-slider-ticks-labels='["short", "medium", "long"]'
  892. data-slider-min="1"
  893. data-slider-max="3"
  894. data-slider-step="1"
  895. data-slider-value="3"
  896. data-slider-tooltip="hide" />
  897. </div>
  898. <h5>HTML</h5>
  899. <pre><code class="html">
  900. &lt;span id="ex18-label-1" class="hidden">Example slider label&lt;/span&gt;
  901. &lt;input id="ex19" type="text"
  902. data-provide="slider"
  903. data-slider-ticks="[1, 2, 3]"
  904. data-slider-ticks-labels='["short", "medium", "long"]'
  905. data-slider-min="1"
  906. data-slider-max="3"
  907. data-slider-step="1"
  908. data-slider-value="3"
  909. data-slider-tooltip="hide" /&gt;
  910. </pre></code>
  911. </div>
  912. <div id="example-20" class="slider-example">
  913. <h3>Example 20: <a href="#top"><small>Back to Top</small></a></h3>
  914. <p>Slider-Elements initially hidden.</p>
  915. <a class="btn btn-primary" href="" id="ex20a">Show</a>
  916. <br><br>
  917. <div class="well" style="display: none">
  918. Slider-Element initially hidden, revealed by Javascript:<br/><br/>
  919. <span id="ex18-label-1" class="hidden">
  920. Example slider label
  921. </span>
  922. <input id="ex20" type="text"
  923. data-provide="slider"
  924. data-slider-ticks="[1, 2, 3]"
  925. data-slider-ticks-labels='["short", "medium", "long"]'
  926. data-slider-min="1"
  927. data-slider-max="3"
  928. data-slider-step="1"
  929. data-slider-value="3"
  930. data-slider-tooltip="hide" />
  931. </div>
  932. <h5>HTML</h5>
  933. <pre><code class="html">
  934. &lt;a class="btn btn-primary" href="" id="ex20a">Show&lt;/a&gt;
  935. &lt;div class="well" style="display: none"&gt;
  936. &lt;span id="ex18-label-1" class="hidden"&gt;Example slider label&lt;/span&gt;
  937. &lt;input id="ex19" type="text"
  938. data-provide="slider"
  939. data-slider-ticks="[1, 2, 3]"
  940. data-slider-ticks-labels='["short", "medium", "long"]'
  941. data-slider-min="1"
  942. data-slider-max="3"
  943. data-slider-step="1"
  944. data-slider-value="3"
  945. data-slider-tooltip="hide" /&gt;
  946. &lt;/div&gt;
  947. </pre></code>
  948. <h5>JavaScript</h5>
  949. <pre><code class="js">
  950. $('#ex20a').on('click', function(e) {
  951. $('#ex20a')
  952. .parent()
  953. .find(' >.well')
  954. .toggle()
  955. .find('input')
  956. .slider('relayout');
  957. e.preventDefault();
  958. });
  959. </pre></code>
  960. </div>
  961. <div id="example-21" class="slider-example">
  962. <h3>Example 21: <a href="#top"><small>Back to Top</small></a></h3>
  963. <p>Create an input element with the <strong>data-provide="slider"</strong> attribute automatically turns it into a slider. Options can be supplied via <strong>data-slider-</strong> attributes.</p>
  964. <div class="well">
  965. <input id="ex21" type="text"
  966. data-provide="slider"
  967. data-slider-ticks="[1, 2, 3]"
  968. data-slider-ticks-labels='["short", "medium", "long"]'
  969. data-slider-min="1"
  970. data-slider-max="3"
  971. data-slider-step="1"
  972. data-slider-value="3"
  973. data-slider-tooltip="hide" />
  974. </div>
  975. <h5>HTML</h5>
  976. <pre><code class="html">
  977. &lt;input id="ex21" type="text"
  978. data-provide="slider"
  979. data-slider-ticks="[1, 2, 3]"
  980. data-slider-ticks-labels='["short", "medium", "long"]'
  981. data-slider-min="1"
  982. data-slider-max="3"
  983. data-slider-step="1"
  984. data-slider-value="3"
  985. data-slider-tooltip="hide" /&gt;
  986. </pre></code>
  987. </div>
  988. <div id="example-22" class="slider-example">
  989. <h3>Example 22: <a href="#top"><small>Back to Top</small></a></h3>
  990. <p>Highlight ranges on slider with <strong>rangeHighlights</strong> attribute.</p>
  991. <div class="well">
  992. <input id="ex22" type="text"
  993. data-slider-id="slider22"
  994. data-slider-min="0"
  995. data-slider-max="20"
  996. data-slider-step="1"
  997. data-slider-value="14"
  998. data-slider-rangeHighlights='[{ "start": 2, "end": 5, "class": "category1" },
  999. { "start": 7, "end": 8, "class": "category2" },
  1000. { "start": 17, "end": 19 },
  1001. { "start": 17, "end": 24 },
  1002. { "start": -3, "end": 19 }]'/>
  1003. </div>
  1004. <h5>HTML</h5>
  1005. <pre><code class="html">
  1006. &ltinput id="ex22" type="text"
  1007. data-slider-id="slider22"
  1008. data-slider-min="0"
  1009. data-slider-max="20"
  1010. data-slider-step="1"
  1011. data-slider-value="14"
  1012. data-slider-rangeHighlights='[{ "start": 2, "end": 5, "class": "category1" },
  1013. { "start": 7, "end": 8, "class": "category2" },
  1014. { "start": 17, "end": 19 },
  1015. { "start": 17, "end": 24 }, //not visible - out of slider range
  1016. { "start": -3, "end": 19 }]' /&gt;
  1017. </pre></code>
  1018. <h5>JavaScript</h5>
  1019. <pre><code class="js">
  1020. // With JQuery
  1021. $('#ex22').slider({
  1022. id: 'slider22',
  1023. min: 0,
  1024. max: 20,
  1025. step: 1,
  1026. value: 14,
  1027. rangeHighlights: [{ "start": 2, "end": 5, "class": "category1" },
  1028. { "start": 7, "end": 8, "class": "category2" },
  1029. { "start": 17, "end": 19 },
  1030. { "start": 17, "end": 24 },
  1031. { "start": -3, "end": 19 }]});
  1032. // Without JQuery
  1033. var slider = new Slider("#ex22", {
  1034. id: 'slider22',
  1035. min: 0,
  1036. max: 20,
  1037. step: 1,
  1038. value: 14,
  1039. rangeHighlights: [{ "start": 2, "end": 5, "class": "category1" },
  1040. { "start": 7, "end": 8, "class": "category2" },
  1041. { "start": 17, "end": 19 },
  1042. { "start": 17, "end": 24 },
  1043. { "start": -3, "end": 19 }]});
  1044. </pre></code>
  1045. <h5>CSS</h5>
  1046. <pre><code class="css">
  1047. #slider22 .slider-selection {
  1048. background: #81bfde;
  1049. }
  1050. #slider22 .slider-rangeHighlight {
  1051. background: #f70616;
  1052. }
  1053. #slider22 .slider-rangeHighlight.category1 {
  1054. background: #FF9900;
  1055. }
  1056. #slider22 .slider-rangeHighlight.category2 {
  1057. background: #99CC00;
  1058. }
  1059. </pre></code>
  1060. </div>
  1061. <div id="example-23" class='slider-example'>
  1062. <h3>Example 23: <a href="#top"><small>Back to Top</small></a></h3>
  1063. <p>Using tick marks at specific positions.</p>
  1064. <div class="well">
  1065. <input id="ex23" type="text"/>
  1066. </div>
  1067. <h5>HTML</h5>
  1068. <pre><code class="html">
  1069. &ltinput id="ex23" type="text" data-slider-ticks="[0, 1, 2, 3, 4]" data-slider-step="0.01" data-slider-ticks-snap-bounds="200" data-slider-ticks-tooltip="true" ticks_positions="[0, 30, 60, 70, 90, 100]" /&gt
  1070. </pre></code>
  1071. <h5>JavaScript</h5>
  1072. <pre><code class="js">
  1073. // With JQuery
  1074. $("#ex23").slider({
  1075. ticks: [0, 1, 2, 3, 4],
  1076. ticks_positions: [0, 30, 60, 70, 90, 100],
  1077. ticks_snap_bounds: 200,
  1078. formatter: function(value) {
  1079. return 'Current value: ' + value;
  1080. },
  1081. ticks_tooltip: true,
  1082. step: 0.01
  1083. });
  1084. // Without JQuery
  1085. var slider = new Slider("#ex23", {
  1086. ticks: [0, 1, 2, 3, 4],
  1087. ticks_positions: [0, 30, 70, 90, 100],
  1088. ticks_snap_bounds: 200,
  1089. formatter: function(value) {
  1090. return 'Current value: ' + value;
  1091. },
  1092. ticks_tooltip: true,
  1093. step: 0.01
  1094. });
  1095. </pre></code>
  1096. </div>
  1097. <div id="example-24" class='slider-example'>
  1098. <h3>Example 24: <a href="#top"><small>Back to Top</small></a></h3>
  1099. <p>rtl mode (auto).</p>
  1100. <div class='well' dir ="rtl">
  1101. <span>-5</span>
  1102. <input id="ex24" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="14"/>
  1103. <span>20</span>
  1104. </div>
  1105. <h5>HTML</h5>
  1106. <pre><code class="html">
  1107. &lt;div class='well' dir ="rtl"&gt;
  1108. &lt;span&gt;-5&lt;/span&gt;
  1109. &lt;span&gt;20&lt;/span&gt;
  1110. &lt;input id="ex24" type="text" data-slider-min="-5" data-slider-max="20" data-slider-step="1" data-slider-value="14"/&gt;
  1111. &lt;/div&gt;
  1112. </pre></code>
  1113. <h5>JavaScript</h5>
  1114. <pre><code class="js">
  1115. // With JQuery
  1116. $("#ex24").slider({});
  1117. </pre></code>
  1118. </div>
  1119. <div id="example-25" class='slider-example'>
  1120. <h3>Example 25: <a href="#top"><small>Back to Top</small></a></h3>
  1121. <p>Lock selection to ticks</p>
  1122. <div class="well">
  1123. <input id="ex25" type="text" />
  1124. </div>
  1125. <h5>HTML</h5>
  1126. <pre><code class="html">
  1127. &lt;input id="ex25" type="text" data-slider-value="[1, 100]" data-slider-ticks="[1, 50, 100]" data-slider-lock-to-ticks="true"/&gt;
  1128. </pre></code>
  1129. <h5>JavaScript</h5>
  1130. <pre><code class="js">
  1131. // With JQuery
  1132. $("#ex25").slider({
  1133. value: [1, 100],
  1134. ticks: [1, 50, 100],
  1135. lock_to_ticks: true
  1136. });
  1137. </pre></code>
  1138. </div>
  1139. <div id="example-26" class='slider-example'>
  1140. <h3>Example 26: <a href="#top"><small>Back to Top</small></a></h3>
  1141. <p>Refresh method with optional `options` object</p>
  1142. <div class="well">
  1143. <input id="ex26" data-slider-id="ex26Slider" type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="10"/>
  1144. <button id="ex26_Refresh" class='btn btn-primary'>Refresh</button>
  1145. <div class="form-check">
  1146. <input class="form-check-input" type="checkbox" value="" id="ex26_UseCurrentVal">
  1147. <label class="form-check-label" for="ex26_UseCurrentVal">
  1148. Use Current Value
  1149. </label>
  1150. </div>
  1151. </div>
  1152. <h5>HTML</h5>
  1153. <pre><code class="html">
  1154. &lt;input id="ex26" data-slider-id="ex26Slider" type="text" data-slider-min="0" data-slider-max="20" data-slider-step="1" data-slider-value="10"/&gt;
  1155. </code></pre>
  1156. <h5>JavaScript</h5>
  1157. <pre><code class="js">
  1158. // With JQuery
  1159. $('#ex26').slider('refresh', { useCurrentValue: true });
  1160. // Without JQuery
  1161. var slider = new Slider('#ex26');
  1162. slider.refresh({ useCurrentValue: true });
  1163. </code></pre>
  1164. </div> <!-- /example-26 -->
  1165. </div> <!-- /examples -->
  1166. </div> <!-- /container -->
  1167. <!-- core JavaScript
  1168. ================================================== -->
  1169. <script type='text/javascript' src="<%= js.jquery %>"></script>
  1170. <script type='text/javascript' src="<%= js.slider %>"></script>
  1171. <script type='text/javascript' src="<%= js.highlightjs %>"></script>
  1172. <script>hljs.initHighlightingOnLoad();</script>
  1173. <script type='text/javascript'>
  1174. $(document).ready(function() {
  1175. /* Example 1 */
  1176. $('#ex1').slider({
  1177. formatter: function(value) {
  1178. return 'Current value: ' + value;
  1179. }
  1180. });
  1181. /* Example 2 */
  1182. $("#ex2").slider({});
  1183. /* Example 3 */
  1184. var RGBChange = function() {
  1185. $('#RGB').css('background', 'rgb('+r.getValue()+','+g.getValue()+','+b.getValue()+')')
  1186. };
  1187. var r = $('#R').slider()
  1188. .on('slide', RGBChange)
  1189. .data('slider');
  1190. var g = $('#G').slider()
  1191. .on('slide', RGBChange)
  1192. .data('slider');
  1193. var b = $('#B').slider()
  1194. .on('slide', RGBChange)
  1195. .data('slider');
  1196. /* Example 4 */
  1197. $("#ex4").slider({
  1198. reversed : true
  1199. });
  1200. /* Example 5 */
  1201. $("#ex5").slider();
  1202. $("#destroyEx5Slider").click(function() {
  1203. $("#ex5").slider('destroy');
  1204. });
  1205. /* Example 6 */
  1206. $("#ex6").slider();
  1207. $("#ex6").on('slide', function(slideEvt) {
  1208. $("#ex6SliderVal").text(slideEvt.value);
  1209. });
  1210. /* Example 7 */
  1211. $("#ex7").slider();
  1212. $("#ex7-enabled").click(function() {
  1213. if(this.checked) {
  1214. $("#ex7").slider("enable");
  1215. }
  1216. else {
  1217. $("#ex7").slider("disable");
  1218. }
  1219. });
  1220. /* Example 8 */
  1221. $("#ex8").slider({
  1222. tooltip: 'always'
  1223. });
  1224. /* Example 9 */
  1225. $("#ex9").slider({
  1226. precision: 2,
  1227. value: 8.115
  1228. });
  1229. /* Example 10 */
  1230. $("#ex10").slider({});
  1231. /* Example 11 */
  1232. $("#ex11").slider({
  1233. step: 20000,
  1234. min: 0,
  1235. max: 200000
  1236. });
  1237. /* Example 12 */
  1238. $("#ex12a").slider({
  1239. id: "slider12a",
  1240. min: 0,
  1241. max: 10,
  1242. value: 5
  1243. });
  1244. $("#ex12b").slider({
  1245. id: "slider12b",
  1246. min: 0,
  1247. max: 10,
  1248. range: true,
  1249. value: [ 3, 7 ]
  1250. });
  1251. $("#ex12c").slider({
  1252. id: "slider12c",
  1253. min: 0,
  1254. max: 10,
  1255. range: true,
  1256. value: [ 3, 7 ]
  1257. });
  1258. /* Example 13 */
  1259. $("#ex13").slider({
  1260. ticks: [0, 100, 200, 300, 400],
  1261. ticks_labels: ['$0', '$100', '$200', '$300', '$400'],
  1262. ticks_snap_bounds: 30,
  1263. value: 200
  1264. });
  1265. /* Example 14 */
  1266. $("#ex14").slider({
  1267. ticks: [0, 100, 200, 300, 400],
  1268. ticks_labels: ['$0', '$100', '$200', '$300', '$400'],
  1269. ticks_positions: [0, 30, 70, 90, 100],
  1270. ticks_snap_bounds: 20,
  1271. value: 200,
  1272. });
  1273. /* Example 15 */
  1274. $("#ex15").slider({
  1275. min: 10,
  1276. max: 1000,
  1277. scale: 'logarithmic',
  1278. step: 10
  1279. });
  1280. /* Example 16 */
  1281. $("#ex16a").slider({
  1282. min : 0,
  1283. max : 10,
  1284. value: 0,
  1285. focus: true
  1286. });
  1287. $("#ex16b").slider({
  1288. min : 0,
  1289. max : 10,
  1290. value: [ 0, 10 ],
  1291. focus: true
  1292. });
  1293. /* Example 17 */
  1294. $("#ex17a").slider({
  1295. min : 0,
  1296. max : 10,
  1297. value: 0,
  1298. tooltip_position:'bottom'
  1299. });
  1300. $("#ex17b").slider({
  1301. min : 0,
  1302. max : 10,
  1303. value: 0,
  1304. orientation: 'vertical',
  1305. tooltip_position:'left'
  1306. });
  1307. /* Example 18 */
  1308. $('#ex18a').slider({
  1309. min : 0,
  1310. max : 10,
  1311. value: 5,
  1312. labelledby: 'ex18-label-1'
  1313. });
  1314. $('#ex18b').slider({
  1315. min : 0,
  1316. max : 10,
  1317. value: [3, 6],
  1318. labelledby: ['ex18-label-2a', 'ex18-label-2b']
  1319. });
  1320. $('#ex20a').on('click', function(e) {
  1321. $('#ex20a')
  1322. .parent()
  1323. .find(' >.well')
  1324. .toggle()
  1325. .find('input')
  1326. .slider('relayout');
  1327. e.preventDefault();
  1328. });
  1329. /* Example 22 */
  1330. $('#ex22').slider({});
  1331. /* Example 23 */
  1332. $('#ex23').slider({
  1333. ticks: [0, 1, 2, 3, 4],
  1334. ticks_positions: [0, 30, 70, 90, 100],
  1335. formatter: function(value) {
  1336. return 'Current value: ' + value;
  1337. },
  1338. step: 0.01,
  1339. ticks_tooltip: true
  1340. });
  1341. /* example 24 */
  1342. $('#ex24').slider({});
  1343. /* example 25 */
  1344. $("#ex25").slider({
  1345. value: [1, 100],
  1346. ticks: [1, 50, 100],
  1347. lock_to_ticks: true
  1348. });
  1349. /* example 26 */
  1350. $('#ex26').slider();
  1351. $('#ex26_Refresh').on('click', function() {
  1352. if ($('#ex26_UseCurrentVal').prop('checked')) {
  1353. $('#ex26').slider('refresh', { useCurrentValue: true });
  1354. }
  1355. else {
  1356. $('#ex26').slider('refresh');
  1357. }
  1358. });
  1359. });
  1360. </script>
  1361. <!-- Placed at the end of the document so the pages load faster -->
  1362. </body>
  1363. </html>