Skip to content

Instantly share code, notes, and snippets.

View bfricka's full-sized avatar

Brian Frichette bfricka

  • Eturi Corp
  • San Diego
View GitHub Profile
@bfricka
bfricka / startFrom.coffee
Created October 30, 2012 15:14
AngularJS startFrom Filter
app.filter 'startFrom', ->
(input, start) ->
if input? and start? and typeof start is 'number'
start = +start
input.slice(start)
@bfricka
bfricka / focus-blur.coffee
Created October 30, 2012 15:17
AngularJS Focus/Blur
app.directive 'ngBlur', ->
(scope, elem, attrs) ->
elem.on "blur", ->
scope.$apply attrs.ngBlur
return
app.directive 'ngFocus', ->
(scope, elem, attrs) ->
elem.on "focus", ->
scope.$apply attrs.ngFocus
@bfricka
bfricka / smallDate.coffee
Created October 30, 2012 15:39
Small Date
smallDate: (raw) ->
date = new Date(raw or "").toDateString()
dateExp = /(\w{3})\s(\w{3})\s(\d{1,2})\s(\d{4})/i
dateArr = date.match(dateExp)
month = dateArr[2]
date = parseInt(dateArr[3], 10)
year = dateArr[4]
pretty = "#{month} #{date}, #{year}"
pretty
@bfricka
bfricka / flexibleDialog.coffee
Created October 30, 2012 15:44
AngualarJS Flexible Dialogbox
app.directive 'dialogbox', ->
{
transclude : true
template : "<div data-ng-transclude></div>"
restrict : "A"
replace : true
scope : false
link : (scope, elem, attrs) ->
$elem = $(elem).addClass('dialog')
dur = 250
@bfricka
bfricka / dialogbox.coffee
Created November 11, 2012 02:54
AngularJS Dialogbox Directive
app.directive 'dialogbox', ->
{
transclude : true
template : "<div class='dialog' data-ng-transclude></div>"
restrict : "A"
replace : true
scope : false
link : (scope, elem, attrs) ->
$elem = $(elem).addClass('dialog')
#dur = if scope.isDesktop then 250 else 0
@bfricka
bfricka / jQuery.slideFade.coffee
Created January 1, 2013 06:44
jQuery.slideFade
# By default requires jQuery.easing by default
# change default easing to 'swing' if not using
# jQuery.slideFade
# Copyright © Brian Frichette, 2012+, All Rights Reserved.
# License: MIT http://opensource.org/licenses/mit-license.php
# Usage:
# @param {String} type A string value of either 'show', 'hide', or 'toggle' (default: 'toggle')
@bfricka
bfricka / cookies.coffee
Created January 1, 2013 06:47
CoffeeScript Cookie Class
class Cookie
constructor: (opts) ->
c = @
def =
path: '/'
domain: ''
expires: do ->
d = new Date().setFullYear(2020)
d = new Date(d).toGMTString()
d
@bfricka
bfricka / jQuery.easing.coffee
Last active December 10, 2015 11:09
jQuery.easing Coffee
# jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
# Uses the built in easing capabilities added In jQuery 1.1 to offer multiple easing options
# TERMS OF USE - jQuery Easing
###
jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
Copyright (c) 2008 George McGinley Smith and (c) 2001 Robert Penner
Open source under the BSD License. (http://www.opensource.org/licenses/bsd-license.php)
@bfricka
bfricka / ua.coffee
Created January 1, 2013 06:56
Simple User Agent
###
Adapted from jqMobi (appMobi)
https://github.com/appMobi/jQ.Mobi
MIT License
###
window.UserAgent = ->
self = @
self.ua = navigator.userAgent
self.os = {}
@bfricka
bfricka / angular-slide-fade.coffee
Created January 1, 2013 07:01
AngularJS slideFade / fade directives
# Requires jQuery.slideFade.coffee gist
# https://gist.github.com/4425644
app.directive 'slideFadeShow', ->
(scope, elem, attrs) ->
$elem = $(elem)
exp = attrs.slideFadeShow
duration = 600
slideElem = (toShow, init = false) ->