This file contains 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
$base-font-size: 16px; | |
// Calculate rem value | |
@function calculateRem($size) { | |
$remSize: $size / $base-font-size; | |
@return $remSize * 1rem; | |
} | |
// Calculate Viewport-Width dependent value | |
@function calculateVW($size) { |
This file contains 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
// Description: Get new width or height while preserving the aspect ratio | |
// TODO: Add AspectRatio related methods | |
var AspectRatio = { | |
getScaled: function ( currentW, currentH, newSize, property ) { | |
return ( property === 'width' )? ((currentH / currentW) * newSize) : (currentW / currentH) * newSize) | |
} | |
}; |
This file contains 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 assert (condition, message) { | |
if (!condition) { | |
message = message || "Assertion failed"; | |
if (typeof Error !== "undefined") { | |
throw new Error(message); | |
} | |
throw message; // Fallback | |
} | |
} |
This file contains 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
Object.size = function ( obj ) { | |
var size = 0, key; | |
for (key in obj) { | |
if ( obj.hasOwnProperty(key) ) { size++; } | |
} | |
return size; | |
}; |
This file contains 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
/*---------------------------------------------------------------*\ | |
RESPONSIVE PROPERTY HANDLER | |
handles the per-breakpoint property for mobile-first approach | |
note: requires a key-less 'breakpoints' scss map | |
e.g. $breakpoints: ( 320px, 760px, 1080px, 1280px ); | |
usage: | |
@include respond(( | |
display: flex, |
This file contains 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 $$(selector, context) { | |
context = context || document; | |
var elements = context.querySelectorAll(selector); | |
return Array.prototype.slice.call(elements); | |
} |
This file contains 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
//------------------------------------------------------------------*\ | |
// PIXEL TO REM | |
// converts px to rem | |
// note: uses @strip-units and $em-base | |
// usage: (https://jsfiddle.net/joshuacerbito/10q09tww/) | |
// width: rem(760); | |
// padding: rem(30 0 10); | |
//------------------------------------------------------------------*\ | |
$base-font-size: 16px; |
This file contains 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 unless(exp, func) { | |
if ( typeof func === 'function' && !exp ) { | |
func.apply(this, arguments); | |
} | |
return !exp; | |
} |
This file contains 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
/*---------------------------------------------------------------*\ | |
ASPECT RATIO HANDLER | |
preserves the aspect ratio of an element | |
usage: | |
@include aspect-ratio(16, 9); | |
note: | |
you can use this link to find your desired aspect ratio | |
http://andrew.hedges.name/experiments/aspect_ratio/ |
This file contains 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
textInput.addEventListener('keydown', function (e) { | |
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 || | |
(e.keyCode == 65 && e.ctrlKey === true) || // Allow: Ctrl+A | |
(e.keyCode == 67 && e.ctrlKey === true) || // Allow: Ctrl+C | |
(e.keyCode == 88 && e.ctrlKey === true) || // Allow: Ctrl+X | |
(e.keyCode >= 35 && e.keyCode <= 39)) // Allow: home, end, left, right | |
{ return; } | |
// Ensure that it is a number and stop the keypress | |
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { |
OlderNewer