Skip to content

Instantly share code, notes, and snippets.

@tkh44
tkh44 / custom-inputs.html
Last active August 29, 2015 13:57
Angular template for dealing with custom fields defined by a json object.
<div ng-switch="input.displayType" ng-class="input.displayType">
<div ng-switch-when="Input" class="text-input custom-input"
ng-class="input.options.multiline ? 'multiline' : 'singleline'">
<span class="category">{{input.name}}</span>
<span class="info">
<input ng-if="!input.options.multiline && input.dataType === 'NUMBER'"
type="{{input.dataType}}" name="{{input.code}}" ng-model="input.value"
required="input.required" min="0" ng-disabled="disabled">
<input ng-if="!input.options.multiline && input.dataType === 'TEXT'"
@tkh44
tkh44 / fixedButtonContainer.js
Created March 24, 2014 21:09
So you can have a fixed button container at the bottom of your ng-view
ticketApp.directive('fixedButtonContainer', function($timeout) {
return {
restrict: 'A',
scope: {
mainView: '@'
},
link: function($scope, $element, attrs) {
$scope.$container = angular.isDefined($scope.mainView) ? $($scope.mainView): $element.closest('[ng-view]');
if (!$scope.$container) return;
(function(angular, $appName$) {
class $controllerName${
constructor($module1$, $module2$, $module3$) {
angular.extend(this, {
$module1$: $module1$,
$module2$: $module2$,
$module3$: $module3$
});
$END$
@tkh44
tkh44 / .bashrc
Created April 14, 2014 21:15
dotfiles
# Need brew ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
# brew install git bash-completion
# if you run into trouble god help you
# this should fix your issues sudo chown -R $USER:admin /usr/local
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)
PURPLE=$(tput setaf 141)
WHITE=$(tput setaf 255)
@tkh44
tkh44 / .gitignore
Last active August 29, 2015 14:02 — forked from rjmunro/.gitignore
.gitignore for cordova >3.4
#platform agnostic
platforms/*/assets/www
# Android
platforms/android/assets/www
platforms/android/bin/
platforms/android/gen/
platforms/android/res/xml/config.xml
platforms/android/ant-build
platforms/android/ant-gen
@tkh44
tkh44 / toggleClass.js
Last active August 29, 2015 14:02
Simple directive to toggle class on click. Can either be applied to element defined on or a child of $element.
app.directive('toggleClass', function () {
return {
restrict: 'A',
scope: {
target: '@',
toggleClass: '@'
},
link: function ($scope, $element, $attr) {
$scope.$targetElement = angular.isDefined($scope.target)? $element.find($scope.target): $element;
@tkh44
tkh44 / geoService.js
Last active August 29, 2015 14:04
Angular service for working with geoLocations using ngCordova
((angular, window) => {
/**
* GeoLocation Utility Service
* @param $localStorage
* @param $cordovaGeolocation
* @param $q
* @returns {{getCachedGeoLocation: getCachedGeoLocation, getDistance: getDistance}}
* @constructor
*/
var GeoService = function($localStorage, $cordovaGeolocation, $q) {
@tkh44
tkh44 / pullToRefresh.html
Last active August 29, 2015 14:04
Simple pull to refresh for angular. Only works on touch devices. Not very good android support.
<div class="pull-to-refresh">
<h1 class="title" ng-bind="text[status]"></h1>
</div>
<div ng-transclude></div>
@tkh44
tkh44 / geoService.js
Last active August 29, 2015 14:04
location caching and distance checking
((angular, window) => {
/**
* GeoLocation Utility Service
* @param $localStorage
* @param $cordovaGeolocation
* @param $q
* @returns {{getCachedGeoLocation: getCachedGeoLocation, getDistance: getDistance}}
* @constructor
*/
var GeoService = function($localStorage, $cordovaGeolocation, $q) {
myApp.service('currentUser', function() {
this.user = {};
})
myApp.controller('myController', function(currentUser) {
$scope.user = currentUser.user;
})