Updating js plugins
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "jquery-mask-plugin",
|
||||
"version": "1.14.16",
|
||||
"main": "dist/jquery.mask.js",
|
||||
"ignore": [
|
||||
"deploy.rb",
|
||||
"jquery.mask.json",
|
||||
"Gruntfile.js",
|
||||
"test/*",
|
||||
".*"
|
||||
],
|
||||
"homepage": "https://github.com/igorescobar/jQuery-Mask-Plugin",
|
||||
"_release": "1.14.16",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.14.16",
|
||||
"commit": "0933428d196b18a08325d53cfeaf57e68d1c6d98"
|
||||
},
|
||||
"_source": "https://github.com/igorescobar/jQuery-Mask-Plugin.git",
|
||||
"_target": "1.14.16",
|
||||
"_originalSource": "jquery-mask-plugin"
|
||||
}
|
||||
@@ -0,0 +1,914 @@
|
||||
== v1.14.15 (Mar/08 2018 22:59 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* rolling back change to fix caret positioning. it didn’t worked on some devices
|
||||
|
||||
== v1.14.14 (Mar/02 2018 16:55 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing mask positioning delays
|
||||
* unmask: also removing place holder if added on the first place.
|
||||
* unmask: unsetting maxlength if we set it in the first place
|
||||
|
||||
== v1.14.13 (Dec/11 2017 18:59 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixes caret issue explained on #636
|
||||
* fixing use strict issue
|
||||
|
||||
== v1.14.12 (Oct/04 2017 09:57 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* bug fixing on caret positioning on some devices
|
||||
|
||||
== v1.14.11 (May/30 2017 21:53 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing a lot of caret positioning issues. Thanks to @onuradsay
|
||||
|
||||
== v1.14.10 (Feb/13 2017 14:18 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing exception when oValue in undefined
|
||||
|
||||
== v1.14.9 (Jan/25 2017 11:17 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* don’t use input event when using samsung browser or old chrome versions
|
||||
|
||||
== v1.14.8 (Dec/26 2016 13:18 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing caret on android with chrome 28
|
||||
|
||||
== v1.14.7 (Dec/25 2016 03:51 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* improving caret positioning when cursor is on the middle
|
||||
|
||||
== v1.14.6 (Dec/24 2016 17:14 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fix caret positioning with multiple mask chars
|
||||
|
||||
== v1.14.5 (Dec/24 2016 14:42 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* fixing reserved word
|
||||
|
||||
== v1.14.4 (Dec/24 2016 14:38 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing android cursor positioning (special thanks to @felipejunges and @fernandobandeira)
|
||||
|
||||
== v1.14.3 (Nov/28 2016 11:53 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing caret positioning on safari
|
||||
|
||||
== v1.14.2 (Nov/27 2016 20:04 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* apply auto maxlength in case the mask doesn't have recursive pattern
|
||||
|
||||
== v1.14.1 (Nov/27 2016 19:20 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Fix input value mangling when inserting before a static mask character
|
||||
* fixing caret position issue
|
||||
|
||||
== v1.14.0 (Apr/03 2016 17:52 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Fix cursor jumping while editing in non-IE browsers. Thanks to @archwyrm
|
||||
|
||||
Features:
|
||||
|
||||
* adding masked function for better angular use
|
||||
|
||||
== v1.13.9 (Mar/20 2016 16:17 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* giving the opportunity to pass watchInputs locally
|
||||
|
||||
== v1.13.8 (Mar/06 2016 23:25 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* adding support for meteor
|
||||
|
||||
== v1.13.7 (Mar/06 2016 22:46 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing onChange behaviour
|
||||
|
||||
== v1.13.6 (Mar/06 2016 22:14 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing deploy procedure
|
||||
|
||||
== v1.13.5 (Mar/06 2016 22:01 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* adding clearIfNotMatch to globalOptions
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing some bugs when using non-input elements
|
||||
* fixing mobile issues at #348.
|
||||
* using input event when supported
|
||||
|
||||
== v1.13.4 (Aug/07 2015 14:21 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Add check to ensure that there are input elements before using them
|
||||
|
||||
== v1.13.3 (Jul/16 2015 16:11 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* adding main property to package.json
|
||||
|
||||
== v1.13.2 (Jul/16 2015 16:06 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* change event wasnt being triggered in some cases
|
||||
|
||||
== v1.13.1 (Jul/07 2015 15:38 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* destroying input event too
|
||||
|
||||
== v1.13.0 (Jul/07 2015 15:26 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* removing the autocomplete default.
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing bower file thanks to @lazyants
|
||||
|
||||
Features:
|
||||
|
||||
* prevent glitch when invalid chars.
|
||||
* turning off autocomplete when browsers doesn't support oninput event.
|
||||
|
||||
== v1.12.0 (Jul/07 2015 11:37 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* giving an alternative to the autocomplete/autofill problem.
|
||||
|
||||
== v1.11.4 (Feb/26 2015 22:11 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* grunt, jshint and better applyDataMask. Thanks to @lagden
|
||||
* automated deploy to npm
|
||||
|
||||
== v1.11.3 (Jan/28 2015 15:41 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* Added commonjs module definition
|
||||
|
||||
== v1.11.2 (Dec/26 2014 15:36 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* unreachable code
|
||||
|
||||
== v1.11.1 (Dec/26 2014 15:34 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* unreachable code
|
||||
|
||||
== v1.11.0 (Dec/26 2014 15:33 +0000 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* implementing selectOnFocus and data-mask-selectonfocus option
|
||||
* adding public method called: .applyDataMask in case you want to decide whether to apply masks in data-mask fields
|
||||
|
||||
== v1.10.13 (Nov/19 2014 16:06 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing bug with watchInputs feature when mask is used as a function and not a string.
|
||||
|
||||
== v1.10.12 (Nov/06 2014 13:08 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* making a few improvements to make selection, copy events easier
|
||||
|
||||
== v1.10.11 (Nov/06 2014 11:26 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* we need to revaluate dataMask flags everytime
|
||||
|
||||
== v1.10.10 (Nov/06 2014 10:41 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing dynamically data-mask added elements
|
||||
|
||||
== v1.10.9 (Nov/05 2014 10:52 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* data-mask wasnt working
|
||||
|
||||
== v1.10.8 (Nov/01 2014 13:49 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* we dont need to seek for data-mask every time
|
||||
|
||||
== v1.10.7 (Nov/01 2014 13:18 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* little optimization
|
||||
|
||||
== v1.10.6 (Oct/28 2014 13:59 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing weird cursor problems in weird cases.
|
||||
* dynamically added inputs wasnt working
|
||||
|
||||
== v1.10.5 (Oct/23 2014 11:41 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing weird cursor problems in weird cases.
|
||||
|
||||
== v1.10.4 (Oct/23 2014 11:02 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing on the fly mask change feature.
|
||||
|
||||
== v1.10.3 (Oct/22 2014 09:50 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing unmask method.
|
||||
|
||||
== v1.10.2 (Oct/20 2014 16:38 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* onChange event fired at the wrong time when the field already has a value.
|
||||
|
||||
== v1.10.1 (Oct/20 2014 16:08 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing onChange event behaviour
|
||||
|
||||
== v1.10.0 (Oct/20 2014 10:56 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* adding a way to change global settings like translation object and the byPassKeys object.
|
||||
|
||||
== v1.9.2 (Oct/20 2014 10:08 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing fallback digits implementation. Thanks @A1rPun
|
||||
|
||||
== v1.9.1 (Oct/18 2014 12:27 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* cant convert circular json exception
|
||||
|
||||
== v1.9.0 (Oct/18 2014 12:07 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* adding onInvalid callback
|
||||
|
||||
== v1.8.0 (Oct/17 2014 11:35 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* removing automatic maxlength support
|
||||
* making a few optimizations to make it faster and retro compatible with other libraries
|
||||
* creating globalOptions to make it more fast and flexible
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing issue #196
|
||||
|
||||
Features:
|
||||
|
||||
* adding the fallback translation option
|
||||
|
||||
== v1.7.8 (Oct/15 2014 10:55 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* change event may experience issues
|
||||
* avoid maximum call stack trace error
|
||||
|
||||
== v1.7.7 (Sep/10 2014 22:31 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing clojure compile issue
|
||||
|
||||
== v1.7.6 (Sep/10 2014 22:14 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing clearifnotmatch in masks with literal digits
|
||||
|
||||
== v1.7.5 (Sep/09 2014 15:43 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing paste inside of empty fields.
|
||||
|
||||
== v1.7.4 (Aug/11 2014 14:53 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* smaller and reliable code
|
||||
|
||||
== v1.7.3 (Aug/11 2014 11:28 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing issue #185
|
||||
|
||||
== v1.7.2 (Aug/08 2014 11:11 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* smaller code
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing remove bug
|
||||
|
||||
== v1.7.1 (Aug/08 2014 00:55 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* upgrading zepto, smaller syntax and fixing build
|
||||
|
||||
== v1.7.0 (Aug/07 2014 23:56 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* applying masks to dynamically added elements. (html/javascript notation)
|
||||
|
||||
== v1.6.5 (Jun/30 2014 10:24 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing clearIfNotMatch feature in cases of optional and recursive digits
|
||||
|
||||
== v1.6.4 (May/08 2014 23:54 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* testing some deployment stunts
|
||||
|
||||
== v1.6.3 (May/08 2014 23:51 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* testing some deployment stunts
|
||||
|
||||
== v1.6.2 (May/08 2014 23:45 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fuckin typo
|
||||
|
||||
== v1.6.1 (May/08 2014 23:39 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing autofocus bug
|
||||
|
||||
== v1.6.0 (May/07 2014 21:13 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing autofocus bug
|
||||
|
||||
Features:
|
||||
|
||||
* adding support to the clearIfNotMatch option
|
||||
* HTML5 placeholder support
|
||||
|
||||
== v1.5.7 (May/01 2014 18:37 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* some cleanup and stuff
|
||||
|
||||
== v1.5.6 (May/01 2014 18:30 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Bug in calculating difference between mask characters between old and new field values
|
||||
* Fix stack limit exceeded
|
||||
|
||||
== v1.5.5 (Apr/27 2014 13:47 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* UMD (Universal Module Definition) patterns for JavaScript modules
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* caret position correction
|
||||
* 114 - Fix onChange Event error
|
||||
|
||||
== v1.5.4 (Feb/09 2014 12:02 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* optmizing code
|
||||
|
||||
== v1.5.3 (Feb/08 2014 14:59 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing ctrl a bug
|
||||
|
||||
== v1.5.2 (Dec/20 2013 16:35 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* smaller source code
|
||||
|
||||
== v1.5.1 (Dec/18 2013 22:34 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* fixing some code climate problems
|
||||
|
||||
== v1.5.0 (Dec/18 2013 22:10 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing getCleanVal()
|
||||
|
||||
Features:
|
||||
|
||||
* new public method called cleanVal
|
||||
|
||||
== v1.4.2 (Dec/16 2013 15:48 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Dirty fix for masks not completing with a literal
|
||||
|
||||
== v1.4.1 (Dec/09 2013 21:23 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* revising ignored keys
|
||||
|
||||
== v1.4.0 (Nov/28 2013 18:06 +0000 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* caret positioning implementation
|
||||
|
||||
== v1.3.1 (Oct/08 2013 20:38 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* adding more keys to ignore list to make the char navigation smoothly
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Sounds like 'options' has disappeared for some reason
|
||||
|
||||
== v1.3.0 (Sep/13 2013 10:37 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* creating the maxlength option
|
||||
|
||||
== v1.2.0 (Sep/07 2013 12:07 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* adding the possibility to put recursive digits inside masks
|
||||
|
||||
== v1.1.3 (Sep/04 2013 21:21 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing late masking
|
||||
|
||||
== v1.1.2 (Aug/26 2013 15:08 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing mask on div,span etc
|
||||
|
||||
== v1.1.1 (Aug/26 2013 14:42 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* better callback handling
|
||||
|
||||
== v1.1.0 (Aug/24 2013 15:59 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* adding onchange support
|
||||
|
||||
== v1.0.3 (Aug/23 2013 23:10 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* optimizations to mask on non html fields
|
||||
|
||||
== v1.0.2 (Aug/23 2013 22:46 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* adding remask method do improve callback performance
|
||||
|
||||
== v1.0.1 (Aug/23 2013 22:01 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* normal releases again
|
||||
|
||||
== v1.0.0 (Aug/23 2013 21:59 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* huge refactoring focusing no reduce source code weight and bugfixing
|
||||
|
||||
== v0.11.5 (Aug/20 2013 17:11 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* bug fixing when mask range is bigger than 2 digits.
|
||||
|
||||
== v0.11.4 (Aug/19 2013 10:24 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* adding de delete key to byPassKeys
|
||||
|
||||
== v0.11.3 (Aug/18 2013 00:48 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing zepto compatibily
|
||||
|
||||
== v0.11.2 (Aug/17 2013 18:39 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* jmask iterate all items
|
||||
|
||||
== v0.11.1 (Aug/17 2013 18:32 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* a little bit smaller source code
|
||||
|
||||
== v0.11.0 (Aug/16 2013 21:27 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Altered "ignored keys" hook to run events (i.e. onKeyPress) afterwards. Otherwise, we miss key triggered events when the user deletes the entire text box, etc.
|
||||
|
||||
Features:
|
||||
|
||||
* adding support to method getCleanVal
|
||||
|
||||
== v0.10.1 (Jul/26 2013 09:35 +0100 by ) ==
|
||||
|
||||
|
||||
|
||||
== v0.10.0 (Jul/19 2013 23:07 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* adding data-mask support
|
||||
|
||||
== v0.9.1 (Jul/19 2013 22:35 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* jQuery-Mask-Plugin is now available at bower.io
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing addEventListener on IE7
|
||||
|
||||
== v0.9.0 (Apr/24 2013 07:44 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* Adding compatibility with Zepto.js
|
||||
|
||||
== v0.8.0 (Apr/07 2013 18:39 +0100 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* applying masks anything != than input :)
|
||||
* implementing the possibility of range chars ex: A{1,3}
|
||||
|
||||
== v0.7.11 (Apr/05 2013 22:12 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* now when you type a wrong char, the plugin will make your text fit inside of the mask instead of lose your data.
|
||||
|
||||
== v0.7.10 (Apr/04 2013 22:14 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* changing yui-compressor to clojure-compiler
|
||||
|
||||
== v0.7.9 (Apr/04 2013 22:04 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* refactoring and implementation of optional mask digits
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing maxlength and adding a smarter mask removal. issue #18
|
||||
|
||||
== v0.7.8 (Mar/30 2013 00:48 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* a few changes to get the code smallest possible.
|
||||
* removing unnecessary methods and making code smaller.
|
||||
|
||||
== v0.7.7 (Mar/29 2013 12:38 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fixing copy and paste problem related on issue #15
|
||||
|
||||
== v0.7.6 (Mar/29 2013 00:28 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* correcting mask formatationg problem related on issue #16
|
||||
|
||||
== v0.7.5 (Mar/03 2013 20:56 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* generating .gz file on deploy
|
||||
|
||||
== v0.7.4 (Mar/03 2013 20:38 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* changing minifier jsmin to yui compressor.
|
||||
|
||||
== v0.7.3 (Mar/02 2013 01:12 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* bug fixing when typed wrong data type on mixing masks.
|
||||
|
||||
== v0.7.2 (Feb/24 2013 22:02 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* fuckin stupid comma.
|
||||
|
||||
== v0.7.1 (Feb/24 2013 21:57 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* testing the private method maskToRegex
|
||||
* a little bit of changes to make the code more testable
|
||||
|
||||
== v0.7.0 (Feb/12 2013 00:30 +0000 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* Now you can decide for jquery mask plugin how to interpret 0 to 9, A and S and even teach him how to reconize patterns.
|
||||
|
||||
== v0.6.3 (Feb/11 2013 12:20 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* When the user paste a text and the last char is valid sanitize may fail
|
||||
|
||||
== v0.6.2 (Feb/11 2013 00:02 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* allowing the user type the same character as the mask without erasing it.
|
||||
|
||||
== v0.6.1 (Jan/20 2013 23:57 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* changing the way ta deployment occurs to correct jquery plugins deployments.
|
||||
|
||||
== v0.6.0 (Jan/18 2013 17:19 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* Now pushing jQuery Mask Plugin to jQuery Plugins Repository
|
||||
|
||||
== v0.5.4 (Jan/17 2013 23:06 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* upgrading jquery plugins manifest file
|
||||
|
||||
== v0.5.3 (Jan/17 2013 22:48 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* correctly generating jmask version inside of jquery mask source
|
||||
|
||||
== v0.5.2 (Jan/17 2013 22:43 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* Now pushing to jQuery Plugin Repository
|
||||
|
||||
== v0.5.1 (Jan/07 2013 23:33 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* improving the deploy process with the new stepup's upgrade.
|
||||
|
||||
== v0.5.0 (Oct/27 2012 13:40 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Bug fixes on OnSupport method with Firefox.
|
||||
|
||||
Features:
|
||||
|
||||
* the first parameter of the .mask() function, now accepts a string or a anonymous function
|
||||
|
||||
== v0.4.7 (Aug/06 2012 22:56 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* Nothing big, just class refactoring
|
||||
|
||||
== v0.4.6 (Aug/06 2012 01:25 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
- better OOP design
|
||||
- implementing the jquery data object on each mask field
|
||||
- implementing the public method .remove to disable and remove the mask
|
||||
|
||||
== v0.4.5 (Aug/04 2012 01:31 +0100 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
- improving support to complex jquery selectors
|
||||
- performance improvement.
|
||||
- callback handling improvement
|
||||
|
||||
== v0.4.4 (Jun/03 2012 21:01 +0100 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Bug fixes on Internet Explorer 8.
|
||||
|
||||
== v0.4.3 (Mar/19 2012 21:52 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Corrigindo bug para mascaras com +
|
||||
|
||||
== v0.4.2 (Mar/18 2012 15:28 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Mascara não pararecia no firefox
|
||||
|
||||
== v0.4.1 (Mar/18 2012 15:01 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Corrigindo tim das macaras.
|
||||
|
||||
== v0.4.0 (Mar/18 2012 14:51 +0000 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* Implementado mascara reversa para moeda/cpf/rg/etc.
|
||||
* Nova engine.
|
||||
|
||||
== v0.3.0 (Mar/14 2012 10:14 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* License and comments up to date.
|
||||
|
||||
Features:
|
||||
|
||||
* On-the-fly mask change.
|
||||
* onComplete and onKeyPress new callbacks.
|
||||
|
||||
== v0.2.5 (Mar/13 2012 22:55 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
- Corrigindo ctrl+v com mascara errada. - Cortando dados que exceder a mascara no ctrl+v ou se segurar alguma tecla. - Refatorando algumas partes do código.
|
||||
|
||||
== v0.2.4 (Mar/13 2012 11:06 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* Codigo refatorado, otimizado, validação mais precisa e efetiva.
|
||||
|
||||
== v0.2.3 (Mar/13 2012 01:01 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* Melhorando expressoes regulares.
|
||||
|
||||
== v0.2.2 (Mar/13 2012 00:50 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Corrindo regex de validação
|
||||
|
||||
== v0.2.1 (Mar/13 2012 00:41 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Corrigida validação alphanumerica.
|
||||
|
||||
== v0.2.0 (Mar/13 2012 00:24 +0000 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
- Input Data Type Validation.
|
||||
- Automatic MaxLength (When are not defined).
|
||||
- Live Event Implemented for Ajax-based Apps.
|
||||
- Mixed mask with validation.
|
||||
* S for string digit
|
||||
* A for alphanumeric digit
|
||||
* 0 to 9 for numeric digit.
|
||||
|
||||
== v0.1.1 (Mar/10 2012 14:05 +0000 by Igor Escobar) ==
|
||||
|
||||
Bugfixes:
|
||||
|
||||
* Implementando Crossbrowser event handling.
|
||||
|
||||
== v0.1.0 (Mar/10 2012 13:10 +0000 by Igor Escobar) ==
|
||||
|
||||
Features:
|
||||
|
||||
* Implementando mascaras com espaço para data e hora
|
||||
|
||||
== v0.0.1 (Mar/10 2012 04:42 +0000 by Igor Escobar) ==
|
||||
|
||||
Changes:
|
||||
|
||||
* Refatorando o codigo para suportar multiplas instancias
|
||||
@@ -0,0 +1,9 @@
|
||||
### Have you take a look into our docs?
|
||||
https://igorescobar.github.io/jQuery-Mask-Plugin/
|
||||
|
||||
### Want to contribute? Make sure you read this first
|
||||
https://github.com/igorescobar/jQuery-Mask-Plugin#contributing
|
||||
|
||||
Is this plugin helping you out? Buy me a beer and cheers! :beer:
|
||||
|
||||
:bowtie: https://www.paypal.me/igorcescobar
|
||||
@@ -0,0 +1,36 @@
|
||||
FROM phusion/baseimage:0.9.17
|
||||
|
||||
# Use baseimage-docker's init system.
|
||||
CMD ["/sbin/my_init"]
|
||||
|
||||
# Java 8 for Google's clojure compiler
|
||||
RUN \
|
||||
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
|
||||
echo "deb http://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list && \
|
||||
add-apt-repository -y ppa:webupd8team/java && \
|
||||
apt-get update && \
|
||||
apt-get install -y oracle-java8-installer git unzip ruby-full && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
rm -rf /var/cache/oracle-jdk8-installer
|
||||
|
||||
# Define commonly used JAVA_HOME variable
|
||||
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
|
||||
|
||||
RUN mkdir /app
|
||||
RUN mkdir /app/clojure-compiler
|
||||
|
||||
# Clojure compiler
|
||||
RUN \
|
||||
curl -O http://dl.google.com/closure-compiler/compiler-latest.zip && \
|
||||
unzip compiler-latest.zip -d /app/clojure-compiler && \
|
||||
chmod a+x /app/clojure-compiler && \
|
||||
rm compiler-latest.zip
|
||||
|
||||
RUN gem install bundler pry step-up --no-rdoc --no-ri
|
||||
|
||||
# Install Node.js
|
||||
RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
|
||||
RUN apt-get install --yes nodejs
|
||||
|
||||
RUN npm install -g grunt-cli
|
||||
WORKDIR /app/jquery-mask-plugin
|
||||
@@ -0,0 +1,22 @@
|
||||
### Have you take a look into our docs?
|
||||
https://igorescobar.github.io/jQuery-Mask-Plugin/
|
||||
|
||||
### Make sure your read this before opening a new issue:
|
||||
https://github.com/igorescobar/jQuery-Mask-Plugin#problems-or-questions
|
||||
|
||||
#### Device
|
||||
[...]
|
||||
|
||||
#### Browser (and version)?
|
||||
[...]
|
||||
|
||||
#### Functional `jsfiddle` exemplifying your problem:
|
||||
You can use this one as exemple: http://jsfiddle.net/igorescobar/6pco4om7/
|
||||
|
||||
#### Describe de problem depth:
|
||||
[...]
|
||||
|
||||
|
||||
Is this plugin helping you out? Buy me a beer and cheers! :beer:
|
||||
|
||||
:bowtie: https://www.paypal.me/igorcescobar
|
||||
@@ -0,0 +1,26 @@
|
||||
Created by Igor Escobar on 2012-03-10. Please report any bug at http://blog.igorescobar.com
|
||||
|
||||
Copyright (c) 2012 Igor Escobar http://blog.igorescobar.com
|
||||
|
||||
The MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
|
||||
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,137 @@
|
||||
# jQuery Mask Plugin
|
||||
A jQuery Plugin to make masks on form fields and HTML elements.
|
||||
|
||||
[](https://travis-ci.org/igorescobar/jQuery-Mask-Plugin)
|
||||
[](https://codeclimate.com/github/igorescobar/jQuery-Mask-Plugin)
|
||||
[](https://www.jsdelivr.com/package/npm/jquery-mask-plugin)
|
||||
[](https://cdnjs.com/libraries/jquery.mask)
|
||||
|
||||
# Documentation, Demos & Usage Examples
|
||||
https://igorescobar.github.io/jQuery-Mask-Plugin/
|
||||
|
||||
## Features
|
||||
|
||||
* Lightweight (~2kb minified, ~1kb gziped).
|
||||
* Built-in support for dynamically added elements.
|
||||
* Masks on any HTML element (no need to server-side mask anymore!)!
|
||||
* HTML notation support (data-mask, data-mask-recursive, data-mask-clearifnotmatch).
|
||||
* String/Numeric/Alpha/Mixed masks.
|
||||
* Reverse mask support for masks on numeric fields.
|
||||
* Sanitization.
|
||||
* Optional digits.
|
||||
* Recursive Digits.
|
||||
* Fallback Digits.
|
||||
* Advanced mask initialization.
|
||||
* Advanced Callbacks.
|
||||
* On-the-fly mask change.
|
||||
* Mask removal.
|
||||
* Full customization.
|
||||
* Compatibility with React/UMD/Zepto.js/Angular.JS.
|
||||
* HTML5 placeholder support.
|
||||
* Clear the field if it not matches support.
|
||||
|
||||
## Want to buy me a beer? :heart_eyes:
|
||||
http://paypal.me/igorcescobar
|
||||
|
||||
## Install it via Package Managers
|
||||
### Bower
|
||||
`bower install jquery-mask-plugin`
|
||||
### NPM
|
||||
`npm i jquery-mask-plugin`
|
||||
### Meteor
|
||||
`meteor add igorescobar:jquery-mask-plugin`
|
||||
### Packagist/Composer
|
||||
`composer require igorescobar/jquery-mask-plugin`
|
||||
|
||||
## CDNs
|
||||
### CDNjs
|
||||
https://cdnjs.com/libraries/jquery.mask
|
||||
### JSDelivr
|
||||
http://www.jsdelivr.com/projects/jquery.mask
|
||||
|
||||
## RubyGems
|
||||
```ruby
|
||||
gem 'jquery_mask_rails' # more details at http://bit.ly/jquery-mask-gem
|
||||
```
|
||||
|
||||
## Tutorials
|
||||
### English
|
||||
* [Masks with jQuery Mask Plugin](http://bit.ly/masks-with-jquery-mask-plugin)
|
||||
* [Using jQuery Mask Plugin With Zepto.js](http://bit.ly/using-jquery-mask-plugin-with-zeptojs)
|
||||
|
||||
### Portuguese
|
||||
* [Mascaras com JQuery Mask Plugin](http://bit.ly/mascaras-com-jquery-mask-plugin)
|
||||
* [Mascara Javascript para os novos telefones de São Paulo](http://bit.ly/mascara-javascript-para-os-novos-telefones-de-sao-paulo)
|
||||
|
||||
### Fun (or not) facts
|
||||
* [I’ve had the chance to troll Donald Trump. But I didn’t.](http://www.igorescobar.com/blog/2016/08/21/ive-the-chance-to-troll-donald-trump-but-i-didnt/)
|
||||
|
||||
## Compatibility
|
||||
jQuery Mask Plugin has been tested with jQuery 1.7+ on all major browsers:
|
||||
|
||||
* Firefox 2+ (Win, Mac, Linux);
|
||||
* IE7+ (Win);
|
||||
* Chrome 6+ (Win, Mac, Linux, Android, iPhone);
|
||||
* Safari 3.2+ (Win, Mac, iPhone);
|
||||
* Opera 8+ (Win, Mac, Linux, Android, iPhone).
|
||||
* Android Default Browser v4+
|
||||
|
||||
## Typescript support
|
||||
Definition can be found [here](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jquery-mask-plugin).
|
||||
|
||||
To install, open terminal and navigate to your working directory.
|
||||
|
||||
### Typescript 1.x users
|
||||
* Install [typings](https://github.com/typings/typings) by running `npm install typings --global`.
|
||||
* Then install the definition by running `typings install dt~jquery-mask-plugin --global --save`.
|
||||
### Typescript 2.x users
|
||||
* Use npm `npm install --save-dev @types/jquery-mask-plugin`.
|
||||
|
||||
For configuration options and troubleshooting refer to these repositories:
|
||||
* [Typings](https://github.com/typings/typings)
|
||||
* [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped)
|
||||
* [Typescript](https://github.com/Microsoft/TypeScript)
|
||||
|
||||
|
||||
## Problems or Questions?
|
||||
Before opening a new [issue](https://github.com/igorescobar/jQuery-Mask-Plugin/issues) take a look on those frequently asked questions:
|
||||
#### [How to integrate with React.js?](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/498)
|
||||
#### [How to integrate with Angular.js?](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/499)
|
||||
#### [How to integrate with Vue.js?](https://github.com/ankurk91/vue-jquery-mask)
|
||||
#### [Problems with old versions of Android keyboard](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/135)
|
||||
#### [Negative numbers, or currency related problems](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/436#issuecomment-253176511)
|
||||
#### [Prefix or sufix on the Mask](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/166)
|
||||
#### [Add validation?](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/387#issuecomment-192998092)
|
||||
#### [Field type number, email not working?](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/450#issuecomment-253225719)
|
||||
#### [Want to keep the placeholder as the user types?](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/633#issuecomment-350819224)
|
||||
#### [E-mail mask?](https://github.com/igorescobar/jQuery-Mask-Plugin/issues/582)
|
||||
|
||||
## Bugs?
|
||||
Did you read our [docs](https://igorescobar.github.io/jQuery-Mask-Plugin/docs.html)? Yes? Cool! So now... make sure that you have a *functional* [jsfiddle](http://jsfiddle.net/) exemplifying your problem and open an [issue](https://github.com/igorescobar/jQuery-Mask-Plugin/issues) for us. Don't know how to do it? Use this [fiddle example](http://jsfiddle.net/igorescobar/6pco4om7/).
|
||||
|
||||
## Contributing
|
||||
* **Bug Reporting**: Yes! You can contribute opening [issues](https://github.com/igorescobar/jQuery-Mask-Plugin/issues)!
|
||||
* **Documenting**: Do you think that something in our [docs](https://github.com/igorescobar/jQuery-Mask-Plugin/tree/gh-pages) should be better? Do you have a cool idea to increase the awesomeness? Summit your pull request with your idea!
|
||||
* **Bug Fixing**: No time to lose? Fix it and help others! Write some [tests](https://github.com/igorescobar/jQuery-Mask-Plugin/tree/master/test) to make sure that everything are working propertly.
|
||||
* **Improving**: Open an [issue](https://github.com/igorescobar/jQuery-Mask-Plugin/issues) and lets discuss it. Just to make sure that you're on the right track.
|
||||
* **Sharing**: Yes! Have we saved some of your time? Are you enjoying our mask plugin? Sharing is caring! Tweet it! Facebook it! Linkedin It(?!) :D
|
||||
* **Donating**: Hey, now that you don't need to worry about masks again... buy me a coffee, beer or a PlayStation 4 (Xbox One also accepted!) :o)
|
||||
|
||||
### Unit Tests
|
||||
We use [QUnit](http://qunitjs.com/) and [GruntJS](http://gruntjs.com/). To run our test suit is just run: ```grunt test``` in your console or you can open those ```test-for*.html``` files inside of our ```test/``` folder.
|
||||
|
||||
In case you're familiar with [Docker](https://www.docker.com/) here is how you can use it:
|
||||
```bash
|
||||
docker build -t jquery-mask .
|
||||
CONTAINER_ID=$(docker run -d -v $PWD:/app/jquery-mask-plugin jquery-mask)
|
||||
docker exec $CONTAINER_ID sh -c "npm install"
|
||||
docker exec -it $CONTAINER_ID /bin/bash
|
||||
grunt test
|
||||
```
|
||||
|
||||
## Contributors
|
||||
* [Igor Lima](https://github.com/igorlima)
|
||||
* [Mark Simmons](https://github.com/Markipelago)
|
||||
* [Gabriel Schammah](https://github.com/gschammah)
|
||||
* [Marcelo Manzan](https://github.com/kawamanza)
|
||||
* [See the full list](https://github.com/igorescobar/jQuery-Mask-Plugin/graphs/contributors)
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "jquery-mask-plugin",
|
||||
"version": "1.14.16",
|
||||
"main": "dist/jquery.mask.js",
|
||||
"ignore": [
|
||||
"deploy.rb",
|
||||
"jquery.mask.json",
|
||||
"Gruntfile.js",
|
||||
"test/*",
|
||||
".*"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "jQuery-Mask-Plugin",
|
||||
"description": "A jQuery Plugin to make masks on form fields and HTML elements.",
|
||||
"version": "1.14.16",
|
||||
"keywords": ["javascript", "mask", "form"],
|
||||
"scripts": [
|
||||
"dist/jquery.mask.js"
|
||||
],
|
||||
"main": "dist/jquery.mask.js"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "igorescobar/jquery-mask-plugin",
|
||||
"type": "library",
|
||||
"description": "A jQuery Plugin to make masks on form fields and html elements.",
|
||||
"keywords": ["jquery", "mask", "plugin"],
|
||||
"homepage": "https://github.com/igorescobar/jQuery-Mask-Plugin",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Igor Escobar",
|
||||
"email": "blog@igorescobar.com",
|
||||
"homepage": "https://about.me/igorescobar",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/igorescobar/jQuery-Mask-Plugin/issues"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,604 @@
|
||||
/**
|
||||
* jquery.mask.js
|
||||
* @version: v1.14.16
|
||||
* @author: Igor Escobar
|
||||
*
|
||||
* Created by Igor Escobar on 2012-03-10. Please report any bug at github.com/igorescobar/jQuery-Mask-Plugin
|
||||
*
|
||||
* Copyright (c) 2012 Igor Escobar http://igorescobar.com
|
||||
*
|
||||
* The MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* jshint laxbreak: true */
|
||||
/* jshint maxcomplexity:17 */
|
||||
/* global define */
|
||||
|
||||
// UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.
|
||||
// https://github.com/umdjs/umd/blob/master/templates/jqueryPlugin.js
|
||||
(function (factory, jQuery, Zepto) {
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object' && typeof Meteor === 'undefined') {
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
factory(jQuery || Zepto);
|
||||
}
|
||||
|
||||
}(function ($) {
|
||||
'use strict';
|
||||
|
||||
var Mask = function (el, mask, options) {
|
||||
|
||||
var p = {
|
||||
invalid: [],
|
||||
getCaret: function () {
|
||||
try {
|
||||
var sel,
|
||||
pos = 0,
|
||||
ctrl = el.get(0),
|
||||
dSel = document.selection,
|
||||
cSelStart = ctrl.selectionStart;
|
||||
|
||||
// IE Support
|
||||
if (dSel && navigator.appVersion.indexOf('MSIE 10') === -1) {
|
||||
sel = dSel.createRange();
|
||||
sel.moveStart('character', -p.val().length);
|
||||
pos = sel.text.length;
|
||||
}
|
||||
// Firefox support
|
||||
else if (cSelStart || cSelStart === '0') {
|
||||
pos = cSelStart;
|
||||
}
|
||||
|
||||
return pos;
|
||||
} catch (e) {}
|
||||
},
|
||||
setCaret: function(pos) {
|
||||
try {
|
||||
if (el.is(':focus')) {
|
||||
var range, ctrl = el.get(0);
|
||||
|
||||
// Firefox, WebKit, etc..
|
||||
if (ctrl.setSelectionRange) {
|
||||
ctrl.setSelectionRange(pos, pos);
|
||||
} else { // IE
|
||||
range = ctrl.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', pos);
|
||||
range.moveStart('character', pos);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
},
|
||||
events: function() {
|
||||
el
|
||||
.on('keydown.mask', function(e) {
|
||||
el.data('mask-keycode', e.keyCode || e.which);
|
||||
el.data('mask-previus-value', el.val());
|
||||
el.data('mask-previus-caret-pos', p.getCaret());
|
||||
p.maskDigitPosMapOld = p.maskDigitPosMap;
|
||||
})
|
||||
.on($.jMaskGlobals.useInput ? 'input.mask' : 'keyup.mask', p.behaviour)
|
||||
.on('paste.mask drop.mask', function() {
|
||||
setTimeout(function() {
|
||||
el.keydown().keyup();
|
||||
}, 100);
|
||||
})
|
||||
.on('change.mask', function(){
|
||||
el.data('changed', true);
|
||||
})
|
||||
.on('blur.mask', function(){
|
||||
if (oldValue !== p.val() && !el.data('changed')) {
|
||||
el.trigger('change');
|
||||
}
|
||||
el.data('changed', false);
|
||||
})
|
||||
// it's very important that this callback remains in this position
|
||||
// otherwhise oldValue it's going to work buggy
|
||||
.on('blur.mask', function() {
|
||||
oldValue = p.val();
|
||||
})
|
||||
// select all text on focus
|
||||
.on('focus.mask', function (e) {
|
||||
if (options.selectOnFocus === true) {
|
||||
$(e.target).select();
|
||||
}
|
||||
})
|
||||
// clear the value if it not complete the mask
|
||||
.on('focusout.mask', function() {
|
||||
if (options.clearIfNotMatch && !regexMask.test(p.val())) {
|
||||
p.val('');
|
||||
}
|
||||
});
|
||||
},
|
||||
getRegexMask: function() {
|
||||
var maskChunks = [], translation, pattern, optional, recursive, oRecursive, r;
|
||||
|
||||
for (var i = 0; i < mask.length; i++) {
|
||||
translation = jMask.translation[mask.charAt(i)];
|
||||
|
||||
if (translation) {
|
||||
|
||||
pattern = translation.pattern.toString().replace(/.{1}$|^.{1}/g, '');
|
||||
optional = translation.optional;
|
||||
recursive = translation.recursive;
|
||||
|
||||
if (recursive) {
|
||||
maskChunks.push(mask.charAt(i));
|
||||
oRecursive = {digit: mask.charAt(i), pattern: pattern};
|
||||
} else {
|
||||
maskChunks.push(!optional && !recursive ? pattern : (pattern + '?'));
|
||||
}
|
||||
|
||||
} else {
|
||||
maskChunks.push(mask.charAt(i).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
|
||||
}
|
||||
}
|
||||
|
||||
r = maskChunks.join('');
|
||||
|
||||
if (oRecursive) {
|
||||
r = r.replace(new RegExp('(' + oRecursive.digit + '(.*' + oRecursive.digit + ')?)'), '($1)?')
|
||||
.replace(new RegExp(oRecursive.digit, 'g'), oRecursive.pattern);
|
||||
}
|
||||
|
||||
return new RegExp(r);
|
||||
},
|
||||
destroyEvents: function() {
|
||||
el.off(['input', 'keydown', 'keyup', 'paste', 'drop', 'blur', 'focusout', ''].join('.mask '));
|
||||
},
|
||||
val: function(v) {
|
||||
var isInput = el.is('input'),
|
||||
method = isInput ? 'val' : 'text',
|
||||
r;
|
||||
|
||||
if (arguments.length > 0) {
|
||||
if (el[method]() !== v) {
|
||||
el[method](v);
|
||||
}
|
||||
r = el;
|
||||
} else {
|
||||
r = el[method]();
|
||||
}
|
||||
|
||||
return r;
|
||||
},
|
||||
calculateCaretPosition: function(oldVal) {
|
||||
var newVal = p.getMasked(),
|
||||
caretPosNew = p.getCaret();
|
||||
if (oldVal !== newVal) {
|
||||
var caretPosOld = el.data('mask-previus-caret-pos') || 0,
|
||||
newValL = newVal.length,
|
||||
oldValL = oldVal.length,
|
||||
maskDigitsBeforeCaret = 0,
|
||||
maskDigitsAfterCaret = 0,
|
||||
maskDigitsBeforeCaretAll = 0,
|
||||
maskDigitsBeforeCaretAllOld = 0,
|
||||
i = 0;
|
||||
|
||||
for (i = caretPosNew; i < newValL; i++) {
|
||||
if (!p.maskDigitPosMap[i]) {
|
||||
break;
|
||||
}
|
||||
maskDigitsAfterCaret++;
|
||||
}
|
||||
|
||||
for (i = caretPosNew - 1; i >= 0; i--) {
|
||||
if (!p.maskDigitPosMap[i]) {
|
||||
break;
|
||||
}
|
||||
maskDigitsBeforeCaret++;
|
||||
}
|
||||
|
||||
for (i = caretPosNew - 1; i >= 0; i--) {
|
||||
if (p.maskDigitPosMap[i]) {
|
||||
maskDigitsBeforeCaretAll++;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = caretPosOld - 1; i >= 0; i--) {
|
||||
if (p.maskDigitPosMapOld[i]) {
|
||||
maskDigitsBeforeCaretAllOld++;
|
||||
}
|
||||
}
|
||||
|
||||
// if the cursor is at the end keep it there
|
||||
if (caretPosNew > oldValL) {
|
||||
caretPosNew = newValL * 10;
|
||||
} else if (caretPosOld >= caretPosNew && caretPosOld !== oldValL) {
|
||||
if (!p.maskDigitPosMapOld[caretPosNew]) {
|
||||
var caretPos = caretPosNew;
|
||||
caretPosNew -= maskDigitsBeforeCaretAllOld - maskDigitsBeforeCaretAll;
|
||||
caretPosNew -= maskDigitsBeforeCaret;
|
||||
if (p.maskDigitPosMap[caretPosNew]) {
|
||||
caretPosNew = caretPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (caretPosNew > caretPosOld) {
|
||||
caretPosNew += maskDigitsBeforeCaretAll - maskDigitsBeforeCaretAllOld;
|
||||
caretPosNew += maskDigitsAfterCaret;
|
||||
}
|
||||
}
|
||||
return caretPosNew;
|
||||
},
|
||||
behaviour: function(e) {
|
||||
e = e || window.event;
|
||||
p.invalid = [];
|
||||
|
||||
var keyCode = el.data('mask-keycode');
|
||||
|
||||
if ($.inArray(keyCode, jMask.byPassKeys) === -1) {
|
||||
var newVal = p.getMasked(),
|
||||
caretPos = p.getCaret(),
|
||||
oldVal = el.data('mask-previus-value') || '';
|
||||
|
||||
// this is a compensation to devices/browsers that don't compensate
|
||||
// caret positioning the right way
|
||||
setTimeout(function() {
|
||||
p.setCaret(p.calculateCaretPosition(oldVal));
|
||||
}, $.jMaskGlobals.keyStrokeCompensation);
|
||||
|
||||
p.val(newVal);
|
||||
p.setCaret(caretPos);
|
||||
return p.callbacks(e);
|
||||
}
|
||||
},
|
||||
getMasked: function(skipMaskChars, val) {
|
||||
var buf = [],
|
||||
value = val === undefined ? p.val() : val + '',
|
||||
m = 0, maskLen = mask.length,
|
||||
v = 0, valLen = value.length,
|
||||
offset = 1, addMethod = 'push',
|
||||
resetPos = -1,
|
||||
maskDigitCount = 0,
|
||||
maskDigitPosArr = [],
|
||||
lastMaskChar,
|
||||
check;
|
||||
|
||||
if (options.reverse) {
|
||||
addMethod = 'unshift';
|
||||
offset = -1;
|
||||
lastMaskChar = 0;
|
||||
m = maskLen - 1;
|
||||
v = valLen - 1;
|
||||
check = function () {
|
||||
return m > -1 && v > -1;
|
||||
};
|
||||
} else {
|
||||
lastMaskChar = maskLen - 1;
|
||||
check = function () {
|
||||
return m < maskLen && v < valLen;
|
||||
};
|
||||
}
|
||||
|
||||
var lastUntranslatedMaskChar;
|
||||
while (check()) {
|
||||
var maskDigit = mask.charAt(m),
|
||||
valDigit = value.charAt(v),
|
||||
translation = jMask.translation[maskDigit];
|
||||
|
||||
if (translation) {
|
||||
if (valDigit.match(translation.pattern)) {
|
||||
buf[addMethod](valDigit);
|
||||
if (translation.recursive) {
|
||||
if (resetPos === -1) {
|
||||
resetPos = m;
|
||||
} else if (m === lastMaskChar && m !== resetPos) {
|
||||
m = resetPos - offset;
|
||||
}
|
||||
|
||||
if (lastMaskChar === resetPos) {
|
||||
m -= offset;
|
||||
}
|
||||
}
|
||||
m += offset;
|
||||
} else if (valDigit === lastUntranslatedMaskChar) {
|
||||
// matched the last untranslated (raw) mask character that we encountered
|
||||
// likely an insert offset the mask character from the last entry; fall
|
||||
// through and only increment v
|
||||
maskDigitCount--;
|
||||
lastUntranslatedMaskChar = undefined;
|
||||
} else if (translation.optional) {
|
||||
m += offset;
|
||||
v -= offset;
|
||||
} else if (translation.fallback) {
|
||||
buf[addMethod](translation.fallback);
|
||||
m += offset;
|
||||
v -= offset;
|
||||
} else {
|
||||
p.invalid.push({p: v, v: valDigit, e: translation.pattern});
|
||||
}
|
||||
v += offset;
|
||||
} else {
|
||||
if (!skipMaskChars) {
|
||||
buf[addMethod](maskDigit);
|
||||
}
|
||||
|
||||
if (valDigit === maskDigit) {
|
||||
maskDigitPosArr.push(v);
|
||||
v += offset;
|
||||
} else {
|
||||
lastUntranslatedMaskChar = maskDigit;
|
||||
maskDigitPosArr.push(v + maskDigitCount);
|
||||
maskDigitCount++;
|
||||
}
|
||||
|
||||
m += offset;
|
||||
}
|
||||
}
|
||||
|
||||
var lastMaskCharDigit = mask.charAt(lastMaskChar);
|
||||
if (maskLen === valLen + 1 && !jMask.translation[lastMaskCharDigit]) {
|
||||
buf.push(lastMaskCharDigit);
|
||||
}
|
||||
|
||||
var newVal = buf.join('');
|
||||
p.mapMaskdigitPositions(newVal, maskDigitPosArr, valLen);
|
||||
return newVal;
|
||||
},
|
||||
mapMaskdigitPositions: function(newVal, maskDigitPosArr, valLen) {
|
||||
var maskDiff = options.reverse ? newVal.length - valLen : 0;
|
||||
p.maskDigitPosMap = {};
|
||||
for (var i = 0; i < maskDigitPosArr.length; i++) {
|
||||
p.maskDigitPosMap[maskDigitPosArr[i] + maskDiff] = 1;
|
||||
}
|
||||
},
|
||||
callbacks: function (e) {
|
||||
var val = p.val(),
|
||||
changed = val !== oldValue,
|
||||
defaultArgs = [val, e, el, options],
|
||||
callback = function(name, criteria, args) {
|
||||
if (typeof options[name] === 'function' && criteria) {
|
||||
options[name].apply(this, args);
|
||||
}
|
||||
};
|
||||
|
||||
callback('onChange', changed === true, defaultArgs);
|
||||
callback('onKeyPress', changed === true, defaultArgs);
|
||||
callback('onComplete', val.length === mask.length, defaultArgs);
|
||||
callback('onInvalid', p.invalid.length > 0, [val, e, el, p.invalid, options]);
|
||||
}
|
||||
};
|
||||
|
||||
el = $(el);
|
||||
var jMask = this, oldValue = p.val(), regexMask;
|
||||
|
||||
mask = typeof mask === 'function' ? mask(p.val(), undefined, el, options) : mask;
|
||||
|
||||
// public methods
|
||||
jMask.mask = mask;
|
||||
jMask.options = options;
|
||||
jMask.remove = function() {
|
||||
var caret = p.getCaret();
|
||||
if (jMask.options.placeholder) {
|
||||
el.removeAttr('placeholder');
|
||||
}
|
||||
if (el.data('mask-maxlength')) {
|
||||
el.removeAttr('maxlength');
|
||||
}
|
||||
p.destroyEvents();
|
||||
p.val(jMask.getCleanVal());
|
||||
p.setCaret(caret);
|
||||
return el;
|
||||
};
|
||||
|
||||
// get value without mask
|
||||
jMask.getCleanVal = function() {
|
||||
return p.getMasked(true);
|
||||
};
|
||||
|
||||
// get masked value without the value being in the input or element
|
||||
jMask.getMaskedVal = function(val) {
|
||||
return p.getMasked(false, val);
|
||||
};
|
||||
|
||||
jMask.init = function(onlyMask) {
|
||||
onlyMask = onlyMask || false;
|
||||
options = options || {};
|
||||
|
||||
jMask.clearIfNotMatch = $.jMaskGlobals.clearIfNotMatch;
|
||||
jMask.byPassKeys = $.jMaskGlobals.byPassKeys;
|
||||
jMask.translation = $.extend({}, $.jMaskGlobals.translation, options.translation);
|
||||
|
||||
jMask = $.extend(true, {}, jMask, options);
|
||||
|
||||
regexMask = p.getRegexMask();
|
||||
|
||||
if (onlyMask) {
|
||||
p.events();
|
||||
p.val(p.getMasked());
|
||||
} else {
|
||||
if (options.placeholder) {
|
||||
el.attr('placeholder' , options.placeholder);
|
||||
}
|
||||
|
||||
// this is necessary, otherwise if the user submit the form
|
||||
// and then press the "back" button, the autocomplete will erase
|
||||
// the data. Works fine on IE9+, FF, Opera, Safari.
|
||||
if (el.data('mask')) {
|
||||
el.attr('autocomplete', 'off');
|
||||
}
|
||||
|
||||
// detect if is necessary let the user type freely.
|
||||
// for is a lot faster than forEach.
|
||||
for (var i = 0, maxlength = true; i < mask.length; i++) {
|
||||
var translation = jMask.translation[mask.charAt(i)];
|
||||
if (translation && translation.recursive) {
|
||||
maxlength = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxlength) {
|
||||
el.attr('maxlength', mask.length).data('mask-maxlength', true);
|
||||
}
|
||||
|
||||
p.destroyEvents();
|
||||
p.events();
|
||||
|
||||
var caret = p.getCaret();
|
||||
p.val(p.getMasked());
|
||||
p.setCaret(caret);
|
||||
}
|
||||
};
|
||||
|
||||
jMask.init(!el.is('input'));
|
||||
};
|
||||
|
||||
$.maskWatchers = {};
|
||||
var HTMLAttributes = function () {
|
||||
var input = $(this),
|
||||
options = {},
|
||||
prefix = 'data-mask-',
|
||||
mask = input.attr('data-mask');
|
||||
|
||||
if (input.attr(prefix + 'reverse')) {
|
||||
options.reverse = true;
|
||||
}
|
||||
|
||||
if (input.attr(prefix + 'clearifnotmatch')) {
|
||||
options.clearIfNotMatch = true;
|
||||
}
|
||||
|
||||
if (input.attr(prefix + 'selectonfocus') === 'true') {
|
||||
options.selectOnFocus = true;
|
||||
}
|
||||
|
||||
if (notSameMaskObject(input, mask, options)) {
|
||||
return input.data('mask', new Mask(this, mask, options));
|
||||
}
|
||||
},
|
||||
notSameMaskObject = function(field, mask, options) {
|
||||
options = options || {};
|
||||
var maskObject = $(field).data('mask'),
|
||||
stringify = JSON.stringify,
|
||||
value = $(field).val() || $(field).text();
|
||||
try {
|
||||
if (typeof mask === 'function') {
|
||||
mask = mask(value);
|
||||
}
|
||||
return typeof maskObject !== 'object' || stringify(maskObject.options) !== stringify(options) || maskObject.mask !== mask;
|
||||
} catch (e) {}
|
||||
},
|
||||
eventSupported = function(eventName) {
|
||||
var el = document.createElement('div'), isSupported;
|
||||
|
||||
eventName = 'on' + eventName;
|
||||
isSupported = (eventName in el);
|
||||
|
||||
if ( !isSupported ) {
|
||||
el.setAttribute(eventName, 'return;');
|
||||
isSupported = typeof el[eventName] === 'function';
|
||||
}
|
||||
el = null;
|
||||
|
||||
return isSupported;
|
||||
};
|
||||
|
||||
$.fn.mask = function(mask, options) {
|
||||
options = options || {};
|
||||
var selector = this.selector,
|
||||
globals = $.jMaskGlobals,
|
||||
interval = globals.watchInterval,
|
||||
watchInputs = options.watchInputs || globals.watchInputs,
|
||||
maskFunction = function() {
|
||||
if (notSameMaskObject(this, mask, options)) {
|
||||
return $(this).data('mask', new Mask(this, mask, options));
|
||||
}
|
||||
};
|
||||
|
||||
$(this).each(maskFunction);
|
||||
|
||||
if (selector && selector !== '' && watchInputs) {
|
||||
clearInterval($.maskWatchers[selector]);
|
||||
$.maskWatchers[selector] = setInterval(function(){
|
||||
$(document).find(selector).each(maskFunction);
|
||||
}, interval);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
$.fn.masked = function(val) {
|
||||
return this.data('mask').getMaskedVal(val);
|
||||
};
|
||||
|
||||
$.fn.unmask = function() {
|
||||
clearInterval($.maskWatchers[this.selector]);
|
||||
delete $.maskWatchers[this.selector];
|
||||
return this.each(function() {
|
||||
var dataMask = $(this).data('mask');
|
||||
if (dataMask) {
|
||||
dataMask.remove().removeData('mask');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.cleanVal = function() {
|
||||
return this.data('mask').getCleanVal();
|
||||
};
|
||||
|
||||
$.applyDataMask = function(selector) {
|
||||
selector = selector || $.jMaskGlobals.maskElements;
|
||||
var $selector = (selector instanceof $) ? selector : $(selector);
|
||||
$selector.filter($.jMaskGlobals.dataMaskAttr).each(HTMLAttributes);
|
||||
};
|
||||
|
||||
var globals = {
|
||||
maskElements: 'input,td,span,div',
|
||||
dataMaskAttr: '*[data-mask]',
|
||||
dataMask: true,
|
||||
watchInterval: 300,
|
||||
watchInputs: true,
|
||||
keyStrokeCompensation: 10,
|
||||
// old versions of chrome dont work great with input event
|
||||
useInput: !/Chrome\/[2-4][0-9]|SamsungBrowser/.test(window.navigator.userAgent) && eventSupported('input'),
|
||||
watchDataMask: false,
|
||||
byPassKeys: [9, 16, 17, 18, 36, 37, 38, 39, 40, 91],
|
||||
translation: {
|
||||
'0': {pattern: /\d/},
|
||||
'9': {pattern: /\d/, optional: true},
|
||||
'#': {pattern: /\d/, recursive: true},
|
||||
'A': {pattern: /[a-zA-Z0-9]/},
|
||||
'S': {pattern: /[a-zA-Z]/}
|
||||
}
|
||||
};
|
||||
|
||||
$.jMaskGlobals = $.jMaskGlobals || {};
|
||||
globals = $.jMaskGlobals = $.extend(true, {}, globals, $.jMaskGlobals);
|
||||
|
||||
// looking for inputs with data-mask attribute
|
||||
if (globals.dataMask) {
|
||||
$.applyDataMask();
|
||||
}
|
||||
|
||||
setInterval(function() {
|
||||
if ($.jMaskGlobals.watchDataMask) {
|
||||
$.applyDataMask();
|
||||
}
|
||||
}, globals.watchInterval);
|
||||
}, window.jQuery, window.Zepto));
|
||||
@@ -0,0 +1,19 @@
|
||||
// jQuery Mask Plugin v1.14.16
|
||||
// github.com/igorescobar/jQuery-Mask-Plugin
|
||||
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,n,f){a instanceof String&&(a=String(a));for(var p=a.length,k=0;k<p;k++){var b=a[k];if(n.call(f,b,k,a))return{i:k,v:b}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
|
||||
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,n,f){a!=Array.prototype&&a!=Object.prototype&&(a[n]=f.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
|
||||
$jscomp.polyfill=function(a,n,f,p){if(n){f=$jscomp.global;a=a.split(".");for(p=0;p<a.length-1;p++){var k=a[p];k in f||(f[k]={});f=f[k]}a=a[a.length-1];p=f[a];n=n(p);n!=p&&null!=n&&$jscomp.defineProperty(f,a,{configurable:!0,writable:!0,value:n})}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,f){return $jscomp.findInternal(this,a,f).v}},"es6","es3");
|
||||
(function(a,n,f){"function"===typeof define&&define.amd?define(["jquery"],a):"object"===typeof exports&&"undefined"===typeof Meteor?module.exports=a(require("jquery")):a(n||f)})(function(a){var n=function(b,d,e){var c={invalid:[],getCaret:function(){try{var a=0,r=b.get(0),h=document.selection,d=r.selectionStart;if(h&&-1===navigator.appVersion.indexOf("MSIE 10")){var e=h.createRange();e.moveStart("character",-c.val().length);a=e.text.length}else if(d||"0"===d)a=d;return a}catch(C){}},setCaret:function(a){try{if(b.is(":focus")){var c=
|
||||
b.get(0);if(c.setSelectionRange)c.setSelectionRange(a,a);else{var g=c.createTextRange();g.collapse(!0);g.moveEnd("character",a);g.moveStart("character",a);g.select()}}}catch(B){}},events:function(){b.on("keydown.mask",function(a){b.data("mask-keycode",a.keyCode||a.which);b.data("mask-previus-value",b.val());b.data("mask-previus-caret-pos",c.getCaret());c.maskDigitPosMapOld=c.maskDigitPosMap}).on(a.jMaskGlobals.useInput?"input.mask":"keyup.mask",c.behaviour).on("paste.mask drop.mask",function(){setTimeout(function(){b.keydown().keyup()},
|
||||
100)}).on("change.mask",function(){b.data("changed",!0)}).on("blur.mask",function(){f===c.val()||b.data("changed")||b.trigger("change");b.data("changed",!1)}).on("blur.mask",function(){f=c.val()}).on("focus.mask",function(b){!0===e.selectOnFocus&&a(b.target).select()}).on("focusout.mask",function(){e.clearIfNotMatch&&!k.test(c.val())&&c.val("")})},getRegexMask:function(){for(var a=[],b,c,e,t,f=0;f<d.length;f++)(b=l.translation[d.charAt(f)])?(c=b.pattern.toString().replace(/.{1}$|^.{1}/g,""),e=b.optional,
|
||||
(b=b.recursive)?(a.push(d.charAt(f)),t={digit:d.charAt(f),pattern:c}):a.push(e||b?c+"?":c)):a.push(d.charAt(f).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"));a=a.join("");t&&(a=a.replace(new RegExp("("+t.digit+"(.*"+t.digit+")?)"),"($1)?").replace(new RegExp(t.digit,"g"),t.pattern));return new RegExp(a)},destroyEvents:function(){b.off("input keydown keyup paste drop blur focusout ".split(" ").join(".mask "))},val:function(a){var c=b.is("input")?"val":"text";if(0<arguments.length){if(b[c]()!==a)b[c](a);
|
||||
c=b}else c=b[c]();return c},calculateCaretPosition:function(a){var d=c.getMasked(),h=c.getCaret();if(a!==d){var e=b.data("mask-previus-caret-pos")||0;d=d.length;var g=a.length,f=a=0,l=0,k=0,m;for(m=h;m<d&&c.maskDigitPosMap[m];m++)f++;for(m=h-1;0<=m&&c.maskDigitPosMap[m];m--)a++;for(m=h-1;0<=m;m--)c.maskDigitPosMap[m]&&l++;for(m=e-1;0<=m;m--)c.maskDigitPosMapOld[m]&&k++;h>g?h=10*d:e>=h&&e!==g?c.maskDigitPosMapOld[h]||(e=h,h=h-(k-l)-a,c.maskDigitPosMap[h]&&(h=e)):h>e&&(h=h+(l-k)+f)}return h},behaviour:function(d){d=
|
||||
d||window.event;c.invalid=[];var e=b.data("mask-keycode");if(-1===a.inArray(e,l.byPassKeys)){e=c.getMasked();var h=c.getCaret(),g=b.data("mask-previus-value")||"";setTimeout(function(){c.setCaret(c.calculateCaretPosition(g))},a.jMaskGlobals.keyStrokeCompensation);c.val(e);c.setCaret(h);return c.callbacks(d)}},getMasked:function(a,b){var h=[],f=void 0===b?c.val():b+"",g=0,k=d.length,n=0,p=f.length,m=1,r="push",u=-1,w=0;b=[];if(e.reverse){r="unshift";m=-1;var x=0;g=k-1;n=p-1;var A=function(){return-1<
|
||||
g&&-1<n}}else x=k-1,A=function(){return g<k&&n<p};for(var z;A();){var y=d.charAt(g),v=f.charAt(n),q=l.translation[y];if(q)v.match(q.pattern)?(h[r](v),q.recursive&&(-1===u?u=g:g===x&&g!==u&&(g=u-m),x===u&&(g-=m)),g+=m):v===z?(w--,z=void 0):q.optional?(g+=m,n-=m):q.fallback?(h[r](q.fallback),g+=m,n-=m):c.invalid.push({p:n,v:v,e:q.pattern}),n+=m;else{if(!a)h[r](y);v===y?(b.push(n),n+=m):(z=y,b.push(n+w),w++);g+=m}}a=d.charAt(x);k!==p+1||l.translation[a]||h.push(a);h=h.join("");c.mapMaskdigitPositions(h,
|
||||
b,p);return h},mapMaskdigitPositions:function(a,b,d){a=e.reverse?a.length-d:0;c.maskDigitPosMap={};for(d=0;d<b.length;d++)c.maskDigitPosMap[b[d]+a]=1},callbacks:function(a){var g=c.val(),h=g!==f,k=[g,a,b,e],l=function(a,b,c){"function"===typeof e[a]&&b&&e[a].apply(this,c)};l("onChange",!0===h,k);l("onKeyPress",!0===h,k);l("onComplete",g.length===d.length,k);l("onInvalid",0<c.invalid.length,[g,a,b,c.invalid,e])}};b=a(b);var l=this,f=c.val(),k;d="function"===typeof d?d(c.val(),void 0,b,e):d;l.mask=
|
||||
d;l.options=e;l.remove=function(){var a=c.getCaret();l.options.placeholder&&b.removeAttr("placeholder");b.data("mask-maxlength")&&b.removeAttr("maxlength");c.destroyEvents();c.val(l.getCleanVal());c.setCaret(a);return b};l.getCleanVal=function(){return c.getMasked(!0)};l.getMaskedVal=function(a){return c.getMasked(!1,a)};l.init=function(g){g=g||!1;e=e||{};l.clearIfNotMatch=a.jMaskGlobals.clearIfNotMatch;l.byPassKeys=a.jMaskGlobals.byPassKeys;l.translation=a.extend({},a.jMaskGlobals.translation,e.translation);
|
||||
l=a.extend(!0,{},l,e);k=c.getRegexMask();if(g)c.events(),c.val(c.getMasked());else{e.placeholder&&b.attr("placeholder",e.placeholder);b.data("mask")&&b.attr("autocomplete","off");g=0;for(var f=!0;g<d.length;g++){var h=l.translation[d.charAt(g)];if(h&&h.recursive){f=!1;break}}f&&b.attr("maxlength",d.length).data("mask-maxlength",!0);c.destroyEvents();c.events();g=c.getCaret();c.val(c.getMasked());c.setCaret(g)}};l.init(!b.is("input"))};a.maskWatchers={};var f=function(){var b=a(this),d={},e=b.attr("data-mask");
|
||||
b.attr("data-mask-reverse")&&(d.reverse=!0);b.attr("data-mask-clearifnotmatch")&&(d.clearIfNotMatch=!0);"true"===b.attr("data-mask-selectonfocus")&&(d.selectOnFocus=!0);if(p(b,e,d))return b.data("mask",new n(this,e,d))},p=function(b,d,e){e=e||{};var c=a(b).data("mask"),f=JSON.stringify;b=a(b).val()||a(b).text();try{return"function"===typeof d&&(d=d(b)),"object"!==typeof c||f(c.options)!==f(e)||c.mask!==d}catch(w){}},k=function(a){var b=document.createElement("div");a="on"+a;var e=a in b;e||(b.setAttribute(a,
|
||||
"return;"),e="function"===typeof b[a]);return e};a.fn.mask=function(b,d){d=d||{};var e=this.selector,c=a.jMaskGlobals,f=c.watchInterval;c=d.watchInputs||c.watchInputs;var k=function(){if(p(this,b,d))return a(this).data("mask",new n(this,b,d))};a(this).each(k);e&&""!==e&&c&&(clearInterval(a.maskWatchers[e]),a.maskWatchers[e]=setInterval(function(){a(document).find(e).each(k)},f));return this};a.fn.masked=function(a){return this.data("mask").getMaskedVal(a)};a.fn.unmask=function(){clearInterval(a.maskWatchers[this.selector]);
|
||||
delete a.maskWatchers[this.selector];return this.each(function(){var b=a(this).data("mask");b&&b.remove().removeData("mask")})};a.fn.cleanVal=function(){return this.data("mask").getCleanVal()};a.applyDataMask=function(b){b=b||a.jMaskGlobals.maskElements;(b instanceof a?b:a(b)).filter(a.jMaskGlobals.dataMaskAttr).each(f)};k={maskElements:"input,td,span,div",dataMaskAttr:"*[data-mask]",dataMask:!0,watchInterval:300,watchInputs:!0,keyStrokeCompensation:10,useInput:!/Chrome\/[2-4][0-9]|SamsungBrowser/.test(window.navigator.userAgent)&&
|
||||
k("input"),watchDataMask:!1,byPassKeys:[9,16,17,18,36,37,38,39,40,91],translation:{0:{pattern:/\d/},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,recursive:!0},A:{pattern:/[a-zA-Z0-9]/},S:{pattern:/[a-zA-Z]/}}};a.jMaskGlobals=a.jMaskGlobals||{};k=a.jMaskGlobals=a.extend(!0,{},k,a.jMaskGlobals);k.dataMask&&a.applyDataMask();setInterval(function(){a.jMaskGlobals.watchDataMask&&a.applyDataMask()},k.watchInterval)},window.jQuery,window.Zepto);
|
||||
@@ -0,0 +1,4 @@
|
||||
web:
|
||||
build: .
|
||||
volumes:
|
||||
- ./:/app/jquery-mask-plugin
|
||||
+2351
File diff suppressed because it is too large
Load Diff
+14
@@ -0,0 +1,14 @@
|
||||
Package.describe({
|
||||
"name": "igorescobar:jquery-mask-plugin",
|
||||
"version": "1.14.16",
|
||||
"summary": "A jQuery Plugin to make masks on form fields and HTML elements.",
|
||||
"git": "git@github.com:igorescobar/jQuery-Mask-Plugin.git",
|
||||
"documentation": "README.md"
|
||||
});
|
||||
|
||||
Package.onUse(function(api) {
|
||||
api.versionsFrom('1.2.1');
|
||||
api.use('ecmascript');
|
||||
api.addFiles('dist/jquery.mask.js', 'client');
|
||||
api.addFiles('dist/jquery.mask.min.js', 'client');
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "jquery-mask-plugin",
|
||||
"version": "1.14.16",
|
||||
"description": "A jQuery Plugin to make masks on form fields and html elements.",
|
||||
"author": "Igor Escobar <blog@igorescobar.com>",
|
||||
"homepage": "http://igorescobar.github.io/jQuery-Mask-Plugin/",
|
||||
"main": "./dist/jquery.mask.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/igorescobar/jQuery-Mask-Plugin"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/igorescobar/jQuery-Mask-Plugin/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"mask",
|
||||
"masks",
|
||||
"form",
|
||||
"input",
|
||||
"jquery-plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-connect": "*",
|
||||
"grunt-contrib-jshint": "^0.11.0",
|
||||
"grunt-contrib-qunit": "*",
|
||||
"grunt-contrib-uglify": "*",
|
||||
"jshint-stylish": "^1.0.0",
|
||||
"load-grunt-tasks": "^3.1.0",
|
||||
"time-grunt": "^1.0.0",
|
||||
"request": "2.81.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,604 @@
|
||||
/**
|
||||
* jquery.mask.js
|
||||
* @version: v1.14.16
|
||||
* @author: Igor Escobar
|
||||
*
|
||||
* Created by Igor Escobar on 2012-03-10. Please report any bug at github.com/igorescobar/jQuery-Mask-Plugin
|
||||
*
|
||||
* Copyright (c) 2012 Igor Escobar http://igorescobar.com
|
||||
*
|
||||
* The MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* jshint laxbreak: true */
|
||||
/* jshint maxcomplexity:17 */
|
||||
/* global define */
|
||||
|
||||
// UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.
|
||||
// https://github.com/umdjs/umd/blob/master/templates/jqueryPlugin.js
|
||||
(function (factory, jQuery, Zepto) {
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object' && typeof Meteor === 'undefined') {
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
factory(jQuery || Zepto);
|
||||
}
|
||||
|
||||
}(function ($) {
|
||||
'use strict';
|
||||
|
||||
var Mask = function (el, mask, options) {
|
||||
|
||||
var p = {
|
||||
invalid: [],
|
||||
getCaret: function () {
|
||||
try {
|
||||
var sel,
|
||||
pos = 0,
|
||||
ctrl = el.get(0),
|
||||
dSel = document.selection,
|
||||
cSelStart = ctrl.selectionStart;
|
||||
|
||||
// IE Support
|
||||
if (dSel && navigator.appVersion.indexOf('MSIE 10') === -1) {
|
||||
sel = dSel.createRange();
|
||||
sel.moveStart('character', -p.val().length);
|
||||
pos = sel.text.length;
|
||||
}
|
||||
// Firefox support
|
||||
else if (cSelStart || cSelStart === '0') {
|
||||
pos = cSelStart;
|
||||
}
|
||||
|
||||
return pos;
|
||||
} catch (e) {}
|
||||
},
|
||||
setCaret: function(pos) {
|
||||
try {
|
||||
if (el.is(':focus')) {
|
||||
var range, ctrl = el.get(0);
|
||||
|
||||
// Firefox, WebKit, etc..
|
||||
if (ctrl.setSelectionRange) {
|
||||
ctrl.setSelectionRange(pos, pos);
|
||||
} else { // IE
|
||||
range = ctrl.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', pos);
|
||||
range.moveStart('character', pos);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
},
|
||||
events: function() {
|
||||
el
|
||||
.on('keydown.mask', function(e) {
|
||||
el.data('mask-keycode', e.keyCode || e.which);
|
||||
el.data('mask-previus-value', el.val());
|
||||
el.data('mask-previus-caret-pos', p.getCaret());
|
||||
p.maskDigitPosMapOld = p.maskDigitPosMap;
|
||||
})
|
||||
.on($.jMaskGlobals.useInput ? 'input.mask' : 'keyup.mask', p.behaviour)
|
||||
.on('paste.mask drop.mask', function() {
|
||||
setTimeout(function() {
|
||||
el.keydown().keyup();
|
||||
}, 100);
|
||||
})
|
||||
.on('change.mask', function(){
|
||||
el.data('changed', true);
|
||||
})
|
||||
.on('blur.mask', function(){
|
||||
if (oldValue !== p.val() && !el.data('changed')) {
|
||||
el.trigger('change');
|
||||
}
|
||||
el.data('changed', false);
|
||||
})
|
||||
// it's very important that this callback remains in this position
|
||||
// otherwhise oldValue it's going to work buggy
|
||||
.on('blur.mask', function() {
|
||||
oldValue = p.val();
|
||||
})
|
||||
// select all text on focus
|
||||
.on('focus.mask', function (e) {
|
||||
if (options.selectOnFocus === true) {
|
||||
$(e.target).select();
|
||||
}
|
||||
})
|
||||
// clear the value if it not complete the mask
|
||||
.on('focusout.mask', function() {
|
||||
if (options.clearIfNotMatch && !regexMask.test(p.val())) {
|
||||
p.val('');
|
||||
}
|
||||
});
|
||||
},
|
||||
getRegexMask: function() {
|
||||
var maskChunks = [], translation, pattern, optional, recursive, oRecursive, r;
|
||||
|
||||
for (var i = 0; i < mask.length; i++) {
|
||||
translation = jMask.translation[mask.charAt(i)];
|
||||
|
||||
if (translation) {
|
||||
|
||||
pattern = translation.pattern.toString().replace(/.{1}$|^.{1}/g, '');
|
||||
optional = translation.optional;
|
||||
recursive = translation.recursive;
|
||||
|
||||
if (recursive) {
|
||||
maskChunks.push(mask.charAt(i));
|
||||
oRecursive = {digit: mask.charAt(i), pattern: pattern};
|
||||
} else {
|
||||
maskChunks.push(!optional && !recursive ? pattern : (pattern + '?'));
|
||||
}
|
||||
|
||||
} else {
|
||||
maskChunks.push(mask.charAt(i).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
|
||||
}
|
||||
}
|
||||
|
||||
r = maskChunks.join('');
|
||||
|
||||
if (oRecursive) {
|
||||
r = r.replace(new RegExp('(' + oRecursive.digit + '(.*' + oRecursive.digit + ')?)'), '($1)?')
|
||||
.replace(new RegExp(oRecursive.digit, 'g'), oRecursive.pattern);
|
||||
}
|
||||
|
||||
return new RegExp(r);
|
||||
},
|
||||
destroyEvents: function() {
|
||||
el.off(['input', 'keydown', 'keyup', 'paste', 'drop', 'blur', 'focusout', ''].join('.mask '));
|
||||
},
|
||||
val: function(v) {
|
||||
var isInput = el.is('input'),
|
||||
method = isInput ? 'val' : 'text',
|
||||
r;
|
||||
|
||||
if (arguments.length > 0) {
|
||||
if (el[method]() !== v) {
|
||||
el[method](v);
|
||||
}
|
||||
r = el;
|
||||
} else {
|
||||
r = el[method]();
|
||||
}
|
||||
|
||||
return r;
|
||||
},
|
||||
calculateCaretPosition: function(oldVal) {
|
||||
var newVal = p.getMasked(),
|
||||
caretPosNew = p.getCaret();
|
||||
if (oldVal !== newVal) {
|
||||
var caretPosOld = el.data('mask-previus-caret-pos') || 0,
|
||||
newValL = newVal.length,
|
||||
oldValL = oldVal.length,
|
||||
maskDigitsBeforeCaret = 0,
|
||||
maskDigitsAfterCaret = 0,
|
||||
maskDigitsBeforeCaretAll = 0,
|
||||
maskDigitsBeforeCaretAllOld = 0,
|
||||
i = 0;
|
||||
|
||||
for (i = caretPosNew; i < newValL; i++) {
|
||||
if (!p.maskDigitPosMap[i]) {
|
||||
break;
|
||||
}
|
||||
maskDigitsAfterCaret++;
|
||||
}
|
||||
|
||||
for (i = caretPosNew - 1; i >= 0; i--) {
|
||||
if (!p.maskDigitPosMap[i]) {
|
||||
break;
|
||||
}
|
||||
maskDigitsBeforeCaret++;
|
||||
}
|
||||
|
||||
for (i = caretPosNew - 1; i >= 0; i--) {
|
||||
if (p.maskDigitPosMap[i]) {
|
||||
maskDigitsBeforeCaretAll++;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = caretPosOld - 1; i >= 0; i--) {
|
||||
if (p.maskDigitPosMapOld[i]) {
|
||||
maskDigitsBeforeCaretAllOld++;
|
||||
}
|
||||
}
|
||||
|
||||
// if the cursor is at the end keep it there
|
||||
if (caretPosNew > oldValL) {
|
||||
caretPosNew = newValL * 10;
|
||||
} else if (caretPosOld >= caretPosNew && caretPosOld !== oldValL) {
|
||||
if (!p.maskDigitPosMapOld[caretPosNew]) {
|
||||
var caretPos = caretPosNew;
|
||||
caretPosNew -= maskDigitsBeforeCaretAllOld - maskDigitsBeforeCaretAll;
|
||||
caretPosNew -= maskDigitsBeforeCaret;
|
||||
if (p.maskDigitPosMap[caretPosNew]) {
|
||||
caretPosNew = caretPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (caretPosNew > caretPosOld) {
|
||||
caretPosNew += maskDigitsBeforeCaretAll - maskDigitsBeforeCaretAllOld;
|
||||
caretPosNew += maskDigitsAfterCaret;
|
||||
}
|
||||
}
|
||||
return caretPosNew;
|
||||
},
|
||||
behaviour: function(e) {
|
||||
e = e || window.event;
|
||||
p.invalid = [];
|
||||
|
||||
var keyCode = el.data('mask-keycode');
|
||||
|
||||
if ($.inArray(keyCode, jMask.byPassKeys) === -1) {
|
||||
var newVal = p.getMasked(),
|
||||
caretPos = p.getCaret(),
|
||||
oldVal = el.data('mask-previus-value') || '';
|
||||
|
||||
// this is a compensation to devices/browsers that don't compensate
|
||||
// caret positioning the right way
|
||||
setTimeout(function() {
|
||||
p.setCaret(p.calculateCaretPosition(oldVal));
|
||||
}, $.jMaskGlobals.keyStrokeCompensation);
|
||||
|
||||
p.val(newVal);
|
||||
p.setCaret(caretPos);
|
||||
return p.callbacks(e);
|
||||
}
|
||||
},
|
||||
getMasked: function(skipMaskChars, val) {
|
||||
var buf = [],
|
||||
value = val === undefined ? p.val() : val + '',
|
||||
m = 0, maskLen = mask.length,
|
||||
v = 0, valLen = value.length,
|
||||
offset = 1, addMethod = 'push',
|
||||
resetPos = -1,
|
||||
maskDigitCount = 0,
|
||||
maskDigitPosArr = [],
|
||||
lastMaskChar,
|
||||
check;
|
||||
|
||||
if (options.reverse) {
|
||||
addMethod = 'unshift';
|
||||
offset = -1;
|
||||
lastMaskChar = 0;
|
||||
m = maskLen - 1;
|
||||
v = valLen - 1;
|
||||
check = function () {
|
||||
return m > -1 && v > -1;
|
||||
};
|
||||
} else {
|
||||
lastMaskChar = maskLen - 1;
|
||||
check = function () {
|
||||
return m < maskLen && v < valLen;
|
||||
};
|
||||
}
|
||||
|
||||
var lastUntranslatedMaskChar;
|
||||
while (check()) {
|
||||
var maskDigit = mask.charAt(m),
|
||||
valDigit = value.charAt(v),
|
||||
translation = jMask.translation[maskDigit];
|
||||
|
||||
if (translation) {
|
||||
if (valDigit.match(translation.pattern)) {
|
||||
buf[addMethod](valDigit);
|
||||
if (translation.recursive) {
|
||||
if (resetPos === -1) {
|
||||
resetPos = m;
|
||||
} else if (m === lastMaskChar && m !== resetPos) {
|
||||
m = resetPos - offset;
|
||||
}
|
||||
|
||||
if (lastMaskChar === resetPos) {
|
||||
m -= offset;
|
||||
}
|
||||
}
|
||||
m += offset;
|
||||
} else if (valDigit === lastUntranslatedMaskChar) {
|
||||
// matched the last untranslated (raw) mask character that we encountered
|
||||
// likely an insert offset the mask character from the last entry; fall
|
||||
// through and only increment v
|
||||
maskDigitCount--;
|
||||
lastUntranslatedMaskChar = undefined;
|
||||
} else if (translation.optional) {
|
||||
m += offset;
|
||||
v -= offset;
|
||||
} else if (translation.fallback) {
|
||||
buf[addMethod](translation.fallback);
|
||||
m += offset;
|
||||
v -= offset;
|
||||
} else {
|
||||
p.invalid.push({p: v, v: valDigit, e: translation.pattern});
|
||||
}
|
||||
v += offset;
|
||||
} else {
|
||||
if (!skipMaskChars) {
|
||||
buf[addMethod](maskDigit);
|
||||
}
|
||||
|
||||
if (valDigit === maskDigit) {
|
||||
maskDigitPosArr.push(v);
|
||||
v += offset;
|
||||
} else {
|
||||
lastUntranslatedMaskChar = maskDigit;
|
||||
maskDigitPosArr.push(v + maskDigitCount);
|
||||
maskDigitCount++;
|
||||
}
|
||||
|
||||
m += offset;
|
||||
}
|
||||
}
|
||||
|
||||
var lastMaskCharDigit = mask.charAt(lastMaskChar);
|
||||
if (maskLen === valLen + 1 && !jMask.translation[lastMaskCharDigit]) {
|
||||
buf.push(lastMaskCharDigit);
|
||||
}
|
||||
|
||||
var newVal = buf.join('');
|
||||
p.mapMaskdigitPositions(newVal, maskDigitPosArr, valLen);
|
||||
return newVal;
|
||||
},
|
||||
mapMaskdigitPositions: function(newVal, maskDigitPosArr, valLen) {
|
||||
var maskDiff = options.reverse ? newVal.length - valLen : 0;
|
||||
p.maskDigitPosMap = {};
|
||||
for (var i = 0; i < maskDigitPosArr.length; i++) {
|
||||
p.maskDigitPosMap[maskDigitPosArr[i] + maskDiff] = 1;
|
||||
}
|
||||
},
|
||||
callbacks: function (e) {
|
||||
var val = p.val(),
|
||||
changed = val !== oldValue,
|
||||
defaultArgs = [val, e, el, options],
|
||||
callback = function(name, criteria, args) {
|
||||
if (typeof options[name] === 'function' && criteria) {
|
||||
options[name].apply(this, args);
|
||||
}
|
||||
};
|
||||
|
||||
callback('onChange', changed === true, defaultArgs);
|
||||
callback('onKeyPress', changed === true, defaultArgs);
|
||||
callback('onComplete', val.length === mask.length, defaultArgs);
|
||||
callback('onInvalid', p.invalid.length > 0, [val, e, el, p.invalid, options]);
|
||||
}
|
||||
};
|
||||
|
||||
el = $(el);
|
||||
var jMask = this, oldValue = p.val(), regexMask;
|
||||
|
||||
mask = typeof mask === 'function' ? mask(p.val(), undefined, el, options) : mask;
|
||||
|
||||
// public methods
|
||||
jMask.mask = mask;
|
||||
jMask.options = options;
|
||||
jMask.remove = function() {
|
||||
var caret = p.getCaret();
|
||||
if (jMask.options.placeholder) {
|
||||
el.removeAttr('placeholder');
|
||||
}
|
||||
if (el.data('mask-maxlength')) {
|
||||
el.removeAttr('maxlength');
|
||||
}
|
||||
p.destroyEvents();
|
||||
p.val(jMask.getCleanVal());
|
||||
p.setCaret(caret);
|
||||
return el;
|
||||
};
|
||||
|
||||
// get value without mask
|
||||
jMask.getCleanVal = function() {
|
||||
return p.getMasked(true);
|
||||
};
|
||||
|
||||
// get masked value without the value being in the input or element
|
||||
jMask.getMaskedVal = function(val) {
|
||||
return p.getMasked(false, val);
|
||||
};
|
||||
|
||||
jMask.init = function(onlyMask) {
|
||||
onlyMask = onlyMask || false;
|
||||
options = options || {};
|
||||
|
||||
jMask.clearIfNotMatch = $.jMaskGlobals.clearIfNotMatch;
|
||||
jMask.byPassKeys = $.jMaskGlobals.byPassKeys;
|
||||
jMask.translation = $.extend({}, $.jMaskGlobals.translation, options.translation);
|
||||
|
||||
jMask = $.extend(true, {}, jMask, options);
|
||||
|
||||
regexMask = p.getRegexMask();
|
||||
|
||||
if (onlyMask) {
|
||||
p.events();
|
||||
p.val(p.getMasked());
|
||||
} else {
|
||||
if (options.placeholder) {
|
||||
el.attr('placeholder' , options.placeholder);
|
||||
}
|
||||
|
||||
// this is necessary, otherwise if the user submit the form
|
||||
// and then press the "back" button, the autocomplete will erase
|
||||
// the data. Works fine on IE9+, FF, Opera, Safari.
|
||||
if (el.data('mask')) {
|
||||
el.attr('autocomplete', 'off');
|
||||
}
|
||||
|
||||
// detect if is necessary let the user type freely.
|
||||
// for is a lot faster than forEach.
|
||||
for (var i = 0, maxlength = true; i < mask.length; i++) {
|
||||
var translation = jMask.translation[mask.charAt(i)];
|
||||
if (translation && translation.recursive) {
|
||||
maxlength = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxlength) {
|
||||
el.attr('maxlength', mask.length).data('mask-maxlength', true);
|
||||
}
|
||||
|
||||
p.destroyEvents();
|
||||
p.events();
|
||||
|
||||
var caret = p.getCaret();
|
||||
p.val(p.getMasked());
|
||||
p.setCaret(caret);
|
||||
}
|
||||
};
|
||||
|
||||
jMask.init(!el.is('input'));
|
||||
};
|
||||
|
||||
$.maskWatchers = {};
|
||||
var HTMLAttributes = function () {
|
||||
var input = $(this),
|
||||
options = {},
|
||||
prefix = 'data-mask-',
|
||||
mask = input.attr('data-mask');
|
||||
|
||||
if (input.attr(prefix + 'reverse')) {
|
||||
options.reverse = true;
|
||||
}
|
||||
|
||||
if (input.attr(prefix + 'clearifnotmatch')) {
|
||||
options.clearIfNotMatch = true;
|
||||
}
|
||||
|
||||
if (input.attr(prefix + 'selectonfocus') === 'true') {
|
||||
options.selectOnFocus = true;
|
||||
}
|
||||
|
||||
if (notSameMaskObject(input, mask, options)) {
|
||||
return input.data('mask', new Mask(this, mask, options));
|
||||
}
|
||||
},
|
||||
notSameMaskObject = function(field, mask, options) {
|
||||
options = options || {};
|
||||
var maskObject = $(field).data('mask'),
|
||||
stringify = JSON.stringify,
|
||||
value = $(field).val() || $(field).text();
|
||||
try {
|
||||
if (typeof mask === 'function') {
|
||||
mask = mask(value);
|
||||
}
|
||||
return typeof maskObject !== 'object' || stringify(maskObject.options) !== stringify(options) || maskObject.mask !== mask;
|
||||
} catch (e) {}
|
||||
},
|
||||
eventSupported = function(eventName) {
|
||||
var el = document.createElement('div'), isSupported;
|
||||
|
||||
eventName = 'on' + eventName;
|
||||
isSupported = (eventName in el);
|
||||
|
||||
if ( !isSupported ) {
|
||||
el.setAttribute(eventName, 'return;');
|
||||
isSupported = typeof el[eventName] === 'function';
|
||||
}
|
||||
el = null;
|
||||
|
||||
return isSupported;
|
||||
};
|
||||
|
||||
$.fn.mask = function(mask, options) {
|
||||
options = options || {};
|
||||
var selector = this.selector,
|
||||
globals = $.jMaskGlobals,
|
||||
interval = globals.watchInterval,
|
||||
watchInputs = options.watchInputs || globals.watchInputs,
|
||||
maskFunction = function() {
|
||||
if (notSameMaskObject(this, mask, options)) {
|
||||
return $(this).data('mask', new Mask(this, mask, options));
|
||||
}
|
||||
};
|
||||
|
||||
$(this).each(maskFunction);
|
||||
|
||||
if (selector && selector !== '' && watchInputs) {
|
||||
clearInterval($.maskWatchers[selector]);
|
||||
$.maskWatchers[selector] = setInterval(function(){
|
||||
$(document).find(selector).each(maskFunction);
|
||||
}, interval);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
$.fn.masked = function(val) {
|
||||
return this.data('mask').getMaskedVal(val);
|
||||
};
|
||||
|
||||
$.fn.unmask = function() {
|
||||
clearInterval($.maskWatchers[this.selector]);
|
||||
delete $.maskWatchers[this.selector];
|
||||
return this.each(function() {
|
||||
var dataMask = $(this).data('mask');
|
||||
if (dataMask) {
|
||||
dataMask.remove().removeData('mask');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.cleanVal = function() {
|
||||
return this.data('mask').getCleanVal();
|
||||
};
|
||||
|
||||
$.applyDataMask = function(selector) {
|
||||
selector = selector || $.jMaskGlobals.maskElements;
|
||||
var $selector = (selector instanceof $) ? selector : $(selector);
|
||||
$selector.filter($.jMaskGlobals.dataMaskAttr).each(HTMLAttributes);
|
||||
};
|
||||
|
||||
var globals = {
|
||||
maskElements: 'input,td,span,div',
|
||||
dataMaskAttr: '*[data-mask]',
|
||||
dataMask: true,
|
||||
watchInterval: 300,
|
||||
watchInputs: true,
|
||||
keyStrokeCompensation: 10,
|
||||
// old versions of chrome dont work great with input event
|
||||
useInput: !/Chrome\/[2-4][0-9]|SamsungBrowser/.test(window.navigator.userAgent) && eventSupported('input'),
|
||||
watchDataMask: false,
|
||||
byPassKeys: [9, 16, 17, 18, 36, 37, 38, 39, 40, 91],
|
||||
translation: {
|
||||
'0': {pattern: /\d/},
|
||||
'9': {pattern: /\d/, optional: true},
|
||||
'#': {pattern: /\d/, recursive: true},
|
||||
'A': {pattern: /[a-zA-Z0-9]/},
|
||||
'S': {pattern: /[a-zA-Z]/}
|
||||
}
|
||||
};
|
||||
|
||||
$.jMaskGlobals = $.jMaskGlobals || {};
|
||||
globals = $.jMaskGlobals = $.extend(true, {}, globals, $.jMaskGlobals);
|
||||
|
||||
// looking for inputs with data-mask attribute
|
||||
if (globals.dataMask) {
|
||||
$.applyDataMask();
|
||||
}
|
||||
|
||||
setInterval(function() {
|
||||
if ($.jMaskGlobals.watchDataMask) {
|
||||
$.applyDataMask();
|
||||
}
|
||||
}, globals.watchInterval);
|
||||
}, window.jQuery, window.Zepto));
|
||||
Reference in New Issue
Block a user