Skip to content

Instantly share code, notes, and snippets.

@AdonaiAraya
AdonaiAraya / Auth.ts
Created April 20, 2017 15:35
Ionic basic auth decorator
export function Auth(data){
return function (target: Function) {
Object.defineProperty(target.prototype, "ionViewCanEnter", {
value: authFunction
});
};
function authFunction(){
//Here you can do your custom validation, it must return a boolean or a Promise
return false;
@AdonaiAraya
AdonaiAraya / typewritter.directive.ts
Last active September 26, 2016 17:06
An angular 2 directive for gettting a type writter effect. Example: http://embed.plnkr.co/mQfnYYiFFGzTcJTSLpay/
import { Directive, ElementRef, Renderer, Input, OnInit } from "@angular/core";
@Directive({
selector: "[typewritter]"
})
export class TypewritterDirective implements OnInit{
@Input("quotes") quotes : string[] = [];
private writtingSpeed : number = 225;
private deletingSpeed : number = 80;
@AdonaiAraya
AdonaiAraya / digitLimitWithFormSubmitDirective.js
Last active May 23, 2016 15:42
Digit limit with form submit on enter (on iOS and Android, input type number not submit the form on "enter")
.directive("digitLimit", function(){
return {
require: "^form",
restrict: "A",
link: function(scope, element, attrs, ctrl){
var max = attrs.digitLimit;
element.bind("keypress keydown", function(e){
if(e.type == "keypress"){
var currentValue = element.val();
@AdonaiAraya
AdonaiAraya / digitLimitDirective.js
Created May 20, 2016 09:29
Angular directive for limit the max length in input number
/*
<input type='number' digit-limit="4" />
*/
.directive("digitLimit", function(){
return {
restrict: "A",
link: function(scope, element, attrs){
var max = attrs.digitLimit;
element.bind("keydown", function(e){
@AdonaiAraya
AdonaiAraya / minDigitsDirective.js
Last active May 20, 2016 09:29
Angular directive for min digits validation in input type number
/*
<input type='number' min-digits='4' />
*/
.directive("minDigits", function () {
return {
require: "ngModel",
link: function (scope, element, attrs, ctrl) {
var min = attrs.minDigits;
element.bind("keyup", function () {
@-webkit-keyframes echo {
0% {
padding: 0;
margin: 0;
opacity: 1;
}
100% {
padding: 50px;
margin: -50px;
[{"country":"Afghanistan","code":"93","iso":"AF"},
{"country":"Albania","code":"355","iso":"AL"},
{"country":"Algeria","code":"213","iso":"DZ"},
{"country":"American Samoa","code":"1-684","iso":"AS"},
{"country":"Andorra","code":"376","iso":"AD"},
{"country":"Angola","code":"244","iso":"AO"},
{"country":"Anguilla","code":"1-264","iso":"AI"},
{"country":"Antarctica","code":"672","iso":"AQ"},
{"country":"Antigua and Barbuda","code":"1-268","iso":"AG"},
{"country":"Argentina","code":"54","iso":"AR"},