Skip to content

Instantly share code, notes, and snippets.

Created Aug 15, 2014
Embed
What would you like to do?
Default object
window.defaultUrl = "";
// Default object
var Ecommerce = {
config: function() {
if ((s = $("head script[src*='modernizr-2.6.2.min.js']")).length > 0) {
window.defaultUrl = s.attr("src").split("js/")[0];
}
$('a[data-rel]').each(function() {
$(this).attr('rel', $(this).data('rel'));
});
// Hide compatibility bar
$('#sawpf').slideToggle(5000);
},
fancybox: function() {
$(".fancybox").fancybox({
openEffect : 'elastic',
closeEffect : 'elastic',
helpers : {
title : { type : 'inside' }
}
});
},
util: function() {
$("ul li:last-child").addClass("last");
$("ul li:first-child").removeClass("last").addClass("first");
$("#content table tr:odd").addClass("odd");
// Break list
$("ul[class*=break-list-]").each(function() {
if (($pp=/break\-list\-at\-([0-9]+)/gi.exec($(this).attr("class").toString())) && $pp.length > 1) {
$(this).find("li:nth-child(" + $pp[1] + "n)").after("<li class='break-line'></li>");
$(this).find("li:last-child").filter(".break-line").remove();
}
});
// ScrollTo
$('a[href*=#]').each(function() {
if (Ecommerce.filterPath(location.pathname) == Ecommerce.filterPath(this.pathname) && location.hostname == this.hostname && this.hash.replace(/#/,'')) {
var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
if ($target) {
var targetOffset = $target.offset().top;
$(this).click(function() {
$('html, body').animate({scrollTop: targetOffset}, 1500);
return false;
});
}
}
});
// Masks (phones/dates)
if ($.fn.mask !== undefined) {
$('.phone').mask('(99) 99999-9999');
$('.phone').focusout(function(){
var phone, element;
element = $(this);
element.unmask();
phone = element.val().replace(/\D/g, '').length;
if (phone == 10) {
element.mask("(99) 9999-9999");
} else {
element.mask("(99) 99999-9999");
}
}).trigger('focusout');
$('.date').mask('99/99/9999');
}
// Register show phones
$('a.add-phone').click(function() {
$(this).hide();
$('.input-phone').slideDown();
});
},
autocomplete: function() {
$(".form-search .f").autocomplete("admin/app.geral/autoCompletar.php", {
width:310,
selectFirst: false
});
$(".form-search .f").result(function(event, data, formatted) {
$('.btn-submit').trigger('click');
});
},
searchFloat: function() {
$(window).scroll(function(){
if ($(window).scrollTop() > 150) {
$(".search-bar").fadeIn("slow");
} else {
$(".search-bar").fadeOut("slow");
}
});
},
filterPath: function(string) {
return string
.replace(/^\//,'')
.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
.replace(/\/$/,'');
},
cep: function() {
$("#clicep").blur(function(e) {
$.ajax({
url : "../../admin/app.geral/consultarCep.php",
type : "POST",
data: "cep=" + $("#clicep").val(),
dataType: "json",
success: function(data){
if (data.sucesso == 1){
$('#cliend').val(data.rua);
$('#clibairro').val(data.bairro);
$('#clicidade').val(data.cidade);
$('#id_estado').val(data.estado);
$('#clinum').focus();
}
}
});
});
}
};
$(function() {
// Load defaults
if ($.fn.fancybox !== undefined) Ecommerce.fancybox();
Ecommerce.autocomplete();
Ecommerce.util();
Ecommerce.searchFloat();
Ecommerce.cep();
// Confirm delete address
$('.btn-delete-address').click(function() {
if (confirm('Você confirma a exclusão deste endereço?')) return true;
return false;
});
// Product float box
$(window).bind('scroll',function(e) {
if (window.pageYOffset > 500) {
$('.product-float-box').fadeIn();
} else {
$('.product-float-box').fadeOut();
}
});
});
// Browser objects
if (!jQuery.browser){jQuery.browser={},jQuery.browser.mozilla=!1,jQuery.browser.webkit=!1,jQuery.browser.opera=!1,jQuery.browser.safari=!1,jQuery.browser.chrome=!1,jQuery.browser.msie=!1,jQuery.browser.android=!1,jQuery.browser.blackberry=!1,jQuery.browser.ios=!1,jQuery.browser.operaMobile=!1,jQuery.browser.windowsMobile=!1,jQuery.browser.mobile=!1;var nAgt=navigator.userAgent;jQuery.browser.ua=nAgt,jQuery.browser.name=navigator.appName,jQuery.browser.fullVersion=""+parseFloat(navigator.appVersion),jQuery.browser.majorVersion=parseInt(navigator.appVersion,10);var nameOffset,verOffset,ix;if(-1!=(verOffset=nAgt.indexOf("Opera")))jQuery.browser.opera=!0,jQuery.browser.name="Opera",jQuery.browser.fullVersion=nAgt.substring(verOffset+6),-1!=(verOffset=nAgt.indexOf("Version"))&&(jQuery.browser.fullVersion=nAgt.substring(verOffset+8));else if(-1!=(verOffset=nAgt.indexOf("MSIE")))jQuery.browser.msie=!0,jQuery.browser.name="Microsoft Internet Explorer",jQuery.browser.fullVersion=nAgt.substring(verOffset+5);else if(-1!=nAgt.indexOf("Trident")){jQuery.browser.msie=!0,jQuery.browser.name="Microsoft Internet Explorer";var start=nAgt.indexOf("rv:")+3,end=start+4;jQuery.browser.fullVersion=nAgt.substring(start,end)}else-1!=(verOffset=nAgt.indexOf("Chrome"))?(jQuery.browser.webkit=!0,jQuery.browser.chrome=!0,jQuery.browser.name="Chrome",jQuery.browser.fullVersion=nAgt.substring(verOffset+7)):-1!=(verOffset=nAgt.indexOf("Safari"))?(jQuery.browser.webkit=!0,jQuery.browser.safari=!0,jQuery.browser.name="Safari",jQuery.browser.fullVersion=nAgt.substring(verOffset+7),-1!=(verOffset=nAgt.indexOf("Version"))&&(jQuery.browser.fullVersion=nAgt.substring(verOffset+8))):-1!=(verOffset=nAgt.indexOf("AppleWebkit"))?(jQuery.browser.webkit=!0,jQuery.browser.name="Safari",jQuery.browser.fullVersion=nAgt.substring(verOffset+7),-1!=(verOffset=nAgt.indexOf("Version"))&&(jQuery.browser.fullVersion=nAgt.substring(verOffset+8))):-1!=(verOffset=nAgt.indexOf("Firefox"))?(jQuery.browser.mozilla=!0,jQuery.browser.name="Firefox",jQuery.browser.fullVersion=nAgt.substring(verOffset+8)):(nameOffset=nAgt.lastIndexOf(" ")+1)<(verOffset=nAgt.lastIndexOf("/"))&&(jQuery.browser.name=nAgt.substring(nameOffset,verOffset),jQuery.browser.fullVersion=nAgt.substring(verOffset+1),jQuery.browser.name.toLowerCase()==jQuery.browser.name.toUpperCase()&&(jQuery.browser.name=navigator.appName));jQuery.browser.android=/Android/i.test(nAgt),jQuery.browser.blackberry=/BlackBerry/i.test(nAgt),jQuery.browser.ios=/iPhone|iPad|iPod/i.test(nAgt),jQuery.browser.operaMobile=/Opera Mini/i.test(nAgt),jQuery.browser.windowsMobile=/IEMobile/i.test(nAgt),jQuery.browser.mobile=jQuery.browser.android||jQuery.browser.blackberry||jQuery.browser.ios||jQuery.browser.windowsMobile||jQuery.browser.operaMobile,-1!=(ix=jQuery.browser.fullVersion.indexOf(";"))&&(jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix)),-1!=(ix=jQuery.browser.fullVersion.indexOf(" "))&&(jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix)),jQuery.browser.majorVersion=parseInt(""+jQuery.browser.fullVersion,10),isNaN(jQuery.browser.majorVersion)&&(jQuery.browser.fullVersion=""+parseFloat(navigator.appVersion),jQuery.browser.majorVersion=parseInt(navigator.appVersion,10)),jQuery.browser.version=jQuery.browser.majorVersion}
// Autocomplete
!function(e){e.fn.extend({autocomplete:function(t,n){var a="string"==typeof t;return n=e.extend({},e.Autocompleter.defaults,{url:a?t:null,data:a?null:t,delay:a?e.Autocompleter.defaults.delay:10,max:n&&!n.scroll?10:150},n),n.highlight=n.highlight||function(e){return e},n.formatMatch=n.formatMatch||n.formatItem,this.each(function(){new e.Autocompleter(this,n)})},result:function(e){return this.bind("result",e)},search:function(e){return this.trigger("search",[e])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(e){return this.trigger("setOptions",[e])},unautocomplete:function(){return this.trigger("unautocomplete")}}),e.Autocompleter=function(t,n){function a(){var a=x.selected();if(!a)return!1;var r=a.result;if(b=r,n.multiple){var o=i(C.val());if(o.length>1){var l,s=n.multipleSeparator.length,c=e(t).selection().start,f=0;e.each(o,function(e,t){return f+=t.length,f>=c?(l=e,!1):void(f+=s)}),o[l]=r,r=o.join(n.multipleSeparator)}r+=n.multipleSeparator}return C.val(r),u(),C.trigger("result",[a.data,a.value]),!0}function r(e,t){if(p==v.DEL)return void x.hide();var a=C.val();(t||a!=b)&&(b=a,a=o(a),a.length>=n.minChars?(C.addClass(n.loadingClass),n.matchCase||(a=a.toLowerCase()),f(a,c,u)):(d(),x.hide()))}function i(t){return t?n.multiple?e.map(t.split(n.multipleSeparator),function(n){return e.trim(t).length?e.trim(n):null}):[e.trim(t)]:[""]}function o(a){if(!n.multiple)return a;var r=i(a);if(1==r.length)return r[0];var o=e(t).selection().start;return r=i(o==a.length?a:a.replace(a.substring(o),"")),r[r.length-1]}function l(a,r){n.autoFill&&o(C.val()).toLowerCase()==a.toLowerCase()&&p!=v.BACKSPACE&&(C.val(C.val()+r.substring(o(b).length)),e(t).selection(b.length,b.length+r.length))}function s(){clearTimeout(m),m=setTimeout(u,200)}function u(){x.visible();x.hide(),clearTimeout(m),d(),n.mustMatch&&C.search(function(e){if(!e)if(n.multiple){var t=i(C.val()).slice(0,-1);C.val(t.join(n.multipleSeparator)+(t.length?n.multipleSeparator:""))}else C.val(""),C.trigger("result",null)})}function c(e,t){t&&t.length&&T?(d(),x.display(t,e),l(e,t[0].value),x.show()):u()}function f(a,r,i){n.matchCase||(a=a.toLowerCase());var l=w.load(a);if(l&&l.length)r(a,l);else if("string"==typeof n.url&&n.url.length>0){var s={timestamp:+new Date};e.each(n.extraParams,function(e,t){s[e]="function"==typeof t?t():t}),e.ajax({mode:"abort",port:"autocomplete"+t.name,dataType:n.dataType,url:n.url,data:e.extend({q:o(a),limit:n.max},s),success:function(e){var t=n.parse&&n.parse(e)||h(e);w.add(a,t),r(a,t)}})}else x.emptyList(),i(a)}function h(t){for(var a=[],r=t.split("\n"),i=0;i<r.length;i++){var o=e.trim(r[i]);o&&(o=o.split("|"),a[a.length]={data:o,value:o[0],result:n.formatResult&&n.formatResult(o,o[0])||o[0]})}return a}function d(){C.removeClass(n.loadingClass)}var m,p,g,v={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8},C=e(t).attr("autocomplete","off").addClass(n.inputClass),b="",w=e.Autocompleter.Cache(n),T=0,A={mouseDownOnSelect:!1},x=e.Autocompleter.Select(n,t,a,A);e.browser.opera&&e(t.form).bind("submit.autocomplete",function(){return g?(g=!1,!1):void 0}),C.bind((e.browser.opera?"keypress":"keydown")+".autocomplete",function(t){switch(T=1,p=t.keyCode,t.keyCode){case v.UP:t.preventDefault(),x.visible()?x.prev():r(0,!0);break;case v.DOWN:t.preventDefault(),x.visible()?x.next():r(0,!0);break;case v.PAGEUP:t.preventDefault(),x.visible()?x.pageUp():r(0,!0);break;case v.PAGEDOWN:t.preventDefault(),x.visible()?x.pageDown():r(0,!0);break;case n.multiple&&","==e.trim(n.multipleSeparator)&&v.COMMA:case v.TAB:case v.RETURN:if(a())return t.preventDefault(),g=!0,!1;break;case v.ESC:x.hide();break;default:clearTimeout(m),m=setTimeout(r,n.delay)}}).focus(function(){T++}).blur(function(){T=0,A.mouseDownOnSelect||s()}).click(function(){T++>1&&!x.visible()&&r(0,!0)}).bind("search",function(){function t(e,t){var a;if(t&&t.length)for(var r=0;r<t.length;r++)if(t[r].result.toLowerCase()==e.toLowerCase()){a=t[r];break}"function"==typeof n?n(a):C.trigger("result",a&&[a.data,a.value])}var n=arguments.length>1?arguments[1]:null;e.each(i(C.val()),function(e,n){f(n,t,t)})}).bind("flushCache",function(){w.flush()}).bind("setOptions",function(){e.extend(n,arguments[1]),"data"in arguments[1]&&w.populate()}).bind("unautocomplete",function(){x.unbind(),C.unbind(),e(t.form).unbind(".autocomplete")})},e.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:!1,matchSubset:!0,matchContains:!1,cacheLength:10,max:100,mustMatch:!1,extraParams:{},selectFirst:!0,formatItem:function(e){return e[0]},formatMatch:null,autoFill:!1,width:0,multiple:!1,multipleSeparator:", ",highlight:function(e,t){return e.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+t.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},scroll:!0,scrollHeight:180},e.Autocompleter.Cache=function(t){function n(e,n){t.matchCase||(e=e.toLowerCase());var a=e.indexOf(n);return"word"==t.matchContains&&(a=e.toLowerCase().search("\\b"+n.toLowerCase())),-1==a?!1:0==a||t.matchContains}function a(e,n){l>t.cacheLength&&i(),o[e]||l++,o[e]=n}function r(){if(!t.data)return!1;var n={},r=0;t.url||(t.cacheLength=1),n[""]=[];for(var i=0,o=t.data.length;o>i;i++){var l=t.data[i];l="string"==typeof l?[l]:l;var s=t.formatMatch(l,i+1,t.data.length);if(s!==!1){var u=s.charAt(0).toLowerCase();n[u]||(n[u]=[]);var c={value:s,data:l,result:t.formatResult&&t.formatResult(l)||s};n[u].push(c),r++<t.max&&n[""].push(c)}}e.each(n,function(e,n){t.cacheLength++,a(e,n)})}function i(){o={},l=0}var o={},l=0;return setTimeout(r,25),{flush:i,add:a,populate:r,load:function(a){if(!t.cacheLength||!l)return null;if(!t.url&&t.matchContains){var r=[];for(var i in o)if(i.length>0){var s=o[i];e.each(s,function(e,t){n(t.value,a)&&r.push(t)})}return r}if(o[a])return o[a];if(t.matchSubset)for(var u=a.length-1;u>=t.minChars;u--){var s=o[a.substr(0,u)];if(s){var r=[];return e.each(s,function(e,t){n(t.value,a)&&(r[r.length]=t)}),r}}return null}}},e.Autocompleter.Select=function(t,n,a,r){function i(){C&&(d=e("<div/>").hide().addClass(t.resultsClass).css("position","absolute").appendTo(document.body),m=e("<ul/>").appendTo(d).mouseover(function(t){o(t).nodeName&&"LI"==o(t).nodeName.toUpperCase()&&(g=e("li",m).removeClass(p.ACTIVE).index(o(t)),e(o(t)).addClass(p.ACTIVE))}).click(function(t){return e(o(t)).addClass(p.ACTIVE),a(),n.focus(),!1}).mousedown(function(){r.mouseDownOnSelect=!0}).mouseup(function(){r.mouseDownOnSelect=!1}),t.width>0&&d.css("width",t.width),C=!1)}function o(e){for(var t=e.target;t&&"LI"!=t.tagName;)t=t.parentNode;return t?t:[]}function l(e){f.slice(g,g+1).removeClass(p.ACTIVE),s(e);var n=f.slice(g,g+1).addClass(p.ACTIVE);if(t.scroll){var a=0;f.slice(0,g).each(function(){a+=this.offsetHeight}),a+n[0].offsetHeight-m.scrollTop()>m[0].clientHeight?m.scrollTop(a+n[0].offsetHeight-m.innerHeight()):a<m.scrollTop()&&m.scrollTop(a)}}function s(e){g+=e,0>g?g=f.size()-1:g>=f.size()&&(g=0)}function u(e){return t.max&&t.max<e?t.max:e}function c(){m.empty();for(var n=u(h.length),a=0;n>a;a++)if(h[a]){var r=t.formatItem(h[a].data,a+1,n,h[a].value,v);if(r!==!1){var i=e("<li/>").html(t.highlight(r,v)).addClass(a%2==0?"ac_even":"ac_odd").appendTo(m)[0];e.data(i,"ac_data",h[a])}}f=m.find("li"),t.selectFirst&&(f.slice(0,1).addClass(p.ACTIVE),g=0),e.fn.bgiframe&&m.bgiframe()}var f,h,d,m,p={ACTIVE:"ac_over"},g=-1,v="",C=!0;return{display:function(e,t){i(),h=e,v=t,c()},next:function(){l(1)},prev:function(){l(-1)},pageUp:function(){l(0!=g&&0>g-8?-g:-8)},pageDown:function(){l(g!=f.size()-1&&g+8>f.size()?f.size()-1-g:8)},hide:function(){d&&d.hide(),f&&f.removeClass(p.ACTIVE),g=-1},visible:function(){return d&&d.is(":visible")},current:function(){return this.visible()&&(f.filter("."+p.ACTIVE)[0]||t.selectFirst&&f[0])},show:function(){var a=e(n).offset();if(d.css({width:"string"==typeof t.width||t.width>0?t.width:e(n).width(),top:a.top+n.offsetHeight,left:a.left}).show(),t.scroll&&(m.scrollTop(0),m.css({maxHeight:t.scrollHeight,overflow:"auto"}),e.browser.msie&&"undefined"==typeof document.body.style.maxHeight)){var r=0;f.each(function(){r+=this.offsetHeight});var i=r>t.scrollHeight;m.css("height",i?t.scrollHeight:r),i||f.width(m.width()-parseInt(f.css("padding-left"))-parseInt(f.css("padding-right")))}},selected:function(){var t=f&&f.filter("."+p.ACTIVE).removeClass(p.ACTIVE);return t&&t.length&&e.data(t[0],"ac_data")},emptyList:function(){m&&m.empty()},unbind:function(){d&&d.remove()}}},e.fn.selection=function(e,t){if(void 0!==e)return this.each(function(){if(this.createTextRange){var n=this.createTextRange();void 0===t||e==t?(n.move("character",e),n.select()):(n.collapse(!0),n.moveStart("character",e),n.moveEnd("character",t),n.select())}else this.setSelectionRange?this.setSelectionRange(e,t):this.selectionStart&&(this.selectionStart=e,this.selectionEnd=t)});var n=this[0];if(n.createTextRange){var a=document.selection.createRange(),r=n.value,i="<->",o=a.text.length;a.text=i;var l=n.value.indexOf(i);return n.value=r,this.selection(l,l+o),{start:l,end:l+o}}return void 0!==n.selectionStart?{start:n.selectionStart,end:n.selectionEnd}:void 0}}(jQuery);
// Placeholder fix
(function(b,f,i){function l(){b(this).find(c).each(j)}function m(a){for(var a=a.attributes,b={},c=/^jQuery\d+/,e=0;e<a.length;e++)if(a[e].specified&&!c.test(a[e].name))b[a[e].name]=a[e].value;return b}function j(){var a=b(this),d;a.is(":password")||(a.data("password")?(d=a.next().show().focus(),b("label[for="+a.attr("id")+"]").attr("for",d.attr("id")),a.remove()):a.realVal()==a.attr("placeholder")&&(a.val(""),a.removeClass("placeholder")))}function k(){var a=b(this),d,c;placeholder=a.attr("placeholder");
b.trim(a.val()).length>0||(a.is(":password")?(c=a.attr("id")+"-clone",d=b("<input/>").attr(b.extend(m(this),{type:"text",value:placeholder,"data-password":1,id:c})).addClass("placeholder"),a.before(d).hide(),b("label[for="+a.attr("id")+"]").attr("for",c)):(a.val(placeholder),a.addClass("placeholder")))}var g="placeholder"in f.createElement("input"),h="placeholder"in f.createElement("textarea"),c=":input[placeholder]";b.placeholder={input:g,textarea:h};!i&&g&&h?b.fn.placeholder=function(){}:(!i&&g&&
!h&&(c="textarea[placeholder]"),b.fn.realVal=b.fn.val,b.fn.val=function(){var a=b(this),d;if(arguments.length>0)return a.realVal.apply(this,arguments);d=a.realVal();a=a.attr("placeholder");return d==a?"":d},b.fn.placeholder=function(){this.filter(c).each(k);return this},b(function(a){var b=a(f);b.on("submit","form",l);b.on("focus",c,j);b.on("blur",c,k);a(c).placeholder()}))})(jQuery,document,window.debug);
// Mask
if ($('.phone').length > 0 || $('.date').length > 0) {
(function(g){"function"===typeof define&&define.amd?define(["jquery"],g):g(window.jQuery||window.Zepto)})(function(g){var z=function(b,f,d){var l=this,x,y;b=g(b);f="function"===typeof f?f(b.val(),void 0,b,d):f;l.init=function(){d=d||{};l.byPassKeys=[9,16,17,18,36,37,38,39,40,91];l.translation={0:{pattern:/\d/},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,recursive:!0},A:{pattern:/[a-zA-Z0-9]/},S:{pattern:/[a-zA-Z]/}};l.translation=g.extend({},l.translation,d.translation);l=g.extend(!0,{},l,d);y=
c.getRegexMask();b.each(function(){!1!==d.maxlength&&b.attr("maxlength",f.length);d.placeholder&&b.attr("placeholder",d.placeholder);b.attr("autocomplete","off");c.destroyEvents();c.events();var a=c.getCaret();c.val(c.getMasked());c.setCaret(a+c.getMaskCharactersBeforeCount(a,!0))})};var c={getCaret:function(){var a;a=0;var e=b.get(0),c=document.selection,e=e.selectionStart;if(c&&!~navigator.appVersion.indexOf("MSIE 10"))a=c.createRange(),a.moveStart("character",b.is("input")?-b.val().length:-b.text().length),
a=a.text.length;else if(e||"0"===e)a=e;return a},setCaret:function(a){if(b.is(":focus")){var e;e=b.get(0);e.setSelectionRange?e.setSelectionRange(a,a):e.createTextRange&&(e=e.createTextRange(),e.collapse(!0),e.moveEnd("character",a),e.moveStart("character",a),e.select())}},events:function(){b.on("keydown.mask",function(){x=c.val()});b.on("keyup.mask",c.behaviour);b.on("paste.mask drop.mask",function(){setTimeout(function(){b.keydown().keyup()},100)});b.on("change.mask",function(){b.data("changeCalled",
!0)});b.on("blur.mask",function(a){a=g(a.target);a.prop("defaultValue")!==a.val()&&(a.prop("defaultValue",a.val()),a.data("changeCalled")||a.trigger("change"));a.data("changeCalled",!1)});b.on("focusout.mask",function(){d.clearIfNotMatch&&!y.test(c.val())&&c.val("")})},getRegexMask:function(){var a=[],e,b,c,d,k;for(k in f)(e=l.translation[f[k]])?(b=e.pattern.toString().replace(/.{1}$|^.{1}/g,""),c=e.optional,(e=e.recursive)?(a.push(f[k]),d={digit:f[k],pattern:b}):a.push(c||e?b+"?":b)):a.push("\\"+
f[k]);a=a.join("");d&&(a=a.replace(RegExp("("+d.digit+"(.*"+d.digit+")?)"),"($1)?").replace(RegExp(d.digit,"g"),d.pattern));return RegExp(a)},destroyEvents:function(){b.off("keydown.mask keyup.mask paste.mask drop.mask change.mask blur.mask focusout.mask").removeData("changeCalled")},val:function(a){var e=b.is("input");return 0<arguments.length?e?b.val(a):b.text(a):e?b.val():b.text()},getMaskCharactersBeforeCount:function(a,e){for(var b=0,c=0,d=f.length;c<d&&c<a;c++)l.translation[f.charAt(c)]||(a=
e?a+1:a,b++);return b},determineCaretPos:function(a,b,d,h){return l.translation[f.charAt(Math.min(a-1,f.length-1))]?Math.min(a+d-b-h,d):c.determineCaretPos(a+1,b,d,h)},behaviour:function(a){a=a||window.event;var b=a.keyCode||a.which;if(-1===g.inArray(b,l.byPassKeys)){var d=c.getCaret(),f=c.val(),n=f.length,k=d<n,p=c.getMasked(),m=p.length,q=c.getMaskCharactersBeforeCount(m-1)-c.getMaskCharactersBeforeCount(n-1);p!==f&&c.val(p);!k||65===b&&a.ctrlKey||(8!==b&&46!==b&&(d=c.determineCaretPos(d,n,m,q)),
c.setCaret(d));return c.callbacks(a)}},getMasked:function(a){var b=[],g=c.val(),h=0,n=f.length,k=0,p=g.length,m=1,q="push",s=-1,r,u;d.reverse?(q="unshift",m=-1,r=0,h=n-1,k=p-1,u=function(){return-1<h&&-1<k}):(r=n-1,u=function(){return h<n&&k<p});for(;u();){var v=f.charAt(h),w=g.charAt(k),t=l.translation[v];if(t)w.match(t.pattern)?(b[q](w),t.recursive&&(-1===s?s=h:h===r&&(h=s-m),r===s&&(h-=m)),h+=m):t.optional&&(h+=m,k-=m),k+=m;else{if(!a)b[q](v);w===v&&(k+=m);h+=m}}a=f.charAt(r);n!==p+1||l.translation[a]||
b.push(a);return b.join("")},callbacks:function(a){var e=c.val(),g=c.val()!==x;if(!0===g&&"function"===typeof d.onChange)d.onChange(e,a,b,d);if(!0===g&&"function"===typeof d.onKeyPress)d.onKeyPress(e,a,b,d);if("function"===typeof d.onComplete&&e.length===f.length)d.onComplete(e,a,b,d)}};l.remove=function(){var a=c.getCaret(),b=c.getMaskCharactersBeforeCount(a);c.destroyEvents();c.val(l.getCleanVal()).removeAttr("maxlength");c.setCaret(a-b)};l.getCleanVal=function(){return c.getMasked(!0)};l.init()};
g.fn.mask=function(b,f){this.unmask();return this.each(function(){g(this).data("mask",new z(this,b,f))})};g.fn.unmask=function(){return this.each(function(){try{g(this).data("mask").remove()}catch(b){}})};g.fn.cleanVal=function(){return g(this).data("mask").getCleanVal()};g("*[data-mask]").each(function(){var b=g(this),f={};"true"===b.attr("data-mask-reverse")&&(f.reverse=!0);"false"===b.attr("data-mask-maxlength")&&(f.maxlength=!1);"true"===b.attr("data-mask-clearifnotmatch")&&(f.clearIfNotMatch=
!0);b.mask(b.attr("data-mask"),f)})});
}
// Compatibility bar
(function(r,d,m){if(!d.getElementById("sawpf")){var g=m.userAgent.toLowerCase(),f={version:function(){var b=(g.match(/.+(?:firefox|ie)[\/: ]([\d.]+)/)||[0,0])[1];if(b===0)b=(g.match(/.+rv:([\d.]+)/)||0)[1];return parseFloat(b)}(),h:(/msie/.test(g)||/trident/.test(g))&&!/opera/.test(g),f:/firefox/.test(g)||/mozilla/.test(g)&&!/(compatible|webkit)/.test(g)},l=f.f;if((m=f.h)&&f.version==6&&/msie 8/.test(g))f.version=8;if(m&&f.version<9&&d.documentMode<9){var A=parseInt((g.match(/.+trident\/(\d+)\..*/)||
[0,0])[1],10);f.version=A<5?8:9}if(l||m)if(!(l&&f.version>=17))if(!(m&&f.version>=9)){var s={b:function(b,h,j){var c=[];c.push(b+"="+h);c.push("path=/");j&&c.push("expires="+this.d(j));d.cookie=c.join("; ")},g:function(b){var h=d.cookie.split(";");b=b+"=";for(var j=0;j<h.length;j++){for(var c=h[j];c.charAt(0)==" ";)c=c.substring(1,c.length);if(c.indexOf(b)==0)return c.substring(b.length,c.length)}return null},k:function(b){s.b(b,"",-1000)},d:function(b){var h=new Date;h.setTime(h.getTime()+b);return h.toGMTString()}};
if(s.g("__sawpf_")!="1"){(function(b,h){function j(a,k,e){return(a+(k-a)*e).toFixed(3)}function c(a){return{c:parseFloat(a),e:j,i:a.replace(/^[\-\d\.]+/,"")}}function B(a){var k={},e=t.length,o;u.innerHTML='<div style="'+a+'"></div>';for(a=u.childNodes[0].style;e--;)if(o=a[t[e]])k[t[e]]=c(o);return k}var u=d.createElement("div"),t=["height"];h[b]=function(a,k,e,o){a=typeof a=="string"?d.getElementById(a):a;e=e||{};var p=B(k);k=a.currentStyle?a.currentStyle:getComputedStyle(a,null);var i,v={},w=+new Date,
x=e.duration||200,y=w+x,z,C=e.j||function(q){return-Math.cos(q*Math.PI)/2+0.5};for(i in p)v[i]=c(k[i]);z=setInterval(function(){var q=+new Date,D=q>y?1:(q-w)/x;for(i in p)a.style[i]=p[i].e(v[i].c,p[i].c,C(D))+p[i].i;if(q>y){clearInterval(z);e.a&&e.a();o&&setTimeout(o,1)}},10)}})("emile",this);f="#sawpf * {margin: 0; padding: 0}#sawpf {text-align: center; height: 0; overflow: hidden; background: #ffffd6; border-width: 1px 0; border-color: #f0e4c3; border-style: solid; font-family: arial; position: absolute; z-index: 1000; width: 100%}#sawpf div {margin: 0 auto; width: 940px; padding: 9px 0}#sawpf strong {color: #333; font-size: 14px}#sawpf p {color: #666; float: left; font-size: 12px; line-height: 18px; margin: 2px 20px 0 0; text-align: left}#sawpf ul {list-style: none}#sawpf li {display: block; float: left; margin-right: 5px}#sawpf a, #sawpf a span {background-image: url("+
((r.base_url||"http://sawpf.com")+"/imgs/1.0.gif")+"); text-indent: -99em; display: block; cursor: pointer}#sawpf a {outline: none; overflow: hidden}#sawpf ul a, #sawpf ul a span {height: 40px; width: 150px}#sawpf ul a:hover {background-position: 0 -40px}#sawpf ul a:active {background-position:0 -80px}#sawpf ul a:active span {margin-top: 1px}#sawpf .sawpf-ie span {background-position: 0 -198px}#sawpf .sawpf-ff span {background-position: 0 -120px}#sawpf .sawpf-gc span {background-position: 0 -158px}#sawpf #sawpf-close {background-position: 0 -240px; width: 15px; height: 15px; position: absolute; right:5px; top: 5px}#sawpf #sawpf-close:hover {background-position: 0 -255px}#sawpf #sawpf-close:active {background-position: 0 -270px}";
l=d.createElement("style");l.type="text/css";if(r.ActiveXObject)l.styleSheet.cssText=f;else l.innerHTML=f;d.getElementsByTagName("head")[0].appendChild(l);r="<div><p><strong>Seu "+(m?"Internet Explorer":"Firefox")+' est\u00e1 desatualizado.</strong><br/>Para uma melhor visualiza\u00e7\u00e3o do site atualize-o ou escolha outro navegador.</p><ul><li><a href="http://www.baixatudo.com.br/google-chrome?utm_source=sawpf&utm_medium=banner&utm_campaign=Chrome" class="sawpf-gc" title="Google Chrome"><span>Google Chrome</span></a></li><li><a href="http://www.baixatudo.com.br/mozilla-firefox?utm_source=sawpf&utm_medium=banner&utm_campaign=Firefox" class="sawpf-ff" title="Firefox"><span>Firefox</span></a></li><li><a href="http://www.baixatudo.com.br/internet-explorer?utm_source=sawpf&utm_medium=banner&utm_campaign=Explorer" class="sawpf-ie" title="Internet Explorer"><span>Internet Explorer</span></a></li></ul><a href="#" id="sawpf-close" title="Fechar">fechar</a></div>';
var n=d.createElement("div");n.id="sawpf";n.innerHTML=r;d.body.insertBefore(n,d.body.firstChild);d.getElementById("sawpf-close").onclick=function(){s.b("__sawpf_","1",6048E5);emile(n,"height: 0",{duration:300,a:function(){n.style.display="none"}});return false};emile(n,"height: 58px",{duration:500})}}}})(this,document,navigator);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment