1(function($) { 2 jQuery.fn.dwSlider = function(options) { 3 var options = $.extend({ 4 rightButton: ".sliderBtnRight", 5 leftButton: ".sliderBtnLeft", 6 afterResize: false, 7 responsive: false, 8 secondDots: false, 9 afterLoad: false, 10 timeLine: false, 11 autoMove: true, 12 delay: 3500, 13 severity: 8, 14 touch: true, 15 speed: 500, 16 }, options); 17 18 var link = $(this).css({"display": "block", "overflow" : "hidden", "position" : "relative"}); 19 var slideBox = link.find(".slideBox").css({"position" : "relative", "left": "0px", "padding" : "0px", "cursor" : options["touch"] ? "move" : "default", "margin" : "0px"}); 20 21 //check for extra div 22 if(slideBox.children("div").length > 0){ 23 var slideElements = slideBox.children("div").children("li"); 24 }else{ 25 var slideElements = slideBox.children("li"); 26 } 27 28 var leftButton = $(options["leftButton"]); 29 var rightButton = $(options["rightButton"]); 30 var currentPosition = 0; 31 var moveValueFx = 0; 32 var timeoutID = 0; 33 var moveValue = 0; 34 35 if(options["secondDots"] != false){ 36 var secondDots = $(options["secondDots"]).children("li"); 37 } 38 39 slideElements.css({ 40 "position" : "relative", 41 "list-style" : "none", 42 "float" : "left", 43 "width" : "100%" 44 }); 45 46 //check length 47 options["touch"] = slideElements.length > 1 && options["touch"] == true ? true : false; 48 49 if(options["touch"]){ 50 var slideElementWidth = slideElements.width(); 51 var slideBoxWidth = ((slideElements.length - 1) * slideElementWidth); 52 var slideStartPosition = false; 53 var clickPositionX = false; 54 var clickPositionY = false;
55 var clickControl = false; 56 } 57 58 if(options["touch"]){ 59 60 slideBox.on("mousedown touchstart", function(e){ 61 timeoutID && clearTimeout(timeoutID); 62 slideElementWidth = slideElements.width(); 63 slideBoxWidth = ((slideElements.length - 1) * slideElementWidth); 64 slideStartPosition = parseInt(slideBox.css("left"), 10); 65 clickPositionX = e.type == "touchstart" ? e.originalEvent.touches[0].pageX : e.pageX; 66 clickPositionY = e.type == "touchstart" ? e.originalEvent.touches[0].pageY : e.pageY; 67 if(e.type == "mousedown"){ 68 e.preventDefault(); 69 } 70 return clickControl = true; 71 }); 72 73 $(document).on("mousemove touchmove", function(e) { 74 if(clickControl == true){ 75 var curTouchPosX = e.type == "touchmove" ? e.originalEvent.touches[0].pageX : e.pageX; 76 var curTouchPosY = e.type == "touchmove" ? e.originalEvent.touches[0].pageY : e.pageY; 77 if(Math.abs(clickPositionY - curTouchPosY) < 450){ 78 var touchExpression = clickPositionX - curTouchPosX; 79 if(Math.abs(touchExpression) == touchExpression){ 80 81 var touchMoveEx = slideStartPosition - Math.abs(touchExpression); 82 touchMoveEx = slideBoxWidth > Math.abs(touchMoveEx) ? touchMoveEx : -(slideBoxWidth + ((Math.abs(touchMoveEx) - slideBoxWidth) / 6)); 83 console.log("touchExpression" + touchExpression); 84 console.log("touchMoveEx" + touchMoveEx); 85 slideBox.finish().css({ 86 left: touchMoveEx + "px" 87 }); 88 89 }else{ 90 var touchMoveEx = slideStartPosition + Math.abs(touchExpression); 91 touchMoveEx = 0 > touchMoveEx ? touchMoveEx : touchMoveEx / 6; 92 slideBox.finish().css({ 93 left: touchMoveEx + "px" 94 }); 95 } 96 } 97 } 98 }); 99 100 $(document).on("mouseup touchend", function(e) { 101 if(clickControl == true){ 102 103 clickControl = false; 104 105 var boxPosition = parseInt(slideBox.css("left"), 10); 106 107 if(Math.abs(Math.abs(slideStartPosition) - Math.abs(boxPosition)) < 10){ 108 slideBox.finish().animate({ 109 left: slideStartPosition + "px" 110 }, 200); 111 112 }else{ 113 var touchMoveEx = (slideStartPosition - boxPosition > 0) ? -(Math.ceil(Math.abs(boxPosition) / slideElements.width()) * 100) : -(Math.floor(Math.abs(boxPosition) / slideElements.width()) * 100); 114 if((Math.abs(touchMoveEx) / 100) > (slideElements.length - 1)){ 115 currentPosition = touchMoveEx = 0; 116 }else if(boxPosition > 0){ 117 touchMoveEx = -((slideElements.length - 1) * 100); 118 currentPosition = (slideElements.length - 1); 119 }else{ 120 currentPosition = (Math.abs(touchMoveEx) / 100); 121 } 122 123 slideBox.finish().animate({ 124 left: touchMoveEx + "%" 125 }, 200); 126 127 if(slideElements.length > 1){ 128 slideDotElements.removeAttr("class").eq(currentPosition).addClass("selected"); 129 if(options["secondDots"] != false){ 130 secondDots.removeAttr("class").eq(currentPosition).addClass("selected"); 131 } 132 } 133 134 } 135 136 } 137 }); 138 } 139 140 if(options.responsive === true){ 141 var slidePictures = slideBox.find("span"); 142 } 143 144 slideBox.width(slideElements.length * 100 + "%"); 145 slideElements.width(100 / slideElements.length + "%"); 146 147 if(slideElements.length > 1){ 148 149 link.append( 150 $("<ol>").addClass("pager").append( 151 function() { 152 var str = ""; 153 for (var i = 1; i <= slideElements.length; i++) { 154 if (i == 1) { 155 str = str + '<li class="selected"></li>'; 156 } else { 157 str = str + '<li></li>'; 158 } 159 } 160 return str; 161 } 162 ) 163 ); 164 165 if(options["timeLine"] === true){ 166 167 var timeLine = $("<ins/>").addClass("timeLine").css({ 168 "position": "absolute", 169 "display": "block", 170 "height": "2px", 171 "width": "0px", 172 "left": "0px",
173 "top": "0px" 174 }); 175 176 link.append( 177 timeLine 178 ); 179 180 } 181 182 var slideDotBox = link.find(".pager"); 183 var slideDotElements = slideDotBox.children("li"); 184 slideDotBox.css("margin-left", "-" + (slideElements.length * 22 / 2) + "px"); 185 186 }else{ 187 leftButton.hide(); 188 rightButton.hide(); 189 } 190 191 var slideAuto = function() { 192 193 nextTimeLine(true); 194 slideMove(false); 195 clearTimeout(timeoutID); 196 timeoutID = setTimeout(function() { 197 slideAuto(); 198 }, options.delay); 199 200 } 201 202 var slideMove = function(left) { 203 204 if (left == true) { 205 if (-1 == --currentPosition) { 206 currentPosition = slideElements.length - 1; 207 } 208 moveValue = "-" + currentPosition * 100 + "%"; 209 } else { 210 if (slideElements.length == ++currentPosition) { 211 currentPosition = 0; 212 moveValue = 0; 213 } else { 214 moveValue = "-" + (currentPosition * 100) + "%" 215 } 216 } 217 slideAnimate(moveValue, moveValueFx); 218 } 219 220 var slideAnimate = function(value, fxValue) { 221 222 slideBox.finish().animate({ 223 "left": value 224 }, 550, "easeInCubic", function() { 225 if(slideElements.length > 1){ 226 slideDotElements.removeAttr("class").eq(currentPosition).addClass("selected"); 227 if(options["secondDots"] != false){ 228 secondDots.removeAttr("class").eq(currentPosition).addClass("selected"); 229 } 230 } 231 }); 232 233 } 234 235 var makeSlider = function(event){ 236 237 if(event.type == "ready"){ 238 nextTimeLine(true); 239 } 240 241 if(options.responsive === true){ 242 var wW = $(window).outerWidth(); 243 var ch = (wW > 1350) ? "large" : "normal"; 244 slidePictures.each(function(i, el){ 245 $(el).css({ 246 "background-image" : "url('" + $(el).data(ch) + "')" 247 }); 248 }); 249 } 250 251 //callBack after resize 252 253 if(event.type == "resize"){ 254 if(options["afterResize"] && typeof(options["afterResize"]) === "function"){ 255 options["afterResize"](link); 256 } 257 } 258 259 }; 260 261 262 var nextTimeLine = function(enableAnimate){ 263 264 if(timeLine != undefined){ 265 266 timeLine.finish().css({ 267 "width" : "0%" 268 }); 269 270 if(enableAnimate == true){ 271 timeLine.animate({ 272 "width" : "100%" 273 }, options.delay); 274 } 275 276 } 277 278 }; 279 280 leftButton.on("click", function(e) { 281 clearTimeout(timeoutID); 282 slideMove(true); 283 e.preventDefault(); 284 }); 285 286 rightButton.on("click", function(e) { 287 clearTimeout(timeoutID); 288 slideMove(false); 289 e.preventDefault(); 290 }); 291 292 if(slideElements.length > 1){ 293 slideDotElements.on("click", function(e) { 294 clearTimeout(timeoutID); 295 currentPosition = $(this).index() - 1; 296 slideMove(false); 297 }); 298 if(options["secondDots"] != false){ 299 secondDots.on("click", function(e) { 300 clearTimeout(timeoutID); 301 currentPosition = $(this).index() - 1; 302 slideMove(false); 303 e.preventDefault(); 304 }); 305 } 306 } 307 308 timeoutID = setTimeout(function() { 309 slideAuto(); 310 }, options.delay); 311 312 link.hover(function(){ 313 clearTimeout(timeoutID); 314 nextTimeLine(false); 315 }, function(){ 316 timeoutID = setTimeout(function() { 317 slideAuto(); 318 }, options.delay); 319 nextTimeLine(true); 320 }); 321 322 $(window).on("ready resize", makeSlider); 323 324 //callBack after load 325 326 if(options["afterLoad"] && typeof(options["afterLoad"]) === "function"){ 327 if(slideElements.length > 0){ 328 options["afterLoad"](link); 329 } 330 } 331 332 }; 333})(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.