1/* 2 jQuery Coda-Slider v1.1 - http://www.ndoherty.com/coda-slider 3 4 Copyright (c) 2007 Niall Doherty 5 6 Inspired by the clever folks at http://www.panic.com/coda 7 Many thanks to Gian Carlo Mingati. Coda-Slider is a heavily modified version of his slideViewer, which can be found at http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html 8 9 Requirements: 10 - jQuery 1.2 ... available via http://www.jquery.com 11 - jQuery easing plugin (1.2) ... available via http://gsgd.co.uk/sandbox/jquery/easing/ 12 - jQuery easing compatability plugin ... available via http://gsgd.co.uk/sandbox/jquery/easing/ 13 - CSS included in index.html 14*/ 15 16/*jQuery(function(){ 17 jQuery("div.csw").prepend("<p class='loading'>Loading...<br /><img src='images/ajax-loader.gif' alt='loading...'/ ></p>"); 18});*/ 19var j = 0; 20jQuery.fn.codaSlider = function(settings) { 21 settings = jQuery.extend({ 22 easeFunc: "expoinout", 23 easeTime: 750, 24 toolTip: false 25 }, settings); 26 return this.each(function(){ 27 var container = jQuery(this); 28 // Remove the preloader gif... 29 container.find("p.loading").remove(); 30 // Self-explanatory... 31 container.removeClass("csw").addClass("stripViewer"); 32 // Get the width of a panel, set from CSS... 33 var panelWidth = container.find("div.panel").width(); 34 // panelCount gives us a count of the panels in the container... 35 var panelCount = container.find("div.panel").size(); 36 // Calculate the width of all the panels when lined up end-to-e
36nd... 37 var stripViewerWidth = panelWidth*panelCount; 38 // Use the above width to specify the CSS width for the panelContainer element... 39 container.find("div.panelContainer").css("width" , stripViewerWidth); 40 // Set the navWidth as a multiple of panelCount to account for margin-right on each li 41 var navWidth = panelCount*2; 42 43 // Specify the current panel. 44 // If the loaded URL has a hash (cross-linking), we're going to use that hash to give the slider a specific starting position... 45 if (location.hash && parseInt(location.hash.slice(1)) <= panelCount) { 46 var cPanel = parseInt(location.hash.slice(1)); 47 var cnt = - (panelWidth*(cPanel - 1)); 48 jQuery(this).find("div.panelContainer").css({ left: cnt }); 49 // Otherwise, we'll just set the current panel to 1... 50 } else { 51 var cPanel = 1; 52 }; 53 54 // Create appropriate nav 55 container.each(function(i) { 56 57 // Create the Left and Right arrows 58 jQuery(this).before("<div class='stripNavL' id='stripNavL" + j + "'><a href='#'>Left</a><\/div>"); 59 jQuery(this).after("<div class='stripNavR' id='stripNavR" + j + "'><a href='#'>Right</a><\/div>"); 60 61 // Create the Tabs 62 jQuery(this).before("<div class='stripNav' id='stripNav" + j + "'><ul><\/ul><\/div>"); 63 jQuery(this).find("div.panel").each(function(n) { 64 jQuery("div#stripNav" + j + " ul").append("<li class='tab" + (n+1) + "'><a href='#" + (n+1) + "'>" + jQuery(this).attr("title") + "<\/a><\/li>"); 65 }); 66 67 // Tab nav 68 jQuery("div#stripNav" + j + " a").each(function(z) { 69 // Figure out the navWidth by adding up the width of each li 70 navWidth += jQuery(this).parent().width(); 71 // What happens when a nav link is clicked 72 jQuery(this).bind("click", function() { 73 jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current"); // wow! 74 var cnt = - (panelWidth*z); 75 cPanel = z + 1; 76 jQuery(this).parent().parent().parent().next().find("div.panelContainer").animate({ left: cnt}, settings.easeTime, settings.easeFunc); 77 }); 78 }); 79 80 // Left nav 81 jQuery("div#stripNavL" + j + " a").click(function(){ 82 if (cPanel == 1) { 83 var cnt = - (panelWidth*(panelCount - 1)); 84 cPanel = panelCount; 85 jQuery(this).parent().parent().find("div.stripNav a.current").removeClass("current").parent().parent().find("li:last a").addClass("current"); 86 } else { 87 cPanel -= 1; 88 var cnt = - (panelWidth*(cPanel - 1)); 89 jQuery(this).parent().parent().find("div.stripNav a.current").removeClass("current").parent().prev().find("a").addClass("current"); 90 }; 91 jQuery(this).parent().parent().find("div.panelContainer").animate({ left: cnt}, settings.easeTime, settings.easeFunc); 92 // Change the URL hash (cross-linking)... 93 location.hash = cPanel; 94 return false; 95 }); 96 97 // Right nav 98 jQuery("div#stripNavR" + j + " a").click(function(){ 99 if (cPanel == panelCount) { 100 var cnt = 0; 101 cPanel = 1; 102 jQuery(this).parent().parent().find("div.stripNav a.current").removeClass("current").parent().parent().find("a:eq(0)").addClass("current"); 103 } else { 104 var cnt = - (panelWidth*cPanel); 105 cPanel += 1; 106 jQuery(this).parent().parent().find("div.stripNav a.current").removeClass("current").parent().next().find("a").addClass("current"); 107 }; 108 jQuery(this).parent().parent().find("div.panelContainer").animate({ left: cnt}, settings.easeTime, settings.easeFunc); 109 // Change the URL hash (cross-linking)... 110 location.hash = cPanel; 111 return false; 112 }); 113 114 // Same-page cross-linking 115 jQuery("a.cross-link").click(function(){ 116 jQuery(this).parents().find(".stripNav ul li a:eq(" + (parseInt(jQuery(this).attr("href").slice(1)) - 1) +")").trigger('click'); 117 }); 118 119 // Set the width of the nav using the navWidth figure we calculated earlier. This is so the nav can be centred above the slider 120 jQuery("div#stripNav" + j).css("width" , navWidth); 121 122 // Specify which tab is initially set to "current". Depends on if the loaded URL had a hash or not (cross-linking). 123 if (location.hash && parseInt(location.hash.slice(1)) <= panelCount) { 124 jQuery("div#stripNav" + j + " a:eq(" + (location.hash.slice(1) - 1) +")").addClass("current"); 125 } else { 126 jQuery("div#stripNav" + j + " a:eq(0)").addClass("current"); 127 } 128 129 }); 130 131 j++; 132 }); 133};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.