var UploadFiles={$form: '',$bload: '',$bfile: '',$bar: '',switchButton: function(e){if(true==e){$('.photos-upload-file-submit').hide();}else{$('.photos-upload-file-submit').show();}},__initialization:function(){u=UploadFiles||this;u.$form=$("#data-upload-form")?$("#data-upload-form"):undefined;u.$bload=$("#data-upload-load")?$("#data-upload-load"):undefined;u.$bfile=$("#data-upload-file")?$("#data-upload-file"):undefined;u.$bar=$(".photos-upload-file-progress",u.$form)?$(".photos-upload-file-progress",u.$form):undefined;var $submit=$('.photos-upload-file-submit');var f=$("#myFile",u.$form);if(u.$form!==undefined&&u.$bload!==undefined&&u.$bfile!==undefined&&u.$bar!==undefined) {$(".data-upload-cancel",u.$bfile).off('click').on('click',function(){$(u.$bload).show();$(u.$bfile).hide();f.val('');u.switchButton(true);return false;});$("#myFile").change(function(){var v = (f.val()).search(/^.*\.(?:jpg|jpeg)\s*$/ig);if(v!=0){f.val('');u.switchButton(true);}else{if($(f).prop('files')&&$(f).prop('files')[0]){var reader=new FileReader();reader.onload=function(e){$(".photos-upload-file-mini").html('<img src="'+e.target.result+'"/>');};reader.readAsDataURL($(f).prop('files')[0]);}$(u.$bload).hide();$(u.$bfile).show();u.switchButton(false);}return false;});u.switchButton(true);$("#data-upload-form").on('submit',function(e){e.preventDefault();$(u.$bar).show();u.switchButton(true);urll=window.location.toString();var $that=$(this),fD=new FormData();fD.append('myFile',f.prop('files')[0]);fD.append('cfms',"1");fD.append('access',$("input[name='access']").val());fD.append('desc',$("textarea[name='desc']").val());$.ajax({url:urll,type:'POST',contentType:false,processData:false,data:fD,dataType:'json',xhr:function(s){var xhr=$.ajaxSettings.xhr();xhr.upload.addEventListener('progress',function(evt){ if(evt.lengthComputable){var percentComplete=Math.ceil(evt.loaded/evt.total*100);$('.app-progress-bar div span').css('width',percentComplete+'%');$('.app-progress-bar span.app-progress-bar').text(percentComplete+'%');}},false);return xhr;},success:function(j){if(j.error){UI.addNote(j.error,true);$(u.$bar).hide();u.switchButton(false);}else{$AJAX.Loader(j.link,true);}}});return false;});}else{debLog('error initializing the boot form');}}};UploadFiles.__initialization();
