﻿function initialize() { navController.init(); anchorController.init(); caseStudy.init(); portfolio.init(); slideShowController.init(); blog.init(); contact.init(); input.init(); socials.init() } var navController = { current: Object, headNav: Object, navLink: Object, clicked: Boolean, init: function () { this.current = $("#header ul").attr("class"); this.headNav = $("#header ul"); this.navLink = $("#header ul li a, #logo"); this.clicked = false; this.run() }, run: function () { this.navLink.hover(function () { navController.headNav.removeClass().addClass($(this).attr("rel")) }, function () { if (!navController.clicked) { navController.headNav.removeClass().addClass(navController.current) } }); this.navLink.click(function () { navController.clicked = true; navController.headNav.removeClass().addClass($(this).attr("rel")) }); $("#logo").hover(function () { $("#nav_home").addClass("hover") }, function () { $("#nav_home").removeClass("hover") }) } }; var color = { links: function (a) { $("#content a").stop().animate({ color: "#" + a }, "slow") }, chameleon: function (a) { $(".chameleon").stop().animate({ backgroundColor: "#" + a }, "slow") }, background: function (a) { $("#hero, #footer").stop().animate({ backgroundColor: "#" + a }, "slow") }, all: function (a) { $(".chameleon").stop().animate({ backgroundColor: "#" + a }, "slow"); $("#content a:not(a.chameleon)").stop().animate({ color: "#" + a }, "slow") } }; var anchorController = { init: function () { $("a[rel*=external]").live("click", function () { window.open(this.href); _gaq.push(["_trackEvent", "Lightburn", "External Link Clicked", $(this).attr("href")]); return false }) } }; var caseStudy = { studies: Object, prev: Object, next: Object, current: Number, init: function () { this.studies = $("div.study"); this.prev = $("#prevStudy"); this.next = $("#nextStudy"); this.current = 1; this.run() }, run: function () { this.prev.click(function (a) { $("div.study.on").fadeOut("normal", function () { $(this).removeClass("on"); if (caseStudy.current == 1) { caseStudy.studies.eq(caseStudy.studies.length - 1).fadeIn("normal").addClass("on"); caseStudy.current = caseStudy.studies.length } else { caseStudy.current--; caseStudy.studies.eq(caseStudy.current - 1).fadeIn("normal").addClass("on") } }); a.preventDefault() }); this.next.click(function (a) { $("div.study.on").fadeOut("normal", function () { $(this).removeClass("on"); if (caseStudy.current == caseStudy.studies.length) { caseStudy.studies.eq(0).fadeIn("normal").addClass("on"); caseStudy.current = 1 } else { caseStudy.current++; caseStudy.studies.eq(caseStudy.current - 1).fadeIn("normal").addClass("on") } }); a.preventDefault() }) } }; var portfolio = { site: Object, large: Object, height: Number, init: function () { this.site = $("#portfolio li:not(#portfolio li.large)"); this.large = $("#portfolio li.large"); this.run() }, run: function () { this.site.hover(function () { $(this).find("img").stop(true, true).fadeOut("fast") }, function () { $(this).find("img").stop(true, true).fadeIn("fast") }); this.large.hover(function () { portfolio.height = $(this).find(".descHolder").innerHeight(); $(this).find(".description").stop(true, false).animate({ height: portfolio.height }, "slow", "easeOutQuint") }, function () { $(this).find(".description").stop(true, false).animate({ height: "34px" }, "slow", "easeInOutQuint") }); if ($(window).width() < 520) { $("#portfolio li h4 a").live("click", function () { $("html, body").animate({ scrollTop: 0 }, "slow") }) } } }; var slideShowController = { images: Object, init: function () { this.images = $("div#slideshow img"); this.run() }, run: function () { var a = 0; var b = 0; $("div#slideshowBottom").prepend('<div id="description"><p>' + $("div#slideshow img.on").attr("alt") + "</p></div>"); if (this.images.length > 1) { $("div#slideshow div#description").prepend("<ul></ul>"); for (var c = 1; c <= this.images.length; c++) { $("div#slideshow div#description ul").append('<li><a href="#" rel=' + c + ">" + c + "</a></li>") } $("div#slideshow div#description ul li:first a").addClass("current") } $("div#slideshow div#description ul li a").click(function (c) { if (!$(this).hasClass("current")) { $("div#slideshowBottom").height($("div#slideshowBottom img.on").height()); $("div#slideshow div#description ul li a.current").removeClass("current"); $(this).addClass("current"); a = $(this).attr("rel") - 1; $("div#slideshow div#description").slideUp(function () { $("div#slideshow img.on").fadeOut("normal", function () { $(this).removeClass("on"); b = slideShowController.images.eq(a).height(); if ($("div#slideshowBottom").height() != b) { $("div#slideshowBottom").animate({ height: b }, 1e3, function () { slideShowController.imageSwitch(a) }) } else { slideShowController.imageSwitch(a) } }) }) } c.preventDefault() }) }, imageSwitch: function (a) { this.images.eq(a).fadeIn("normal", function () { $(this).addClass("on"); $("div#slideshow div#description").slideDown(); slideShowController.changeDesc() }) }, changeDesc: function () { $("div#slideshow div#description p").html($("div#slideshow img.on").attr("alt")) } }; var blog = { errors: Boolean, init: function () { this.errors = false; $(".post:last").addClass("last"); $("#controls li span.chameleon:empty").parent().css("display", "none"); $(".commentlist li").hover(function () { $(this).find(".reply:not(li li .reply)").css("display", "block") }, function () { $(this).find(".reply:not(li li .reply)").css("display", "none") }); this.checkComments() }, checkComments: function () { $("#submitBtn").click(function (a) { if (blog.errors == true) { $("#errors ul").html("") } if ($("#author").val() == "") { blog.makeErrorHolder(); $("#errors ul").append("<li>Your name is required</li>"); a.preventDefault() } if ($("#email").val() == "") { blog.makeErrorHolder(); $("#errors ul").append("<li>Your email is required</li>"); a.preventDefault() } if ($("#comment").val() == "") { blog.makeErrorHolder(); $("#errors ul").append("<li>If you're not going to write anything, what's the point of commenting?</li>"); a.preventDefault() } if (blog.errors == true) { $("#errors").slideDown("normal") } }) }, makeErrorHolder: function () { if (this.errors == false) { $("#commentform fieldset").append('<div id="errors"><ul></ul></div>'); this.errors = true } } }; var input = { init: function () { $("input:text, textarea").focus(function () { if ($(this).val() == $(this).attr("defaultValue")) { $(this).val("") } }); $("input:text, textarea").blur(function () { if ($(this).val() == "") { $(this).val($(this).attr("defaultValue")) } }) } }; var contact = { name: Object, email: Object, message: Object, sendBtn: Object, error: Boolean, init: function () { this.name = $("input#Name"); this.email = $("input#Email"); this.message = $("textarea#Message"); this.sendBtn = $("a#send"); this.error = false; this.run() }, run: function () { this.sendBtn.click(function (a) { if (contact.name.val() == "*Name" || contact.name.val() == "") { contact.error = true; contact.name.animate({ color: "#af1616" }, "fast"); if ($(".nameError").length == 0) { contact.name.after('<span class="error nameError"><span>Enter your name</span></span>') } } else { $("span.nameError").remove(); contact.name.animate({ color: "#666666" }, "fast") } if (contact.email.val() == "*Email Address" || contact.email.val() == "") { contact.error = true; contact.email.animate({ color: "#af1616" }, "fast"); if ($(".emailError").length == 0) { contact.email.after('<span class="error emailError"><span>Enter your e-mail address</span></span>') } } else { $("span.emailError").remove(); contact.email.animate({ color: "#666666" }, "fast") } if (contact.message.val() == "*Message" || contact.message.val() == "") { contact.error = true; contact.message.animate({ color: "#af1616" }, "fast"); if ($(".messageError").length == 0) { contact.message.after('<span class="error messageError"><span>Please say something :(</span></span>') } } else { $("span.messageError").remove(); contact.message.animate({ color: "#666666" }, "fast") } if (contact.error == true) { color.background("af1616"); a.preventDefault(); $("span.error").fadeIn("fast"); contact.error = false } else { _gaq.push(["_trackEvent", "Contact Form", "Form Submit", contact.name.val()]); $("form#contactform").submit() } }) } }; var socials = { newHeight: Number, firstTime: Boolean, init: function () { this.firstTime = true; $(".twitter").tweet({ username: "lightburn", count: 1 }); this.run() }, run: function () { $("#social li a").click(function (a) { if (!$(this).hasClass("on")) { _gaq.push(["_trackEvent", "Footer", "Footer Social Link Clicked", $(this).parent().attr("id")]); $("#social li a.on").removeClass("on"); $(this).addClass("on"); $("#socialHolder").height($("#socialHolder .on").innerHeight()); $("#socialHolder .on").fadeOut("fast", function () { $(this).removeClass("on"); $("#socialHolder ." + $("#social li a.on").attr("rel")).addClass("on"); if ($(".socialSlide.on").hasClass("flickr") && socials.firstTime == true) { socials.getFlickr(); socials.firstTime = false } socials.newHeight = $("#socialHolder .on").height(); if ($("#socialHolder").height() != socials.newHeight) { $("#socialHolder").animate({ height: socials.newHeight }, 500, function () { $("#socialHolder .on").fadeIn("fast") }) } }) } a.preventDefault() }) }, getFlickr: function () { $.ajax({ type: "GET", url: "http://api.flickr.com/services/feeds/photos_public.gne?id=44149998@N03&lang=en-us&format=json&jsoncallback=?", dataType: "jsonp", success: function (a) { $.each(a.items, function (a, b) { $("<img/>").attr("src", b.media.m.replace("_m.jpg", "_s.jpg")).appendTo(".flickr"); if (a < 5) { $(".flickr").find("img:last").wrap('<a href="' + b.link + '" rel="external"></a>') } else { $(".flickr").find("img:last").wrap('<a href="' + b.link + '" rel="external" class="last"></a>'); return false } }) }, error: function (a, b, c) { $(".flickr").append("<p>A gremlin ate our photos.</p>") } }) } }; $(document).ready(function () { initialize() }); (function (a) { a.fn.tweet = function (b) { function d(a) { var b = Date.parse(a); var c = arguments.length > 1 ? arguments[1] : new Date; var d = parseInt((c.getTime() - b) / 1e3); if (d < 60) { return "less than a minute ago" } else if (d < 120) { return "about a minute ago" } else if (d < 45 * 60) { return parseInt(d / 60).toString() + " minutes ago" } else if (d < 90 * 60) { return "about an hour ago" } else if (d < 24 * 60 * 60) { return "about " + parseInt(d / 3600).toString() + " hours ago" } else if (d < 48 * 60 * 60) { return "1 day ago" } else { return parseInt(d / 86400).toString() + " days ago" } } var c = { username: ["seaofclouds"], avatar_size: null, count: 3, intro_text: null, outro_text: null, join_text: null, auto_join_text_default: "i said,", auto_join_text_ed: "i", auto_join_text_ing: "i am", auto_join_text_reply: "i replied to", auto_join_text_url: "i was looking at", loading_text: null, query: null }; if (b) a.extend(c, b); a.fn.extend({ linkUrl: function () { var b = []; var c = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; this.each(function () { b.push(this.replace(c, '<a href="$1">$1</a>')) }); return a(b) }, linkUser: function () { var b = []; var c = /[\@]+([A-Za-z0-9-_]+)/gi; this.each(function () { b.push(this.replace(c, '<a href="http://twitter.com/$1">@$1</a>')) }); return a(b) }, linkHash: function () { var b = []; var d = / [\#]+([A-Za-z0-9-_]+)/gi; this.each(function () { b.push(this.replace(d, ' <a href="http://search.twitter.com/search?q=&tag=$1&lang=all&from=' + c.username.join("%2BOR%2B") + '">#$1</a>')) }); return a(b) }, capAwesome: function () { var b = []; this.each(function () { b.push(this.replace(/(a|A)wesome/gi, "AWESOME")) }); return a(b) }, capEpic: function () { var b = []; this.each(function () { b.push(this.replace(/(e|E)pic/gi, "EPIC")) }); return a(b) }, makeHeart: function () { var b = []; this.each(function () { b.push(this.replace(/(<)+[3]/gi, "<tt class='heart'>&#x2665;</tt>")) }); return a(b) } }); return this.each(function () { var b = a('<ul class="tweet_list">').appendTo(this); var e = '<p class="tweet_intro">' + c.intro_text + "</p>"; var f = '<p class="tweet_outro">' + c.outro_text + "</p>"; var g = a('<p class="loading">' + c.loading_text + "</p>"); if (typeof c.username == "string") { c.username = [c.username] } var h = ""; if (c.query) { h += "q=" + c.query } h += "&q=from:" + c.username.join("%20OR%20from:"); var i = "http://search.twitter.com/search.json?&" + h + "&rpp=" + c.count + "&callback=?"; if (c.loading_text) a(this).append(g); a.getJSON(i, function (h) { if (c.loading_text) g.remove(); if (c.intro_text) b.before(e); a.each(h.results, function (e, f) { if (c.join_text == "auto") { if (f.text.match(/^(@([A-Za-z0-9-_]+)) .*/i)) { var g = c.auto_join_text_reply } else if (f.text.match(/(^\w+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+) .*/i)) { var g = c.auto_join_text_url } else if (f.text.match(/^((\w+ed)|just) .*/im)) { var g = c.auto_join_text_ed } else if (f.text.match(/^(\w*ing) .*/i)) { var g = c.auto_join_text_ing } else { var g = c.auto_join_text_default } } else { var g = c.join_text } var h = '<span class="tweet_join"> ' + g + " </span>"; var i = c.join_text ? h : " "; var j = '<a class="tweet_avatar" href="http://twitter.com/' + f.from_user + '"><img src="' + f.profile_image_url + '" height="' + c.avatar_size + '" width="' + c.avatar_size + '" alt="' + f.from_user + '\'s avatar" title="' + f.from_user + '\'s avatar" border="0"/></a>'; var k = c.avatar_size ? j : ""; var l = '<span class="tweet_text">' + a([f.text]).linkUrl().linkUser().linkHash().makeHeart().capAwesome().capEpic()[0] + "</span>"; var m = ' <a href="http://twitter.com/' + f.from_user + "/statuses/" + f.id + '" title="view tweet on twitter" class="time">- ' + d(f.created_at) + "</a>"; b.append("<li>" + k + i + l + m + "</li>"); b.children("li:first").addClass("tweet_first"); b.children("li:odd").addClass("tweet_even"); b.children("li:even").addClass("tweet_odd") }); if (c.outro_text) b.after(f) }) }) } })(jQuery)
