1/* Copyright (c) 2008 Kean Loong Tan http://www.gimiti.com/kltan 2 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 3 * jFlow 4 * Version: 1.2 (July 7, 2008) 5 * Requires: jQuery 1.2+ 6 */ 7 8(function($) { 9 10 $.fn.jFlow = function(options) { 11 var opts = $.extend({}, $.fn.jFlow.defaults, options); 12 var randNum = Math.floor(Math.random()*11); 13 var jFC = opts.controller; 14 var jFS = opts.slideWrapper; 15 var jSel = opts.selectedWrapper; 16 17 var cur = 0; 18 var timer; 19 var maxi = $(jFC).length; 20 // sliding function 21 var slide = function (dur, i) { 22 $(opts.slides).children().css({ 23 overflow:"hidden" 24 }); 25 $(opts.slides + " iframe").hide().addClass("temp_hide"); 26 $(opts.slides).animate({ 27 marginLeft: "-" + (i * $(opts.slides).find(":first-child").width() + "px") 28 }, 29 opts.duration*(dur), 30 opts.easing, 31 function(){ 32 $(opts.slides).children().css({ 33 overflow:"hidden" 34 }); 35 $(".temp_hide").show(); 36 } 37 ); 38 39 } 40 $(this).find(jFC).each(function(i){ 41 $(this).click(function(){ 42 dotimer(); 43 if ($(opts.slides).is(":not(:animated)")) { 44 $(jFC).removeClass(jSel); 45 $(this).addClass(jSel); 46 var dur = Math.abs(cur-i); 47 slide(dur,i); 48 cur = i; 49 } 50 }); 51 }); 52 53 $(opts.slides).before('<div id="'+jFS.substring(1, jFS.length)+'"></div>').appendTo(jFS); 54 55 $(opts.slides).find("div").each(function(){ 56 $(this).before('<div class="jFlowSlideContainer"></div>').appendTo($(this).prev()); 57 }); 58 59 //initialize the controller 60 $(jFC).eq(cur).addClass(jSel); 61 62 var resize = function (x){ 63 $(jFS).css({ 64 position:"relative", 65 width: opts.width, 66 height: opts.height, 67 overflow: "hidden" 68 }); 69 //opts.slides or #mySlides container 70 $(opts.slides).css({ 71 position:"relative", 72 width: $(jFS).width()*$(jFC).length+"px", 73 height: $(jFS).height()+"px", 74 overflow: "hidden" 75 }); 76 // jFlowSlideContainer 77 $(opts.slides).children().css({ 78 position:"relative", 79 width: $(jFS).width()+"px", 80 height: $(jFS).height()+"px", 81 "float":"left", 82 overflow:"hidden" 83 }); 84 85 $(opts.slides).css({ 86 marginLeft: "-" + (cur * $(opts.slides).find(":eq(0)").width() + "px") 87 }); 88 } 89 90 // sets initial size 91 resize(); 92 93 // resets size 94 $(window).resize(function(){ 95 resize(); 96 }); 97 98 $(opts.prev).click(function(){ 99 dotimer(); 100 doprev(); 101 102 }); 103 104 $(opts.next).click(function(){ 105 dotimer(); 106 donext(); 107 108 }); 109 110 var doprev = function (x){ 111 if ($(opts.slides).is(":not(:animated)")) { 112 var dur = 1; 113 if (cur > 0) 114 cur--; 115 else { 116 cur = maxi -1; 117 dur = cur; 118 } 119 $(jFC).removeClass(jSel); 120 slide(dur,cur); 121 $(jFC).eq(cur).addClass(jSel); 122 } 123 } 124 125 var donext = function (x){ 126 if ($(opts.slides).is(":not(:animated)")) { 127 var dur = 1; 128 if (cur < maxi - 1) 129 cur++; 130 else { 131 cur = 0; 132 dur = maxi -1; 133 } 134 $(jFC).removeClass(jSel); 135 //$(jFS).fadeOut("fast"); 136 slide(dur, cur); 137 //$(jFS).fadeIn("fast"); 138 $(jFC).eq(cur).addClass(jSel); 139 } 140 } 141 142 var dotimer = function (x){ 143 if((opts.auto) == true) { 144 if(timer != null) 145 clearInterval(timer); 146 147 timer = setInterval(function() { 148 $(opts.next).click(); 149 }, 3000); 150 } 151 } 152 153 dotimer(); 154 }; 155 156 $.fn.jFlow.defaults = { 157 controller: ".jFlowControl", // must be class, use . sign 158 slideWrapper : "#jFlowSlide", // must be id, use # sign 159 selectedWrapper: "jFlowSelected", // just pure text, no sign 160 auto: false, 161 easing: "swing", 162 duration: 400, 163 width: "100%", 164 prev: ".jFlowPrev", // must be class, use . sign 165 next: ".jFlowNext" // must be class, use . sign 166 }; 167 168})(jQuery);
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.