Uploading file...
or cancel and closeHide Details
').overlay({closeSelector:'.lw_cancel a',zIndex:1151});$('#lw_uploads_files').on('click','a',function(e){e.preventDefault();livewhale.previewImage($(this).attr('href'));return true;});}).bind('fileuploadsend',function(e,data){$.each(data.files,function(id,file){if($.inArray(file.name,file_ids)===-1){file_ids[file_ids.length]=file.name;}
id=$.inArray(file.name,file_ids);$('#lw_uploads_files').append('
');$('#lw_'+id+' .lw_uploader_complete').removeClass('lw_complete').removeClass('lw_failed').width(0);$('#lw_'+id+' .lw_uploader_filename,#lw_'+id+' .lw_uploader_complete_filename').html(file.name);});}).bind('fileuploaddone',function(e,data){if(!data.result||data.result.error){uploadOverlay.overlay('destroy');$("body").notify({type:'failure',id:'upload',message:(data.result)?data.result.error:'Server Error'});return;}
$.each(data.files,function(id,file){id=$.inArray(file.name,file_ids);var $progress=$('#lw_'+id),$li=$progress.closest('li');$li.find('.lw_uploader_image_placeholder').remove();$('#lw_'+id+' .lw_uploader_complete').stop().animate({width:'100%'},function(){$(this).addClass('lw_complete').children().eq(0).html('
'+file.name+' uploaded successfully!');});});theform.find('.lw_hidden_upload').remove();if(options.upload_to_element_id){theform.prepend('
');}else{theform.prepend('
');}
uploadOverlay.overlay('destroy');setTimeout(function(){if($.isFunction(options.onSuccess)){options.onSuccess.apply(self,[e,data]);}},600);}).bind('fileuploadprogress',function(e,data){var onProgress=options.onProgress||$.noop;onProgress.apply(self,[e,data]);$.each(data.files,function(id,file){id=$.inArray(file.name,file_ids);$('#lw_'+id+' .lw_uploader_complete').stop().animate({width:Math.floor((data.loaded/data.total)*100)+'%'});});}).fileupload({dataType:'json',url:'/livewhale/backend.php?livewhale=uploader&type='+type+'&page='+encodeURIComponent(livewhale.page),fail:options.onError||$.noop,success:$.noop,timeout:900000,pasteZone:null,maxFileSize:livewhale.upload_max_filesize*1024*1024});});},uploadInline:function(type,options){return this.each(function(){var that=this,$this=$(this),is_plural=false,self;if(!options.status){options.status=0;}
helpers.initEditLink();if(!$this.next('input[name=upload]').length&&!$this.find('input[name=upload]').length){if(legacyBrowser){$this.css({overflow:'hidden',width:'auto',position:'relative',verticalAlign:'text-bottom',top:'0.25em'}).append('
');}else{$('
').insertAfter($this);}}
self=($this.next('input').length)?$this.next('input'):$this.find('input[name=upload]');if(!legacyBrowser){if(!options.disableClick){$(this).click(function(){$(this).siblings('input[name=upload]').click();return false;});}}
var file_ids=[],is_first_file=true;self.bind('fileuploadadd',function(e,data){var file_ext=(data.files.length)?data.files[0].name.match(/\.([\w]+)$/):[],save_txt='Save ',title=type,str;if(!isValidFileType(type,data.originalFiles[0])){return false;}
if(!$('#lw_uploads_batch').length){save_txt='Save this '+type.substring(0,type.length-1);if(options.mode){title='Add '+(type==='images'?'Images':'Files')+' to Library';}
str='
';var footer='
';self.data('uploader',{}).data('uploader').overlay=$(str).overlay({closeSelector:'.lw_cancel a',zIndex:1151,title:title,footer:footer});$('#lw_uploads_files').on('click','a',function(e){e.preventDefault();livewhale.previewImage($(this).attr('href'));return true;});if(options.mode){$('#lw_uploads_batch_save').data('upload_val','Add to library').html('Add to library');}}else if(!is_plural){self.data('uploader').overlay.find('#lw_uploads_batch_save').val('Save these '+type);is_plural=true;}}).bind('fileuploadsend',function(e,data){$.each(data.files,function(id,file){if($.inArray(file.name,file_ids)===-1)file_ids[file_ids.length]=file.name;id=$.inArray(file.name,file_ids);$('#lw_uploads_files').append('
');$('#lw_'+id+' .lw_uploader_complete').removeClass('lw_complete').removeClass('lw_failed').width(0);$('#lw_'+id+' .lw_uploader_filename,#lw_'+id+' .lw_uploader_complete_filename').html(file.name);});}).bind('fileuploaddone',function(e,data){is_plural=false;if(!data.result||data.result.error){$.each(data.files,function(id,file){id=$.inArray(file.name,file_ids);$("#lw_"+id+" .lw_uploader_complete").stop().animate({width:"100%"},function(){$(this).addClass("lw_failed").children().eq(0).html('
'+file.name+' could not be uploaded.');});$("#lw_"+id).after('
'+data.result.error+'
');});return;}
$('.lw_overlay_save_toggle').show();$.each(data.files,function(id,file){id=$.inArray(file.name,file_ids);var $progress=$('#lw_'+id),$li=$progress.closest('li'),file_markup;$li.find('.lw_uploader_image_placeholder').remove();$progress.find('.lw_uploader_complete').stop().animate({width:'100%'},function(){$(this).addClass('lw_complete').children().eq(0).html('
'+file.name+' uploaded successfully!');});$progress.find('.lw_uploader_hidden').val(data.result.upload);var collections=options.collections||[];var collection_id=options.collection_id||null;if(options.mode==='images_upload_batch'||options.mode==="quick_upload"){file_markup=(type==='images')?getImageDetailsMarkup(id,data.result,file,{collection:collection_id}):getFileDetailsMarkup(id,data.result);$progress.after(file_markup).on('click','.lw_uploads_image > a',function(e){livewhale.previewImage($(this).attr('href'));});if('images'===type){$li.find('.upload-caption').wysiwyg({limited:true,init:function(e,data){$('#'+data.editor.id+'_ifr').height(60);}});}
$('#lw_'+id+'_details :input[placeholder]').placeholder({clear:'#lw_uploads_batch_save,#submit_button'});}else if(options.mode==='files_upload_batch'){$('#lw_'+id).after('
');$('#lw_'+id+'_details :input[placeholder]').placeholder({clear:'#lw_uploads_batch_save,#submit_button'});}});$(this).parents('form').find('.lw_hidden_upload').remove();}).bind('fileuploadprogress',function(e,data){var onProgress=options.onProgress||function(){};onProgress.apply(self,[e,data]);$.each(data.files,function(id,file){id=$.inArray(file.name,file_ids);$('#lw_'+id+' .lw_uploader_complete').stop().animate({width:Math.floor((data.loaded/data.total)*100)+'%'});});}).fileupload({dataType:'json',url:'/livewhale/backend.php?livewhale=uploader&type='+type+'&page='+encodeURIComponent(livewhale.page),fail:options.onError||function(){},timeout:900000,dropZone:options.dropZone||null,dragDropSupport:options.dragDropSupport||null,pasteZone:null,maxFileSize:livewhale.upload_max_filesize*1024*1024,success:function(e,data){if(options.mode==='files_upload_batch'||options.mode==='quick_upload'){if(is_first_file){is_first_file=false;var $form=$('#lw_uploads_batch_form').submit(function(e){e.preventDefault();var $this=$(this),$btn=$('#lw_uploads_batch_save',$this);if(!$('#lw_uploads_batch').data('complete')){$btn.attr('disabled','disabled');$btn.val('Please wait...');$('#lw_uploads_batch').data('complete',1);$.ajax({type:'post',url:'/livewhale/backend.php?livewhale=uploader_save_library&type='+type+'&status='+options.status+(livewhale.group_id?'&gid='+livewhale.group_id:''),data:$this.serialize(),success:function(data){var errors=_.chain(data).filter('error').map('error').uniq().value();if(errors&&errors.length){$('#lw_uploads_files').children().each(function(index){if(data[index]&&data[index].id){$(this).remove();}});livewhale.prompt('Save Error',errors.join('
'),'failure');$btn.removeAttr('disabled').val('Save these '+type);$('#lw_uploads_batch').data('complete',0);}else{$('#lw_uploads_batch').overlay('destroy');if($.isFunction(options.onSuccess)){var $titles=$this.find('[name="titles\[\]"]');if(type==='files'&&$titles.length&&data.length===$titles.length){$titles.each(function(i,val){data[i].title=$(this).val();});}
options.onSuccess.apply(self,[e,data]);}
is_first_file=true;}},timeout:900000,dataType:'json'});}
return false;});$('#lw_uploads_batch_save').click(function(e){$form.submit();});}}else if($.isFunction(options.onSuccess)){options.onSuccess.apply(self,[e,data]);}}}).bind('click',function(e,data){var sub_file_ids=[],mode;if(options.mode==="images_upload_batch"){mode='images';}
if(options.mode==="files_upload_batch"){mode='files';}
if(!mode){return;}
var collections_field='';if(mode==='images'){if(options.collections){collections_field=getCollectionsSelect(options.collections,options.collection_id);}else{$.ajax({url:'/livewhale/backend.php?livewhale=images_get_collections',dataType:'json',async:false,success:function(data){if(data){collections=_.map(data,function(val,key){return{id:key,title:val};});}
collections_field=getCollectionsSelect(collections,options.collection_id);}});}}
var html,footer,$footer;html='
'
+'
'
+'If you enter values in the fields below, they will be applied to all the '+mode+' in '
+'your bulk upload.'+(livewhale.upload_max_filesize?' Note that there is a '
+livewhale.upload_max_filesize+'MB file size limit for all uploads.':'')
+'
'
+'
'
+'
'
+'
'
+collections_field
+'
'
+'
'
+'
'
+'
'
+'
'
+'
'
+'
';footer='
';$footer=$(footer);var overlay=$(html);self.data('uploader',{}).data('uploader').overlay=overlay;var overlay_opts={closeSelector:'.lw_cancel a',zIndex:1151,title:'Upload several '+type+' at once',footer:$footer};if(mode==='images'){overlay.overlay($.extend({},overlay_opts,{close:function(){overlay.find('#images_caption').wysiwyg('destroy');}}));overlay.find('#images_caption').wysiwyg({limited:true});}else if(mode==='files'){overlay.find('#images_keywords_wrapper').remove();overlay.find('#images_caption_wrapper').remove();overlay.find('#images_credit_wrapper').remove();if(LW.upload_accepted_file_types&&LW.upload_accepted_file_types.length){var file_types=LW.upload_accepted_file_types.join(', ').toUpperCase();overlay.append('
Supported files: '+file_types+'
');}
overlay.overlay(overlay_opts);}
$('body').bind('lw-upload-form-close',function(){overlay.show();});if(livewhale.tags){overlay.find('.tag_suggest').multisuggest({name:'tags',type:'tags',data:livewhale.tags,selected:false,zIndex:1152,create:true});}else $.getJSON('/livewhale/backend.php?livewhale=ajax&function=getTagsListJSON',function(response){overlay.find('.tag_suggest').multisuggest({name:'tags',type:'tags',data:response,selected:false,zIndex:1152,create:true});});overlay.find('.star').click(function(){var value=$(this).find('input');if(value.val()==='1'){value.val('');$(this).removeClass('active');}else{value.val(1);$(this).addClass('active');}});overlay.find('.globe').click(function(){var value=$(this).find('input');if(value.val()==='1'){value.val('');$(this).removeClass('active');}else{value.val(1);$(this).addClass('active');}});var $pop_form=overlay.find('#pop_form').click(function(){helpers.initUploadForm(overlay,type,sub_file_ids,options);});if(($.browser.mozilla&&parseFloat($.browser.version.substr(0,3))<2.0)||$.browser.msie){$footer.find('#lw_uploads_batch_name').hide();$pop_form.css('visibility','visible');}else{$footer.on('click','#lw_uploads_batch_name',function(evt){evt.preventDefault();$('#pop_form').find('input').click();overlay.hide();return false;});}
return false;});});},uploadInPlace:function(type,options){return this.each(function(){var that=this,$this=$(this),theform=$(this).parents('form'),self;if(!$this.next('input[name=upload]').length&&!$this.find('input[name=upload]').length){if(legacyBrowser){$(this).css({overflow:'hidden',width:'auto',position:'relative',verticalAlign:'text-bottom',top:'0.25em'}).append('
');}else{$('
').insertAfter($(this));}}
self=($this.next('input').length)?$this.next('input'):$this.find('input[name=upload]');if(!legacyBrowser){if(!options.disableClick){$(this).click(function(){$(this).siblings('input[name=upload]').click();return false;});}}
var file_ids=file_ids||[];self.bind('fileuploadadd',function(e,data){if(!isValidFileType(type,data.originalFiles[0])){return false;}
$(that).parent().find('input[name=upload]').prev().append('
');}).bind('fileuploadsend',function(e,data){$.each(data.files,function(id,file){var html;if($.inArray(file.name,file_ids)===-1)file_ids[file_ids.length]=file.name;id=$.inArray(file.name,file_ids);html='
';$(that).find('#lw_uploads_files').append(html).end().find('#lw_'+id+' .lw_uploader_complete').removeClass('lw_complete').removeClass('lw_failed').width(0).end().find('#lw_'+id+' .lw_uploader_filename,#lw_'+id+' .lw_uploader_complete_filename').html(file.name);});}).bind('fileuploaddone',function(e,data){if(data.result&&data.result.error){$("body").notify({type:'failure',id:'upload',message:data.result.error});$(that).find("#lw_uploads_files").remove();return;}
$.each(data.files,function(id,file){id=$.inArray(file.name,file_ids);$(that).find('#lw_'+id+' .lw_uploader_complete').stop().animate({width:'100%'},function(){$(this).addClass('lw_complete').children().eq(0).html('
'+file.name+' uploaded successfully!');});});if(options.upload_to_element_id){var upload_name=$(that).find('.lw_upload[type="hidden"]').attr('id');theform.find('[name="'+upload_name+'"]').remove();theform.prepend('
');}else{theform.find('.lw_hidden_upload').remove();theform.prepend('
');}
setTimeout(function(){if($.isFunction(options.onSuccess)){options.onSuccess.apply(self,[e,data]);}},600);}).bind('fileuploadprogress',function(e,data){$.each(data.files,function(id,file){id=$.inArray(file.name,file_ids);var onProgress=options.onProgress||function(){};onProgress.apply(self,[e,data]);});$.each(data.files,function(id,file){$(that).find('#lw_'+id+' .lw_uploader_complete').stop().animate({width:Math.floor((data.loaded/data.total)*100)+'%'});});}).fileupload({dataType:'json',url:'/livewhale/backend.php?livewhale=uploader&type='+type+'&page='+encodeURIComponent(livewhale.page),fail:options.onError||$.noop,success:$.noop,timeout:900000,pasteZone:null,maxFileSize:livewhale.upload_max_filesize*1024*1024});});}};helpers={addDecorationCheckboxHandler:function(){},initEditLink:function($overlay){$('body').off('click','#lw_files_toggle a');$('body').on('click','#lw_files_toggle a',function(e){e.preventDefault();var $this=$(this),$file=$this.closest('#lw_uploads_batch').find('#lw_uploads_files');if($file.hasClass('compact')){$this.text('Hide Details');}else{$this.text('Edit Details');}
$file.toggleClass('compact');return false;});},initUploadForm:function($overlay,type,sub_file_ids,options){var $popform=$overlay.find('#pop_form').unbind(".uploader").data("upload_overlay",""),$sub_overlay;var user_data={description:$overlay.find("#images_description").val(),is_starred:$overlay.find("#is_starred").val(),is_shared:$overlay.find("#is_shared").val(),tags:[],tags_added:[]};$overlay.find(".lw-multisuggest-tags input[name='tags[]']").each(function(){user_data.tags.push($(this).val());});$overlay.find(".lw-multisuggest-tags input[name='tags_added[]']").each(function(){user_data.tags_added.push($(this).val());});if(type==='images'){user_data.keywords=$overlay.find("#images_keywords").val();user_data.caption=$overlay.find("#images_caption").val();user_data.is_decoration=$overlay.find("#images_is_decoration").prop('checked');user_data.credit=$overlay.find("#images_credit").val();user_data.collection=$overlay.find("#images_collection").val()||'';}
$popform.bind('fileuploadadd.uploader',function(e,data){var html,footer,$footer;if(!isValidFileType(type,data.originalFiles[0])){return false;}
if(!$(this).data("upload_overlay")){html='
';footer='
';$sub_overlay=$(html).overlay({closeSelector:'.lw_cancel a',title:'Upload '+type,footer:footer,zIndex:1151,close:function(){$('body').trigger('lw-upload-form-close');}});$(this).data("upload_overlay",$sub_overlay);}else{$sub_overlay=$(this).data('upload_overlay');}
helpers.addDecorationCheckboxHandler($sub_overlay);if(data.files.length&&data.files[0].size&&livewhale.upload_max_filesize&&data.files[0].size>livewhale.upload_max_filesize*1024*1024){$sub_overlay.find('#lw_uploads_files').append('
"'+data.files[0].name+'" exceeds the maximum upload size.
');}else{data.submit();}}).bind('fileuploadsend.uploader',function(e,data){$.each(data.files,function(id,file){if($.inArray(file.name,sub_file_ids)===-1){sub_file_ids[sub_file_ids.length]=file.name;}
id=$.inArray(file.name,sub_file_ids);$("#lw_sub_uploader #lw_uploads_files").append('
');$('#lw_'+id+' .lw_uploader_complete').removeClass('lw_complete').removeClass('lw_failed').width(0);$('#lw_'+id+' .lw_uploader_filename,#lw_'+id+' .lw_uploader_complete_filename').html(file.name);});}).bind('fileuploaddone.uploader',function(e,data){var file_markup,$ul=$sub_overlay.find('#lw_uploads_files');if(data.result&&data.result.error){$.each(data.files,function(id,file){id=$.inArray(file.name,sub_file_ids);$("#lw_"+id+" .lw_uploader_complete").stop().animate({width:"100%"},function(){$(this).addClass("lw_failed").children().eq(0).html('
'+file.name+' could not be uploaded.');});$("#lw_"+id).after('
'+data.result.error+'
');});}else{$('.lw_overlay_save_toggle').show();$.each(data.files,function(id,file){id=$.inArray(file.name,sub_file_ids);var $progress=$('#lw_'+id),$li=$progress.closest('li'),$ul=$li.parent();$li.find('.lw_uploader_image_placeholder').remove();$progress.find('.lw_uploader_complete').stop().animate({width:'100%'},function(){$(this).addClass('lw_complete').children().eq(0).html('
'+file.name+' uploaded successfully!');});$progress.find('.lw_uploader_hidden').val(data.result.upload);file_markup=(type==='images')?getImageDetailsMarkup(id,data.result,file,user_data):getFileDetailsMarkup(id,data.result,user_data);$progress.after(file_markup).on('click','.lw_uploads_image > a',function(e){livewhale.previewImage($(this).attr('href'));});if('images'===type){$li.find('.upload-caption').wysiwyg({limited:true,init:function(e,data){$('#'+data.editor.id+'_ifr').height(60);if(user_data.is_decoration){setTimeout(function(){$li.find('.decoration-only input:checkbox').click();},200);}}});}
$('#lw_'+id+'_details :input[placeholder]').placeholder({clear:'#lw_uploads_batch_save,#submit_button'});});if(user_data.tags.length){$.each(user_data.tags,function(i,val){$ul.after('
');});}
if(user_data.tags_added.length){$.each(user_data.tags_added,function(i,val){$ul.after('
');});}
$(this).parents('form').find('.lw_hidden_upload').remove();}}).bind('fileuploadprogress.uploader',function(e,data){var onProgress=options.onProgress||function(){};onProgress.apply($(this),[e,data]);$.each(data.files,function(id,file){id=$.inArray(file.name,sub_file_ids);$('#lw_'+id+' .lw_uploader_complete').stop().animate({width:Math.floor((data.loaded/data.total)*100)+"%"});});}).fileupload({dataType:'json',url:'/livewhale/backend.php?livewhale=uploader&type='+type+'&page='+encodeURIComponent(livewhale.page),fail:options.onError||function(){},timeout:900000,dropZone:options.dropZone||null,dragDropSupport:options.dragDropSupport||null,pasteZone:null,maxFileSize:livewhale.upload_max_filesize*1024*1024,success:function(e,data){$('#lw_uploads_batch_save').click(function(){if(!$('#lw_uploads_batch').data('complete')){var $submit=$(this).attr('disabled','disabled').val('Please wait...');$('#lw_uploads_batch').data('complete',1);$.ajax({type:'post',url:'/livewhale/backend.php?livewhale=uploader_save_library&type='+type+'&status='+options.status+(livewhale.group_id?'&gid='+livewhale.group_id:''),data:$('#lw_sub_uploader :input').serialize(),success:function(data){var errors=_.chain(data).filter('error').map('error').uniq().value();if(errors&&errors.length){$('#lw_uploads_files').children().each(function(index){if(data[index]&&data[index].id){$(this).remove();}});livewhale.prompt('Save Error',errors.join('
'),'failure');$submit.removeAttr('disabled').val('Save these '+type);$('#lw_uploads_batch').data('complete',0);}else{$("#pop_form").data("upload_overlay").overlay('destroy');$('#lw_uploads_batch').overlay('destroy');if($.isFunction(options.onSuccess)){options.onSuccess.apply($(this),[e,data]);}}},timeout:900000,dataType:'json'});}});},add:function(){}});}};$.fn.uploader=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1));}else{$.error('Method '+method+' does not exist for jQuery.uploader.');}};}(livewhale,livewhale.jQuery));