// Portfolio Javascript file // Requires JQuery // Created on 05/09/2007 by I Slade function pageturn(url) { if ($("#pcont")) { $("#pcont").show(); //$("#pageturn").style.visibility = "visible"; var delay = setTimeout("goToPage('" + url + "')",250); } } function goToPage(whatPage) { //alert('go to page' + whatPage); window.location.href=whatPage; } // Site variables // TO DO: make these into parts of an object? var mydomain = "http://www.islade.co.uk"; var imagefolder = "i/"; // Highlight links that are exnteral or documents. // Relies on jQuery & shrinkUrl, called by DOM ready. function linkHighlight() { // Find all content links that aren't image links. var links = $("#content a").filter(function(index) { return $("img", this).length == 0; }) $(links).each(function(i){ var link = links[i]; // This link var url = $(link).attr("href").toLowerCase(); // the URL var contents = $(link).text(); // The text of the link // Trim long URLs in the content of each link. First, incase it's a long external/document link. if( ( contents.indexOf("http://")==0 ) && ( contents.length>25 ) ) { var newContent = shrinkUrl(contents); $(link).empty().append(newContent); } // Match documents if (url.lastIndexOf(".doc") == (url.length-4)){ $(link).addClass("highlightlink"); $(link).append(" (Word document) "); } // Match PDFs if (url.lastIndexOf(".pdf") == (url.length-4)){ $(link).addClass("highlightlink"); $(link).append(" (PDF document) "); } // Match ZIPs if (url.lastIndexOf(".zip") == (url.length-4)){ $(link).addClass("highlightlink"); $(link).append(" (Zip file) "); } // Match external links if( ( url.indexOf("http://")==0) && ( url.indexOf(mydomain)!=0 ) ) { // Add image icon with title. NB: didn't include alt, as that would disrupt reading too much. $(link).append(" "); $(link).addClass("highlightlink"); } // Match withpage links //if( ( url.indexOf("#")==0)) { // // Add image icon with title. // $(link).append(""); // $(link).addClass("highlightlink"); // } }); // end each } // end linkHighlight // Add anchor icon to each heading with an ID. // Relies on jQuery, called by DOM ready. //function headingAnchors(){ // // var headings = $("#content h2[@id], #content h3[@id]"); // $(headings).each(function(i){ // // var heading = headings[i]; // This heading // var hId = $(heading).attr("id"); // get the ID. // // // Add an anchor image // $(heading).append("  (anchor link). "); // // }); // end each //} // Shrink longer URLs by taking out the middle. // Called by quotes & linkHighlight function shrinkUrl(longUrl){ if((longUrl.length<=50)||(longUrl.indexOf('http')!=0)) return longUrl.substring(7); var l=longUrl.length; var firstUrlPart=longUrl.substring(7,49); var lastUrlPart=longUrl.substring(l-15,l); var shortUrl=firstUrlPart+'...'+lastUrlPart; return shortUrl; } //insert todays date formatted to newspaper format function insertDate(){ var d=new Date(); var weekday=new Array(7); weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday"; var month=new Array(12); month[0]="January"; month[1]="February"; month[2]="March"; month[3]="April"; month[4]="May"; month[5]="June"; month[6]="July"; month[7]="August"; month[8]="September"; month[9]="October"; month[10]="November"; month[11]="December"; var dayNo = d.getDate(); if (dayNo.length > 1) { var dayNo2 = dayNo.substr(1,1); } switch(dayNo2) { case 1: dayNo = dayNo + "st"; case 2: dayNo = dayNo + "nd"; case 3: dayNo = dayNo + "rd"; default: dayNo = dayNo + "th"; } $("#date").html("" + weekday[d.getDay()] + ", " + dayNo + " " + month[d.getMonth()] + ", " + d.getFullYear()); } function ajaxLoad(url, target) { $("#view").append("

Please wait, loading data

"); $.ajax({ type: "GET", url: url, timeout: 1000, error: function(msg){ $("#view").html("

Sorry there was an error retrieving the information please try again.

"); }, success: function(msg){ $("#view").html(msg); } }); $("#view").animate({ opacity: 'show' }, 1000); return false; } // Functions to call on DOM ready. $(document).ready(function() { linkHighlight(); // //headingAnchors(); insertDate(); // // $("#resume").each(function(i){ // $(this).click( function() { // pageturn(this.href); // return false; // }); // }); //Attach ajax page load event to each internet section icon $("a.internetItem").each(function(i){ //$(this).css("position","absolute"); $(this).click(function(){ return ajaxLoad(this.href, 'view'); }); }); //Attach ajax page load event to each multimedia section icon $("a.mmicon").each(function(i){ $(this).click(function(){ return ajaxLoad(this.href, 'view'); }); $(this).attr({ onmousedown: "window.acInit=false;" }); }); //Check for fisheye container and initialise control if (document.getElementById('fisheye')) { $('#fisheye').Fisheye( { maxWidth: 90, items: 'a', itemsText: 'span', container: '.fisheyeContainer', itemWidth: 90, proximity: 90, halign : 'center' }); } //if (document.getElementById('panelinternet')) { // $('a').Tooltip(); // }); }); jQuery(function( $ ){ //borrowed from jQuery easing plugin //http://gsgd.co.uk/sandbox/jquery.easing.php $.easing.elasout = function(x, t, b, c, d) { var s=1.70158;var p=0;var a=c; if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; }; $('#filmbar').css({overflow: "hidden"}); $('#filmcont').append(""); $('#scrollleft').click(function(){ $('#filmbar').stop().scrollTo( '-=129px', { speed:2000, easing:'elasout', queue:true, axis:'x' } ); return false; }); $('#scrollright').click(function(){ $('#filmbar').stop().scrollTo( '+=129px', { speed:2000, easing:'elasout', queue:true, axis:'x' } ); return false; }); });