This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates a random guid. | |
* | |
* @example 064ca254-ab32-4a0b-bb38-4a35c730f323 | |
*/ | |
function guid(){ | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); | |
return v.toString(16); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* add a script dynamically to the head of your document | |
* use <script ng-src="/path/to/script.js"></script> | |
*/ | |
.directive('script', ($parse, $rootScope) => { | |
return { | |
restrict: 'E', | |
terminal: true, | |
link: (scope, element, attr) => { | |
if (attr.ngSrc) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Angular Directive to collapse a panel | |
* | |
* Params: | |
* name {string} the name of the directive (bound by angular.module.directive(name, fn)) | |
* | |
* Use: | |
* <div class="sidebar"> | |
* <div class="toggle" collapse=".sidebar"> </div> | |
* </div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyComponentController { | |
static $inject = ['AnyService']; | |
constructor( private service: AnyService) {} | |
} | |
class MyComponent implements ng.IComponentOptions { | |
public bindings: { [binding: string]: string }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Angular directive to search inside a list of objects | |
* | |
* @event search-select on selection. Emits the selected obj upstream to parents | |
*/ | |
class SearchDirective implements ng.IDirective { | |
public restrict: string = "EA"; | |
public scope: Object = {}; // always use an isolated scope | |
public bindToController: Object = { // bind properties to controller (not the scope) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Wraps a match inside a string between <b>...</b> tags | |
* | |
* Example: | |
* $filter('filtername').('match'); | |
* | |
* Note: make sure you'll render this using ng-bind-html (in a repeater you'll probably must use ng-if as well, or otherwise all nodes will be rendered (empty when no match)) | |
*/ | |
class MarkSelectedFilter { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var phantomjs = require('phantomjs-prebuilt/bin/phantomjs'); | |
var page = require('webpage').create(); | |
page.open('http://github.com/', function() { | |
page.render('github.png'); | |
phantom.exit(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Register a debug helper for Handlebars to be able to log data or inspect data in the browser console | |
* | |
* Usage: | |
* {{debug someObj.data}} => logs someObj.data to the console | |
* {{debug someObj.data true}} => logs someObj.data to the console and stops at a debugger point | |
* | |
* https://gist.github.com/elgervb/5c38c8d70870f92ef6338a291edf88e9 | |
* | |
* @param {any} the data to log to console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Truncate the current element with a ellipsis over a fixed number of lines when it does not fit | |
* | |
* @param {strimg} $lineHeight The line height with unit (1em, 1.785rem, 25px) | |
* @param {number} $lineCount The number of lines to show | |
* @param { | |
* | |
* @see http://hackingui.com/front-end/a-pure-css-solution-for-multiline-text-truncation/ | |
*/ | |
@mixin wrap-ellipsis-multiline($lineHeight: 1.2em, $lineCount: 1, $bgColor: #ffffff){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hack for equal column height, together with parent display: table; | |
.row-eq-height { | |
display: table; | |
margin-left: 0; | |
margin-right: 0; | |
width: 100%; | |
> [class*="col-"] { | |
float: none; | |
display: table-cell; |
OlderNewer