Skip to content

Instantly share code, notes, and snippets.

@thotbox
thotbox / JavaScript: Required Toggle.js
Last active August 29, 2015 14:03
JavaScript: Required Toggle
// Cable Field Required
$('#email_optin').click(function() {
if ($('#email_optin').prop('checked')) {
$('#cable_provider').attr('required', true);
$('#cable_provider_label').addClass('required-label');
}
if (!$('#email_optin').prop('checked')) {
$('#cable_provider').removeAttr('required');
$('#cable_provider_label').removeClass('required-label');
@thotbox
thotbox / CSS: Retina Media Queries.css
Last active August 29, 2015 14:03
CSS: Retina Media Queries
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
#header { background: url('/themes/site_themes/site/img/header-image-retina.jpg'); }
}
@media only screen and (min--moz-device-pixel-ratio: 2) {
#header { background: url('/themes/site_themes/site/img/header-image-retina.jpg'); }
}
@media only screen and (-o-min-device-pixel-ratio: 2/1) {
#header { background: url('/themes/site_themes/site/img/header-image-retina.jpg'); }
}
@media only screen and (min-device-pixel-ratio: 2) {
@thotbox
thotbox / JavaScript: Center Block Grid Orphans.js
Last active August 29, 2015 14:03
JavaScript: Center Block Grid Orphans
// Blog Grid Center Fix
function centerBlockGrid(listID){
$window = $(window);
var windowWidth = $window.width();
var listWidth = $(listID).width();
var smallGrid;
var mediumGrid;
var largeGrid;
@thotbox
thotbox / JavaScript: Viewport Height.js
Last active August 29, 2015 14:04
JavaScript: Viewport Height
$(document).ready(function(){
$window = $(window);
var targetHeight = $window.height();
var viewportWidth = $window.width();
if (viewportWidth > 640) {
$('#targetID').css({ height: targetHeight });
}
});
$(window).bind('resize', function () {
@thotbox
thotbox / JavaScript: Email Submit Disable.js
Last active August 29, 2015 14:04
JavaScript: Email Submit Disable
// Email Submit Disable
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pat
@thotbox
thotbox / JavaScript: Popup Confirm Close.js
Last active August 29, 2015 14:04
JavaScript: Popup Confirm Close
// Vote Submit
function voteShare (pageURL,title,w,h) {
var left = (window.screen.width/2)-(w/2);
var top = (window.screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
var pollTimer = window.setInterval(function() {
if (targetWin.closed !== false) {
window.clearInterval(pollTimer);
setTimeout(function () {
@thotbox
thotbox / JavaScript: Facebook Iframe Scroll Hack.js
Last active September 2, 2015 09:14
JavaScript: Facebook Iframe Scroll Hack
// Scroll Top Iframe Hack
$(document).ready(function() {
if($('#focus-field').length ) {
setTimeout(function () {
$('#focus-field').focus();
$('#focus-field').blur();
}, 300);
}
});
@thotbox
thotbox / CSS: Facebook Iframe Scroll Hack.css
Created July 28, 2014 15:12
CSS: Facebook Iframe Scroll Hack
#focus-field {
position: absolute;
height: 0!important;
width: 0!important;
margin-top: -500px;
z-index: -999;
}
#focus-field.sub-focus {
margin-top: 500px;
@thotbox
thotbox / JavaScript: Freeform Pagination HTTPS Fix.js
Last active August 29, 2015 14:04
JavaScript: Freeform Pagination HTTPS Fix
// Pagination Links Fix
$('#pagination a').each(function() {
var href = $(this).attr('href');
if (href.indexOf('http:') > -1) {
href = href.replace('http:', 'https:');
$(this).attr('href', href);
}
});
@thotbox
thotbox / PHP: IE8 Conditional.php
Created July 31, 2014 13:43
PHP: IE8 Conditional
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 8')) {
// IE 8 Stuff
}
else {
// Default Stuff
}
?>