Skip to content

Instantly share code, notes, and snippets.

@thallisphp
Created July 16, 2013 13:34
Show Gist options
  • Save thallisphp/6008738 to your computer and use it in GitHub Desktop.
Save thallisphp/6008738 to your computer and use it in GitHub Desktop.
Coffee - Utilidades
bower install jquery
bower install jQuery-Mask-Plugin
c = (variavel) ->
console.log variavel
### --------------------------------------------------------- ###
sto = (tempo, callback) ->
setTimeout callback, tempo
### --------------------------------------------------------- ###
# bower install jQuery-Mask-Plugin
mascara_telefone = (seletor = '.mascara_telefone') ->
elementos = jQuery seletor
if elementos.mask?
regex = /^(\(?11\)? ?9(5[0-9]|6[0-9]|7[01234569]|8[0-9]|9[0-9])[0-9]{1})/g
SPphoneMask = (phone, e, currentField, options) ->
if phone.match regex
'(00) 00000-0000'
else
'(00) 0000-0000'
elementos.mask SPphoneMask,
onKeyPress: (phone, e, currentField, options) ->
jQuery(currentField).mask SPphoneMask(phone), options
### --------------------------------------------------------- ###
internet_explorer = ->
a = false
b = false
c = false
if jQuery.browser?.msie?
a = jQuery.browser.msie is true
if jQuery.support?.leadingWhitespace?
b = !(jQuery.support.leadingWhitespace is true)
if navigator?.appName?
c = navigator.appName is "Microsoft Internet Explorer"
a or b or c
### --------------------------------------------------------- ###
window.c = c
window.sto = sto
window.mascara_telefone = mascara_telefone
window.internet_explorer = internet_explorer
### --------------------------------------------------------- ###
### --------------------------------------------------------- ###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment