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
function qs(selector: string, parent: ParentNode = document): Element | null { | |
return parent.querySelector(selector) | |
} | |
function qsa(selector: string, parent: ParentNode = document): Element[] { | |
return [...parent.querySelectorAll(selector)] | |
} | |
function createElement(type: string, options: Record<string, string | object> & Partial<{ class: string, dataset: object, text: string }> = {}): HTMLElement { | |
const elm = document.createElement(type) |
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
const randomNumber = (min, max) => Math.random() * (max - min) + min; | |
const isNil = (val) => val === null || val === undefined; | |
const removeDuplicates = (arr) => [...new Set(arr)]; | |
const isDateString = (val) => !isNaN(Date.parse(val)); | |
const shuffle = (arr) => arr.sort(() => Math.random() - 0.5); |
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('Confirmation', []) | |
.directive 'ngConfirmClick', ($parse) -> | |
restrict: 'A' | |
link: (scope, element, attrs) -> | |
popId = Math.floor Math.random() * 10000000000 | |
attrs.popId = popId | |
message = attrs.message ? 'Do you really want to delete?' | |
okLabel = attrs.okLabel ? 'Yes' | |
cancelLabel = attrs.cancelLabel ? 'No' |
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
myApp = angular.module 'myApp', [] | |
myApp.service 'FlashMessage', ($rootScope) -> | |
Flash = () -> | |
$rootScope.flashes = [] | |
$rootScope.$on '$routeChangeSuccess', () -> | |
$rootScope.$broadcast 'FlashMessage:reset', $rootScope.flashes = [] | |
return |