widget_float.js
34 lines
| 1.0 KiB
| application/javascript
|
JavascriptLexer
Jonathan Frederic
|
r17198 | // Copyright (c) IPython Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||||
Jonathan Frederic
|
r14672 | |||
Jonathan Frederic
|
r17198 | define([ | ||
"widgets/js/widget", | ||||
"widgets/js/widget_int", | ||||
], function(widget, int_widgets){ | ||||
var IntSliderView = int_widgets.IntSliderView; | ||||
var IntTextView = int_widgets.IntTextView; | ||||
Jonathan Frederic
|
r14672 | |||
Jonathan Frederic
|
r14694 | var FloatSliderView = IntSliderView.extend({ | ||
Gordon Ball
|
r17957 | _parse_value: parseFloat, | ||
Gordon Ball
|
r17956 | |||
Gordon Ball
|
r17957 | // matches: whitespace?, float, whitespace?, [-:], whitespace?, float | ||
_range_regex: /^\s*([+-]?(?:\d*\.?\d+|\d+\.)(?:[eE][+-]?\d+)?)\s*[-:]\s*([+-]?(?:\d*\.?\d+|\d+\.)(?:[eE][+-]?\d+)?)/, | ||||
Gordon Ball
|
r17953 | |||
Jonathan Frederic
|
r14694 | _validate_slide_value: function(x) { | ||
Jonathan Frederic
|
r19176 | /** | ||
* Validate the value of the slider before sending it to the back-end | ||||
* and applying it to the other views on the page. | ||||
*/ | ||||
Jonathan Frederic
|
r14694 | return x; | ||
Jonathan Frederic
|
r14672 | }, | ||
}); | ||||
MinRK
|
r14792 | var FloatTextView = IntTextView.extend({ | ||
Gordon Ball
|
r17957 | _parse_value: parseFloat | ||
Jonathan Frederic
|
r14672 | }); | ||
Jonathan Frederic
|
r17198 | |||
return { | ||||
'FloatSliderView': FloatSliderView, | ||||
'FloatTextView': FloatTextView, | ||||
}; | ||||
Jonathan Frederic
|
r14672 | }); | ||