var current_photo = 0; var add_height = 25; // pure JS var elem = document.getElementById('mySwipe'); window.mySwipe = Swipe(elem, { // startSlide: 4, auto: 0, continuous: true, // disableScroll: true, // stopPropagation: true, callback: function(index, element) { $( "#caption_bar").addClass('hidden'); resize( index ); }, // transitionEnd: function(index, element) {} }); $( "#mySwipe" ).mouseenter(function() { $( ".photo_arrow" ).removeClass( 'hidden' ); }); $( ".photo_thumb_browser" ).on( "click", function() { $photo_num = $(this).attr('photo_num'); $( ".photo_arrow" ).addClass( 'hidden' ); window.mySwipe.slide( $photo_num, 500 ); $( ".photo_browser_thumb" ).removeClass('photo_browser_thumb_active'); $( "#thumb_img_"+$photo_num ).addClass('photo_browser_thumb_active'); }); function resize( $photo_num ) { if( !$photo_num ) $photo_num = 0; $( ".photo_browser_thumb" ).removeClass('photo_browser_thumb_active'); $( "#thumb_img_"+$photo_num ).addClass('photo_browser_thumb_active'); $height = parseInt($('#photo_'+$photo_num).outerHeight() ) + 20; $thumb_height = parseInt($('#thumb_img_'+$photo_num).outerHeight() ) + 15; $arrow_height = -parseInt($height/2)-add_height; $username = $( "#photo_"+$photo_num ).attr('username'); if( $username ) { $( "#caption_bar").removeClass('hidden'); $( "#caption_username").html( $username ); $( "#caption_username").attr( 'href', "/user/"+$username ); } current_photo = $photo_num; $( "#mySwipe" ).animate({ height: $height }, 500, function() { $('#mySwipe').css('height', $height); }); $( "#myThumbs" ).animate({ height: $thumb_height }, 500, function() { $('#myThumbs').css('height', $thumb_height); }); $( ".photo_arrow_div" ).animate({ top: $arrow_height }, 500, function() { $('.photo_arrow_div').css('height', $arrow_height); }); } var waitForFinalEvent = (function () { var timers = {}; return function (callback, ms, uniqueId) { if (!uniqueId) { uniqueId = "Don't call this twice without a uniqueId"; } if (timers[uniqueId]) { clearTimeout (timers[uniqueId]); } timers[uniqueId] = setTimeout(callback, ms); }; })(); $( document ).ready(function() { add_height = $( "#mySwipe" ).attr('add_height'); setTimeout(resize, 2000); }); $( window ).resize(function() { waitForFinalEvent(function(){ resize( current_photo ); }, 500, "resize function"); }); $(function () { 'use strict'; // Change this to the location of your server-side upload handler: var $entity_id = $('#fileupload').attr('entity_id'); var $entity_type = $('#fileupload').attr('entity_type'); var $code_name = $('#fileupload').attr('code_name'); var $is_admin = $('#fileupload').attr('is_admin'); var url = '/upload.php'; $('#fileupload').fileupload({ url: url, dataType: 'json', formData: { entity_id: $entity_id, entity_type: $entity_type }, done: function (e, data) { if( $is_admin == 1 ) { window.location.replace("/"+$entity_type+"/"+$code_name); } else { $('#photo_uploaded').modal('toggle'); } }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $('#progress .progress-bar').css( 'width', progress + '%' ); } }).prop('disabled', !$.support.fileInput) .parent().addClass($.support.fileInput ? undefined : 'disabled'); });