Skip to content

Instantly share code, notes, and snippets.

View veryrobert's full-sized avatar

Robert Farrelly veryrobert

View GitHub Profile
@veryrobert
veryrobert / font-mixin.scss
Last active March 8, 2016 12:24
Font Mixin for Sizes
@mixin phone {
@media (max-width: #{$phone-width}) {
@content;
}
}
@mixin tablet {
@media (max-width: #{$tablet-width}) {
@content;
}
// Using Kirby structure field with a selection field inside for images
<?php foreach($page->structureName()->yaml() as $name) {
$title = $name['fieldNameText'];
$image = $name['fieldNameImage'];
$imageUrl = $page->file($image)->url();
echo html('<h1>'.$title.'</h1><img src="'.$imageUrl.'" alt="'.$title.'">');
}
@veryrobert
veryrobert / spriteMixin
Created April 25, 2014 10:29
Sprite with some useful mixins and a png fallback
// sprite for images
.sprite-1 {
background-image: url(../img/icon_sprite.png); // Fallback going on here
background-image: url(../img/icon_sprite.svg);
}
// mixin for logos and large image that needs text-indext
@mixin sprite($sprite-class, $x: 0, $y: 0, $h: 0, $w: 0) {
@extend .#{$sprite-class};
@veryrobert
veryrobert / formValidate
Created April 25, 2014 10:19
Form Validation for Errors
// <form id="myForm" name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post" class="form" novalidate>
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
$('input.required').addClass('warning');
$('input.required').after('<p class="warning four-eight">Form field entered incorrectly please try again</p>');
return false;
@veryrobert
veryrobert / gist:9055415
Last active August 29, 2015 13:56
Asynchronous Loading for Google Maps with custom Icon
// Asynchronous Loading Google maps
function initialize() {
var styles = [ ]
var position = new google.maps.LatLng();
var mapOptions = {
zoom: 15,
@veryrobert
veryrobert / Ajax Call
Last active January 4, 2016 05:49
Ajax function with working back button
$(document).ready(function(){
ajaxCall('nav a', '#container', '#guts', 200);
});
var ajaxCall = function(link, container, guts, speed){
var mainContent = $(container);
var contents = $(guts);
@veryrobert
veryrobert / spritehover.scss
Last active December 25, 2015 06:29
Image Sprite Hover Fade with Sass & Compass
@mixin sprite {
display: inline-block;
position: relative;
text-indent: -9999px;
}
@mixin sprite-after {
content: "";
position: absolute;
top: 0;
@veryrobert
veryrobert / randomimage.js
Created September 16, 2013 16:13
Quick javascript tool for random image placement
$('.images').each(function(i,el){
var tLeft = Math.floor(Math.random()*960),
tTop = Math.floor(Math.random()*1000);
console.log('left =' + tLeft);
$(el).css({left:tLeft, top: tTop});
@veryrobert
veryrobert / loadContent.js
Last active December 20, 2015 04:19
Jquery Load Content and maintain nav
$('#wrapper').hide();
//loads content
function loadContent(url) {
$('#wrapper').load(url).delay(500).fadeIn(500);
}
$(function() {
$('#nav a').on('click', function(e) {
e.preventDefault();
@veryrobert
veryrobert / panel.html
Created May 28, 2013 09:26
Two panel on grey with and without button
<section class="panel bg-gray-bg">
<div class="content-wrapper">
<div class="row">
<li class="d5-d10 two-up media-on-panel" >
<img src="http://placehold.it/470x290/000000/ffffff" alt="Image Alt">
<span class="box-out ual-white-bg block">
<h3>This is a title</h3>