Skip to content
This repository was archived by the owner on Dec 11, 2017. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
eb1e27f
first pass at auto-completion. Currently breaks 'completed' setting.
Aug 2, 2011
11ac5fd
fixed "completed" setting
Aug 2, 2011
82f9534
Fixed bug in checkVal(true) when a mask literal matches a defined and…
Aug 3, 2011
67b47c5
updated demo page
Aug 3, 2011
ae690e1
further autocomplete pattern refinements
Aug 3, 2011
b736095
Fixed bug in checkVal(true) when a mask literal matches a defined and…
Aug 3, 2011
5606b63
added IRS style rounded dollars input to demo, for testing mask liter…
Aug 3, 2011
9052a72
inadvertent adds of ignored files
Aug 3, 2011
82e845e
added predefined autocomplete definitions, began autocomplete specs
Aug 11, 2011
1b50073
added predefined autocomplete definitions, began autocomplete specs
Aug 11, 2011
3dbbf78
started on year specs for mmddyyyy
Aug 11, 2011
6cc8656
translation of autocomplete spec to coffee-script
codelahoma Aug 12, 2011
1101516
coffeescript'd the autocomplete specs
Aug 12, 2011
492b87c
Rewrote coffescript spec to use plain Jasmine, to avoid keyword confi…
codelahoma Aug 13, 2011
79ef668
Merge branch 'add-auto'
codelahoma Aug 13, 2011
1a8adaf
ported plugin to CoffeeScript; began work on progressive-reveal
codelahoma Aug 15, 2011
22f6410
added leading slash supression to predefined masks and specs
codelahoma Aug 15, 2011
a524888
Merge branch 'add-auto' into progressive-reveal
codelahoma Aug 15, 2011
d80a94a
fixed a couple of autocomplete regexes
codelahoma Aug 15, 2011
1a82129
corrected stylesheet link
codelahoma Aug 16, 2011
ff40c38
Fixed some autocomplete regexes
codelahoma Aug 16, 2011
428cfa4
Started progressive reveal mods, both code and tests
codelahoma Aug 16, 2011
26673be
ignore node files
Aug 19, 2011
cfcec57
generated file no longer "mod"
Aug 19, 2011
c0e430e
fixed bare call to CreateRange
codelahoma Aug 20, 2011
88616ca
fixed bare call to CreateRange
codelahoma Aug 20, 2011
935aa85
Merge branch 'progressive-reveal' of github.com:codelahoma/jquery.mas…
codelahoma Aug 20, 2011
5c86158
update for reserve word in spec
codelahoma Aug 20, 2011
51cad16
update for reserve word in spec
codelahoma Aug 20, 2011
f55652f
Merge branch 'progressive-reveal' of github.com:codelahoma/jquery.mas…
codelahoma Aug 20, 2011
1523f1e
working on caret issues
codelahoma Aug 20, 2011
1c4345b
corrected typo in progressive_reveal default setting
codelahoma Aug 20, 2011
0af2bd4
fixed function calls in spec
codelahoma Aug 20, 2011
aa5cd28
fixed precedence problem in checkVal
codelahoma Aug 21, 2011
8b14f50
fixed logic around moveCaret() for IE
codelahoma Aug 21, 2011
041a94c
add missing regex to mmyyyy
Sep 21, 2011
3acfd1e
make Backspace and Delete clear input in certain conditions
Sep 21, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

.idea/*
dist/*
# vim undo files
*~
# vim swap files
*.swp
acs.tmp
node_modules/
npm-debug.log
6 changes: 4 additions & 2 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ minify = (js)->
process = uglify.uglify
ast = process.ast_mangle(ast)
ast = process.ast_squeeze(ast)
comment = uglify.parser.tokenizer(js)().comments_before[0].value;
'/*'+comment+'*/\n'+process.gen_code(ast)
#comment = uglify.parser.tokenizer(js)().comments_before[0].value;
#'/*'+comment+'*/\n'+process.gen_code(ast)
process.gen_code(ast)


