Skip to content

Instantly share code, notes, and snippets.

View jbasdf's full-sized avatar

Justin Ball jbasdf

View GitHub Profile
@jbasdf
jbasdf / ember_chosen.js
Created October 7, 2013 18:34
Ember.Select using Chosen
App.Chosen = Ember.Select.extend({
multiple: false,
width: '95%',
disableSearchThreshold: 10,
searchContains: true,
attributeBindings:['multiple', 'width', 'disableSearchThreshold', 'searchContains'],
didInsertElement: function(){
this._super();
@jbasdf
jbasdf / chosen.jquery.js
Created October 10, 2013 15:40
Chosen modified to provide a clean search text callback.
// Chosen, a Select Box Enhancer for jQuery and Prototype
// by Patrick Filler for Harvest, http://getharvest.com
//
// Version 1.0.0
// Full source at https://github.com/harvesthq/chosen
// Copyright (c) 2011 Harvest http://getharvest.com
// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
// This file is generated by `grunt build`, do not edit it by hand.
(function() {
@jbasdf
jbasdf / inactivity-warning.hbs
Created January 2, 2014 23:09
Handlebars template for Ember inactivity warning component.
<div class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button {{action 'close'}} type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="tmModalLabel">Inactivity Warning</h4>
</div>
<div class="modal-body">
You will be logged out in 30 seconds.
</div>
@jbasdf
jbasdf / inactivity-warning.js
Created January 2, 2014 23:14
Javascript for Ember inactivity component
App.InactivityWarningComponent = Ember.Component.extend({
active: false,
inactiveTimeout: 12000000, // Amount of time before we redirect to the sign in screen - the session should have expired by this point. (20 minutes)
warningTimeout: 30000, // Amount of time the user has to perform an action before the last keep alive fires - 30 seconds
timeout: 1170000, // 19.5 minutes. We want to be less than the 20 minute timeout to be sure the session is renewed.
didInsertElement: function(){
//if($('meta[name="in-development"]').attr('content')){ return; } // Uncomment and add a meta tag to your head if you want to avoid session timeout in development
var context = this;
@jbasdf
jbasdf / ember-textfield
Created February 25, 2014 04:08
Ember Textfield
{{ view Ember.Textfield
class="form-control"
placeholderBinding="controller.prompt"
valueBinding="controller.value"
onEvent="keyPress"
action="typing"
}}
@jbasdf
jbasdf / Ember arrow keys
Created February 25, 2014 04:12
Ember bind arrow keys
App.Textfield = Ember.TextField.extend({
init: function() {
this._super();
this.on("keyUp", this, this.interpretKeyEvents);
},
interpretKeyEvents: function(event){
var map = TM.Textfield .KEY_EVENTS;
var method = map[event.keyCode];
@jbasdf
jbasdf / Ember TextField With Arrow Keys
Created February 25, 2014 04:13
Ember Textfield with arrow bindings
{{ view App.Textfield
class="form-control"
placeholderBinding="view.prompt"
valueBinding="view.value"
viewName="inputField"
arrow-up="arrowUp"
arrow-down="arrowDown"
}}
@jbasdf
jbasdf / facebook.js
Created February 28, 2014 00:41
Facebook OAuth2 client side.
var Facebook = {
init: function(){
if(!GLOBAL_SETTINGS.FBappId){ return; }
if(GLOBAL_SETTINGS.application_name){
Facebook.authorize_message = "Authorize your Facebook account for " + GLOBAL_SETTINGS.application_name;
}
Facebook.load_fb();
$('#facebook_connect').on('click', function(e){
e.preventDefault();
@jbasdf
jbasdf / webpack.config.js
Created May 16, 2015 18:46
Development webpack.config.js for hot reloader
{ context: '/Users/jbasdf/projects/canvas_starter_app/client/config',
entry:
{ app:
[ 'webpack-dev-server/client?http://localhost:8080/assets/',
'webpack/hot/dev-server',
'/Users/jbasdf/projects/canvas_starter_app/client/js/app.jsx' ],
app_admin:
[ 'webpack-dev-server/client?http://localhost:8080/assets/',
'webpack/hot/dev-server',
'/Users/jbasdf/projects/canvas_starter_app/client/js/app_admin.jsx' ],
@jbasdf
jbasdf / stub_context.js
Created June 4, 2015 00:23
Stub context for React Router and Material UI >= 0.8.0
"use strict";
import React from "react";
import assign from "object-assign";
var { func } = React.PropTypes;
var mui = require('material-ui');
var ThemeManager = new mui.Styles.ThemeManager();