View anim.component.ts
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { expandCollapse } from './expandCollapse.animation';
@Component({
selector: 'app-anim',
animations: [expandCollapse],
template: `
<button (click)="toggle()">{{showText}}</button>
<div *ngIf="show" [@expandCollapse]>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vestibulum bibendum justo sed posuere. Integer consequat nec nisi ac lacinia. Nulla a urna at risus tempus mattis a ut sapien. Mauris eleifend ornare nibh, a semper ligula hendrerit ut. Nullam sit amet elementum mauris, ac lobortis lacus. Cras vestibulum pellentesque ligula vel laoreet. Vivamus eget nibh consequat, viverra mi vel, commodo lectus. Donec cursus aliquam purus nec blandit. Etiam et pellentesque diam, at egestas nisl. Mauris faucibus non erat quis malesuada.</p>
View dateAndTimeStringsToDate.js
// MM/DD/YYYY, M/D/YYYY
const dateRegex = new RegExp(/^(\d{2}|\d{1})\/(\d{2}|\d{1})\/\d{4}$/);
// HH:MM am/pm, HH:MM AM/PM
const timeRegex = new RegExp(/\b((1[0-2]|0?[1-9]):([0-5][0-9]) ([AaPp][Mm]))/);
// Convert date and time strings to a Date object
function stringsToDate(dateStr, timeStr) {
if (!dateRegex.test(dateStr) || !timeRegex.test(timeStr)) {
return null;
}
View capitalize.js
function capitalize(str) {
// Capitalize first letter of string
return str.charAt(0).toUpperCase() + str.slice(1);
}
View formUtils.factory.ts
// MM/DD/YYYY, M/D/YYYY
const DATE_REGEX = new RegExp(/^(\d{2}|\d{1})\/(\d{2}|\d{1})\/\d{4}$/);
export { DATE_REGEX };
View slugify.js
function slugify(text) {
const a = 'ãàáäâèéëêìíïîòóöôùúüûñçßÿœæŕśńṕẃǵǹḿǘẍźḧ·/_,:;'
const b = 'aaaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------'
const p = new RegExp(a.split('').join('|'), 'g')
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c =>
b.charAt(a.indexOf(c))) // Replace special chars
.replace(/&/g, '-and-') // Replace & with 'and'
View app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { DatePipe } from '@angular/common';
import { FilterSortService } from './core/filter-sort.service';
@NgModule({
declarations: [
AppComponent
],
imports: [],
View randomDates.js
/**
* Generate a random date between now and one year from now
* With a time between 7am and 8pm
* Minutes on the full hour :00
* @returns {Date}
*/
function randomDate() {
var start = new Date();
var end = new Date(new Date().setFullYear(start.getFullYear() + 1));
var date = new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
View ordinal.js
/**
* Get ordinal value
*
* @param n {number} if a string is provided, % will attempt to convert to number
* @returns {string} th, st, nd, rd
*/
function getOrdinal(n) {
var ordArr = ['th', 'st', 'nd', 'rd'];
var modulus = n % 100;
View _mq.scss
/*-- Media query variables --*/
$mq-small: 'media and (max-width: 767px)';
$mq-large: 'media and (min-width: 768px)';
/*-- Media query mixin --*/
@mixin mq($mqString) {
@media #{$mqString} {
@content;
View scrollPosition.js
// Firefox uses HTML, Webkit uses body, iOS uses pageYOffset, therefore check for any:
var scrollPosition = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;