| 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"> |
| 6 |
<title>jQuery UI Spinner - Time</title> |
| 7 |
<link rel="stylesheet" href="../../themes/base/all.css"> |
| 8 |
<link rel="stylesheet" href="../demos.css"> |
| 9 |
<script src="../../external/requirejs/require.js"></script> |
| 10 |
<script src="../bootstrap.js" data-modules="external/globalize/globalize external/globalize/globalize.culture.de-DE external/jquery-mousewheel/jquery.mousewheel"> |
| 11 |
$.widget( "ui.timespinner", $.ui.spinner, { |
| 12 |
options: { |
| 13 |
// seconds |
| 14 |
step: 60 * 1000, |
| 15 |
// hours |
| 16 |
page: 60 |
| 17 |
}, |
| 18 |
|
| 19 |
_parse: function( value ) { |
| 20 |
if ( typeof value === "string" ) { |
| 21 |
// already a timestamp |
| 22 |
if ( Number( value ) == value ) { |
| 23 |
return Number( value ); |
| 24 |
} |
| 25 |
return +Globalize.parseDate( value ); |
| 26 |
} |
| 27 |
return value; |
| 28 |
}, |
| 29 |
|
| 30 |
_format: function( value ) { |
| 31 |
return Globalize.format( new Date(value), "t" ); |
| 32 |
} |
| 33 |
}); |
| 34 |
|
| 35 |
$( "#spinner" ).timespinner(); |
| 36 |
|
| 37 |
$( "#culture" ).on( "change", function() { |
| 38 |
var current = $( "#spinner" ).timespinner( "value" ); |
| 39 |
Globalize.culture( $(this).val() ); |
| 40 |
$( "#spinner" ).timespinner( "value", current ); |
| 41 |
}); |
| 42 |
</script> |
| 43 |
</head> |
| 44 |
<body> |
| 45 |
|
| 46 |
<p> |
| 47 |
<label for="spinner">Time spinner:</label> |
| 48 |
<input id="spinner" name="spinner" value="08:30 PM"> |
| 49 |
</p> |
| 50 |
<p> |
| 51 |
<label for="culture">Select a culture to use for formatting:</label> |
| 52 |
<select id="culture"> |
| 53 |
<option value="en-EN" selected="selected">English</option> |
| 54 |
<option value="de-DE">German</option> |
| 55 |
</select> |
| 56 |
</p> |
| 57 |
|
| 58 |
<div class="demo-description"> |
| 59 |
<p> |
| 60 |
A custom widget extending spinner. Use the Globalization plugin to parse and output |
| 61 |
a timestamp, with custom step and page options. Cursor up/down spins minutes, page up/down |
| 62 |
spins hours. |
| 63 |
</p> |
| 64 |
</div> |
| 65 |
</body> |
| 66 |
</html> |