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 / focusMeDrct.js
Last active August 29, 2015 14:02
Angular Directive for auto focusing an element if a value gets true.
/**
* Sets focus to this element if the value of focus-me is true.
* @example
* <a ng-click="addName=true">add name</a>
* <input ng-show="addName" type="text" ng-model="name" focus-me="{{addName}}" />
*/
app.directive('focusMe', ['$timeout', function($timeout) {
return {
scope: { trigger: '@focusMe' },
link: function(scope, element) {
@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>
@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 / 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 / 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 / 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';
// AtScript
class MyClass {
methodA(name:string):int {
var length:int = name.length;
return length;
}
}
// ES6
class MyClass {
@bettysteger
bettysteger / directive.js
Created November 11, 2014 14:29
Declarative Metadata (Angular 2.0 directive)
// AtScript
@Directive({
selector: '[blink]'
})
class Blink {
constructor(elment:Element, options:Options, timeout:Timeout) {}
}
// ES6
class Blink {
@bettysteger
bettysteger / replace_regex.js
Last active August 29, 2015 14:27
How to reuse matched value of regex in replace JS function
var text = "this is a {highlighted} text";
var regex = /\{\S+?\}/g;
var html = text.replace(regex, '<mark>$&</mark>'); // $& = matched value = {highlight}
alert(html); // => "this is a <mark>{highlighted}</mark> text"
var regex2 = /\{(\S+?)\}/g; // you need ()-brackets to get $1
var html2 = text.replace(regex2, '<mark>$1</mark>'); // $1 = first () = highlight
alert(html2); // => "this is a <mark>highlighted</mark> text"
@bettysteger
bettysteger / facebox.sass with compass-mixins
Created March 26, 2011 18:04
facebox.sass with compass-mixins
#facebox
position: absolute
top: 0
left: 0
z-index: 100
text-align: left
#facebox .popup
position:relative
border: 3px solid rgba(0,0,0,0)