Skip to content

Instantly share code, notes, and snippets.

View allusis's full-sized avatar
👊

Tony Montemorano allusis

👊
View GitHub Profile
@allusis
allusis / IconSprite.component
Created February 15, 2016 18:50
SVG Icon Sprites in VisualForce
<!-- CSS will cascade the fill or stroke through the shapes, as long as there are no presentational fill attributes on the shapes themselves -->
<apex:component layout="none">
<svg xmlns="http://www.w3.org/2000/svg" class="hide">
<symbol id="chevron" viewBox="0 0 15.5 39.5">
<polygon points="15.5,19.8 10.2,19.8 0,0 5.2,0 "/>
<polygon points="15.5,19.8 10.2,19.8 0,39.5 5.2,39.5 "/>
</symbol>
</svg>
</apex:component>
@allusis
allusis / input.number.js
Last active December 17, 2015 06:08
Apex - input number only
<script>
function isNumberOnly(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
//console.log(charCode);
if(charCode == 110 || charCode == 190) {
return true;
}
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57 && charCode < 96 || charCode > 105)) {
evt.preventDefault();
@allusis
allusis / inline-svg.js
Last active December 17, 2015 06:08
Replace <img> with svg file source
$(document).ready(function () {
// Replace img tag with svg src
jQuery('.img-inline').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {
// Get the SVG tag, ignore the rest
var $svg = jQuery(data).find('svg');
@allusis
allusis / collapse-toggle.js
Last active December 17, 2015 06:08
Expand / Collapse text toggling for Bootstrap3
$(function () {
var active = true;
$('#expand-btn').click(function() {
if (active) {
active = false;
$('.collapse:not(.in)').collapse('show');
$('.panel-header').attr('data-toggle', 'collapse');
$(this).text('Collapse all sections');
} else {
active = true;
@allusis
allusis / _color-contrast.scss
Last active December 17, 2015 06:09
A Sass function for determine contrasting colors
$text-color: #555;
@function contrast-color($color) {
@if (lightness($color) > 75) {
// Lighter background, return dark color
@return $text-color;
} @else {
// Darker background, return light color
@return white;
}
@allusis
allusis / _material-shadow.scss
Last active December 17, 2015 06:09
Material shadow mixin
// Material-like shadowing
@mixin shadow($level: 1) {
@if $level == 1 {box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);}
@else if $level == 2 {box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);}
@else if $level == 3 {box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);}
@else if $level == 4 {box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);}
@else if $level == 5 {box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);}
}
// Example usage
@allusis
allusis / _drop-shadow.scss
Last active December 12, 2015 18:34
A SCSS Mixin for drop-shadow
@mixin drop-shadow($dropshadow) {
-webkit-filter:drop-shadow($dropshadow);
-moz-filter:drop-shadow($dropshadow);
-ms-filter:drop-shadow($dropshadow);
filter:drop-shadow($dropshadow);
}
// Example usage
.box {
@include drop-shadow(0 0 5px black);
@allusis
allusis / footer.scss
Created December 12, 2015 18:30
A sticky footer that pays little or no regard to markup
@allusis
allusis / scroll-class.js
Created December 12, 2015 18:27
Add CSS class on scroll
$(function(){
var shrinkHeader = 10;
$(window).scroll(function() {
var scroll = getCurrentScroll();
if ( scroll >= shrinkHeader ) {
$('body').addClass('scrolled');
}
else {
$('body').removeClass('scrolled');
}
@allusis
allusis / copyright.js
Created December 12, 2015 18:23
Make the copyright year that you hate updating dynamic