1(function($) { 2 3// Call & init 4$(document).ready(function(){ 5 $('.ba-slide').each(function(){ 6 var cur = $(this); 7 // Adjust the slider 8 var width = cur.width()+'px'; 9 cur.find('.resize img').css('width', width); 10 }); 11}); 12 13 14function drags(dragElement, resizeElement, container) { 15 16 // Initialize the dragging event on mousedown. 17 dragElement.on('mousedown touchstart', function(e) { 18 19 dragElement.addClass('draggable'); 20 resizeElement.addClass('resizable'); 21 22 // Check if it's a mouse or touch event and pass along the correct value 23 var startX = (e.pageX) ? e.pageX : e.originalEvent.touches[0].pageX; 24 25 // Get the initial position 26 var dragWidth = dragElement.outerWidth(), 27 posX = dragElement.offset().left + dragWidth - startX, 28 containerOffset = container.offset().left, 29 containerWidth = container.outerWidth(); 30 31 // Set limits 32 minLeft = containerOffset + 10; 33 maxLeft = containerOffset + containerWidth - dragWidth - 10; 34 35 // Calculate the dragging distance on mousemove. 36 dragElement.parents().on("mousemove touchmove", function(e) { 37 38 // Check if it's a mouse or touch event and pass along the correct value 39 var moveX = (e.pageX) ? e.pageX : e.originalEvent.touches[0].pageX; 40 41 leftValue = moveX + posX - dragWidth; 42 43 // Prevent going off limits 44 if ( leftValue < minLeft) { 45 leftValue = minLeft; 46 } else if (leftValue > maxLeft) { 47 leftValue = maxLeft; 48 } 49 50 // Translate the handle's left value to masked divs width. 51 widthValue = (leftValue + dragWidth/2 - containerOffset)*100/containerWidth+'%'; 52 53 // Set the new values for the slider and the handle. 54 // Bind mouseup events to stop dragging. 55 $('.draggable').css('left', widthValue).on('mouseup touchend touchcancel', function () { 56 $(this).removeClass('draggable'); 57 resizeElement.removeClass('resizable'); 58 }); 59 $('.resizable').css('width', widthValue); 60 }).on('mouseup touchend touchcancel', function(){ 61 dragElement.removeClass('draggable'); 62 resizeElement.removeClass('resizable'); 63 }); 64 e.preventDefault(); 65 }).on('mouseup touchend touchcancel', function(e){ 66 dragElement.removeClass('draggable'); 67 resizeElement.removeClass('resizable'); 68 }); 69} 70 71 72// Call & init 73$(document).ready(function(){ 74 $('.ba-slide').each(function(){ 75 var cur = $(this); 76 // Adjust the slider 77 var width = cur.width()+'px'; 78 cur.find('.resize img').css('width', width); 79 // Bind dragging events 80 drags(cur.find('.handle'), cur.find('.resize'), cur); 81 }); 82}); 83 84// Update sliders on resize 85$(window).resize(function(){ 86 $('.ba-slide').each(function(){ 87 var cur = $(this); 88 var width = cur.width()+'px'; 89 cur.find('.resize img').css('width', width); 90 }); 91}); 92 93})( 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.