$(document).ready(function(){ // Prevent the default action when a file is dropped on the window $(document).on('drop dragover', function (e) { e.preventDefault(); }); $('.photo-back-button').on('click', function(event){ fileUploadShowMedia(); event.preventDefault(); }); }); var bindFileUploadChoose = function(formElement, callbackFunc){ var closeBtn = $($(formElement).find('.cr-close-media-btn')); closeBtn.on('click', function(e){ $('.dropfile-parts').hide(); $('.dropfile-parts.dropfilewrap').show(); e.preventDefault(); }); $(formElement).find('.add-more-people').on('click', function(event){ fileUploadShowMedia(); event.preventDefault(); }); $(formElement).find('.drop-btn-delete').on('click', function(e){ if(callbackFunc) callbackFunc('clear', null); fileUploadReset(formElement); e.preventDefault(); }); $(formElement).find('.drop-btn-edit').on('click', function(e){ $(formElement).find('.icon-obi-check').toggleClass('off'); if($(formElement).find('.icon-obi-check').hasClass('off')){ $(this).html('Edit'); $(formElement).find('.obi-edit-menu').addClass('off'); }else{ $(this).html('Cancel'); $(formElement).find('.obi-edit-menu').removeClass('off'); } e.preventDefault(); }); } var fileUploadReset = function(formElement){ $(formElement).find('.dropfile-parts').hide(); $(formElement).find('.dropfile-parts.dropfilewrap').show(); } var croppieInstance = []; var dropfile_reset = function(formElement){ fileUploadReset(); var remove = []; for(var i = 0; i < croppieInstance.length; i++){ var id = croppieInstance[i][0]; if(id == formElement) remove[remove.length] = i; } for(var i = 0; i < remove.length; i++){ croppieInstance.splice(i, 1); } } var fileUploadShowMedia = function(){ $('.dropfile-parts').hide(); $('.dropfile-parts.dropfilechoosemedia').show(); $.get('/x/medialist').done(function(html){ $('.dropfile-parts.dropfilechoosemedia .pp-add-media').html(html); }); } var bindFileUpload = function(formElement, callbackFunc, flavour){ //var overall = 0; //var knobs = new Array(); /*$('#drop a').click(function(){ // Simulate a click on the file input button // to show the file browser dialog $(this).parent().find('input').click(); });*/ var shape = 'square'; var width = 200; var height = 200; if(flavour == 'profile'){ shape = 'circle'; }else if(flavour == 'post'){ width = 250; height = 122; }else if(flavour == 'sip'){ width = 250; height = 160; } var fileCount = 0; var viewport = { width: width, height: height, type: shape }; bindFileUploadChoose(formElement, callbackFunc); // Initialize the jQuery File Upload plugin //$('#upload').fileupload({ $(formElement).fileupload({ url: '/content/upload/', // This element will accept file drag/drop uploading dropZone: $(formElement).find('.add-photo-section'), // This function is called when a file is added to the queue; // either via the browse button, or via drag/drop: add: function (e, data) { //var ul = $('#upload ul'); var ul = $(formElement).find('ul.uploadprogress'); var progressInput = $(formElement).find('.progressInput'); if(!progressInput.length){ var tpl = $('
Uploading..