This file contains hidden or 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
app.directive('ngSpace', function() { | |
return function(scope, element, attrs) { | |
element.bind("keydown keypress", function(event) { | |
if(event.which === 32) { | |
scope.$apply(function(){ | |
scope.$eval(attrs.ngSpace); | |
}); | |
event.preventDefault(); | |
} |
This file contains hidden or 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
app.directive('ngEnter', function() { | |
return function(scope, element, attrs) { | |
element.bind("keydown keypress", function(event) { | |
if(event.which === 13) { | |
scope.$apply(function(){ | |
scope.$eval(attrs.ngEnter); | |
}); | |
event.preventDefault(); | |
} |
This file contains hidden or 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
app.filter('creditcard', function(){ | |
return function(cc, maskChar, sep){ | |
if(!sep) | |
sep = '-'; | |
var maskedNum = Array(cc.length - 3).join(maskChar) + cc.substr(cc.length - 4, 4); | |
maskedNum = maskedNum.substring(0, 4) + sep + | |
maskedNum.substring(4, 8) + sep + | |
maskedNum.substring(8, 12) + sep + | |
maskedNum.substring(12, 16); |
This file contains hidden or 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
/** | |
* Custom submit directive that will only submit when all the validation has passed | |
* for all the fields. This extends on the ng-submit directive provided by AngularJS. | |
* | |
* This directive will also remove the 'pristine' flag from all the fields when | |
* hitting submit, allowing the form to display no errors until the submit button | |
* is clicked/enter is pressed. | |
* | |
* The variable 'app' is the instance of a module. | |
* E.g. var app = angular.module('my-app', []); |
This file contains hidden or 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.module('myApp'). | |
filter('capitalise', function() { | |
return function(input) { | |
return (!!input) ? input.replace(/([^\W_]+[^\s-]*) */g, function(txt) { | |
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); | |
}) : ''; | |
}; | |
}); |
This file contains hidden or 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
.help-block { | |
display: none; | |
} | |
.has-error .help-block { | |
display: block; | |
} |
This file contains hidden or 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
.form-group .help-block { | |
display: none; | |
} | |
.form-group.has-error .help-block { | |
display: block; | |
} |
This file contains hidden or 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
app.filter('noFractionCurrency', | |
[ '$filter', '$locale', function(filter, locale) { | |
var currencyFilter = filter('currency'); | |
var formats = locale.NUMBER_FORMATS; | |
return function(amount, currencySymbol) { | |
var value = currencyFilter(amount, currencySymbol); | |
var sep = value.indexOf(formats.DECIMAL_SEP); | |
console.log(amount, value); | |
if(amount >= 0) { | |
return value.substring(0, sep); |
This file contains hidden or 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 inView = false; | |
function isScrolledIntoView(elementID) { | |
// This checks if the element is in view | |
var docViewTop = $(window).scrollTop(); | |
var docViewBottom = docViewTop + $(window).height(); | |
var elemTop = $(elementID).offset().top; | |
var elementBottom = elemTop + $(elementID).height(); |
This file contains hidden or 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
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'currencyCustom' | |
}) | |
export class CurrencyCustom implements PipeTransform { | |
/** | |
* @param value | |
*/ |
OlderNewer