Skip to content

Instantly share code, notes, and snippets.

View spsaucier's full-sized avatar

Stephen Saucier spsaucier

View GitHub Profile
@spsaucier
spsaucier / gist:6044001
Last active December 20, 2015 00:48
Wordpress - Create a Widget Area
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name'=> 'Top Tabs',
'id' => 'top_tabs',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="offscreen">',
'after_title' => '</h2>',
));
register_sidebar(array(
@spsaucier
spsaucier / gist:6044003
Created July 20, 2013 05:47
Wordpress - Add widget area to template
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Homepage Widget Area')) : ?>
<?php endif; ?>
@spsaucier
spsaucier / gist:6044007
Created July 20, 2013 05:48
AJAX call including JS and CSS
<a href="javascript:ajaxpage('test.htm', 'contentarea'); loadobjs('external.css', 'feature.js')">test</a>
<div id="contentarea"></div>
@spsaucier
spsaucier / gist:6044010
Created July 20, 2013 05:49
Hide iframe onclick
<!--[if lte IE 8]>
<script type="text/javascript">
<!--
function HideFrame() {
var fr = document.getElementById ("sunrise");
if(fr.style.display=="none") {
fr.style.display="block";
}
else {
fr.style.display="none";
@spsaucier
spsaucier / gist:6044011
Created July 20, 2013 05:49
Call Hide Iframe
<a href="#" onclick="HideFrame()">Sample text</a>
@spsaucier
spsaucier / gist:6044016
Created July 20, 2013 05:50
User Guide - jQuery hide on heading click
//On click of the heading-click class members or h4 elements, expand the following element. The sub-content of the headings are wrapped in <article> or <section> tags.
jQuery(document).ready(function(){
$('.heading-click, h4').click(function() {
$(this).next().toggle('slow');
return false;
}).next().hide();
//Go to the location shown by the hash in the URL and show the element(s) containing it.
function goToByScroll(id){
$('html,body').animate({scrollTop: $("#"+id).offset().top},'fast');}
@spsaucier
spsaucier / gist:6044018
Created July 20, 2013 05:50
Convert Table to Divs with jQuery
$(".productTable").after("<div id='product-container'></div>");
$(".productTable .product_item").appendTo("#product-container").each(function() {});
$('.productTable').remove();
@spsaucier
spsaucier / gist:6044020
Created July 20, 2013 05:50
Table to Divs - HTML
<table class="productTable ">
<tbody>
<tr>
<td class="productItem">
<div class="product_item">
Product 1
</div>
</td>
<td class="productItem">
<div class="product_item">
@spsaucier
spsaucier / gist:6044023
Created July 20, 2013 05:52
jQuery - Form Validation without PHP
jQuery(document).ready(function(){
function randomgen()
{
var rannumber='';
for(ranNum=1; ranNum<=6; ranNum++){
rannumber+=Math.floor(Math.random()*10).toString();
}
$('#verifyNum').html(rannumber);
$('#verifyNumHidden').val(rannumber);
}
@spsaucier
spsaucier / gist:6044024
Created July 20, 2013 05:53
Delivery Form with jQuery
<form id="checkDelivery">
<label for="postcode">Enter your postcode</label>
<input type="text" required name="postcode"/>
<button class="button">Submit</button>
</form>
<div id="delivery_options"></div>
<script>
$('#checkDelivery').submit(function() {
var data = $(this).serializeArray(),