Skip to content

Instantly share code, notes, and snippets.

View mikedugan's full-sized avatar

Mike Dugan mikedugan

View GitHub Profile
@mikedugan
mikedugan / flyout.jquery.js
Created November 7, 2013 14:34
creates a flyout menu
//expects the following values to be set:
// flyout menu: "#fixedOptions"
// expects an image to be the first li in the menu
// default css should have it margin-right to ($('#fixedOptions').width()- $('#fixedOptions li:eq(0)').width() )
function createFlyout() {
//set some vars to work with
var fly = $('#fixedOptions');
var icon = $('#fixedOptions img');
var iWidth = $('#fixedOptions img').width();
@mikedugan
mikedugan / ieversion.jquery.js
Created November 7, 2013 14:35
gets the ie version of the browser, else returns -1
//usage: returns IE version else -1
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
@mikedugan
mikedugan / imageload.jquery.js
Created November 7, 2013 14:35
gradually loads in images
jQuery.fn.loadComplete = function (fn) {     return this.each(function () {         if (this.complete || this.readyState == 'complete') {             fn.call(this);         } else {             $(this).load(fn);         }     }); }; $('img').loadComplete(function(){    $(this).fadeIn(800); }); //don't forget to initially hide them!
@mikedugan
mikedugan / modal_load.jquery.js
Created November 7, 2013 14:37
loads a modal dialog
function modal() {     var html = "./path/to/modalFile.html";     var div= $('a#modal'); //the empty container div in your doc for the modal dialog     feedback.click(function() {         $('#modDisplay').dialog({position: {my: 'right top', at:'center center', of: window}}).load(html);         return false; //prevent the page from navigating     });   }
@mikedugan
mikedugan / passCompare.jquery.js
Created November 7, 2013 14:38
compares 2 password to make sure they match
// Code Block used displaying color code on passwords.
function PasswordValidator() {
$(document).ready(function() {
$('#m2_MB_txt_UserPass2').hide();
$("#m2_MB_txt_UserPass1").keyup(function(event) {
var textBox = document.getElementById("m2_MB_txt_UserPass1");
var count = textBox.value.length;
if (count > 5) {
$('#m2_MB_txt_UserPass2').show();
@mikedugan
mikedugan / ready.jquery.js
Created November 7, 2013 14:38
useful functions for various stages of page loasd
//does something when the DOM is ready to be traversed
$(function() {
//code here
})();
//does something when everything is completely loaded
$(window).load(function(){
//code here
})
@mikedugan
mikedugan / resize.jquery.js
Created November 7, 2013 14:39
detects and executes function on window resize with 1 second delay
var id;
$(window).resize(function() {
clearTimeout(id);
id = setTimeout(function() {
if($(window).innerHeight() < 700 || $(window).innerWidth < 900) {
//do this if it's being resized down && params met
}
else {
//do this if it's being resized up
@mikedugan
mikedugan / slideshow.jquery.js
Created November 7, 2013 14:39
basic slideshow using jquery
//expects the following vars to be set:
// individual slides ".slideshow"
// insert an element in addSliderBtns if there is a parent container class/ID
function createSlideshow(){
cSlide = $('.slideshow:eq(0)'); //the current slide
$('.slideshow').not(':eq(0)').hide(); //make all others invisible
//add the next and previous buttons and set vars
addSliderBtns(cSlide); ///create the buttons
@mikedugan
mikedugan / smoothScroll.jquery.js
Created November 7, 2013 14:40
script to provide smooth scrolling
//User settings
var maxSections = 5;
var sectionNamePrefix = 'page-section';
var currSection = 1;
function scrollToHash(e,sectionNumber) {
var hash = '#' + sectionNamePrefix + sectionNumber;
var target = $(hash);
@mikedugan
mikedugan / text-insert.jquery.js
Created November 7, 2013 14:41
inputs text from file (ie xml) into input box
//uses a select box to input content from file into a text area
var sel = $('select');
sel.change(function() {
var f = $(this).val();
$.get("./path/to/file/" + f, function(d) {
$('textarea').val(d);
})
})