Skip to content

Instantly share code, notes, and snippets.

@chancesmith
chancesmith / jquery.overlayMap.js
Last active September 23, 2016 21:46
Disable Google-Map/iFrame scroll until clicked. We first wrap all iframes with .overlay div, to disable the iframe. Then the user clicks to use. Then adds the overlay back when mouseleave
// // wrap all iFrames, except those with an id of #noOverlay
$('iframe').not( document.getElementById( "noOverlay" ) ).wrap('<div class="overlayiFrame" />');
//overlay on iframes
$('.overlayiFrame iframe').css("pointer-events","none");
$('.overlayiFrame').click(function () {
$('.overlayiFrame iframe').css("pointer-events", "auto");
});
$('.overlayiFrame').mouseleave(function () {
$('.overlayiFrame iframe').css("pointer-events", "none");
@chancesmith
chancesmith / jquery.tabs.js
Created October 12, 2016 14:40
Tabs HTML/javascript with jQuery and no bulk
$( document ).ready(function() {
$("ul.tabs li").click(function(e){
e.preventDefault();
if(!$("this a").hasClass("active")){
nthContent = $(this).index();
nthContent += 1;
// remove active class from tabs and content
$("ul.tabs li a.active, .content.active").removeClass("active");
// add active class to tab and content
$("this a").addClass("active");
@chancesmith
chancesmith / product.html
Created October 12, 2016 14:52
Update order subtotal with jQuery
<div class="summary_block">
<h3 id="title-price" content="574.8">Books - $574.80</h3>
<form action="/cart/add" method="post" enctype="multipart/form-data" id="AddToCartForm">
<div class="quantity">
<div class="filter_cnt pull-left">
<label for="Quantity">Quantity</label>
<div class="filter">
<select id="Quantity" name="quantity" class="selectpicker" tabindex="-98">
<option value="1">1</option>
<option value="2">2</option>
@chancesmith
chancesmith / jquery.rotate-logos.js
Created October 12, 2016 15:11
Rotating logos - fade-in/fade-out [one-at-a-time] (no carousel)
// Client logos
var logoEls = $('.social-proofs .clientLogo'),
logoCount = logoEls.size(),
unusedLogos = [{
src: 'img/companies-we-represent/house-of-raeford.png',
alt: 'YOUR COMPANY serves House of Raeford'
}, {
src: 'img/companies-we-represent/pictsweet.png',
alt: 'YOUR COMPANY serves Pict-Sweet'
@chancesmith
chancesmith / main.js
Last active October 12, 2016 17:03
Float specific li items to the top of a list
// list featured collections in opposite order desired
var featured = ['Metal Signs',
'Canvas Prints',
'Gallery Prints'];
var ul = $(".list");
for(var i = 0; i < featured.length; i++){
ul.prepend( $( ".list li:contains('" + featured[i] + "')" ) );
}
@chancesmith
chancesmith / mobile-check.js
Created October 13, 2016 14:20
if mobile device
function isMobile(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
return true;
}
}
@chancesmith
chancesmith / anchor-offset.js
Created October 13, 2016 14:20
Adds top offset to all anchor links clicked (reads URL for anchor link and adds offset of scroll position)
// anchor links offset
$('a[href^="#"]').click(function() {
var target = $(this.hash);
if (target.length == 0) target = $('a[name="' + this.hash.substr(1) + '"]');
if (target.length == 0) target = $('html');
$('html, body').animate({ scrollTop: target.offset().top-170 }, 1000);
return false;
});
// Might need a mobile query to handle a different offset
@chancesmith
chancesmith / main.js
Created October 13, 2016 16:47
match text by iterate through desired results
$(document).ready(function() {
var selection = $('select').text().trim();
var featured = ["Art Prints",
"Postcards"];
for(var i = 0; i < featured.length; i++){
if( selection !== featured[i] ){
// do something, in my case...
$('.frames').hide();
}
@chancesmith
chancesmith / scroll-to-top.html
Created October 24, 2016 16:10
Scroll-to-top icon (slide in/out)
<style>
// scroll to top
#back-to-top{
position: fixed;
bottom: -66px;
right: 20px;
color: white;
z-index: 3;
width: 40px;
height: 40px;
@chancesmith
chancesmith / wp-config.php
Last active October 26, 2016 19:41
local wordpress developement URL
// source: http://mardell.me/blog/how-to-use-a-single-wordpress-config-for-local-and-remote-environments/
/////
if ($_SERVER['SERVER_NAME'] === "blog.dev") {
// test site
define( 'WP_SITEURL', 'http://blog.dev' );
define( 'WP_HOME', 'http://blog.dev' );
} else {
// live site
};