var files = new Array(); var selectedFile = null; var visibleFiles=4; $(document).ready(function () { var selectedValue = false; var selectedIndex = 0; var cp_pid; var cm_pid; var start=0; var end = 50; if ($('#fileField').attr('value') != '') { selectedValue = $('#fileField').attr('value'); } cp_pid = $('#edit-collection-pid').attr('value'); cm_pid = $('#model_pid').attr('value'); $.getJSON("/filechooser/generatePreview/"+cp_pid+"/"+cm_pid+"?start="+start+"&end="+end,function (data) { $('#fileList').html(''); if (data.length == 0) { $('#fileList').append('
No files found in staging area.
'); } else { $.each(data, function(i, item) { var html; files[i]=item.name; var selected= ""; if (selectedValue == item.name) { selected='class="selected"'; selectedFile='file'+i; selectedIndex=i - (i%visibleFiles); } if (item.thumb) { html='
  • '+item.name+'
    '+item.mime+'
    '+item.size+'  '+item.resolution+'
  • '; } else { var type=item.mime.split('/',1).shift(); html='
  •  
    '+item.name+'
    '+item.mime+'
    '+item.size+'
  • '; } $('#fileList').append(html); }); $('#fileList li div').breakly(15); } $(".carousel .jCarouselLite").jCarouselLite({ btnNext: ".carousel .next", btnPrev: ".carousel .prev", mouseWheel: true, circular: false, speed: 750, visible: visibleFiles, scroll: visibleFiles, initial: selectedIndex }); $(".carousel li").click(function() { if (selectedFile != this.id) { $('#fileField').attr('value',files[this.id.split('file',2).pop()]); $("#"+(this.id)).addClass('selected'); if (selectedFile != null) { $("#"+selectedFile).removeClass('selected'); } selectedFile=this.id; } }) }); });