1/* Copyright (c) 2010 WordImpressed.com jFlow Plus derived from Kean Loong Tan's orgininal jFlow http://www.wordimpressed.com 2 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 3 * jFlow 1.2 (Plus) 4 * Version: jFlow Plus 5 * Requires: jQuery 1.2+ 6 */ 7 8(function($) { 9 'use strict' 10 11 $.fn.jFlow = function (options) { 12 var opts = $.extend({}, $.fn.jFlow.defaults, options); 13 var randNum = Math.floor(Math.random() * 11); 14 var jFC = opts.controller; 15 var jFS = opts.slideWrapper; 16 var jSel = opts.selectedWrapper; 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 $(this).find(jFC).each(function (i) { 40 $(this).click(function () { 41 dotimer(); 42 if ($(opts.slides).is(":not(:animated)")) { 43 $(jFC).removeClass(jSel); 44 $(this).addClass(jSel); 45 var dur = Math.abs(cur - i); 46 slide(dur, i); 47 cur = i; 48 } 49 }); 50 }); 51 52 $(opts.slides).before('<div id="' + jFS.substring(1, jFS.length) + '"></div>').appendTo(jFS); 53 54 $(opts.slides).find("div").each(function () { 55 $(this).before('<div class="jFlowSlideContainer"></div>').appendTo($(this).prev()); 56 }); 57 58 //initialize the controller 59 $(jFC).eq(cur).addClass(jSel); 60 61 var resize = function (x) { 62 $(jFS).css({ 63 position: "relative", 64 width: opts.width, 65 height: opts.height, 66 overflow: "hidden" 67 }); 68 //opts.slides or #mySlides container 69 $(opts.slides).css({ 70 position: "relative", 71 width: $(jFS).width() * $(jFC).length + "px", 72 height: $(jFS).height() + "px", 73 overflow: "hidden" 74 }); 75 // jFlowSlideContainer 76 $(opts.slides).children().css({ 77 position: "relative", 78 width: $(jFS).width() + "px", 79 height: $(jFS).height() + "px", 80 "float": "left", 81 overflow: "hidden" 82 }); 83 84 $(opts.slides).css({ 85 marginLeft: "-" + (cur * $(opts.slides).find(":eq(0)").width() + "px") 86 }); 87 } 88 89 // sets initial size 90 resize(); 91 92 // resets size 93 $(window).resize(function () { 94 resize(); 95 }); 96 97 $(opts.prev).click(function () { 98 dotimer(); 99 doprev(); 100 }); 101 102 $(opts.next).click(function () { 103 dotimer(); 104 donext(); 105 }); 106 107 var doprev = function (x) { 108 if ($(opts.slides).is(":not(:animated)")) { 109 var dur = 1; 110 if (cur > 0) 111 cur--; 112 else { 113 cur = maxi - 1; 114 dur = cur; 115 } 116 $(jFC).removeClass(jSel); 117 slide(dur, cur); 118 $(jFC).eq(cur).addClass(jSel); 119 } 120 } 121 122 var donext = function (x) { 123 if ($(opts.slides).is(":not(:animated)")) { 124 var dur = 1; 125 if (cur < maxi - 1) 126 cur++; 127 else { 128 cur = 0; 129 dur = maxi - 1; 130 } 131 $(jFC).removeClass(jSel); 132 //$(jFS).fadeOut("fast"); 133 slide(dur, cur); 134 //$(jFS).fadeIn("fast"); 135 $(jFC).eq(cur).addClass(jSel); 136 } 137 } 138 139 var dotimer = function (x) { 140 if ((opts.auto) == true) { 141 if (timer != null) 142 clearInterval(timer); 143 144 timer = setInterval(function () { 145 $(opts.next).click(); 146 }, 5000); 147 148 } 149 } 150 151//Pause/Resume function fires at hover 152 dotimer(); 153 $(opts.slides).hover( 154 function () { 155 clearInterval(timer); 156 }, 157 function () { 158 dotimer(); 159 } 160 ); 161 }; 162 163 $.fn.jFlow.defaults = { 164 controller: "#myController", // must be class, use . sign 165 slideWrapper: "#mySlides", // must be id, use # sign 166 selectedWrapper: ".jFlowSelected", // just pure text, no sign 167 auto: true, 168 easing: "swing", 169 duration: 400, 170 width: "100%", 171 prev: ".jFlowPrev", // must be class, use . sign 172 next: ".jFlowNext" // must be class, use . sign 173 }; 174 175 $(function () { 176 $("#myController").jFlow({ 177 controller: ".jFlowControl", // must be class, use . sign 178 slideWrapper: "#jFlowSlider", // must be id, use # sign 179 slides: "#mySlides", // the div where all your sliding divs are nested in 180 selectedWrapper: "jFlowSelected", // just pure text, no sign 181 width: "610px", // this is the width for the content-slider 182 height: "318px", // this is the height for the content-slider 183 duration: 400, // time in miliseconds to transition one slide 184 prev: ".jFlowPrev", // must be class, use . sign 185 next: ".jFlowNext", // must be class, use . sign 186 auto: true 187 }) 188 }) 189}).call(this, 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.