Skip to content

Instantly share code, notes, and snippets.

@atsea
atsea / gist:2cbeb39e9f878014c9d4
Created May 12, 2015 15:42
JS: preventDefault fix for IE
/**
* http://stackoverflow.com/questions/1000597/event-preventdefault-function-not-working-in-ie
*/
change this:
e.preventDefault;
to this:
e.preventDefault ? e.preventDefault() : event.returnValue = false;
@atsea
atsea / gibagoba.php
Created May 26, 2015 17:41
prevent the category widget from using the category description as the list item title attribute
prevent the category widget from using the category description as the list item title attribute
@atsea
atsea / window-width.js
Created May 27, 2015 19:17
javascript: check window width
var adjustLayout = function() {
var current_width = $(window).width();
//Get the canvas & context
if (current_width < 320) {
$('#anniversary_mobile img').addClass('invisible');
}
else {
$('#anniversary_mobile img').removeClass('invisible');
}
@atsea
atsea / custom-header-for-divi.php
Created June 10, 2015 17:59
wordpress custom header for divi
/**
*
* NOT BEING USED BUT GOOD REFERENCE
* Adding Content to the wp_after_body Hook
* http://www.internoetics.com/2014/01/02/add-a-hook-in-wordpress-after-the-opening-body-tag/
*/
function wp_after_body() {
do_action('wp_after_body');
}
@atsea
atsea / radio checked.php
Created July 1, 2015 13:01
PHP: radio checked
<?php
foreach ( templateFactory::displayTemplatesHeader() as $key=>$value){
?>
<input type="radio" class="switch-input" name="udel_theme_module_option" id="<?php echo $value['id']; ?>" value="<?php echo $value['id']; ?>" <?php echo ( $udel_theme_module_option == $value['id'] ) ? 'checked' : ''?>><label for="<?php echo $value['id']; ?>" class="switch-label <?php echo ( $udel_theme_module_option == $value['id'] ) ? 'switch-label-on' : 'switch-label-off'?>"><?php echo $value['display']; ?></label>
<?php
}
if ( strstr($udel_theme_module_option, 'blankHeader') ):
echo '<p>Header is off.</p>';
@atsea
atsea / safari.js
Created July 31, 2015 14:25
JS: Feature detect Safari/Mac
/**
* Hack for Safari Mac feature detect
*/
var isWebKit = 'WebkitAppearance' in document.documentElement.style;
var isMac = navigator.appVersion.indexOf("Mac")!=-1;
if ( (isWebKit ) && ( isMac ) ) {
$('.main-nav').addClass('main-nav-safari');
$('body').animate({
scrollTop: 0
}, 0);
@atsea
atsea / resize_event.js
Created August 6, 2015 16:53
jQuery: fire event AFTER window resize is complete
*
* Hide site search drop down and default to sites.udel.edu/<site> search. 5/27/15 CL
* http://bigwilliam.com/jquery-fire-event-after-window-resize-is-completed/
* https://gist.github.com/atsea/3f53c9ceca40277918da
*/
var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
@atsea
atsea / delayaddclass.js
Created August 7, 2015 17:44
jQuery: delay addClass
// https://css-tricks.com/forums/topic/delay-addclass-with-jquery/
$('#ud_primary_logo_big').delay(145).queue(function(){
$('#ud_primary_logo_big').fadeToggle();
$('#ud_primary_logo_big').dequeue();
});
@atsea
atsea / script-full.js
Created August 12, 2015 12:50
jQuery: animate opacity on slideToggle
/**
* UDBrand header
* http://stackoverflow.com/questions/21918477/jquery-toggle-opacity-on-click-using-css-animation
* http://stackoverflow.com/questions/18995647/jquery-make-global-variable
*/
var current_width;
var pixel_ratio;
var logo_big;
$('#searchdiv').on('click', function(e){
@atsea
atsea / script-full.js
Created August 14, 2015 19:22
jQuery: append date
/**
* Append date to footer
*/
$("#date").append("&copy; "+(new Date).getFullYear());