replaceTokens = (js,tokens)->
js.replace(
Expand Down
15 changes: 12 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<!doctype html>
<html>
<head>
<title> jQuery Mask Test </title>
<script src="../lib/jquery-1.4.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/jquery.maskedinput.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$.mask.definitions['~'] = "[+-]";
$("#date").mask("99/99/9999",{completed:function(){alert("completed!");}});
$("#phone").mask("(999) 999-9999");
$.mask.definitions['~'] = "[+-]";
$.mask.definitions['m'] = "[0-9\/]";
$.mask.definitions['d'] = "[0-9\/]";
$.mask.definitions['y'] = "[0-9\/]";
$("#date").mask("mm/dd/yyyy",{ placeholder: " ", progressive_reveal: true,
autocomplete: $.mask.autocomplete_predefined["mmddyyyy"] });
$("#phone").mask("mm/yyyy",{ placeholder: " ", progressive_reveal: true,
autocomplete: $.mask.autocomplete_predefined["mmyyyy"] });
<!--$("#phone").mask("(999) 999-9999");-->
$("#phoneExt").mask("(999) 999-9999? x99999");
$("#iphone").mask("+33 999 999 999");
$("#tin").mask("99-9999999");
Expand All @@ -16,6 +23,7 @@
$("#eyescript").mask("~9.99 ~9.99 999");
$("#po").mask("PO: aaa-999-***");
$("#pct").mask("99%");
$("#rd").mask("$99.00");

$("input").blur(function() {
$("#info").html("Unmasked value: " + $(this).mask());
Expand All @@ -38,6 +46,7 @@
<tr><td>Eye Script</td><td><input id="eyescript" type="text" tabindex="6"/></td><td>~9.99 ~9.99 999</td></tr>
<tr><td>Purchase Order</td><td><input id="po" type="text" tabindex="6"/></td><td>aaa-999-***</td></tr>
<tr><td>Percent</td><td><input id="pct" type="text" tabindex="6"/></td><td>99%</td></tr>
<tr><td>Rounded Dollar (IRS Style)</td><td><input id="rd" type="text" tabindex="7"/></td><td>$99.00</td></tr>
</table>
<div id="info"></div>
</body>
Expand Down
100 changes: 100 additions & 0 deletions spec/AutoComplete.Spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
feature "Autocompletion", ->
story "User interacts with an input with 'mmddyyyy' predefined autocomplete settings", ->
beforeEach ->
input.mask "mm/dd/yyyy",
placeholder: " "
autocomplete: $.mask.autocomplete_predefined["mmddyyyy"]

it "Should reset the input to blank if the user inputs an invalid month", ->
input.mashKeys "13"
expect(input).toHaveValue " / / "

it "Should reset the input to blank if the user inputs a slash as the first month character", ->
input.mashKeys "/"
expect(input).toHaveValue " / / "

it "Should zero pad a single digit month if followed by a slash", ->
input.mashKeys "4/"
expect(input).toHaveValue "04/ / "

it "Should advance to the day fields if user enters a valid two digit month", ->
input.mashKeys "09"
expect(input).toHaveValue "09/ / "
expect(input.caret().begin).toEqual 3

it "Should reset to blank day of month if a slash is entered as the first charactor of day of month", ->
input.mashKeys "09/"
expect(input).toHaveValue "09/ / "

it "Should reset to blank day of month if any invalid day of month is entered", ->
input.mashKeys "0941"
expect(input).toHaveValue "09/ / "

it "Should reset to blank day of month if '00' is entered for the day of month", ->
input.mashKeys "0900"
expect(input).toHaveValue "09/ / "

it "Should zero pad the day of month if a single digit day of month is followed by a slash", ->
input.mashKeys "099/"
expect(input).toHaveValue "09/09/ "

it "Should consider a two digit year less than 30, but not 19 or 20, to be 21st century and prefix with '20'", ->
input.mashKeys "090918"
expect(input).toHaveValue "09/09/2018"

it "Should consider a two digit year greater than 29 to be 20th century and prefix with '19'", ->
input.mashKeys "090964"
expect(input).toHaveValue "09/09/1964"

it "Should not prefix the year if the first two digits entered are '20'", ->
input.mashKeys "090920"
expect(input).toHaveValue "09/09/20 "

it "Should not prefix the year if the first two digits entered are '19'", ->
input.mashKeys "090919"
expect(input).toHaveValue "09/09/19 "

story "User interacts with an input with 'mmyyyy' predefined autocomplete settings", ->
beforeEach ->
input.mask "mm/yyyy",
placeholder: " "
autocomplete: $.mask.autocomplete_predefined["mmyyyy"]

it "Should reset the input to blank if the user inputs an invalid month", ->
input.mashKeys "13"
expect(input).toHaveValue " / "

it "Should reset to blank day of month if '00' is entered for the month", ->
input.mashKeys "00"
expect(input).toHaveValue " / "


it "Should reset the input to blank if the user inputs a slash as the first character", ->
input.mashKeys "/"
expect(input).toHaveValue " / "

it "Should zero pad a single digit month if followed by a slash", ->
input.mashKeys "4/"
expect(input).toHaveValue "04/ "

it "Should advance to the year field if user enters a valid two digit month", ->
input.mashKeys "09"
expect(input).toHaveValue "09/ "

it "Should consider a two digit digit less than 30, but not 19 or 20, to be 21st century and prefix with '20'", ->
input.mashKeys "0918"
expect(input).toHaveValue "09/2018"

it "Should consider a two digit year greater than 29 to be 20th century and prefix with '19'", ->
input.mashKeys "0964"
expect(input).toHaveValue "09/1964"

it "Should not prefix the year if the first two digits entered are '20'", ->
input.mashKeys "0920"
expect(input).toHaveValue "09/20 "

it "Should not prefix the year if the first two digits entered are '19'", ->
input.mashKeys "0919"
expect(input).toHaveValue "09/19 "


105 changes: 105 additions & 0 deletions spec/AutoComplete.Spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
(function() {
feature("Autocompletion", function() {
story("User interacts with an input with 'mmddyyyy' predefined autocomplete settings", function() {
beforeEach(function() {
return input.mask("mm/dd/yyyy", {
placeholder: " ",
autocomplete: $.mask.autocomplete_predefined["mmddyyyy"]
});
});
it("Should reset the input to blank if the user inputs an invalid month", function() {
input.mashKeys("13");
return expect(input).toHaveValue(" / / ");
});
it("Should reset the input to blank if the user inputs a slash as the first month character", function() {
input.mashKeys("/");
return expect(input).toHaveValue(" / / ");
});
it("Should zero pad a single digit month if followed by a slash", function() {
input.mashKeys("4/");
return expect(input).toHaveValue("04/ / ");
});
it("Should advance to the day fields if user enters a valid two digit month", function() {
input.mashKeys("09");
expect(input).toHaveValue("09/ / ");
return expect(input.caret().begin).toEqual(3);
});
it("Should reset to blank day of month if a slash is entered as the first charactor of day of month", function() {
input.mashKeys("09/");
return expect(input).toHaveValue("09/ / ");
});
it("Should reset to blank day of month if any invalid day of month is entered", function() {
input.mashKeys("0941");
return expect(input).toHaveValue("09/ / ");
});
it("Should reset to blank day of month if '00' is entered for the day of month", function() {
input.mashKeys("0900");
return expect(input).toHaveValue("09/ / ");
});
it("Should zero pad the day of month if a single digit day of month is followed by a slash", function() {
input.mashKeys("099/");
return expect(input).toHaveValue("09/09/ ");
});
it("Should consider a two digit year less than 30, but not 19 or 20, to be 21st century and prefix with '20'", function() {
input.mashKeys("090918");
return expect(input).toHaveValue("09/09/2018");
});
it("Should consider a two digit year greater than 29 to be 20th century and prefix with '19'", function() {
input.mashKeys("090964");
return expect(input).toHaveValue("09/09/1964");
});
it("Should not prefix the year if the first two digits entered are '20'", function() {
input.mashKeys("090920");
return expect(input).toHaveValue("09/09/20 ");
});
return it("Should not prefix the year if the first two digits entered are '19'", function() {
input.mashKeys("090919");
return expect(input).toHaveValue("09/09/19 ");
});
});
return story("User interacts with an input with 'mmyyyy' predefined autocomplete settings", function() {
beforeEach(function() {
return input.mask("mm/yyyy", {
placeholder: " ",
autocomplete: $.mask.autocomplete_predefined["mmyyyy"]
});
});
it("Should reset the input to blank if the user inputs an invalid month", function() {
input.mashKeys("13");
return expect(input).toHaveValue(" / ");
});
it("Should reset to blank day of month if '00' is entered for the month", function() {
input.mashKeys("00");
return expect(input).toHaveValue(" / ");
});
it("Should reset the input to blank if the user inputs a slash as the first character", function() {
input.mashKeys("/");
return expect(input).toHaveValue(" / ");
});
it("Should zero pad a single digit month if followed by a slash", function() {
input.mashKeys("4/");
return expect(input).toHaveValue("04/ ");
});
it("Should advance to the year field if user enters a valid two digit month", function() {
input.mashKeys("09");
return expect(input).toHaveValue("09/ ");
});
it("Should consider a two digit digit less than 30, but not 19 or 20, to be 21st century and prefix with '20'", function() {
input.mashKeys("0918");
return expect(input).toHaveValue("09/2018");
});
it("Should consider a two digit year greater than 29 to be 20th century and prefix with '19'", function() {
input.mashKeys("0964");
return expect(input).toHaveValue("09/1964");
});
it("Should not prefix the year if the first two digits entered are '20'", function() {
input.mashKeys("0920");
return expect(input).toHaveValue("09/20 ");
});
return it("Should not prefix the year if the first two digits entered are '19'", function() {
input.mashKeys("0919");
return expect(input).toHaveValue("09/19 ");
});
});
});
}).call(this);
12 changes: 6 additions & 6 deletions spec/Delete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ feature("Delete Key", function() {
});

when("hitting the delete key",function(){
input.mashKeys(function(keys){keys.type(keys.delete)});
input.mashKeys(function(keys){keys.type(keys[ 'delete' ]);});
});

then("value should be correct",function(){
Expand All @@ -36,7 +36,7 @@ feature("Delete Key", function() {
});

when("hitting the delete key",function(){
input.mashKeys(function(keys){keys.type(keys.delete)});
input.mashKeys(function(keys){keys.type(keys[ 'delete' ]);});
});

then("value should be correct",function(){
Expand All @@ -62,7 +62,7 @@ feature("Delete Key", function() {
});

when("hitting the delete key",function(){
input.mashKeys(function(keys){keys.type(keys.delete)});
input.mashKeys(function(keys){keys.type(keys[ 'delete' ]);});
});

then("value should be correct",function(){
Expand All @@ -86,7 +86,7 @@ feature("Delete Key", function() {
});

when("hitting the delete key",function(){
input.mashKeys(function(keys){keys.type(keys.delete)});
input.mashKeys(function(keys){keys.type(keys[ 'delete' ]);});
});

then("value should be correct",function(){
Expand All @@ -111,7 +111,7 @@ feature("Delete Key", function() {
});

when("hitting the delete key",function(){
input.mashKeys(function(keys){keys.type(keys.delete)});
input.mashKeys(function(keys){keys.type(keys[ 'delete' ]);});
});

then("value should be correct",function(){
Expand All @@ -135,7 +135,7 @@ feature("Delete Key", function() {
});

when("hitting the delete key",function(){
input.mashKeys(function(keys){keys.type(keys.delete)});
input.mashKeys(function(keys){keys.type(keys[ 'delete' ]);});
});

then("value should be correct",function(){
Expand Down
53 changes: 53 additions & 0 deletions spec/ProgressiveReveal.Spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
feature "Progressive Reveal", ->

story "User interacts with an input with 'mmddyyyy' predefined autocomplete settings and 'progressive_reveal' set to true", ->

beforeEach ->
input.mask "mm/dd/yyyy",
placeholder: " "
autocomplete: $.mask.autocomplete_predefined["mmddyyyy"]
progressive_reveal: true

scenario "User hasn't entered anything yet", ->

given "An empty input", ->
null

whilst "User does nothing", ->
null

hence "Input is blank", ->
(expect input).toHaveValue ''

scenario "User enters two digit month", ->

given "An empty input", ->
null

whilst "User enters valid month", ->
input.mashKeys "11"

hence "Input advances to the day of month field", ->
(expect input).toHaveValue "11/"
(expect input.caret().begin).toEqual 3

scenario "User enters two digit month, then backspace", ->

given "An empty input", ->
null

whilst "User enters valid month", ->
input.mashKeys "11"

likewise "User hits backspace", ->
input.mashKeys (keys) ->
keys.type keys.backspace


hence "Input deletes slash and second digit of month", ->
(expect input).toHaveValue "1"

likewise "The cursor is positioned after the first digit of month", ->
(expect input.caret().begin).toEqual 1


Loading