Add frontend assets and plugin bundles
Add the legacy frontend themes, scripts, and plugin assets required by the main SPOTA interfaces.
This commit is contained in:
2
assets/plugins/jquery.maskedinput/.gitignore
vendored
Normal file
2
assets/plugins/jquery.maskedinput/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
.idea/*
|
||||
31
assets/plugins/jquery.maskedinput/Jakefile
Normal file
31
assets/plugins/jquery.maskedinput/Jakefile
Normal file
@@ -0,0 +1,31 @@
|
||||
var Handlebars=require("handlebars"),
|
||||
fs = require("fs"),
|
||||
path = require ("path"),
|
||||
UglifyJS = require("uglify-js"),
|
||||
distPath='dist/';
|
||||
|
||||
Handlebars.registerHelper('include', function(context) {
|
||||
return fs.readFileSync(context,'utf8');
|
||||
});
|
||||
|
||||
function keepComment(node,comment){
|
||||
return comment.type === "comment2";
|
||||
}
|
||||
|
||||
task('clean',function(){
|
||||
fs.rmdir(distPath)
|
||||
});
|
||||
|
||||
task('default',['clean'], function (params) {
|
||||
fs.mkdir(distPath,0755);
|
||||
|
||||
var options = JSON.parse(fs.readFileSync('plugin.json','utf8'))
|
||||
options.Year=new Date().getFullYear()
|
||||
|
||||
var template = Handlebars.compile(fs.readFileSync('templates/jquery.maskedinput.template','utf8'));
|
||||
var debugFile = path.join(distPath,'jquery.maskedinput.js');
|
||||
fs.writeFileSync(debugFile,template(options));
|
||||
|
||||
compressed = UglifyJS.minify(debugFile,{output:{comments:keepComment}});
|
||||
fs.writeFileSync(path.join(distPath,'jquery.maskedinput.min.js'), compressed.code);
|
||||
});
|
||||
22
assets/plugins/jquery.maskedinput/LICENSE
Normal file
22
assets/plugins/jquery.maskedinput/LICENSE
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2007-2013 Josh Bush (digitalbush.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
15
assets/plugins/jquery.maskedinput/README.md
Normal file
15
assets/plugins/jquery.maskedinput/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
Masked Input Plugin for jQuery
|
||||
==============================
|
||||
|
||||
Overview
|
||||
--------
|
||||
This is a masked input plugin for the jQuery javascript library. It allows a user to more easily enter fixed width input where you would like them to enter the data in a certain format (dates,phone numbers, etc). It has been tested on Internet Explorer, Firefox, Safari, Opera, and Chrome. A mask is defined by a format made up of mask literals and mask definitions. Any character not in the definitions list below is considered a mask literal. Mask literals will be automatically entered for the user as they type and will not be able to be removed by the user.The following mask definitions are predefined:
|
||||
|
||||
* a - Represents an alpha character (A-Z,a-z)
|
||||
* 9 - Represents a numeric character (0-9)
|
||||
* \* - Represents an alphanumeric character (A-Z,a-z,0-9)
|
||||
|
||||
If your requirements aren't met by the predefined placeholders, you can always add your own. For example, maybe you need a mask to only allow hexadecimal characters. You can add your own definition for a placeholder, say 'h', like so: `$.mask.definitions['h'] = "[A-Fa-f0-9]";` Then you can use that to mask for something like css colors in hex with a mask "#hhhhhh".
|
||||
|
||||
By design, this plugin will reject input which doesn't complete the mask. You can bypass this by using a '?' character at the position where you would like to consider input optional. For example, a mask of "(999) 999-9999? x99999" would require only the first 10 digits of a phone number with extension being optional.
|
||||
|
||||
22
assets/plugins/jquery.maskedinput/demo/datepicker.html
Normal file
22
assets/plugins/jquery.maskedinput/demo/datepicker.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<title> datepicker demo </title>
|
||||
<script src="../lib/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../src/jquery.maskedinput.js" type="text/javascript"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" />
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$("#date")
|
||||
.datepicker({ nextText: "", prevText: "", changeMonth: true, changeYear: true })
|
||||
.mask("99/99/9999");
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr><td>Date</td><td><input id="date" value="1231" type="text" tabindex="1" /></td><td>99/99/9999</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
44
assets/plugins/jquery.maskedinput/demo/index.html
Normal file
44
assets/plugins/jquery.maskedinput/demo/index.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<html>
|
||||
<head>
|
||||
<title> jQuery Mask Test </title>
|
||||
<script src="../lib/jquery-1.9.0.min.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="../dist/jquery.maskedinput.min.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");
|
||||
$("#phoneExt").mask("(999) 999-9999? x99999");
|
||||
$("#iphone").mask("+33 999 999 999");
|
||||
$("#tin").mask("99-9999999");
|
||||
$("#ssn").mask("999-99-9999");
|
||||
$("#product").mask("a*-999-a999", { placeholder: " " });
|
||||
$("#eyescript").mask("~9.99 ~9.99 999");
|
||||
$("#po").mask("PO: aaa-999-***");
|
||||
$("#pct").mask("99%");
|
||||
|
||||
$("input").blur(function() {
|
||||
$("#info").html("Unmasked value: " + $(this).mask());
|
||||
}).dblclick(function() {
|
||||
$(this).unmask();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr><td>Date</td><td><input id="date" value="1231" type="text" tabindex="1" /></td><td>99/99/9999</td></tr>
|
||||
<tr><td>Phone</td><td><input id="phone" type="text" tabindex="2"/></td><td>(999) 999-9999</td></tr>
|
||||
<tr><td>Phone + Ext</td><td><input id="phoneExt" type="text" tabindex="2"/></td><td>(999) 999-9999? x99999</td></tr>
|
||||
<tr><td>Int'l Phone</td><td><input id="iphone" type="text" tabindex="2"/></td><td>+33 999 999 999</td></tr>
|
||||
<tr><td>Tax ID</td><td><input id="tin" type="text" tabindex="3"/></td><td>99-9999999</td></tr>
|
||||
<tr><td>SSN</td><td><input id="ssn" type="text" tabindex="4"/></td><td>999-99-9999</td></tr>
|
||||
<tr><td>Product Key</td><td><input id="product" type="text" tabindex="5"/></td><td>a*-999-a999</td></tr>
|
||||
<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>
|
||||
</table>
|
||||
<div id="info"></div>
|
||||
</body>
|
||||
</html>
|
||||
338
assets/plugins/jquery.maskedinput/dist/jquery.maskedinput.js
vendored
Normal file
338
assets/plugins/jquery.maskedinput/dist/jquery.maskedinput.js
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
/*
|
||||
Masked Input plugin for jQuery
|
||||
Copyright (c) 2007-2013 Josh Bush (digitalbush.com)
|
||||
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
|
||||
Version: 1.3.1
|
||||
*/
|
||||
(function($) {
|
||||
function getPasteEvent() {
|
||||
var el = document.createElement('input'),
|
||||
name = 'onpaste';
|
||||
el.setAttribute(name, '');
|
||||
return (typeof el[name] === 'function')?'paste':'input';
|
||||
}
|
||||
|
||||
var pasteEventName = getPasteEvent() + ".mask",
|
||||
ua = navigator.userAgent,
|
||||
iPhone = /iphone/i.test(ua),
|
||||
android=/android/i.test(ua),
|
||||
caretTimeoutId;
|
||||
|
||||
$.mask = {
|
||||
//Predefined character definitions
|
||||
definitions: {
|
||||
'9': "[0-9]",
|
||||
'a': "[A-Za-z]",
|
||||
'*': "[A-Za-z0-9]"
|
||||
},
|
||||
dataName: "rawMaskFn",
|
||||
placeholder: '_'
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
//Helper Function for Caret positioning
|
||||
caret: function(begin, end) {
|
||||
var range;
|
||||
|
||||
if (this.length === 0 || this.is(":hidden")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof begin == 'number') {
|
||||
end = (typeof end === 'number') ? end : begin;
|
||||
return this.each(function() {
|
||||
if (this.setSelectionRange) {
|
||||
this.setSelectionRange(begin, end);
|
||||
} else if (this.createTextRange) {
|
||||
range = this.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', end);
|
||||
range.moveStart('character', begin);
|
||||
range.select();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (this[0].setSelectionRange) {
|
||||
begin = this[0].selectionStart;
|
||||
end = this[0].selectionEnd;
|
||||
} else if (document.selection && document.selection.createRange) {
|
||||
range = document.selection.createRange();
|
||||
begin = 0 - range.duplicate().moveStart('character', -100000);
|
||||
end = begin + range.text.length;
|
||||
}
|
||||
return { begin: begin, end: end };
|
||||
}
|
||||
},
|
||||
unmask: function() {
|
||||
return this.trigger("unmask");
|
||||
},
|
||||
mask: function(mask, settings) {
|
||||
var input,
|
||||
defs,
|
||||
tests,
|
||||
partialPosition,
|
||||
firstNonMaskPos,
|
||||
len;
|
||||
|
||||
if (!mask && this.length > 0) {
|
||||
input = $(this[0]);
|
||||
return input.data($.mask.dataName)();
|
||||
}
|
||||
settings = $.extend({
|
||||
placeholder: $.mask.placeholder, // Load default placeholder
|
||||
completed: null
|
||||
}, settings);
|
||||
|
||||
|
||||
defs = $.mask.definitions;
|
||||
tests = [];
|
||||
partialPosition = len = mask.length;
|
||||
firstNonMaskPos = null;
|
||||
|
||||
$.each(mask.split(""), function(i, c) {
|
||||
if (c == '?') {
|
||||
len--;
|
||||
partialPosition = i;
|
||||
} else if (defs[c]) {
|
||||
tests.push(new RegExp(defs[c]));
|
||||
if (firstNonMaskPos === null) {
|
||||
firstNonMaskPos = tests.length - 1;
|
||||
}
|
||||
} else {
|
||||
tests.push(null);
|
||||
}
|
||||
});
|
||||
|
||||
return this.trigger("unmask").each(function() {
|
||||
var input = $(this),
|
||||
buffer = $.map(
|
||||
mask.split(""),
|
||||
function(c, i) {
|
||||
if (c != '?') {
|
||||
return defs[c] ? settings.placeholder : c;
|
||||
}
|
||||
}),
|
||||
focusText = input.val();
|
||||
|
||||
function seekNext(pos) {
|
||||
while (++pos < len && !tests[pos]);
|
||||
return pos;
|
||||
}
|
||||
|
||||
function seekPrev(pos) {
|
||||
while (--pos >= 0 && !tests[pos]);
|
||||
return pos;
|
||||
}
|
||||
|
||||
function shiftL(begin,end) {
|
||||
var i,
|
||||
j;
|
||||
|
||||
if (begin<0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = begin, j = seekNext(end); i < len; i++) {
|
||||
if (tests[i]) {
|
||||
if (j < len && tests[i].test(buffer[j])) {
|
||||
buffer[i] = buffer[j];
|
||||
buffer[j] = settings.placeholder;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
j = seekNext(j);
|
||||
}
|
||||
}
|
||||
writeBuffer();
|
||||
input.caret(Math.max(firstNonMaskPos, begin));
|
||||
}
|
||||
|
||||
function shiftR(pos) {
|
||||
var i,
|
||||
c,
|
||||
j,
|
||||
t;
|
||||
|
||||
for (i = pos, c = settings.placeholder; i < len; i++) {
|
||||
if (tests[i]) {
|
||||
j = seekNext(i);
|
||||
t = buffer[i];
|
||||
buffer[i] = c;
|
||||
if (j < len && tests[j].test(t)) {
|
||||
c = t;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function keydownEvent(e) {
|
||||
var k = e.which,
|
||||
pos,
|
||||
begin,
|
||||
end;
|
||||
|
||||
//backspace, delete, and escape get special treatment
|
||||
if (k === 8 || k === 46 || (iPhone && k === 127)) {
|
||||
pos = input.caret();
|
||||
begin = pos.begin;
|
||||
end = pos.end;
|
||||
|
||||
if (end - begin === 0) {
|
||||
begin=k!==46?seekPrev(begin):(end=seekNext(begin-1));
|
||||
end=k===46?seekNext(end):end;
|
||||
}
|
||||
clearBuffer(begin, end);
|
||||
shiftL(begin, end - 1);
|
||||
|
||||
e.preventDefault();
|
||||
} else if (k == 27) {//escape
|
||||
input.val(focusText);
|
||||
input.caret(0, checkVal());
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function keypressEvent(e) {
|
||||
var k = e.which,
|
||||
pos = input.caret(),
|
||||
p,
|
||||
c,
|
||||
next;
|
||||
|
||||
if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
|
||||
return;
|
||||
} else if (k) {
|
||||
if (pos.end - pos.begin !== 0){
|
||||
clearBuffer(pos.begin, pos.end);
|
||||
shiftL(pos.begin, pos.end-1);
|
||||
}
|
||||
|
||||
p = seekNext(pos.begin - 1);
|
||||
if (p < len) {
|
||||
c = String.fromCharCode(k);
|
||||
if (tests[p].test(c)) {
|
||||
shiftR(p);
|
||||
|
||||
buffer[p] = c;
|
||||
writeBuffer();
|
||||
next = seekNext(p);
|
||||
|
||||
if(android){
|
||||
setTimeout($.proxy($.fn.caret,input,next),0);
|
||||
}else{
|
||||
input.caret(next);
|
||||
}
|
||||
|
||||
if (settings.completed && next >= len) {
|
||||
settings.completed.call(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function clearBuffer(start, end) {
|
||||
var i;
|
||||
for (i = start; i < end && i < len; i++) {
|
||||
if (tests[i]) {
|
||||
buffer[i] = settings.placeholder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function writeBuffer() { input.val(buffer.join('')); }
|
||||
|
||||
function checkVal(allow) {
|
||||
//try to place characters where they belong
|
||||
var test = input.val(),
|
||||
lastMatch = -1,
|
||||
i,
|
||||
c;
|
||||
|
||||
for (i = 0, pos = 0; i < len; i++) {
|
||||
if (tests[i]) {
|
||||
buffer[i] = settings.placeholder;
|
||||
while (pos++ < test.length) {
|
||||
c = test.charAt(pos - 1);
|
||||
if (tests[i].test(c)) {
|
||||
buffer[i] = c;
|
||||
lastMatch = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pos > test.length) {
|
||||
break;
|
||||
}
|
||||
} else if (buffer[i] === test.charAt(pos) && i !== partialPosition) {
|
||||
pos++;
|
||||
lastMatch = i;
|
||||
}
|
||||
}
|
||||
if (allow) {
|
||||
writeBuffer();
|
||||
} else if (lastMatch + 1 < partialPosition) {
|
||||
input.val("");
|
||||
clearBuffer(0, len);
|
||||
} else {
|
||||
writeBuffer();
|
||||
input.val(input.val().substring(0, lastMatch + 1));
|
||||
}
|
||||
return (partialPosition ? i : firstNonMaskPos);
|
||||
}
|
||||
|
||||
input.data($.mask.dataName,function(){
|
||||
return $.map(buffer, function(c, i) {
|
||||
return tests[i]&&c!=settings.placeholder ? c : null;
|
||||
}).join('');
|
||||
});
|
||||
|
||||
if (!input.attr("readonly"))
|
||||
input
|
||||
.one("unmask", function() {
|
||||
input
|
||||
.unbind(".mask")
|
||||
.removeData($.mask.dataName);
|
||||
})
|
||||
.bind("focus.mask", function() {
|
||||
clearTimeout(caretTimeoutId);
|
||||
var pos,
|
||||
moveCaret;
|
||||
|
||||
focusText = input.val();
|
||||
pos = checkVal();
|
||||
|
||||
caretTimeoutId = setTimeout(function(){
|
||||
writeBuffer();
|
||||
if (pos == mask.length) {
|
||||
input.caret(0, pos);
|
||||
} else {
|
||||
input.caret(pos);
|
||||
}
|
||||
}, 10);
|
||||
})
|
||||
.bind("blur.mask", function() {
|
||||
checkVal();
|
||||
if (input.val() != focusText)
|
||||
input.change();
|
||||
})
|
||||
.bind("keydown.mask", keydownEvent)
|
||||
.bind("keypress.mask", keypressEvent)
|
||||
.bind(pasteEventName, function() {
|
||||
setTimeout(function() {
|
||||
var pos=checkVal(true);
|
||||
input.caret(pos);
|
||||
if (settings.completed && pos == input.val().length)
|
||||
settings.completed.call(input);
|
||||
}, 0);
|
||||
});
|
||||
checkVal(); //Perform initial check for existing values
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})(jQuery);
|
||||
7
assets/plugins/jquery.maskedinput/dist/jquery.maskedinput.min.js
vendored
Normal file
7
assets/plugins/jquery.maskedinput/dist/jquery.maskedinput.min.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
Masked Input plugin for jQuery
|
||||
Copyright (c) 2007-2013 Josh Bush (digitalbush.com)
|
||||
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
|
||||
Version: 1.3.1
|
||||
*/
|
||||
(function(e){function t(){var e=document.createElement("input"),t="onpaste";return e.setAttribute(t,""),"function"==typeof e[t]?"paste":"input"}var n,a=t()+".mask",r=navigator.userAgent,i=/iphone/i.test(r),o=/android/i.test(r);e.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},dataName:"rawMaskFn",placeholder:"_"},e.fn.extend({caret:function(e,t){var n;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof e?(t="number"==typeof t?t:e,this.each(function(){this.setSelectionRange?this.setSelectionRange(e,t):this.createTextRange&&(n=this.createTextRange(),n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",e),n.select())})):(this[0].setSelectionRange?(e=this[0].selectionStart,t=this[0].selectionEnd):document.selection&&document.selection.createRange&&(n=document.selection.createRange(),e=0-n.duplicate().moveStart("character",-1e5),t=e+n.text.length),{begin:e,end:t})},unmask:function(){return this.trigger("unmask")},mask:function(t,r){var c,l,s,u,f,h;return!t&&this.length>0?(c=e(this[0]),c.data(e.mask.dataName)()):(r=e.extend({placeholder:e.mask.placeholder,completed:null},r),l=e.mask.definitions,s=[],u=h=t.length,f=null,e.each(t.split(""),function(e,t){"?"==t?(h--,u=e):l[t]?(s.push(RegExp(l[t])),null===f&&(f=s.length-1)):s.push(null)}),this.trigger("unmask").each(function(){function c(e){for(;h>++e&&!s[e];);return e}function d(e){for(;--e>=0&&!s[e];);return e}function m(e,t){var n,a;if(!(0>e)){for(n=e,a=c(t);h>n;n++)if(s[n]){if(!(h>a&&s[n].test(R[a])))break;R[n]=R[a],R[a]=r.placeholder,a=c(a)}b(),x.caret(Math.max(f,e))}}function p(e){var t,n,a,i;for(t=e,n=r.placeholder;h>t;t++)if(s[t]){if(a=c(t),i=R[t],R[t]=n,!(h>a&&s[a].test(i)))break;n=i}}function g(e){var t,n,a,r=e.which;8===r||46===r||i&&127===r?(t=x.caret(),n=t.begin,a=t.end,0===a-n&&(n=46!==r?d(n):a=c(n-1),a=46===r?c(a):a),k(n,a),m(n,a-1),e.preventDefault()):27==r&&(x.val(S),x.caret(0,y()),e.preventDefault())}function v(t){var n,a,i,l=t.which,u=x.caret();t.ctrlKey||t.altKey||t.metaKey||32>l||l&&(0!==u.end-u.begin&&(k(u.begin,u.end),m(u.begin,u.end-1)),n=c(u.begin-1),h>n&&(a=String.fromCharCode(l),s[n].test(a)&&(p(n),R[n]=a,b(),i=c(n),o?setTimeout(e.proxy(e.fn.caret,x,i),0):x.caret(i),r.completed&&i>=h&&r.completed.call(x))),t.preventDefault())}function k(e,t){var n;for(n=e;t>n&&h>n;n++)s[n]&&(R[n]=r.placeholder)}function b(){x.val(R.join(""))}function y(e){var t,n,a=x.val(),i=-1;for(t=0,pos=0;h>t;t++)if(s[t]){for(R[t]=r.placeholder;pos++<a.length;)if(n=a.charAt(pos-1),s[t].test(n)){R[t]=n,i=t;break}if(pos>a.length)break}else R[t]===a.charAt(pos)&&t!==u&&(pos++,i=t);return e?b():u>i+1?(x.val(""),k(0,h)):(b(),x.val(x.val().substring(0,i+1))),u?t:f}var x=e(this),R=e.map(t.split(""),function(e){return"?"!=e?l[e]?r.placeholder:e:void 0}),S=x.val();x.data(e.mask.dataName,function(){return e.map(R,function(e,t){return s[t]&&e!=r.placeholder?e:null}).join("")}),x.attr("readonly")||x.one("unmask",function(){x.unbind(".mask").removeData(e.mask.dataName)}).bind("focus.mask",function(){clearTimeout(n);var e;S=x.val(),e=y(),n=setTimeout(function(){b(),e==t.length?x.caret(0,e):x.caret(e)},10)}).bind("blur.mask",function(){y(),x.val()!=S&&x.change()}).bind("keydown.mask",g).bind("keypress.mask",v).bind(a,function(){setTimeout(function(){var e=y(!0);x.caret(e),r.completed&&e==x.val().length&&r.completed.call(x)},0)}),y()}))}})})(jQuery);
|
||||
2
assets/plugins/jquery.maskedinput/lib/jquery-1.8.3.min.js
vendored
Normal file
2
assets/plugins/jquery.maskedinput/lib/jquery-1.8.3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
assets/plugins/jquery.maskedinput/lib/jquery-1.9.0.min.js
vendored
Normal file
4
assets/plugins/jquery.maskedinput/lib/jquery-1.9.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
23
assets/plugins/jquery.maskedinput/maskedinput.jquery.json
Normal file
23
assets/plugins/jquery.maskedinput/maskedinput.jquery.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "maskedinput",
|
||||
"title": "jQuery Masked Input",
|
||||
"description": "jQuery plugin for forcing fixed width inputs to follow a certain patern.",
|
||||
"keywords": ["input", "form", "mask"],
|
||||
"version": "1.3.1",
|
||||
"author": {
|
||||
"name": "Josh Bush",
|
||||
"url": "http://digitalbush.com"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://raw.github.com/digitalBush/jquery.maskedinput/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"bugs": "https://github.com/digitalBush/jquery.maskedinput/issues",
|
||||
"homepage": "http://digitalbush.com/projects/masked-input-plugin/",
|
||||
"docs": "http://digitalbush.com/projects/masked-input-plugin/#usage",
|
||||
"dependencies": {
|
||||
"jquery": ">=1.5"
|
||||
}
|
||||
}
|
||||
5
assets/plugins/jquery.maskedinput/plugin.json
Normal file
5
assets/plugins/jquery.maskedinput/plugin.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name" : "jquery.maskedinput",
|
||||
"author" : "Josh Bush (digitalbush.com)",
|
||||
"version" : "1.3.1"
|
||||
}
|
||||
151
assets/plugins/jquery.maskedinput/spec/Backspace.Spec.js
Normal file
151
assets/plugins/jquery.maskedinput/spec/Backspace.Spec.js
Normal file
@@ -0,0 +1,151 @@
|
||||
feature("Backspace Key", function() {
|
||||
story('User presses backspace with cursor to the right of a mask literal',function(){
|
||||
scenario('character at cursor matches definition to the left',function(){
|
||||
given("an input with a mask definition of '9-99'", function(){
|
||||
input
|
||||
.mask("9-99")
|
||||
.mashKeys("123");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned to the right of literal", function(){
|
||||
input.caret(2);
|
||||
});
|
||||
|
||||
when("hitting the backspace key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.backspace)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('2-3_');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
scenario('character at cursor does not match definition to the left',function(){
|
||||
given("an input with a mask definition of 'a-99'", function(){
|
||||
input
|
||||
.mask("a-99")
|
||||
.mashKeys("z12");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned to the right of literal", function(){
|
||||
input.caret(2);
|
||||
});
|
||||
|
||||
when("hitting the backspace key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.backspace)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('_-12');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
story('User presses backspace with cursor on last character',function(){
|
||||
scenario('cursor character matches definition to the left',function(){
|
||||
given("an input with a mask definition of '99'", function(){
|
||||
input
|
||||
.mask("99")
|
||||
.mashKeys("12");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on first character", function(){
|
||||
input.caret(1);
|
||||
});
|
||||
|
||||
when("hitting the backspace key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.backspace)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('2_');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
scenario('cursor character does not match definition to the left',function(){
|
||||
given("an input with a mask definition of '9a'", function(){
|
||||
input
|
||||
.mask("9a")
|
||||
.mashKeys("1z");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on first character", function(){
|
||||
input.caret(1);
|
||||
});
|
||||
|
||||
when("hitting the backspace key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.backspace)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('_z');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('There is a mask literal between the two placeholders',function(){
|
||||
scenario('character at end matches definition of first position',function(){
|
||||
given("an input with a mask definition of '9-9'", function(){
|
||||
input
|
||||
.mask("9-9")
|
||||
.mashKeys("12");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on literal", function(){
|
||||
input.caret(1);
|
||||
});
|
||||
|
||||
when("hitting the backspace key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.backspace)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('2-_');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
scenario('character at end does not match definition of first position',function(){
|
||||
given("an input with a mask definition of '9-9'", function(){
|
||||
input
|
||||
.mask("9-a")
|
||||
.mashKeys("1z");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on literal", function(){
|
||||
input.caret(1);
|
||||
});
|
||||
|
||||
when("hitting the backspace key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.backspace)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('_-z');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
151
assets/plugins/jquery.maskedinput/spec/Delete.spec.js
Normal file
151
assets/plugins/jquery.maskedinput/spec/Delete.spec.js
Normal file
@@ -0,0 +1,151 @@
|
||||
feature("Delete Key", function() {
|
||||
story('User presses delete with cursor on a mask literal',function(){
|
||||
scenario('character at end matches definition to the right',function(){
|
||||
given("an input with a mask definition of '9-99'", function(){
|
||||
input
|
||||
.mask("9-99")
|
||||
.mashKeys("123");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on literal", function(){
|
||||
input.caret(1);
|
||||
});
|
||||
|
||||
when("hitting the delete key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.delete)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('1-3_');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
scenario('character at end does not match definition to the right',function(){
|
||||
given("an input with a mask definition of '9-9a'", function(){
|
||||
input
|
||||
.mask("9-9a")
|
||||
.mashKeys("12z");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on literal", function(){
|
||||
input.caret(1);
|
||||
});
|
||||
|
||||
when("hitting the delete key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.delete)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('1-_z');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
story('User presses delete with cursor on first character',function(){
|
||||
scenario('character to right matches definition of current position',function(){
|
||||
given("an input with a mask definition of '99'", function(){
|
||||
input
|
||||
.mask("99")
|
||||
.mashKeys("12");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on first character", function(){
|
||||
input.caret(0);
|
||||
});
|
||||
|
||||
when("hitting the delete key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.delete)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('2_');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
scenario('character to right does not match definition of current position',function(){
|
||||
given("an input with a mask definition of '9a'", function(){
|
||||
input
|
||||
.mask("9a")
|
||||
.mashKeys("1z");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on first character", function(){
|
||||
input.caret(0);
|
||||
});
|
||||
|
||||
when("hitting the delete key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.delete)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('_z');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('There is a mask literal between the two placeholders',function(){
|
||||
scenario('character to right matches definition of current position',function(){
|
||||
given("an input with a mask definition of '9-9'", function(){
|
||||
input
|
||||
.mask("9-9")
|
||||
.mashKeys("12");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on first character", function(){
|
||||
input.caret(0);
|
||||
});
|
||||
|
||||
when("hitting the delete key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.delete)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('2-_');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
scenario('character to right does not match definition of current position',function(){
|
||||
given("an input with a mask definition of '9-9'", function(){
|
||||
input
|
||||
.mask("9-a")
|
||||
.mashKeys("1z");
|
||||
});
|
||||
|
||||
given("the input has cursor positioned on first character", function(){
|
||||
input.caret(0);
|
||||
});
|
||||
|
||||
when("hitting the delete key",function(){
|
||||
input.mashKeys(function(keys){keys.type(keys.delete)});
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('_-z');
|
||||
});
|
||||
|
||||
and("caret position should be correct",function(){
|
||||
expect(input.caret().begin).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
23
assets/plugins/jquery.maskedinput/spec/Escape.Spec.js
Normal file
23
assets/plugins/jquery.maskedinput/spec/Escape.Spec.js
Normal file
@@ -0,0 +1,23 @@
|
||||
feature("Escape Key", function() {
|
||||
story('User presses escape key after typing in some changes',function(){
|
||||
scenario('mask is applied with an existing value',function(){
|
||||
given("an input an existing value '6'", function(){
|
||||
input
|
||||
.val('6');
|
||||
});
|
||||
|
||||
given("a mask definition of '9'", function(){
|
||||
input
|
||||
.mask('9').focus();
|
||||
});
|
||||
waits(1);
|
||||
when("user types something different then hits escape key",function(){
|
||||
input.mashKeys(function(keys){keys.type('1',keys.esc)});
|
||||
});
|
||||
|
||||
then("value is return to previous value",function(){
|
||||
expect(input).toHaveValue('6');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
105
assets/plugins/jquery.maskedinput/spec/Focus.Spec.js
Normal file
105
assets/plugins/jquery.maskedinput/spec/Focus.Spec.js
Normal file
@@ -0,0 +1,105 @@
|
||||
feature("Focusing A Masked Input",function(){
|
||||
scenario("Mask starts with a placeholder",function(){
|
||||
given("a mask beginning with a placeholder",function(){
|
||||
input.mask("9");
|
||||
});
|
||||
when("focusing",function(){
|
||||
input.focus();
|
||||
});
|
||||
waits(20);
|
||||
then("placeholder text should be correct",function(){
|
||||
expect(input).toHaveValue('_');
|
||||
});
|
||||
and("caret position should be correct",function(){
|
||||
var caret=input.caret();
|
||||
expect(caret.begin).toEqual(0);
|
||||
expect(caret.end).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
scenario("Mask starts with a literal",function(){
|
||||
given("a mask beginning with a literal",function(){
|
||||
input.mask("(9)");
|
||||
});
|
||||
when("focusing",function(){
|
||||
input.focus();
|
||||
});
|
||||
waits(20);
|
||||
then("placeholder text should be correct",function(){
|
||||
expect(input).toHaveValue('(_)');
|
||||
});
|
||||
and("caret position should be correct",function(){
|
||||
var caret=input.caret();
|
||||
expect(caret.begin).toEqual(1);
|
||||
expect(caret.end).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
scenario("Masking a hidden input",function(){
|
||||
var error;
|
||||
$(window).on("error.test",function(err){error=err;})
|
||||
|
||||
given("a mask on a hidden input",function(){
|
||||
input.hide().mask("9");
|
||||
});
|
||||
when("focusing input",function(){
|
||||
input.focus();
|
||||
});
|
||||
waits(1);
|
||||
then("should not throw an error",function(){
|
||||
expect(error).toBeUndefined();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
feature("Leaving A Masked Input",function(){
|
||||
scenario("All placeholders filled",function(){
|
||||
given("a mask with two placeholders",function(){
|
||||
input.mask("99");
|
||||
});
|
||||
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(){
|
||||
input.mask("99?99");
|
||||
});
|
||||
when("typing one character and leaving",function(){
|
||||
input.mashKeys("1").blur();
|
||||
});
|
||||
then("value should be empty",function(){
|
||||
expect(input).toHaveValue("");
|
||||
});
|
||||
});
|
||||
|
||||
scenario("Placeholders filled to marker",function(){
|
||||
given("a mask with an optional marker",function(){
|
||||
input.mask("99?99");
|
||||
});
|
||||
when("typing two characters and leaving",function(){
|
||||
input.mashKeys("12").blur();
|
||||
});
|
||||
then("value should remain",function(){
|
||||
expect(input).toHaveValue("12");
|
||||
});
|
||||
});
|
||||
});
|
||||
16
assets/plugins/jquery.maskedinput/spec/Paste.Spec.js
Normal file
16
assets/plugins/jquery.maskedinput/spec/Paste.Spec.js
Normal file
@@ -0,0 +1,16 @@
|
||||
feature("Pasting", function() {
|
||||
scenario('When pasting a value',function(){
|
||||
var completed=false;
|
||||
given("an input with a completed callback", function(){
|
||||
input.mask("99",{completed:function(){completed=true;}});
|
||||
});
|
||||
|
||||
when("pasting",function(){
|
||||
input.val("99").trigger("paste").trigger("input");
|
||||
});
|
||||
waits(1);
|
||||
then("completed callback should be called",function(){
|
||||
expect(completed).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
57
assets/plugins/jquery.maskedinput/spec/Raw.Spec.js
Normal file
57
assets/plugins/jquery.maskedinput/spec/Raw.Spec.js
Normal file
@@ -0,0 +1,57 @@
|
||||
feature("Getting raw value",function(){
|
||||
scenario("After typing",function(){
|
||||
given("an input with a mask containing a literal", function(){
|
||||
input
|
||||
.mask("9/9");
|
||||
});
|
||||
|
||||
when("typing all numbers",function(){
|
||||
input.mashKeys("12");
|
||||
});
|
||||
|
||||
then("raw value should be correct",function(){
|
||||
expect(input.mask()).toEqual("12");
|
||||
});
|
||||
});
|
||||
|
||||
scenario("While typing",function(){
|
||||
given("an input with a mask containing a literal", function(){
|
||||
input
|
||||
.mask("9/9");
|
||||
});
|
||||
|
||||
when("typing a number",function(){
|
||||
input.mashKeys("1");
|
||||
});
|
||||
|
||||
then("raw value should be correct",function(){
|
||||
expect(input.mask()).toEqual("1");
|
||||
});
|
||||
});
|
||||
|
||||
scenario("Before typing",function(){
|
||||
given("an input with a mask containing a literal", function(){
|
||||
input
|
||||
.mask("9/9");
|
||||
});
|
||||
|
||||
then("raw value should be correct",function(){
|
||||
expect(input.mask()).toEqual("");
|
||||
});
|
||||
});
|
||||
|
||||
scenario("After typing partial input past an optional marker",function(){
|
||||
given("an input with a mask containing a literal", function(){
|
||||
input
|
||||
.mask("9?99");
|
||||
});
|
||||
|
||||
when("typing a partial input",function(){
|
||||
input.mashKeys("12");
|
||||
});
|
||||
|
||||
then("raw value should be correct",function(){
|
||||
expect(input.mask()).toEqual("12");
|
||||
});
|
||||
});
|
||||
});
|
||||
18
assets/plugins/jquery.maskedinput/spec/Setup.Spec.js
Normal file
18
assets/plugins/jquery.maskedinput/spec/Setup.Spec.js
Normal file
@@ -0,0 +1,18 @@
|
||||
feature("Masking an Input", function() {
|
||||
scenario('Applying a mask to an already masked input',function(){
|
||||
given("an input with two masks", function(){
|
||||
input
|
||||
.mask("9")
|
||||
.mask("99");
|
||||
});
|
||||
|
||||
when("typing a number",function(){
|
||||
input.mashKeys("1");
|
||||
});
|
||||
|
||||
then("value should be correct",function(){
|
||||
expect(input).toHaveValue('1_');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
68
assets/plugins/jquery.maskedinput/spec/SpecRunner.html
Normal file
68
assets/plugins/jquery.maskedinput/spec/SpecRunner.html
Normal file
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Masked Input Plugin Tests</title>
|
||||
|
||||
<!--Jasmine-->
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine/jasmine.css">
|
||||
<script type="text/javascript" src="lib/jasmine/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine/jasmine-html.js"></script>
|
||||
|
||||
<!--Jasmine Species-->
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-species/calm.css">
|
||||
<script type="text/javascript" src="lib/jasmine-species/jasmine-grammar.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-species/jasmine-reporting.js"></script>
|
||||
|
||||
<!--My Stuff-->
|
||||
<script type="text/javascript" src="lib/matchers.js"></script>
|
||||
<script type="text/javascript">
|
||||
function importGrammar(g){
|
||||
for (var prop in g) {
|
||||
if (g.hasOwnProperty(prop))
|
||||
window[prop] = g[prop];
|
||||
|
||||
}
|
||||
}
|
||||
importGrammar(jasmine.grammar.FeatureStory);
|
||||
importGrammar(jasmine.grammar.GWT);
|
||||
|
||||
var input;
|
||||
beforeEach(function(){ input = $("<input />").appendTo("body").focus(); });
|
||||
afterEach(function(){ input.remove();});
|
||||
|
||||
</script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="../lib/jquery-1.9.0.min.js"></script>
|
||||
<script type="text/javascript" src="lib/jquery.keymasher.js"></script>
|
||||
<script type="text/javascript" src="../dist/jquery.maskedinput.min.js"></script>
|
||||
|
||||
<!-- Specs -->
|
||||
<script type="text/javascript" src="Setup.Spec.js"></script>
|
||||
<script type="text/javascript" src="Raw.Spec.js"></script>
|
||||
<script type="text/javascript" src="Focus.Spec.js"></script>
|
||||
<script type="text/javascript" src="Typing.Spec.js"></script>
|
||||
<script type="text/javascript" src="Backspace.Spec.js"></script>
|
||||
<script type="text/javascript" src="Delete.Spec.js"></script>
|
||||
<script type="text/javascript" src="Escape.Spec.js"></script>
|
||||
<script type="text/javascript" src="Paste.Spec.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
var styledReporter = new jasmine.reporting.StyledHtmlReporter();
|
||||
|
||||
jasmineEnv.addReporter(styledReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return styledReporter.specFilter(spec);
|
||||
};
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
58
assets/plugins/jquery.maskedinput/spec/Typing.Spec.js
Normal file
58
assets/plugins/jquery.maskedinput/spec/Typing.Spec.js
Normal file
@@ -0,0 +1,58 @@
|
||||
describe("Typing Specifications", function() {
|
||||
|
||||
describe("with caret position to the left of a character",function(){
|
||||
describe("when character to right matches the next mask definition",function(){
|
||||
beforeEach(function(){
|
||||
runs(function(){
|
||||
input
|
||||
.mask("99")
|
||||
.focus()
|
||||
});
|
||||
waits(1);
|
||||
runs(function(){
|
||||
input
|
||||
.mashKeys("1")
|
||||
.caret(0)
|
||||
.mashKeys("2");
|
||||
});
|
||||
})
|
||||
|
||||
it("should shift character to the right",function(){
|
||||
expect(input).toHaveValue("21");
|
||||
});
|
||||
|
||||
it("should have correct caret position",function(){
|
||||
var caret=input.caret();
|
||||
expect(caret.begin).toEqual(1);
|
||||
expect(caret.end).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when character to right does not match the next mask definition",function(){
|
||||
beforeEach(function(){
|
||||
runs(function(){
|
||||
input
|
||||
.mask("9a")
|
||||
.focus()
|
||||
});
|
||||
waits(1);
|
||||
runs(function(){
|
||||
input
|
||||
.mashKeys("1")
|
||||
.caret(0)
|
||||
.mashKeys("2");
|
||||
});
|
||||
})
|
||||
|
||||
it("should overwrite character",function(){
|
||||
expect(input).toHaveValue("2_");
|
||||
});
|
||||
|
||||
it("should have correct caret position",function(){
|
||||
var caret=input.caret();
|
||||
expect(caret.begin).toEqual(1);
|
||||
expect(caret.end).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2010-2011, Rudy Lattae
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Rudy Lattae nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL Rudy Lattae BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* Calm theme for the jasmine-bloom StyledHtmlReporter output.
|
||||
*
|
||||
* This theme does away with the default boxey look. The resulting report
|
||||
* is a lot less "busy" thus making it easy to focus on your specs.
|
||||
*/
|
||||
|
||||
/* jasmine-reporter style overrides for */
|
||||
.jasmine_reporter a { text-decoration:none; }
|
||||
|
||||
.jasmine_reporter > .suite {
|
||||
padding-bottom: 0.3em;
|
||||
margin-bottom: 0.3em;
|
||||
border-bottom: solid 2px #eee; }
|
||||
|
||||
.banner, .runner {
|
||||
-webkit-border-radius: 7px;
|
||||
-moz-border-radius: 7px;
|
||||
border-radius: 7px; }
|
||||
|
||||
.runner {
|
||||
-webkit-box-shadow: 2px 2px 3px #888;
|
||||
-moz-box-shadow: 2px 2px 3px #888;
|
||||
box-shadow: 2px 2px 5px #888; }
|
||||
|
||||
.suite {
|
||||
border: none;
|
||||
padding-left: 0.5em; }
|
||||
.suite.failed,
|
||||
.suite.passed,
|
||||
.suite.skipped {
|
||||
background: transparent; }
|
||||
.suite.passed > a {
|
||||
color: green; }
|
||||
.suite.failed > a {
|
||||
color: #c11b17; }
|
||||
.suite.skipped > a {
|
||||
color: #aaa; }
|
||||
.suite > .description {
|
||||
font-weight: bold; }
|
||||
.suite.step > .description {
|
||||
font-weight: normal; }
|
||||
|
||||
.spec {
|
||||
margin: 0px;
|
||||
border: none;
|
||||
padding-left: 0.5em;
|
||||
margin-left: 0.5em;
|
||||
margin-top: 0.2em; }
|
||||
.spec.failed,
|
||||
.spec.passed,
|
||||
.spec.skipped {
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding-bottom: 0.2em; }
|
||||
.spec.failed a {
|
||||
color: #c11b17; }
|
||||
.spec.passed a {
|
||||
color: green; }
|
||||
.spec.skipped a {
|
||||
color: #ccc; }
|
||||
.spec:hover {
|
||||
background-color: #eee;
|
||||
-webkit-border-radius: 7px;
|
||||
-moz-border-radius: 7px;
|
||||
border-radius: 7px; }
|
||||
.spec .description {
|
||||
padding-left: 0.5em; }
|
||||
|
||||
.messages {
|
||||
border: none;
|
||||
margin-left: 1em;
|
||||
padding-bottom: 0.5em; }
|
||||
|
||||
.jasmine_reporter .summary ul {
|
||||
font-size: 0.9em;
|
||||
color: #333;
|
||||
padding-left: 0.2em;
|
||||
margin: 0 0.5em; }
|
||||
|
||||
.jasmine_reporter .summary li {
|
||||
list-style: none; }
|
||||
|
||||
.jasmine_reporter .details ul {
|
||||
font-size: 0.8em;
|
||||
color: #777;
|
||||
padding-left: 0.2em;
|
||||
margin: 0 0.8em; }
|
||||
|
||||
.jasmine_reporter .details li {
|
||||
list-style: none; }
|
||||
|
||||
|
||||
/* header style (if header is used) */
|
||||
.header {
|
||||
margin: 0 5px; }
|
||||
.header h1 {
|
||||
font-size: 1.3em; }
|
||||
.header ul.menu {
|
||||
margin: 0 0 0.5em 0;
|
||||
padding: 0.3em;
|
||||
background-color: #eee; }
|
||||
.header ul.menu li {
|
||||
display: inline;
|
||||
list-style-type: none;
|
||||
margin-right: 1em; }
|
||||
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* Jasmine Grammar - Additional Jasmine grammar to enable alternate BDD approaches.
|
||||
*
|
||||
* Copyright (C) 2010-2011, Rudy Lattae
|
||||
* License: Simplified BSD
|
||||
*
|
||||
* Jasmine-Grammar contains some additions to the jasmine api that make it
|
||||
* more suitable to alternate BDD approaches. The end-goal is streamline the
|
||||
* grammatical aspect of specing out an application from different view-points.
|
||||
*
|
||||
* The new grammar should make it easier to create other types of specifications
|
||||
* apart from "describe" and "it should". They are simply wrappers
|
||||
* for "describe" and "it" so they follow the same rules for nesting.
|
||||
*/
|
||||
|
||||
// Top level namespace for the package
|
||||
jasmine.grammar = (typeof jasmine.grammar === 'undefined') ? {} : jasmine.grammar;
|
||||
|
||||
|
||||
/**
|
||||
* Feature / Story => Scenario => ... style grammar
|
||||
*/
|
||||
jasmine.grammar.FeatureStory = {
|
||||
|
||||
/**
|
||||
* Defines a suite tagged as a "feature"
|
||||
*/
|
||||
feature: function(description, specDefinitions) {
|
||||
var suite = jasmine.grammar.getEnv().describe('Feature: ' + description, specDefinitions);
|
||||
suite.tags = ['feature'];
|
||||
return suite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a suite tagged as a "story"
|
||||
*/
|
||||
story: function(description, specDefinitions) {
|
||||
var suite = jasmine.grammar.getEnv().describe('Story: ' + description, specDefinitions);
|
||||
suite.tags = ['story'];
|
||||
return suite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a suite tagged as a "component"
|
||||
*/
|
||||
component: function(description, specDefinitions) {
|
||||
var suite = jasmine.grammar.getEnv().describe('Component: ' + description, specDefinitions);
|
||||
suite.tags = ['component'];
|
||||
return suite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a spec marked as a "scenario"
|
||||
*/
|
||||
scenario: function(desc, func) {
|
||||
return jasmine.grammar.getEnv().it('Scenario: ' + desc, func);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Given => When => Then ... style grammar
|
||||
*/
|
||||
jasmine.grammar.GWT = {
|
||||
|
||||
/**
|
||||
* Defines a "given" step as a runs block that marks the beginning of a GWT chain
|
||||
*/
|
||||
given: function(desc, func) {
|
||||
return this._addStepToCurrentSpec('Given ' + desc, func);
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a "when" step as a runs block that marks the interesting event in a GWT chain
|
||||
*/
|
||||
when: function(desc, func) {
|
||||
return this._addStepToCurrentSpec('When ' + desc, func);
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a "then" step as a runs block that marks the conclusion of a Given, when, then construct
|
||||
*/
|
||||
then: function(desc, func) {
|
||||
return this._addStepToCurrentSpec('Then ' + desc, func);
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines an "and" step as a runs block that is a continuation from a "then" statement
|
||||
*/
|
||||
and: function(desc, func) {
|
||||
return this._addStepToCurrentSpec('And ' + desc, func);
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a "but" step as a runs block that is a continuation from a "then" statement
|
||||
*/
|
||||
but: function(desc, func) {
|
||||
return this._addStepToCurrentSpec('But ' + desc, func);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds the given function as a step (runs block) in the current spec. Also adds the description to the details list of the spec
|
||||
*/
|
||||
_addStepToCurrentSpec: function(desc, func) {
|
||||
var spec = jasmine.grammar.getEnv().currentSpec;
|
||||
spec.details = spec.details || [];
|
||||
spec.details.push(desc);
|
||||
spec.runs(func);
|
||||
return spec;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Concern => Context => Specification style grammar
|
||||
*/
|
||||
jasmine.grammar.ContextSpecification = {
|
||||
|
||||
/**
|
||||
* Defines a suite tagged as a "concern"
|
||||
*/
|
||||
concern: function(description, specDefinitions) {
|
||||
var suite = jasmine.grammar.getEnv().describe(description, specDefinitions);
|
||||
suite.tags = ['concern'];
|
||||
return suite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a suite tagged as a "context"
|
||||
*/
|
||||
context: function(description, specDefinitions) {
|
||||
var suite = jasmine.grammar.getEnv().describe(description, specDefinitions);
|
||||
suite.tags = ['context'];
|
||||
return suite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a simple spec -- similar to it
|
||||
*/
|
||||
spec: function(desc, func) {
|
||||
return jasmine.grammar.getEnv().it(desc, func);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executable docs (Topic => Example) style grammar
|
||||
*/
|
||||
jasmine.grammar.XDoc = {
|
||||
|
||||
/**
|
||||
* Defines a suite tagged as a "topic"
|
||||
*/
|
||||
topic: function(description, specDefinitions) {
|
||||
var suite = jasmine.grammar.getEnv().describe(description, specDefinitions);
|
||||
suite.tags = ['topic'];
|
||||
return suite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a suite tagged as an "example".
|
||||
*
|
||||
* An axample suite actually stores the inner suites as a string in the "defs" attribute
|
||||
*/
|
||||
example: function(description, specDefinitions) {
|
||||
var suite = jasmine.grammar.getEnv().describe(description, specDefinitions);
|
||||
suite.tags = ['example'];
|
||||
suite.expose = true;
|
||||
suite.defs = specDefinitions.toString()
|
||||
.replace(/^function.*\(.*\).*{/, '')
|
||||
.replace(/}$/, '').trim(); // stored for later output
|
||||
return suite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines a simple spec without any associated function
|
||||
*/
|
||||
pass: function(desc, func) {
|
||||
return jasmine.grammar.getEnv().it(desc);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Some more useful constructs that attach metadata to suites and specs
|
||||
*/
|
||||
jasmine.grammar.Meta = {
|
||||
|
||||
/**
|
||||
* Adds summary content to the current suite.
|
||||
*
|
||||
* @param {String} content(s) variable number of detail content
|
||||
* @see jasmine.grammar.SuiteDetails
|
||||
*/
|
||||
summary: function() {
|
||||
var suite = jasmine.grammar.getEnv().currentSuite;
|
||||
suite.summary = suite.summary || [];
|
||||
|
||||
if (arguments.length > 0) {
|
||||
for(i=0; i<arguments.length; i++) {
|
||||
suite.summary.push(arguments[i]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds detail entries in the current spec.
|
||||
*
|
||||
* @param {String} content(s) variable number of detail content
|
||||
* @see jasmine.grammar.SuiteDetails
|
||||
*/
|
||||
details: function() {
|
||||
var spec = jasmine.grammar.getEnv().currentSpec;
|
||||
spec.details = spec.details || [];
|
||||
|
||||
if (arguments.length > 0) {
|
||||
for(i=0; i<arguments.length; i++) {
|
||||
spec.details.push(arguments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Utilities
|
||||
// =========
|
||||
|
||||
/**
|
||||
* Getter for the Jasmine environment. Makes it possible to inject a different environment when necessary.
|
||||
*/
|
||||
jasmine.grammar.getEnv = function() {
|
||||
return jasmine.grammar._currentEnv = jasmine.grammar._currentEnv || jasmine.getEnv();
|
||||
};
|
||||
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
* Jasmine Reporting - Companion reporting with metadata output for your
|
||||
* Jasmine specs with extended grammar
|
||||
*
|
||||
* Copyright (C) 2010-2011, Rudy Lattae
|
||||
* License: Simplified BSD
|
||||
*/
|
||||
|
||||
// Top level namespace for the package
|
||||
jasmine.reporting = (typeof jasmine.reporting === 'undefined') ? {} : jasmine.reporting;
|
||||
|
||||
|
||||
/**
|
||||
* The StyledHtmlReporter provides augments the jasmine.TrivialReporter
|
||||
*
|
||||
* It outputs additional meta-data relating to your specs to streamline
|
||||
* the presentation of the spec report. When used in conjunction with the
|
||||
* the alternate BDD grammar, your Html report is much easier on the eyes.
|
||||
*/
|
||||
jasmine.reporting.StyledHtmlReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.reporting.StyledHtmlReporter.prototype = new jasmine.TrivialReporter();
|
||||
jasmine.reporting.StyledHtmlReporter.prototype.constructor = jasmine.reporting.StyledHtmlReporter;
|
||||
|
||||
|
||||
jasmine.reporting.StyledHtmlReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
|
||||
var suiteTags = (typeof suite.tags === 'undefined') ? '' : ' ' + suite.tags.join(' ');
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' + suiteTags },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
|
||||
if (suite.summary) {
|
||||
suiteDiv.appendChild(this.createDom('div', {className: 'summary'}, this.createDomFromListOrString(suite.summary)));
|
||||
}
|
||||
|
||||
if (suite.expose) {
|
||||
suiteDiv.appendChild(this.createDom('pre', {}, suite.defs));
|
||||
}
|
||||
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onchange = function(evt) {
|
||||
if (evt.target.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onchange = function(evt) {
|
||||
if (evt.target.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.reporting.StyledHtmlReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount == 0 && (!status == 'failed' || !suite.isIntermediate)) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.reporting.StyledHtmlReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
if (spec.details) {
|
||||
specDiv.appendChild(this.createDom('div', {className: 'details'}, this.createDomFromListOrString(spec.details)));
|
||||
}
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates the proper dom element for the given data object.
|
||||
*
|
||||
* If the data is a simple string, the element created is a "p".
|
||||
* If the data is a list, the element created is an unordered list.
|
||||
* The tags are rendered to the class attribute on the dom element created
|
||||
*/
|
||||
jasmine.reporting.StyledHtmlReporter.prototype.createDomFromListOrString = function(data, tags) {
|
||||
var classAttrs = '';
|
||||
if (typeof tags !== 'undefined') {
|
||||
classAttrs = (tags instanceof Array) ? tags.join(' ') : tags;
|
||||
}
|
||||
if (data instanceof Array) {
|
||||
return this.createDomList('ul', ((classAttrs == '') ? {} : { className: classAttrs}), data);
|
||||
}
|
||||
|
||||
return this.createDom('p', { className: classAttrs}, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates dom element with the suite defs as content
|
||||
*/
|
||||
jasmine.reporting.StyledHtmlReporter.prototype.createDomFromSuiteDefs = function(defs) {
|
||||
var classAttrs = '';
|
||||
if (typeof defs !== 'undefined') {
|
||||
return this.createDom('p', {}, defs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a list of 'li' elements given an array
|
||||
*/
|
||||
jasmine.reporting.StyledHtmlReporter.prototype.createDomList = function(type, attrs, items) {
|
||||
var list;
|
||||
if (typeof items !== 'undefined' && items.length > 0) {
|
||||
list = this.createDom(type, attrs);
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
list.appendChild(this.createDom('li', {}, items[i]));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
{"version": "0.8.5b"}
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2008-2010 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,188 @@
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onclick = function(evt) {
|
||||
if (showPassed.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onclick = function(evt) {
|
||||
if (showSkipped.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap["spec"]) return true;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
||||
};
|
||||
166
assets/plugins/jquery.maskedinput/spec/lib/jasmine/jasmine.css
Normal file
166
assets/plugins/jquery.maskedinput/spec/lib/jasmine/jasmine.css
Normal file
@@ -0,0 +1,166 @@
|
||||
body {
|
||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
}
|
||||
|
||||
|
||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||
color: #303;
|
||||
}
|
||||
|
||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.run_spec {
|
||||
float:right;
|
||||
padding-right: 5px;
|
||||
font-size: .8em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.jasmine_reporter {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.banner {
|
||||
color: #303;
|
||||
background-color: #fef;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
float: left;
|
||||
font-size: 1.1em;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.logo .version {
|
||||
font-size: .6em;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
.options {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 5px 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.suite .suite {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.suite.passed {
|
||||
background-color: #dfd;
|
||||
}
|
||||
|
||||
.suite.failed {
|
||||
background-color: #fdd;
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
padding-left: 1em;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.spec.failed, .spec.passed, .spec.skipped {
|
||||
padding-bottom: 5px;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
.spec.failed {
|
||||
background-color: #fbb;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.spec.passed {
|
||||
background-color: #bfb;
|
||||
border-color: green;
|
||||
}
|
||||
|
||||
.spec.skipped {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.messages {
|
||||
border-left: 1px dashed gray;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: #cfc;
|
||||
/*display: none;*/
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: #fbb;
|
||||
}
|
||||
|
||||
.skipped {
|
||||
color: #777;
|
||||
background-color: #eee;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/*.resultMessage {*/
|
||||
/*white-space: pre;*/
|
||||
/*}*/
|
||||
|
||||
.resultMessage span.result {
|
||||
display: block;
|
||||
line-height: 2em;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.resultMessage .mismatch {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
border: 1px inset red;
|
||||
padding: 1em;
|
||||
background: #eef;
|
||||
}
|
||||
|
||||
.finished-at {
|
||||
padding-left: 1em;
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
.show-passed .passed,
|
||||
.show-skipped .skipped {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.runner {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
}
|
||||
2421
assets/plugins/jquery.maskedinput/spec/lib/jasmine/jasmine.js
Normal file
2421
assets/plugins/jquery.maskedinput/spec/lib/jasmine/jasmine.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
Key Masher plugin for jQuery (https://github.com/digitalBush/jquery.keymasher)
|
||||
Copyright (c) 2010-2013 Josh Bush (digitalbush.com)
|
||||
Licensed under the MIT license
|
||||
Version: 0.3
|
||||
*/
|
||||
|
||||
(function($,undefined){
|
||||
//numberPad={'0':96,'1':97,'2':98,'3':99,'4':100,'5':101,'6':102,'7':103,'8':104,'9':105,'*':106,'+':107,'-':109,'.':110,'/':111},
|
||||
|
||||
var keys=(function(){
|
||||
var defs={},
|
||||
keys = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`-=[]\\;',./ \t\n",
|
||||
shifted = "abcdefghijklmnopqrstuvwxyz!@#$%^&*()~_+{}|:\"<>?",
|
||||
noprint={shift:16,ctrl:17,meta:91,alt:18,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,
|
||||
capslock:20,numlock:144,scrolllock:145,pageup:33,pagedown:34,end:35,home:36,backspace:8,
|
||||
insert:45, 'delete':46,pause:19,esc:27,left:37,up:38,right:39,down:40,printscreen:44};
|
||||
|
||||
$.each(keys.split(''),function(index,value){
|
||||
var keyCode=value.charCodeAt(0),shift=shifted[index];
|
||||
defs[value]={keyCode:keyCode,charCode:keyCode,shift:shift};
|
||||
if(shift)
|
||||
defs[shift]={keyCode:keyCode,charCode:shift.charCodeAt(0),shift:value,requiresShift:index>=26};
|
||||
});
|
||||
$.each(noprint,function(key,value){defs[key]={keyCode:value};});
|
||||
return defs;
|
||||
})();
|
||||
|
||||
var KeyMasher=function(elm){
|
||||
var modifierState={alt: false, ctrl: false, meta: false, shift: false},
|
||||
forced={};
|
||||
|
||||
var queueModifierEvent=function(direction,modifier,isForced){
|
||||
forced[modifier]=isForced;
|
||||
modifierState[modifier]=(direction=='down');
|
||||
var event=$.extend($.Event(), modifierState, {type:'key'+direction, keyCode: keys[modifier].keyCode, charCode: 0});
|
||||
elm.trigger(event);
|
||||
};
|
||||
|
||||
var queueStroke=function(key){
|
||||
if($.type(key)==='string')
|
||||
key=keys[key];
|
||||
if(key.requiresShift && !modifierState.shift)
|
||||
queueModifierEvent('down','shift',true);
|
||||
else if(modifierState.shift && key.shift)
|
||||
key=keys[key.shift];
|
||||
|
||||
var ignore = !key.charCode || modifierState.alt || modifierState.ctrl || modifierState.meta,
|
||||
down = $.extend($.Event('keydown'), modifierState, {keyCode: key.keyCode, charCode: 0, which:key.keyCode}),
|
||||
press = $.extend($.Event('keypress'), modifierState, {keyCode: key.charCode, charCode: key.charCode, which: key.charCode}),
|
||||
up = $.extend($.Event('keyup'), modifierState, {keyCode: key.keyCode, charCode: 0, which:key.keyCode});
|
||||
|
||||
elm.trigger(down);
|
||||
if(!down.isDefaultPrevented() && !ignore){
|
||||
elm.trigger(press);
|
||||
if(!press.isDefaultPrevented()){
|
||||
//need to do caret positioning
|
||||
elm.val(elm.val()+String.fromCharCode(key.charCode));
|
||||
}
|
||||
}
|
||||
elm.trigger(up);
|
||||
|
||||
if(forced.shift)
|
||||
queueModifierEvent('up','shift');
|
||||
};
|
||||
|
||||
var public={
|
||||
hold:function(holding,typing){
|
||||
var toks=holding.split(',');
|
||||
$.each(toks,function(index,value){queueModifierEvent('down',value);});
|
||||
public.type(typing);
|
||||
$.each(toks,function(index,value){queueModifierEvent('up',value);});
|
||||
return public;
|
||||
},
|
||||
type:function(){
|
||||
$.each(arguments,function(index,typing){
|
||||
if($.type(typing)==='string')
|
||||
$.each(typing.split(''),function(index,value){queueStroke(value);});
|
||||
else
|
||||
queueStroke(typing);
|
||||
});
|
||||
return public;
|
||||
}
|
||||
};
|
||||
return $.extend(public,keys);
|
||||
};
|
||||
|
||||
$.fn.mashKeys=function(fn){
|
||||
if($.type(fn)==='string'){
|
||||
var typing=fn;
|
||||
fn=function(keys){keys.type(typing)};
|
||||
}
|
||||
return this.each(function(){
|
||||
fn(KeyMasher($(this)));
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
16
assets/plugins/jquery.maskedinput/spec/lib/matchers.js
Normal file
16
assets/plugins/jquery.maskedinput/spec/lib/matchers.js
Normal file
@@ -0,0 +1,16 @@
|
||||
beforeEach(function(){
|
||||
this.addMatchers({
|
||||
toHaveValue:function(expected){
|
||||
return (this.actual=this.actual.val())===expected;
|
||||
},
|
||||
toMatchPropertiesOf:function(expected){
|
||||
if($.type(expected)!=='object')
|
||||
return false;
|
||||
for(var prop in expected){
|
||||
if(this.actual[prop]!==expected[prop])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
329
assets/plugins/jquery.maskedinput/src/jquery.maskedinput.js
Normal file
329
assets/plugins/jquery.maskedinput/src/jquery.maskedinput.js
Normal file
@@ -0,0 +1,329 @@
|
||||
function getPasteEvent() {
|
||||
var el = document.createElement('input'),
|
||||
name = 'onpaste';
|
||||
el.setAttribute(name, '');
|
||||
return (typeof el[name] === 'function')?'paste':'input';
|
||||
}
|
||||
|
||||
var pasteEventName = getPasteEvent() + ".mask",
|
||||
ua = navigator.userAgent,
|
||||
iPhone = /iphone/i.test(ua),
|
||||
android=/android/i.test(ua),
|
||||
caretTimeoutId;
|
||||
|
||||
$.mask = {
|
||||
//Predefined character definitions
|
||||
definitions: {
|
||||
'9': "[0-9]",
|
||||
'a': "[A-Za-z]",
|
||||
'*': "[A-Za-z0-9]"
|
||||
},
|
||||
dataName: "rawMaskFn",
|
||||
placeholder: '_'
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
//Helper Function for Caret positioning
|
||||
caret: function(begin, end) {
|
||||
var range;
|
||||
|
||||
if (this.length === 0 || this.is(":hidden")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof begin == 'number') {
|
||||
end = (typeof end === 'number') ? end : begin;
|
||||
return this.each(function() {
|
||||
if (this.setSelectionRange) {
|
||||
this.setSelectionRange(begin, end);
|
||||
} else if (this.createTextRange) {
|
||||
range = this.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', end);
|
||||
range.moveStart('character', begin);
|
||||
range.select();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (this[0].setSelectionRange) {
|
||||
begin = this[0].selectionStart;
|
||||
end = this[0].selectionEnd;
|
||||
} else if (document.selection && document.selection.createRange) {
|
||||
range = document.selection.createRange();
|
||||
begin = 0 - range.duplicate().moveStart('character', -100000);
|
||||
end = begin + range.text.length;
|
||||
}
|
||||
return { begin: begin, end: end };
|
||||
}
|
||||
},
|
||||
unmask: function() {
|
||||
return this.trigger("unmask");
|
||||
},
|
||||
mask: function(mask, settings) {
|
||||
var input,
|
||||
defs,
|
||||
tests,
|
||||
partialPosition,
|
||||
firstNonMaskPos,
|
||||
len;
|
||||
|
||||
if (!mask && this.length > 0) {
|
||||
input = $(this[0]);
|
||||
return input.data($.mask.dataName)();
|
||||
}
|
||||
settings = $.extend({
|
||||
placeholder: $.mask.placeholder, // Load default placeholder
|
||||
completed: null
|
||||
}, settings);
|
||||
|
||||
|
||||
defs = $.mask.definitions;
|
||||
tests = [];
|
||||
partialPosition = len = mask.length;
|
||||
firstNonMaskPos = null;
|
||||
|
||||
$.each(mask.split(""), function(i, c) {
|
||||
if (c == '?') {
|
||||
len--;
|
||||
partialPosition = i;
|
||||
} else if (defs[c]) {
|
||||
tests.push(new RegExp(defs[c]));
|
||||
if (firstNonMaskPos === null) {
|
||||
firstNonMaskPos = tests.length - 1;
|
||||
}
|
||||
} else {
|
||||
tests.push(null);
|
||||
}
|
||||
});
|
||||
|
||||
return this.trigger("unmask").each(function() {
|
||||
var input = $(this),
|
||||
buffer = $.map(
|
||||
mask.split(""),
|
||||
function(c, i) {
|
||||
if (c != '?') {
|
||||
return defs[c] ? settings.placeholder : c;
|
||||
}
|
||||
}),
|
||||
focusText = input.val();
|
||||
|
||||
function seekNext(pos) {
|
||||
while (++pos < len && !tests[pos]);
|
||||
return pos;
|
||||
}
|
||||
|
||||
function seekPrev(pos) {
|
||||
while (--pos >= 0 && !tests[pos]);
|
||||
return pos;
|
||||
}
|
||||
|
||||
function shiftL(begin,end) {
|
||||
var i,
|
||||
j;
|
||||
|
||||
if (begin<0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = begin, j = seekNext(end); i < len; i++) {
|
||||
if (tests[i]) {
|
||||
if (j < len && tests[i].test(buffer[j])) {
|
||||
buffer[i] = buffer[j];
|
||||
buffer[j] = settings.placeholder;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
j = seekNext(j);
|
||||
}
|
||||
}
|
||||
writeBuffer();
|
||||
input.caret(Math.max(firstNonMaskPos, begin));
|
||||
}
|
||||
|
||||
function shiftR(pos) {
|
||||
var i,
|
||||
c,
|
||||
j,
|
||||
t;
|
||||
|
||||
for (i = pos, c = settings.placeholder; i < len; i++) {
|
||||
if (tests[i]) {
|
||||
j = seekNext(i);
|
||||
t = buffer[i];
|
||||
buffer[i] = c;
|
||||
if (j < len && tests[j].test(t)) {
|
||||
c = t;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function keydownEvent(e) {
|
||||
var k = e.which,
|
||||
pos,
|
||||
begin,
|
||||
end;
|
||||
|
||||
//backspace, delete, and escape get special treatment
|
||||
if (k === 8 || k === 46 || (iPhone && k === 127)) {
|
||||
pos = input.caret();
|
||||
begin = pos.begin;
|
||||
end = pos.end;
|
||||
|
||||
if (end - begin === 0) {
|
||||
begin=k!==46?seekPrev(begin):(end=seekNext(begin-1));
|
||||
end=k===46?seekNext(end):end;
|
||||
}
|
||||
clearBuffer(begin, end);
|
||||
shiftL(begin, end - 1);
|
||||
|
||||
e.preventDefault();
|
||||
} else if (k == 27) {//escape
|
||||
input.val(focusText);
|
||||
input.caret(0, checkVal());
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function keypressEvent(e) {
|
||||
var k = e.which,
|
||||
pos = input.caret(),
|
||||
p,
|
||||
c,
|
||||
next;
|
||||
|
||||
if (e.ctrlKey || e.altKey || e.metaKey || k < 32) {//Ignore
|
||||
return;
|
||||
} else if (k) {
|
||||
if (pos.end - pos.begin !== 0){
|
||||
clearBuffer(pos.begin, pos.end);
|
||||
shiftL(pos.begin, pos.end-1);
|
||||
}
|
||||
|
||||
p = seekNext(pos.begin - 1);
|
||||
if (p < len) {
|
||||
c = String.fromCharCode(k);
|
||||
if (tests[p].test(c)) {
|
||||
shiftR(p);
|
||||
|
||||
buffer[p] = c;
|
||||
writeBuffer();
|
||||
next = seekNext(p);
|
||||
|
||||
if(android){
|
||||
setTimeout($.proxy($.fn.caret,input,next),0);
|
||||
}else{
|
||||
input.caret(next);
|
||||
}
|
||||
|
||||
if (settings.completed && next >= len) {
|
||||
settings.completed.call(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function clearBuffer(start, end) {
|
||||
var i;
|
||||
for (i = start; i < end && i < len; i++) {
|
||||
if (tests[i]) {
|
||||
buffer[i] = settings.placeholder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function writeBuffer() { input.val(buffer.join('')); }
|
||||
|
||||
function checkVal(allow) {
|
||||
//try to place characters where they belong
|
||||
var test = input.val(),
|
||||
lastMatch = -1,
|
||||
i,
|
||||
c,
|
||||
pos;
|
||||
|
||||
for (i = 0, pos = 0; i < len; i++) {
|
||||
if (tests[i]) {
|
||||
buffer[i] = settings.placeholder;
|
||||
while (pos++ < test.length) {
|
||||
c = test.charAt(pos - 1);
|
||||
if (tests[i].test(c)) {
|
||||
buffer[i] = c;
|
||||
lastMatch = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pos > test.length) {
|
||||
break;
|
||||
}
|
||||
} else if (buffer[i] === test.charAt(pos) && i !== partialPosition) {
|
||||
pos++;
|
||||
lastMatch = i;
|
||||
}
|
||||
}
|
||||
if (allow) {
|
||||
writeBuffer();
|
||||
} else if (lastMatch + 1 < partialPosition) {
|
||||
input.val("");
|
||||
clearBuffer(0, len);
|
||||
} else {
|
||||
writeBuffer();
|
||||
input.val(input.val().substring(0, lastMatch + 1));
|
||||
}
|
||||
return (partialPosition ? i : firstNonMaskPos);
|
||||
}
|
||||
|
||||
input.data($.mask.dataName,function(){
|
||||
return $.map(buffer, function(c, i) {
|
||||
return tests[i]&&c!=settings.placeholder ? c : null;
|
||||
}).join('');
|
||||
});
|
||||
|
||||
if (!input.attr("readonly"))
|
||||
input
|
||||
.one("unmask", function() {
|
||||
input
|
||||
.unbind(".mask")
|
||||
.removeData($.mask.dataName);
|
||||
})
|
||||
.bind("focus.mask", function() {
|
||||
clearTimeout(caretTimeoutId);
|
||||
var pos;
|
||||
|
||||
focusText = input.val();
|
||||
pos = checkVal();
|
||||
|
||||
caretTimeoutId = setTimeout(function(){
|
||||
writeBuffer();
|
||||
if (pos == mask.length) {
|
||||
input.caret(0, pos);
|
||||
} else {
|
||||
input.caret(pos);
|
||||
}
|
||||
}, 10);
|
||||
})
|
||||
.bind("blur.mask", function() {
|
||||
checkVal();
|
||||
if (input.val() != focusText)
|
||||
input.change();
|
||||
})
|
||||
.bind("keydown.mask", keydownEvent)
|
||||
.bind("keypress.mask", keypressEvent)
|
||||
.bind(pasteEventName, function() {
|
||||
setTimeout(function() {
|
||||
var pos=checkVal(true);
|
||||
input.caret(pos);
|
||||
if (settings.completed && pos == input.val().length)
|
||||
settings.completed.call(input);
|
||||
}, 0);
|
||||
});
|
||||
checkVal(); //Perform initial check for existing values
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Masked Input plugin for jQuery
|
||||
Copyright (c) 2007-{{Year}} Josh Bush (digitalbush.com)
|
||||
Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
|
||||
Version: {{version}}
|
||||
*/
|
||||
(function($) {
|
||||
{{{include "src/jquery.maskedinput.js"}}}
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user