Skip to content

Instantly share code, notes, and snippets.

View SethTompkins's full-sized avatar

Seth Tompkins SethTompkins

View GitHub Profile
@SethTompkins
SethTompkins / datepicker.js
Created August 8, 2014 14:20
jQuery Datepicker: mm/yyyy format with drop-downs only, also sets the default date to the date the is currently selected. This prevents the date from reverting to today's date when the field is selected after the initial set.
// set a configuration object. This allows you to recursively call it in order to
// change the default date after the initial set.
var datePickerDefaults = {
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'mm/yy',
onClose: function(dateText, inst) {
// variables to capture the selected month and year. jQuery datepicker acts
// funky without the calndar, so you need to manually grab these values.
@SethTompkins
SethTompkins / http-provider.js
Created August 6, 2014 15:36
Angular module to make $http behave like jQuery AJAX
angular.module('http-provider', [], function($httpProvider) {
// http://victorblog.com/2012/12/20/make-angularjs-http-service-behave-like-jquery-ajax/
// Use x-www-form-urlencoded Content-Type
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
var param = function(obj) {
var query = '', name, value, fullSubName, subName, subValue, innerObj, i;
for(name in obj) {
value = obj[name];
@SethTompkins
SethTompkins / fileUpload.js
Created August 6, 2014 15:36
Angular factory for using angular-file-upload in any controller.
// replace dentalExchangeApp with the name of your Angular App.
// angular-file-upload.js needs to be included on your page,
// and included as a dependency in your App
dentalExchangeApp.factory('fileUpload', function($upload) {
return {
get: function($files, callback) {
//https://github.com/danialfarid/angular-file-upload
//callback is added so that you can access the returned data inside of your preferred scope.
var filename = $files[0].name;
for (var i = 0; i < $files.length; i++) {