Skip to content

Instantly share code, notes, and snippets.

View matharchod's full-sized avatar

Jani Momolu Anderson matharchod

View GitHub Profile
@matharchod
matharchod / Site Skin and Background Image Swapper for Takeover Ads
Created October 21, 2011 19:43
A script that uses core JavaScript & jQuery to change the BODY background image and add a transparent link over the background of the page.
//Ad SKINS
function loadAdSkinBkg(bgrnd_skin_bgColor,bgrnd_skin_imageSrc,bgrnd_skin_linkTarget){
$('body','html').css({"background-image":"none","background-color":bgrnd_skin_bgColor});
$('body','html').css({"background-image":bgrnd_skin_imageSrc, "background-position":"center top","background-repeat":"no-repeat"}).prepend('<a id="skin_background" href="'+ bgrnd_skin_linkTarget+'" target="_blank">&nbsp;</a>');
$.getDocHeight = function(){
return Math.max(
$(document).height(),
$(window).height(),
document.documentElement.clientHeight
);
@matharchod
matharchod / jQuery Modal Popup Script
Created October 21, 2011 19:34
A jQuery script that uses jQuery UI, Modal Popups and Cookies to show content based on a timer and/or a cookie value: used as a way to serve modal content through a JavaScript ad server.
//AD MODALS
function myModalClose() {
$('.myOverlay, #exposeMask').fadeOut('slow');
$('.ad').css({'position':'relative','margin-left':'auto'}); //SHOW ADS
};
function myModalPop(type,timer,target,link,creative,width,height) { //setup for variables coming from ad server script
var date = new Date();
@matharchod
matharchod / Fade In a Group of Elements One Element At a Time
Created October 19, 2011 23:30
A jQuery function that fades in a group of elements (i.e. a group of LIs) one element at a time, in succession.
/* FADE IN TEXT */
$('.fader').delay(0).each(function (i){ //SELECTS ALL ELEMENTS WITH THE CLASS "FADER"
var me = $(this);
setTimeout(function(){ $(me).fadeIn('slow'); }, (400 * i)); // SETS FADE IN SPEED AND DELAY BETWEEN EACH
});
@matharchod
matharchod / Busy Message - CSS Switcher on a Timer
Created October 19, 2011 23:26
A jQuery function that creates a "busy" message for 10 seconds by switching CSS classes on multiple elements simultaneously.
//BUSY MESSAGE
function busy() {
var x = $('#header a, #portfolio a');//ALL ELEMENTS TO BE AFFECTED
$(x).addClass('busy');
setTimeout(function(){
$(x).removeClass('busy').addClass('ready');
}, 10000);
}
@matharchod
matharchod / Custom jQuery Easing Function
Created October 19, 2011 23:16
A custom jQuery easing function called "comicSwing". I use it on my portfolio site for my jQuery scrollables.
// custom easing called "comicSwing"
$.easing.comicSwing = function (x, t, b, c, d) {
var s = 1.5;
if ((t/=d/2) < 1) return c/5*(t*t*(((s*=(1.525))+1)*t - s)) + b;
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}
@matharchod
matharchod / Animated Toggle Function
Created October 19, 2011 19:40
A jQuery toggle function that uses callbacks to animate elements in a particular order.
/* SET #PORTFOLIO TOGGLE */
$("#portfolio_toggle").toggle(
function(){
portfolioOpen();
},
function(){
portfolioClose();
}
);
@matharchod
matharchod / Liquid Layout - Change Classes Based on Width of Browser Window
Created October 18, 2011 20:37
A core JavaScript liquid layout function that checks the current width of a browser window and assigns a new class to the BODY accordingly.
//LIQUID LAYOUT
function setScreenClass(){
var fmt = document.documentElement.clientWidth;
var cls = (fmt>640&&fmt<=800)?'screen_low':(fmt>800&&fmt<=1024)?'screen_med':(fmt>1024&&fmt<=1280)?'screen_high':(fmt>1280)?'screen_wide':'screen_low';
document.body.className=cls;
};