Cross-browser function to trigger DOM events.
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
[ | |
{ | |
"name": "awaiting: API", | |
"color": "c2e0c6" | |
}, | |
{ | |
"name": "awaiting: decision", | |
"color": "bfd4f2" | |
}, | |
{ |
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
export default class Ajax { | |
get(url, callback) { | |
let xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); | |
xhr.open('GET', url); | |
xhr.onreadystatechange = () => { | |
if (xhr.readyState > 3 && xhr.status === 200) { | |
callback(xhr.responseText); | |
} | |
}; | |
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); |
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
// Modified from source: http://stackoverflow.com/a/18078705/772086 | |
var ajax = {}; | |
ajax.x = function () { | |
if (typeof XMLHttpRequest !== 'undefined') { | |
return new XMLHttpRequest(); | |
} | |
var versions = [ | |
"MSXML2.XmlHttp.6.0", | |
"MSXML2.XmlHttp.5.0", |
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
// Returns a function, that, as long as it continues to be invoked, will not | |
// be triggered. The function will be called after it stops being called for | |
// N milliseconds. If `immediate` is passed, trigger the function on the | |
// leading edge, instead of the trailing. | |
function debounce(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; |
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 includes(array, obj) { | |
return Array.prototype.indexOf.call(array, obj) != -1; | |
} | |
function arrayRemove(array, value) { | |
var index = array.indexOf(value); | |
if (index >= 0) { | |
array.splice(index, 1); | |
} | |
return index; |
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
@mixin breakpoint($point) { | |
@if ($MQs == true) { | |
@if $point == baby-bear { | |
@media (max-width: 500px) { @content; } | |
} | |
@if $point == mama-bear { | |
@media (max-width: 700px) { @content; } | |
} | |
@if $point == papa-bear { | |
@media (max-width: 800px) { @content; } |
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
// More : http://davidwalsh.name/write-media-queries-sass | |
@mixin breakpoint($point) { | |
@if $point == tablet { | |
@media (min-width: 768px) and (max-width: 1024px) { | |
@content; | |
} | |
} @else if $point == phone { | |
@media (max-width: 767px) { | |
@content; | |
} |
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
/** | |
* Resource | |
* https://24ways.org/2010/calculating-color-contrast | |
*/ | |
function getContrastYIQ(hexcolor){ | |
var r = parseInt(hexcolor.substr(0,2),16); | |
var g = parseInt(hexcolor.substr(2,2),16); | |
var b = parseInt(hexcolor.substr(4,2),16); | |
var yiq = ((r*299)+(g*587)+(b*114))/1000; |
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 doThousands(n) { | |
n = '' + n; | |
if (n.length < 4) return n; | |
var c = n.length % 3; | |
var pre = n.substring(0, c); | |
return pre + (pre.length? ',' : '') + n.substring(c).match(/\d{3}/g).join(','); | |
} | |
function doThousandsRegExp(n) { | |
if (n.length < 4) return n; |
NewerOlder