Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Updated minified version.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorarins committed Jun 15, 2016
1 parent 0723b62 commit d2880ac
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions jquery.price_format.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
* Release: 2014-01-26
*/
!function(t){t.fn.priceFormat=function(r){var r=t.extend(!0,{},t.fn.priceFormat.defaults,r)
return this.each(function(){function n(t){p.is("input")?p.val(t):p.html(t)}function i(){return m=p.is("input")?p.val():p.html()}function e(t){for(var r="",n=0;n<t.length;n++)char_=t.charAt(n),0==r.length&&0==char_&&(char_=!1),char_&&char_.match(v)&&(x?r.length<x&&(r+=char_):r+=char_)
return r}function a(t){for(;t.length<S+1;)t="0"+t
return t}function f(r,n){if(!n&&(""===r||r==f("0",!0))&&w)return""
var i=a(e(r)),c="",u=0
0==S&&(g="",o="")
var o=i.substr(i.length-S,S),s=i.substr(0,i.length-S)
if(i=0==S?s:s+g+o,b||""!=t.trim(b)){for(var h=s.length;h>0;h--)char_=s.substr(h-1,1),u++,u%3==0&&(char_=b+char_),c=char_+c
c.substr(0,1)==b&&(c=c.substring(1,c.length)),i=0==S?c:c+g+o}return!O||0==s&&0==o||(i=-1!=r.indexOf("-")&&r.indexOf("+")<r.indexOf("-")?"-"+i:P?"+"+i:""+i),d&&(i=d+i),_&&(i+=_),i}function c(t){var r=t.keyCode?t.keyCode:t.which,i=String.fromCharCode(r),e=!1,a=m,c=f(a+i);(r>=48&&57>=r||r>=96&&105>=r)&&(e=!0),8==r&&(e=!0),9==r&&(e=!0),13==r&&(e=!0),46==r&&(e=!0),37==r&&(e=!0),39==r&&(e=!0),!O||189!=r&&109!=r&&173!=r||(e=!0),!P||187!=r&&107!=r&&61!=r||(e=!0),e||(t.preventDefault(),t.stopPropagation(),a!=c&&n(c))}function u(){var t=i(),r=f(t)
t!=r&&n(r),r==f("0",!0)&&w&&n("")}function o(){p.val(d+i())}function s(){p.val(i()+_)}function h(){if(""!=t.trim(d)&&y){var r=i().split(d)
n(r[1])}}function l(){if(""!=t.trim(_)&&k){var r=i().split(_)
n(r[0])}}var p=t(this),m="",v=/[0-9]/
m=p.is("input")?p.val():p.html()
var d=r.prefix,_=r.suffix,g=r.centsSeparator,b=r.thousandsSeparator,x=r.limit,S=r.centsLimit,y=r.clearPrefix,k=r.clearSuffix,O=r.allowNegative,P=r.insertPlusSign,w=r.clearOnEmpty
P&&(O=!0),p.bind("keydown.price_format",c),p.bind("keyup.price_format",u),p.bind("focusout.price_format",u),y&&(p.bind("focusout.price_format",function(){h()}),p.bind("focusin.price_format",function(){o()})),k&&(p.bind("focusout.price_format",function(){l()}),p.bind("focusin.price_format",function(){s()})),i().length>0&&(u(),h(),l())})},t.fn.unpriceFormat=function(){return t(this).unbind(".price_format")},t.fn.unmask=function(){var r,n=""
r=t(this).is("input")?t(this).val():t(this).html()
for(var i in r)isNaN(r[i])&&"-"!=r[i]||(n+=r[i])
return n},t.extend(t.fn.priceFormat,{defaults:{prefix:"US$ ",suffix:"",centsSeparator:".",thousandsSeparator:",",limit:!1,centsLimit:2,clearPrefix:!1,clearSufix:!1,allowNegative:!1,insertPlusSign:!1,clearOnEmpty:!1}})}(jQuery)
!function(t){t.fn.priceFormat=function(n){var n=t.extend(!0,{},t.fn.priceFormat.defaults,n)
return this.each(function(){function r(t){m.is("input")?m.val(t):m.html(t)}function i(){return v=m.is("input")?m.val():m.html()}function e(t){for(var n="",r=0;r<t.length;r++)char_=t.charAt(r),0==n.length&&0==char_&&(char_=!1),char_&&char_.match(d)&&(S?n.length<S&&(n+=char_):n+=char_)
return n}function a(t){for(;t.length<y+1;)t="0"+t
return t}function f(n,r){if(!r&&(""===n||n==f("0",!0))&&C)return""
var i=a(e(n)),c="",u=0
0==y&&(x="",o="")
var o=i.substr(i.length-y,y),s=i.substr(0,i.length-y)
if(i=0==y?s:s+x+o,b||""!=t.trim(b)){for(var h=s.length;h>0;h--)char_=s.substr(h-1,1),u++,u%3==0&&(char_=b+char_),c=char_+c
c.substr(0,1)==b&&(c=c.substring(1,c.length)),i=0==y?c:c+x+o}return!P||0==s&&0==o||(i=-1!=n.indexOf("-")&&n.indexOf("+")<n.indexOf("-")?"-"+i:w?"+"+i:""+i),_&&(i=_+i),g&&(i+=g),i}function c(t){var n=t.keyCode?t.keyCode:t.which,i=String.fromCharCode(n),e=!1,a=v,c=f(a+i);(n>=48&&57>=n||n>=96&&105>=n)&&(e=!0),8==n&&(e=!0),9==n&&(e=!0),13==n&&(e=!0),46==n&&(e=!0),37==n&&(e=!0),39==n&&(e=!0),!P||189!=n&&109!=n&&173!=n||(e=!0),!w||187!=n&&107!=n&&61!=n||(e=!0),e||(t.preventDefault(),t.stopPropagation(),a!=c&&r(c))}function u(t){return t==="0"+x+"0"||t==="0"+x||"0"===t||""===t}function o(){var t=i(),n=f(t)
t!=n&&r(n),u(t)&&n==f("0",!0)&&C&&r("")}function s(){m.val(_+i())}function h(){m.val(i()+g)}function l(){if(""!=t.trim(_)&&k){var n=i().split(_)
r(n[1])}}function p(){if(""!=t.trim(g)&&O){var n=i().split(g)
r(n[0])}}var m=t(this),v="",d=/[0-9]/
v=m.is("input")?m.val():m.html()
var _=n.prefix,g=n.suffix,x=n.centsSeparator,b=n.thousandsSeparator,S=n.limit,y=n.centsLimit,k=n.clearPrefix,O=n.clearSuffix,P=n.allowNegative,w=n.insertPlusSign,C=n.clearOnEmpty
w&&(P=!0),m.bind("keydown.price_format",c),m.bind("keyup.price_format",o),k&&(m.bind("focusout.price_format",function(){l()}),m.bind("focusin.price_format",function(){s()})),O&&(m.bind("focusout.price_format",function(){p()}),m.bind("focusin.price_format",function(){h()})),i().length>0&&(o(),l(),p())})},t.fn.unpriceFormat=function(){return t(this).unbind(".price_format")},t.fn.unmask=function(){var n,r=""
n=t(this).is("input")?t(this).val():t(this).html()
for(var i in n)isNaN(n[i])&&"-"!=n[i]||(r+=n[i])
return r},t.extend(t.fn.priceFormat,{defaults:{prefix:"US$ ",suffix:"",centsSeparator:".",thousandsSeparator:",",limit:!1,centsLimit:2,clearPrefix:!1,clearSufix:!1,allowNegative:!1,insertPlusSign:!1,clearOnEmpty:!1}})}(jQuery)

0 comments on commit d2880ac

Please sign in to comment.