.JavaScript
Below is a list of my JavaScript code samples.
Below is a list of my JavaScript code samples.
This is a simple couple of jQuery lines that takes image tags, which are links to videos, and overlays a little play icon on top. I’ve attached it to the window load event instead of the window ready event because with some browsers (Safari if I remember correctly) the image width isn’t available on the onready event, at least not on Windows. I used the original image tag’s width to position the icon in the lower right over the image as requested by the client.
The jQuery filter immediately following the window load line literally translates into:
After selecting these specific anchor tags, the next line wraps them with a div with class playButtonWrap that I use, with the original image width, to include and position the play icon.
There is no end to JavaScript image sliders. Rather than using one which probably had a lot of bells and whistles that I wasn’t going to use (and may have taken me just as long to rewrite the client’s markup), I just created one from scratch. The snippet of code below uses jQuery and the preLoadImages plugin.
I built the stylesheet changer, over 6 years ago, primarily to cycle through a handful of stylesheets in order to give the user some freedom to customize the site environment easily. I also, from day to day, like to change things up a bit especially when working on the same site (like this portfolio) often.
The changer will ignore stylesheets that are inline (don’t have a href value) and by manipulating the sheetPattern you may filter out other linked sheets. To remember and load your last enabled stylesheet on page load you’ll want to add changeSheets(‘set’,”); to your onload event like I’ve done below. Also, I’ve added it on the double click event in the example so to use it otherwise you may want to remove that.
Below I’ve given the html, event and full function.
The search suggest function that I built for my previous portfolio site is a quick demonstration of timers, stopping timers, objects, events and AJAX. It has one dependent function that’s called ‘findPos’ which I found on quirksmode – it’s a cross-browser function that finds and returns the position of an element.