Skip to content

Instantly share code, notes, and snippets.

View bettysteger's full-sized avatar
🏠
Working from home

Betty Steger bettysteger

🏠
Working from home
View GitHub Profile
@bettysteger
bettysteger / es6-classes-inheritance.js
Last active October 11, 2020 00:05
ES6 Classes and Inheritance example (www.es6fiddle.net)
/**
* Classes and Inheritance
* Code Example from http://www.es6fiddle.net/
*/
class Polygon {
constructor(height, width) { //class constructor
this.name = 'Polygon';
this.height = height;
this.width = width;
}
@bettysteger
bettysteger / authInterceptor.js
Created October 30, 2014 14:31
Set specific http headers on every http request from cookies (angular)
'use strict';
/**
* Authentication with token and email for every server request. (Sets HTTP headers)
*
* This interceptor shows the error from the server (i18n key).
* Also sets global error variable if the request fails and redirects the user to '/' when he is not authorized.
* @see http://engineering.talis.com/articles/client-side-error-logging/
*/
app.factory('authInterceptor', function ($rootScope, $q, $cookies, $location, $timeout) {
@bettysteger
bettysteger / userCtrl.js
Last active March 24, 2017 20:34
Custom angular form validation (Angular 1.2 vs 1.3)
/**
* Angular 1.2
* Helper method for Signup and Update. Checks if email or username of user exists per GET request.
* Sets custom validation: 'exists' to true or false.
* @example
* <input type="email" name="email" ng-model="user.email" ng-change="checkIfExists(form.email)" />
*/
var timeout = false;
$scope.checkIfExists = function(input) {
if(!input.$viewValue) { return; }
@bettysteger
bettysteger / formErrorsSvc.js
Last active January 16, 2018 10:14
Angular Form Group Directive and Form Errors Service (sets validities depending on server response)
/**
* Handles form errors from server.
*/
app.factory('formErrors', function () {
return {
/**
* Creates $error.errorKey (String) and sets validity
* for every failing model validation received from the server.
* E.g. 'form.message.$error.errorKey' can be accessed in the view.
@bettysteger
bettysteger / _head.html
Last active January 13, 2016 19:42
Fix for $location:nobase for angular-1.3.0-rc.0 app
<!--
Uncaught Error: [$location:nobase]
https://docs.angularjs.org/error/$location/nobase
-->
<head>
<base href="/">
</head>
@bettysteger
bettysteger / menuDrct.js
Last active August 29, 2015 14:04
Recursive Menu Directive
/**
* Menu with clickable items (no hover)
* Recursive Menu Directive (needs $compile)
* @see http://stackoverflow.com/questions/19962872/recursive-menu-directive
* @example
* <menu menu="[{ title: 'Home'}, { title: 'Projects', submenu: [{ title: 'Project1' }] }]"></menu>
*/
app.directive('menu', ['$compile', '$document', '$timeout', function ($compile, $document, $timeout) {
'use strict';
@bettysteger
bettysteger / pie.scss
Created June 27, 2014 08:02
Overwrites CSS for a nvd3 pie chart
$pieSize: 18px;
.pie-wrap { // own class
float: left;
svg {
display: inline-block;
width: $pieSize;
height: $pieSize;
margin: 4px;
@bettysteger
bettysteger / nvd3PieChart.html
Created June 27, 2014 07:40
How-to create a simple pie chart with angular-nvd3
<nvd3 options="pieOptions" data="pieData"></nvd3>
@bettysteger
bettysteger / nvd3PieChart.html
Created June 27, 2014 07:35
How-to create a simple pie chart with angularjs-nvd3-directives
<nvd3-pie-chart id="{{id}}"
data="pieData"
width="80"
height="80"
x="xFunction()"
y="yFunction()">
</nvd3-pie-chart>
@bettysteger
bettysteger / pieChartjs.html
Last active August 29, 2015 14:03
How-to create a simple pie chart with tc-angular-chartjs
<canvas tc-chartjs-pie chart-data="pieData" chart-options="{segmentShowStroke: false}" width="25" height="25"></canvas>