Skip to content

Instantly share code, notes, and snippets.

View gavacho's full-sized avatar

Ken Browning gavacho

View GitHub Profile
@gavacho
gavacho / gist:3795551
Created September 27, 2012 18:25
A shim for older versions of jQuery which don't have the `on` method defined.
(function( $ ) {
'use strict';
if ( !$.fn.on && $.fn.live && $.fn.bind ) {
$.fn.on = function() {
var args = createObjectFromArgs( arguments );
if ( args.selector ) {
@gavacho
gavacho / gist:4061898
Created November 12, 2012 21:06
HauteLook.ChildViewObserver

This mixin, when applied to an Ember.ContainerView (and, by extension, a CollectionView) creates three new methods on the extended view. These methods are called whenever a contained view raises a willInsertElement, didInsertElement or willDestroyElement event.

    HauteLook.ChildViewObserver = Ember.Mixin.create({
        childViewsWillChange: function(childViews, start, removeCount, addCount) {
            this._super.apply(this, arguments);
            for(var i=0; i < removeCount; i++) {
                var cv = childViews.objectAt(start + i);
                cv.off('willInsertElement', this, this.willInsertChildElement);
                cv.off('didInsertElement', this, this.didInsertChildElement);
@gavacho
gavacho / gist:4091852
Created November 16, 2012 23:22
Ember Containers

I would like to create a Oocss.Module view which encapsulates boilerplate markup which is part of stubornella's Object Oriented CSS (https://github.com/stubbornella/oocss/wiki). The boilerplate markup looks like this:

<div class="mod">
  <b class="top"><b class="tl"></b><b class="tr"></b></b>
  <div class="inner">
    <div class="hd">...</div>
    <div class="bd">...</div>
    <div class="ft">...</div>
  </div>
@gavacho
gavacho / HauteLook.MultiViewHoverMonitor.js
Last active December 11, 2015 10:08
Multi-View Hover Monitor
HauteLook.MultiViewHoverMonitor = Ember.Object.extend({
toleranceInMilliseconds : 500,
init : function(){
this._super();
this.set( 'isHovering', false );
this.onViewsChanged();
},
jQuery.fn.isInView = function(){
// setup different vars for easier access to these values
var middle = Math.round(this.height() / 2),
winHeight = $(window).height(),
posTop = this.position().top,
scrollTop = $(window).scrollTop(),
middlePos = middle + posTop;
if ( middlePos < scrollTop ) {
EmberRunPromise = function(resolver, name) {
return new Ember.RSVP.Promise(function(resolve, reject) {
resolver(wrapInRun(resolve), wrapInRun(reject));
}, name);
}
function wrapInRun(fn) {
return function() {
var context = this;
var args = [].prototype.slice.apply(arguments);
@gavacho
gavacho / SassMeister-input.scss
Created May 6, 2014 21:52
Generated by SassMeister.com.
// ----
// Sass (v3.3.6)
// Compass (v1.0.0.alpha.18)
// ----
.block {
background-color: black;
&--light {
background-color: white;
@gavacho
gavacho / SassMeister-input.scss
Created May 6, 2014 21:54
Generated by SassMeister.com.
// ----
// Sass (v3.3.6)
// Compass (v1.0.0.alpha.18)
// ----
.block {
background-color: black;
&--light {
background-color: white;