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
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
4 changes: 2 additions & 2 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sys = require 'sys'
util = require 'util'
fs = require 'fs'
path = require 'path'
uglify = require 'uglify-js'
Expand Down Expand Up @@ -29,7 +29,7 @@ replaceTokens = (js,tokens)->

task 'compress', 'compress javascript', ->
invoke 'clean'
fs.mkdir(distPath,0755)
fs.mkdir(distPath,0o0755)
compressed = minify(fs.readFileSync('src/jquery.maskedinput.js','utf8'))
final=replaceTokens(compressed,plugin)
fs.writeFileSync(path.join(distPath,'jquery.maskedinput.min.js'), final)
Expand Down
26 changes: 26 additions & 0 deletions spec/Focus.Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,32 @@ feature("Leaving A Masked Input",function(){
});
});

feature("Leaving A Masked Input With retainPartial",function(){
scenario("All placeholders filled",function(){
given("a mask with two placeholders",function(){
input.mask("99", { retainPartial: true });
});
when("typing two characters and blurring",function(){
input.mashKeys("12").blur();
});
then("value should be correct",function(){
expect(input).toHaveValue("12");
});
});

scenario("Empty placeholders remaining",function(){
given("a mask with two placeholders",function(){
input.mask("99");
});
when("typing one character and blurring",function(){
input.mashKeys("1").blur();
});
then("value should be empty",function(){
expect(input).toHaveValue("");
});
});
});

feature("Optional marker",function(){
scenario("Placeholders not filled to marker",function(){
given("a mask with an optional marker",function(){
Expand Down
6 changes: 4 additions & 2 deletions src/jquery.maskedinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@
}
}
if (!allow && lastMatch + 1 < partialPosition) {
input.val("");
clearBuffer(0, len);
if (lastMatch == 0 || ! settings.retainPartial) {
input.val("");
clearBuffer(0, len);
}
} else if (allow || lastMatch + 1 >= partialPosition) {
writeBuffer();
if (!allow) input.val(input.val().substring(0, lastMatch + 1));
Expand Down