1(function($){ 2 $.fn.cherryfullBgSlider=function(opt){ 3 4 var options = { 5 prevButton: $('.prevButton') 6 , nextButton: $('.nextButton') 7 , paginationList: $('.paginationList') 8 , duration: 1000 9 , parallaxEffect: true 10 , autoSwitcher: true 11 , autoSwitcherDelay: 7000 12 , animateLayout: 'zoom-fade-eff' //simple-fade-eff, zoom-fade-eff, slide-top-eff 13 } 14 $.extend(options, opt); 15 16 var 17 _this = $(this) 18 , _window = $(window) 19 , _document = $(document) 20 , currSet = 0 21 , currImgId = 0 22 , ImgIdCounter = 0 23 , itemsLength = 0 24 , previewArray = [] 25 , isPreviewLoading = false 26 , isPreviewAnimate = false 27 , intervalSwitcher 28 , parsedArray 29 , _thisHeight = _this.height() 30 , _thisHeightBuffer = 0 31 , _windowWidth = 0 32 , _windowHeight = 0 33 , _documentHeight = 0 34 , bufferRatio = 0.5 35 , itemLength = 0 36 ; 37 38 var 39 mainImageHolder 40 , primaryImageHolder 41 , secondaryHolder 42 , previewSpinner 43 ; 44 45///////////////////////////// INIT ///////////////////////////////////////////////////////// 46 init(); 47 48 function init(){ 49 parsedArray = []; 50 $('ul li', _this).each( 51 function(){ 52 parsedArray.push([$(this).attr('data-preview'), $(this).attr('data-img-width'), $(this).attr('data-img-height'), $(this).html()]); 53 } 54 ) 55 // holder erase 56 _this.html(''); 57 _this.addClass(options.animateLayout); 58 59 // preview holder build 60 _this.append("<div id='mainImageHolder'><div class='primaryHolder'><img src='' alt=''></div><div class='secondaryHolder'><img src='' alt=''></div></div>"); 61 mainImageHolder = $('#mainImageHolder'); 62 primaryImageHolder = $('#mainImageHolder > .primaryHolder'); 63 secondarImageHolder = $('#mainImageHolder > .secondaryHolder'); 64 65 // preview loader build 66 _this.append("<div id='previewSpinner'><span></span></div>"); 67 previewSpinner = $('#previewSpinner'); 68 69 _this.on("reBuild", 70 function(e,d){ 71 setBuilder(d); 72 } 73 ) 74 75 _this.on("currentSwitcher", 76 function(e,d){ 77 imageSwitcher(d); 78 } 79 ) 80 81 _this.on("switchNext", 82 function(e){ 83 nextSwither(); 84 } 85 ) 86 87 _this.on("switchPrev", 88 function(e){ 89 prevSwither(); 90 } 91 ) 92 93 setBuilder({'urlArray':parsedArray}); 94 95 _thisHeight = _this.height(); 96 97 if(options.parallaxEffect){ 98 mainImageHolder.css({height:"150%"}); 99 bufferRatio = 0.5; 100 } 101 _thisHeightBuffer = _thisHeight*bufferRatio; 102 addEventsFunction(); 103 addEventsPagination(); 104 autoSwitcher(); 105 } 106 //------------------------- set Builder -----------------------------// 107 function setBuilder(dataObj){ 108 currIndex = 0; 109 ImgIdCounter = 0; 110 previewArray = []; 111 previewArray = dataObj.urlArray; 112 itemLength = previewArray.length; 113 imageSwitcher(0); 114 } 115 116 function autoSwitcher(){ 117 if(options.autoSwitcher){ 118 if(itemLength > 1){ 119 intervalSwitcher = setInterval(function(){ 120 nextSwither(); 121 }, options.autoSwitcherDelay); 122 } 123 } 124 } 125 ////////////////////////// addEvents ///////////////////////////////////////////// 126 function addEventsPagination(){ 127 $(">li", options.paginationList).eq(ImgIdCounter).addClass('active'); 128 $(">li", options.paginationList).on("click", 129 function(){ 130 if((!isPreviewLoading) && (!isPreviewAnimate) && ($(this).index() !== ImgIdCounter)){ 131 ImgIdCounter = $(this).index(); 132 imageSwitcher(ImgIdCounter); 133 } 134 } 135 ) 136 } 137 function addEventsFunction(){ 138 //--------------- controls events ----------------------// 139 options.prevButton.on("click", 140 function(){ 141 clearInterval(intervalSwitcher); 142 prevSwither(); 143 } 144 ) 145 options.nextButton.on("click", 146 function(){ 147 clearInterval(intervalSwitcher); 148 nextSwither(); 149 } 150 ) 151 //--------------- keyboard events ----------------------// 152 _window.on("keydown", 153 function(eventObject){ 154 switch (eventObject.keyCode){ 155 case 37: 156 clearInterval(intervalSwitcher); 157 prevSwither(); 158 break 159 case 39: 160 clearInterval(intervalSwitcher); 161 nextSwither(); 162 break 163 } 164 } 165 ) 166 //------------------ window scroll event -------------// 167 $(window).on('scroll', 168 function(){ 169 mainScrollFunction(); 170 } 171 ).trigger('scroll'); 172 //------------------ window resize event -------------// 173 $(window).on("resize", 174 function(){ 175 mainResizeFunction(); 176 } 177 ) 178 } 179 //----------------------------------------------------------------- 180 function prevSwither(){ 181 if(!isPreviewLoading && !isPreviewAnimate){ 182 if(ImgIdCounter > 0){ 183 ImgIdCounter--; 184 }else{ 185 ImgIdCounter = itemLength-1; 186 } 187 imageSwitcher(ImgIdCounter); 188 } 189 } 190 function nextSwither(){ 191 if(!isPreviewLoading && !isPreviewAnimate){ 192 if(ImgIdCounter < itemLength-1){ 193 ImgIdCounter++; 194 }else{ 195 ImgIdCounter = 0; 196 } 197 imageSwitcher(ImgIdCounter); 198 } 199 } 200 //------------------------- main Swither ----------------------------// 201 function imageSwitcher(currIndex){ 202 $(">li", options.paginationList).removeClass('active'); 203 $(">li", options.paginationList).eq(currIndex).addClass('active'); 204 $('> img', primaryImageHolder).attr('src','').attr('src', previewArray[currIndex][
2040]); 205 $('> img', primaryImageHolder).attr('data-image-width', previewArray[currIndex][1]); 206 $('> img', primaryImageHolder).attr('data-image-height', previewArray[currIndex][2]); 207 objectCssTransition(primaryImageHolder, 0, 'ease'); 208 primaryImageHolder.addClass('animateState'); 209 210 isPreviewLoading = true; 211 isPreviewAnimate = true; 212 previewSpinner.css({display:'block'}).stop().fadeTo(300, 1); 213 $('> img', primaryImageHolder).on('load', function(){ 214 isPreviewLoading = false; 215 previewSpinner.stop().fadeTo(300, 0, function(){ $(this).css({display:'none'}); }) 216 $(this).off('load'); 217 objectResize($('> img', primaryImageHolder), mainImageHolder, "fill"); 218 219 objectCssTransition(primaryImageHolder, options.duration, 'outCubic'); 220 primaryImageHolder.removeClass('animateState'); 221 objectCssTransition(secondarImageHolder, options.duration, 'outCubic'); 222 secondarImageHolder.addClass('animateState'); 223 224 setTimeout( 225 function(){ 226 objectCssTransition(secondarImageHolder, 0, 'ease'); 227 secondarImageHolder.removeClass('animateState'); 228 229 $('> img', secondarImageHolder).attr('src', "").attr('src', previewArray[currIndex][0]); 230 $('> img', secondarImageHolder).attr('data-image-width', previewArray[currIndex][1]); 231 $('> img', secondarImageHolder).attr('data-image-height', previewArray[currIndex][2]); 232 233 objectResize($('> img', secondarImageHolder), mainImageHolder, "fill"); 234 isPreviewAnimate = false; 235 }, options.duration 236 ) 237 }); 238 } 239 240 //----------------------------------------------------// 241 function objectCssTransition(obj, duration, ease){ 242 var durationValue; 243 244 if(duration !== 0){ 245 durationValue = duration/1000; 246 }else{ 247 durationValue = 0 248 } 249 250 switch(ease){ 251 case 'ease': 252 obj.css({"-webkit-transition":"all "+durationValue+"s ease", "-moz-transition":"all "+durationValue+"s ease", "-o-transition":"all "+durationValue+"s ease", "transition":"all "+durationValue+"s ease"}); 253 break; 254 case 'outSine': 255 obj.css({"-webkit-transition":"all "+durationValue+"s cubic-bezier(0.470, 0.000, 0.745, 0.715)", "-moz-transition":"all "+durationValue+"s cubic-bezier(0.470, 0.000, 0.745, 0.715)", "-o-transition":"all "+durationValue+"s cubic-bezier(0.470, 0.000, 0.745, 0.715)", "transition":"all "+durationValue+"s cubic-bezier(0.470, 0.000, 0.745, 0.715)"}); 256 break; 257 case 'outCubic': 258 obj.css({"-webkit-transition":"all "+durationValue+"s cubic-bezier(0.215, 0.610, 0.355, 1.000)", "-moz-transition":"all "+durationValue+"s cubic-bezier(0.215, 0.610, 0.355, 1.000)", "-o-transition":"all "+durationValue+"s cubic-bezier(0.215, 0.610, 0.355, 1.000)", "transition":"all "+durationValue+"s cubic-bezier(0.215, 0.610, 0.355, 1.000)"}); 259 break; 260 case 'outExpo': 261 obj.css({"-webkit-transition":"all "+durationValue+"s cubic-bezier(0.190, 1.000, 0.220, 1.000)", "-moz-transition":"all "+durationValue+"s cubic-bezier(0.190, 1.000, 0.220, 1.000)", "-o-transition":"all "+durationValue+"s cubic-bezier(0.190, 1.000, 0.220, 1.000)", "transition":"all "+durationValue+"s cubic-bezier(0.190, 1.000, 0.220, 1.000)"}); 262 break; 263 case 'outBack': 264 obj.css({"-webkit-transition":"all "+durationValue+"s cubic-bezier(0.175, 0.885, 0.320, 1.275)", "-moz-transition":"all "+durationValue+"s cubic-bezier(0.175, 0.885, 0.320, 1.275)", "-o-transition":"all "+durationValue+"s cubic-bezier(0.175, 0.885, 0.320, 1.275)", "transition":"all "+durationValue+"s cubic-bezier(0.175, 0.885, 0.320, 1.275)"}); 265 break; 266 } 267 } 268 //----------------------------------------------------// 269 function objectResize(obj, container, type){ 270 var 271 prevImgWidth = 0 272 , prevImgHeight = 0 273 , imageRatio 274 , windowRatio 275 , newImgWidth 276 , newImgHeight 277 , newImgTop 278 , newImgLeft 279 , alignIMG = 'top' 280 ; 281 282 prevImgWidth = parseInt(obj.attr('data-image-width')); 283 prevImgHeight = parseInt(obj.attr('data-image-height')); 284 285 286 imageRatio = prevImgHeight/prevImgWidth; 287 containerRatio = container.height()/container.width(); 288 289 switch(type){ 290 case 'fill': 291 if(containerRatio > imageRatio){ 292 newImgHeight = container.height(); 293 newImgWidth = Math.round( (newImgHeight*prevImgWidth) / prevImgHeight ); 294 }else{ 295 newImgWidth = container.width(); 296 newImgHeight = Math.round( (newImgWidth*prevImgHeight) / prevImgWidth ); 297 } 298 299 obj.css({width: newImgWidth, height: newImgHeight}); 300 301 screenWidth = container.width(); 302 screenHeight = container.height(); 303 imgWidth = obj.width(); 304 imgHeight = obj.height(); 305 306 switch(alignIMG){ 307 case "top": 308 newImgLeft=-(imgWidth-screenWidth)*.5; 309 newImgTop=0; 310 break; 311 case "bottom": 312 newImgLeft=-(imgWidth-screenWidth)*.5; 313 newImgTop=-(imgHeight-screenHeight); 314 break; 315 case "right": 316 newImgLeft=-(imgWidth-screenWidth); 317 newImgTop=-(imgHeight-screenHeight)*.5; 318 break;
319 case "left": 320 newImgLeft=0; 321 newImgTop=-(imgHeight-screenHeight)*.5; 322 break; 323 case "top_left": 324 newImgLeft=0; 325 newImgTop=0; 326 break; 327 case "top_right": 328 newImgLeft=-(imgWidth-screenWidth); 329 newImgTop=0; 330 break; 331 case "bottom_right": 332 newImgLeft=-(imgWidth-screenWidth); 333 newImgTop=-(imgHeight-screenHeight); 334 break; 335 case "bottom_left": 336 newImgLeft=0; 337 newImgTop=-(imgHeight-screenHeight); 338 break; 339 default: 340 newImgLeft=-(imgWidth-screenWidth)*.5; 341 newImgTop= -(imgHeight-screenHeight)*.5; 342 } 343 break 344 case 'fit': 345 if(containerRatio > imageRatio){ 346 newImgWidth = container.width(); 347 newImgHeight = (prevImgHeight*container.width())/prevImgWidth; 348 newImgTop = container.height()/2 - newImgHeight/2; 349 newImgLeft = 0; 350 }else{ 351 newImgWidth = (prevImgWidth*container.height())/prevImgHeight; 352 newImgHeight = container.height(); 353 newImgTop = 0; 354 newImgLeft = container.width()/2 - newImgWidth/2; 355 } 356 obj.css({width: newImgWidth, height: newImgHeight}); 357 break 358 } 359 360 obj.css({top: newImgTop, left: newImgLeft}); 361 } 362 //------------------- main window scroll function -------------------// 363 function mainScrollFunction(){ 364 var 365 _documentScrollTop 366 ; 367 368 _windowWidth = _window.width(); 369 _windowHeight = _window.height(); 370 _documentHeight = _document.height(); 371 _documentScrollTop = _document.scrollTop(); 372 373 _documentScrollBuffer = _documentHeight-_windowHeight; 374 percentScrolled = _documentScrollTop/_documentScrollBuffer; 375 deltaTopScrollVal = _thisHeightBuffer*percentScrolled; 376 if(options.parallaxEffect){ 377 mainImageHolder.css({top:-_thisHeightBuffer+(deltaTopScrollVal)}); 378 } 379 } 380 381 //------------------- main window resize function -------------------// 382 function mainResizeFunction(){ 383 _windowWidth = _window.width(); 384 _windowHeight = _window.height(); 385 _documentHeight = _document.height(); 386 _thisHeight = _this.height(); 387 _thisHeightBuffer = _thisHeight*bufferRatio; 388 389 objectResize($('> img', primaryImageHolder), mainImageHolder, "fill"); 390 objectResize($('> img', secondarImageHolder), mainImageHolder, "fill"); 391 } 392 //end window resizefunction 393 //--------------------------------------------------------------------// 394 function toDegrees (angle) { 395 return angle * (180 / Math.PI); 396 } 397 function toRadians (angle) { 398 return angle * (Math.PI / 180); 399 } 400//////////////////////////////////////////////////////////////////////////////////////////// 401 } 402})(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.