<script src="../../jquery.js"></script>
<script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
<script src="../../../external/globalize.js"></script>
+ <script src="../../../external/globalize.culture.ja-JP.js"></script>
<script src="../../../ui/jquery.ui.core.js"></script>
<script src="../../../ui/jquery.ui.widget.js"></script>
<script src="../../../ui/jquery.ui.button.js"></script>
module( "spinner: options" );
+// culture is tested after numberFormat, since it depends on numberFormat
+
test( "incremental, false", function() {
expect( 100 );
equal( element.val(), "$1.00", "formatted after step" );
});
+test( "culture, null", function() {
+ expect( 2 );
+ Globalize.culture( "ja-JP" );
+ var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "C" });
+ equal( element.val(), "¥0", "formatted on init" );
+ element.spinner( "stepUp" );
+ equal( element.val(), "¥1", "formatted after step" );
+
+ // reset culture
+ Globalize.culture( "default" );
+});
+
+test( "currency, ja-JP", function() {
+ expect( 2 );
+ var element = $( "#spin" ).val( 0 ).spinner({
+ numberFormat: "C",
+ culture: "ja-JP"
+ });
+ equal( element.val(), "¥0", "formatted on init" );
+ element.spinner( "stepUp" );
+ equal( element.val(), "¥1", "formatted after step" );
+});
+
test( "max", function() {
expect( 3 );
var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 });
defaultElement: "<input>",
widgetEventPrefix: "spin",
options: {
+ culture: null,
incremental: true,
max: null,
min: null,
_parse: function( val ) {
if ( typeof val === "string" && val !== "" ) {
- val = window.Globalize && this.options.numberFormat ? Globalize.parseFloat( val ) : +val;
+ val = window.Globalize && this.options.numberFormat ?
+ Globalize.parseFloat( val, 10, this.options.culture ) : +val;
}
return val === "" || isNaN( val ) ? null : val;
},
return "";
}
return window.Globalize && this.options.numberFormat ?
- Globalize.format( value, this.options.numberFormat ) :
+ Globalize.format( value, this.options.numberFormat, this.options.culture ) :
value;
},