Skip to content

Commit

Permalink
Mask/Timepicker: Lint fixes. Units still fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaefferer committed Nov 17, 2012
1 parent 4929eed commit 4f5a83c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion tests/unit/mask/mask_methods.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test( "value: able to get (and set) raw values", function() {
test( "value: able to get (and set) raw values with optional section", function() { test( "value: able to get (and set) raw values with optional section", function() {
expect( 5 ); expect( 5 );
var input = $( "#mask1" ).val("1234").mask({ var input = $( "#mask1" ).val("1234").mask({
mask: "(999) 999-9999?x9999", mask: "(999) 999-9999?x9999"
}); });


equal( input.mask('value'), "1234", "Reading initial value" ); equal( input.mask('value'), "1234", "Reading initial value" );
Expand Down
35 changes: 17 additions & 18 deletions tests/unit/mask/mask_options.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ module( "mask: options" );
test( "clearEmpty", function() { test( "clearEmpty", function() {
expect( 4 ); expect( 4 );
var input = $( "#mask1" ).val( "" ).mask({ var input = $( "#mask1" ).val( "" ).mask({
mask: "99/99/99", mask: "99/99/99",
placeholder: "_", placeholder: "_",
clearEmpty: true clearEmpty: true
}), });
mask = input.data( "mask" );


equal( input.val(), "", "Empty value with clearEmpty displays no mask" ); equal( input.val(), "", "Empty value with clearEmpty displays no mask" );
TestHelpers.focus( input ); TestHelpers.focus( input );
Expand Down Expand Up @@ -48,7 +47,7 @@ test( "mask", function() {
test( "mask with optional input", function() { test( "mask with optional input", function() {
expect( 1 ); expect( 1 );
var input = $( "#mask1" ).val( "1234" ).mask({ var input = $( "#mask1" ).val( "1234" ).mask({
mask: "(999) 999-9999?x9999", mask: "(999) 999-9999?x9999"
}); });


equal( input.val(), "(123) 4__-____", "Initial value" ); equal( input.val(), "(123) 4__-____", "Initial value" );
Expand All @@ -57,7 +56,7 @@ test( "mask with optional input", function() {
test( "mask with multiple optional inputs", function() { test( "mask with multiple optional inputs", function() {
expect( 1 ); expect( 1 );
var input = $( "#mask1" ).val( "1234" ).mask({ var input = $( "#mask1" ).val( "1234" ).mask({
mask: "(999) 999-9999?x9?9?9?9", mask: "(999) 999-9999?x9?9?9?9"
}); });


equal( input.val(), "(123) 4__-____", "Initial value" ); equal( input.val(), "(123) 4__-____", "Initial value" );
Expand All @@ -66,7 +65,7 @@ test( "mask with multiple optional inputs", function() {
test( "mask with escaped characters", function() { test( "mask with escaped characters", function() {
expect( 1 ); expect( 1 );
var input = $( "#mask1" ).val( "1234" ).mask({ var input = $( "#mask1" ).val( "1234" ).mask({
mask: "(\\9\\9\\9)\\\\ 999-99\\a\\*\\?x9999", mask: "(\\9\\9\\9)\\\\ 999-99\\a\\*\\?x9999"
}); });


equal( input.val(), "(999)\\ 123-4_a*?x____", "Initial value" ); equal( input.val(), "(999)\\ 123-4_a*?x____", "Initial value" );
Expand All @@ -75,7 +74,7 @@ test( "mask with escaped characters", function() {
test( "escaped use of custom mask with wrapper ", function() { test( "escaped use of custom mask with wrapper ", function() {
expect( 1 ); expect( 1 );
var input = $( "#mask1" ).val( "1" ).mask({ var input = $( "#mask1" ).val( "1" ).mask({
mask: "9\\<xyz\\>", mask: "9\\<xyz\\>"
}); });


equal( input.val(), "1<xyz>", "Initial value" ); equal( input.val(), "1<xyz>", "Initial value" );
Expand All @@ -90,23 +89,23 @@ test( "custom mask with wrapper and escape", function() {
if ( $.inArray(value, [ "mon", "tue", "wed", "thu", "fri", "sat", "sun" ]) ) { if ( $.inArray(value, [ "mon", "tue", "wed", "thu", "fri", "sat", "sun" ]) ) {
return value; return value;
} else if ( $.inArray(value, [ "m", "mo" ])) { } else if ( $.inArray(value, [ "m", "mo" ])) {
return "mon"; return "mon";
} else if ( value === "t" ) { } else if ( value === "t" ) {
return "t"; return "t";
} else if ( value === "tu" ) { } else if ( value === "tu" ) {
return "tue"; return "tue";
} else if ( value === "thu" ) { } else if ( value === "thu" ) {
return "thu"; return "thu";
} else if ( $.inArray(value, [ "w", "we" ]) ) { } else if ( $.inArray(value, [ "w", "we" ]) ) {
return "wed"; return "wed";
} else if ( $.inArray(value, [ "f", "fr" ]) ) { } else if ( $.inArray(value, [ "f", "fr" ]) ) {
return "fri"; return "fri";
} else if ( value === "s" ) { } else if ( value === "s" ) {
return "s"; return "s";
} else if ( value === "sa" ) { } else if ( value === "sa" ) {
return "sat"; return "sat";
} else if ( value === "su" ) { } else if ( value === "su" ) {
return "sun"; return "sun";
} }
}, },
d: /[0-9]/ d: /[0-9]/
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/timepicker/timepicker_core.js
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
(function( $ ) { (function() {


module( "timepicker: core" ); module( "timepicker: core" );


}( jQuery ) ); }());
5 changes: 2 additions & 3 deletions tests/unit/timepicker/timepicker_methods.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ module( "timepicker: methods" );
test( "value - get and set value", function() { test( "value - get and set value", function() {
expect( 3 ); expect( 3 );


var i, var input = $( "#timepicker1" ).val( "12:00:00 AM" ).timepicker();
input = $( "#timepicker1" ).val( "12:00:00 AM" ).timepicker();


equal( input.timepicker( "value" ), "00:00:00", "Expected value for 12am" ); equal( input.timepicker( "value" ), "00:00:00", "Expected value for 12am" );


Expand All @@ -17,7 +16,7 @@ test( "value - get and set value", function() {


input.timepicker( "value", "12:34:56" ); input.timepicker( "value", "12:34:56" );
equal( input.val(), "12:34:56 PM", "Expected val() for 12:34:56" ); equal( input.val(), "12:34:56 PM", "Expected val() for 12:34:56" );

}); });


}( jQuery ) ); }( jQuery ) );
20 changes: 10 additions & 10 deletions ui/jquery.ui.mask.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ $.widget( "ui.mask", {
return value; return value;
}, },
_events: { _events: {
focus: function( event ) { focus: function() {
this.lastUnsavedValue = this.element.val(); this.lastUnsavedValue = this.element.val();
this._paint( true ); this._paint( true );
this._caretSelect( this._seekRight( this._parseValue() ) ); this._caretSelect( this._seekRight( this._parseValue() ) );
Expand All @@ -171,18 +171,18 @@ $.widget( "ui.mask", {
this._justFocused = false; this._justFocused = false;
}, 100); }, 100);
}, },
click: function( event ) { click: function() {
/* Normally, the call to handle this in the focus event handler would be // Normally, the call to handle this in the focus event handler would be
sufficient, but Chrome fires the focus events before positioning the // sufficient, but Chrome fires the focus events before positioning the
cursor based on where the user clicked (and then fires the click event). */ // cursor based on where the user clicked (and then fires the click event).


// We only want to move the caret on clicks that resulted in focus // We only want to move the caret on clicks that resulted in focus
if ( this._justFocused ) { if ( this._justFocused ) {
this._caretSelect( this._seekRight( this._parseValue() ) ); this._caretSelect( this._seekRight( this._parseValue() ) );
this._justFocused = false; this._justFocused = false;
} }
}, },
blur: function( event ) { blur: function() {
this._justFocused = false; this._justFocused = false;


// because we are constantly setting the value of the input, the change event // because we are constantly setting the value of the input, the change event
Expand Down Expand Up @@ -311,7 +311,7 @@ $.widget( "ui.mask", {
} }
return true; return true;
}, },
_paste: function(event) { _paste: function() {
this._delay( function() { this._delay( function() {
var position = this._parseValue(); var position = this._parseValue();
this._paint(); this._paint();
Expand Down Expand Up @@ -342,7 +342,7 @@ $.widget( "ui.mask", {
return true; return true;
}, },
_removeCharacter: function( mask, index ) { _removeCharacter: function( mask, index ) {
var x, bufferObject; var x, bufferObject;


for ( x = index ; x < mask.length - 1 ; x++ ) { for ( x = index ; x < mask.length - 1 ; x++ ) {
bufferObject = this.buffer[ x + 1 ]; bufferObject = this.buffer[ x + 1 ];
Expand All @@ -361,7 +361,7 @@ $.widget( "ui.mask", {
return mask.substring( 0, index ) + mask.substring( index + 1 ); return mask.substring( 0, index ) + mask.substring( index + 1 );
}, },
_parseMask: function() { _parseMask: function() {
var key, x, bufferObject, optionalPosition, builder, var key, x, optionalPosition,
index = -1, index = -1,
options = this.options, options = this.options,
mask = options.mask, mask = options.mask,
Expand All @@ -375,7 +375,7 @@ $.widget( "ui.mask", {
// search for escaped reserved characters // search for escaped reserved characters
for ( index = 0 ; index < mask.length - 1 ; index++ ) { for ( index = 0 ; index < mask.length - 1 ; index++ ) {
if ( mask.charAt( index ) === "\\" && if ( mask.charAt( index ) === "\\" &&
$.inArray( mask.charAt( index + 1 ), reservedChars ) !== -1 ) { $.inArray( mask.charAt( index + 1 ), reservedChars ) !== -1 ) {
// remove escape character // remove escape character
mask = mask.substring( 0, index ) + mask.substring( index + 1 ); mask = mask.substring( 0, index ) + mask.substring( index + 1 );


Expand Down
4 changes: 2 additions & 2 deletions ui/jquery.ui.timepicker.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ $.widget( "ui.timepicker", {


return mask; return mask;
}, },
_highlightField: function( field ) { _highlightField: function() {
this.mask._caretSelect( this.currentField * 3 ); this.mask._caretSelect( this.currentField * 3 );
}, },
_setField: function( field ) { _setField: function( field ) {
Expand Down Expand Up @@ -267,4 +267,4 @@ $.widget( "ui.timepicker", {
} }
}); });


}( jQuery )); }( jQuery ));

0 comments on commit 4f5a83c

Please sign in to comment.