Sie sind auf Seite 1von 3

/*

* XenForo attachment_editor.min.js
* Copyright 2010-2014 XenForo Ltd.
* Released under the XenForo License Agreement: http://xenforo.com/license-agre
ement
*/
(function(e,l,j){var h=XenForo.speed.normal,g=XenForo.speed.fast;XenForo.Attachm
entUploader=function(c){var f=e(c.data("trigger"));c.closest("form");var a=e(c.d
ata("placeholder")),b={},d=null,i=null,m=c.data("maxfilesize");c.data("maxupload
s");var g=c.data("extensions"),h=c.data("uniquekey");c.show();var k=XenForo.cano
nicalizeUrl(c.data("flashurl")||"js/swfupload/Flash/swfupload.swf");console.info
("flash url: %s",k);typeof SWFUpload=="function"&&!l.navigator.userAgent.match(/
Android|iOS|iPhone|iPad|Mobile Safari/i)&&
(d=new SWFUpload({upload_url:c.data("action"),file_post_name:c.data("postname"),
file_types:"*."+(g.toLowerCase()+","+g.toUpperCase()).replace(/,/g,";*."),post_p
arams:e.extend({_xfToken:XenForo._csrfToken,_xfNoRedirect:1,_xfResponseType:"jso
n"},b),button_placeholder_id:a.attr("id"),button_width:1,button_height:1,button_
window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,button_cursor:SWFUpload.CURSOR.HAN
D,flash_url:k,prevent_swf_caching:!1,swfupload_loaded_handler:function(){this.se
tButtonDimensions(f.outerWidth(),
f.outerHeight());e(this.movieElement).css("top",f.position().top);c.find(".Hidde
nInput").each(function(a,c){d.addPostParam(e(c).data("name"),e(c).data("value"))
});e(j).bind("CSRFRefresh",function(a){a.ajaxData&&(d.addPostParam("_xfToken",a.
ajaxData.csrfToken),d.addPostParam("_xfSessionId",a.ajaxData.sessionId))})},file
_dialog_complete_handler:function(){try{this.getStats().files_queued>0&&this.sta
rtUpload(this.getFile(0).ID)}catch(a){this.debug(a)}},file_queued_handler:functi
on(a){var b;switch(a.name.substr(a.name.lastIndexOf(".")).toLowerCase()){case ".
jpg":case ".jpeg":case ".jpe":case ".png":case ".gif":b=
!0;break;default:b=!1}var d=e.Event("AttachmentQueueValidation");d.file=a;d.swfU
pload=this;d.isImage=b;c.trigger(d);if(!d.isDefaultPrevented())a.size>m&&!b?(thi
s.cancelUpload(a.id,!1),typeof this.settings.file_queue_error_handler=="function
"&&this.settings.file_queue_error_handler.call(this,a,SWFUpload.QUEUE_ERROR.FILE
_EXCEEDS_SIZE_LIMIT,"The uploaded file is too large.")):(d=e.Event("AttachmentQu
eued"),d.file=a,d.swfUpload=this,d.isImage=b,c.trigger(d))},file_queue_error_han
dler:function(a,b,d){var f=
e.Event("AttachmentQueueError");f.file=a;f.errorCode=b;f.message=d;f.swfUpload=t
his;c.trigger(f);f.isDefaultPrevented()||i(a,b,d)},upload_start_handler:function
(a){console.log("Uploading %s",a.name)},upload_progress_handler:function(a,b){c.
trigger({type:"AttachmentUploadProgress",file:a,bytes:b,swfUpload:this})},upload
_success_handler:function(a,b){try{var d=e.parseJSON(b)}catch(f){console.warn(f)
;return}d.error?c.trigger({type:"AttachmentUploadError",file:a,ajaxData:d,swfUpl
oad:this}):c.trigger({type:"AttachmentUploaded",
file:a,ajaxData:d,swfUpload:this})},upload_error_handler:function(a,b,d){b!=SWFU
pload.UPLOAD_ERROR.FILE_CANCELLED&&(console.warn("Upload failed: %o",arguments),
c.trigger({type:"AttachmentUploadError",file:a,errorCode:b,message:d,ajaxData:{e
rror:[c.data("err-unknown")]},swfUpload:this}))},upload_complete_handler:functio
n(){try{this.getStats().files_queued>0?this.startUpload(this.getFile(0).ID):cons
ole.info("All files uploaded.")}catch(a){this.debug(a)}}}),i=function(a,b,d){b=c
.data("err"+b)||d;a?XenForo.alert(b+
"<br /><br />"+a.name):XenForo.alert(b)});e(j).bind("AutoInlineUploadComplete",f
unction(a){if(h&&a.ajaxData&&h!==a.ajaxData.key)return!1;if(e(a.target).is("form
.AttachmentUploadForm"))return f.overlay()&&f.overlay().close(),c.trigger({type:
"AttachmentUploaded",ajaxData:a.ajaxData}),!1});return{getSwfUploader:function()
{return d},swfAlert:i}};XenForo.AttachmentEditor=function(c){this.setVisibility=
function(a){var b=c.closest(".ctrlUnit"),d=c.find(".AttachmentInsertAllBlock"),f
=c.find(".AttachedFile:not(#AttachedFileTemplate)"),
e=f.filter(".AttachedImage");console.log("Attachments changed, total files: %d,
images: %d",f.length,e.length);b.length==0&&(b=c);a===!0?f.length?(e.length>1?d.
show():d.hide(),b.show()):b.hide():f.length?(e.length>1?b.is(":hidden")?d.show()
:d.xfFadeDown(XenForo.speed.fast):b.is(":hidden")?d.hide():d.xfFadeUp(XenForo.sp

eed.fast,!1,XenForo.speed.fast,"swing"),b.xfFadeDown(XenForo.speed.normal)):(d.s
lideUp(XenForo.speed.fast),b.xfFadeUp(XenForo.speed.normal,!1,!1,"swing"))};this
.setVisibility(!0);e("#AttachmentUploader").bind({AttachmentQueued:function(a){c
onsole.info("Queued file %s (%d bytes).",
a.file.name,a.file.size);var b=e("#AttachedFileTemplate").clone().attr("id",a.fi
le.id);b.find(".Filename").text(a.file.name);b.find(".ProgressCounter").text("0%
");b.find(".ProgressGraphic span").css("width","0%");a.isImage&&b.addClass("Atta
chedImage");b.xfInsert("appendTo",".AttachmentList.New",null,h);b.find(".Attachm
entCanceller").css("display","block").click(function(){a.swfUpload.cancelUpload(
a.file.id);b.xfRemove(null,function(){c.trigger("AttachmentsChanged")},g,"swing"
)});c.trigger("AttachmentsChanged")},
AttachmentUploadProgress:function(a){console.log("Uploaded %d/%d bytes.",a.bytes
,a.file.size);var b=Math.min(100,Math.ceil(a.bytes*100/a.file.size)),d=b+"%",a=e
("#"+a.file.id),c=a.find(".ProgressCounter"),f=a.find(".ProgressGraphic");c.text
(d);f.css("width",d);b>=100&&a.find(".AttachmentCanceller").prop("disabled",!0).
addClass("disabled");f.width()>c.outerWidth()&&c.appendTo(f)},AttachmentUploadEr
ror:function(a){var b="";e.each(a.ajaxData.error,function(a,c){b+=c+"\n"});XenFo
ro.alert(b+"<br /><br />"+
a.file.name);e("#"+a.file.id).xfRemove();console.warn("AttachmentUploadError: %o
",a)},AttachmentUploaded:function(a){if(a.file){var b=e("#"+a.file.id),d=b.find(
".AttachmentText"),f=e(a.ajaxData.templateHtml),g;d.fadeOut(XenForo.speed.fast,f
unction(){f.find(".AttachmentText").xfInsert("insertBefore",d,"fadeIn",XenForo.s
peed.fast);g=b.find(".Thumbnail");g.html(f.find(".Thumbnail").html());d.xfRemove
();b.attr("id","attachment"+a.ajaxData.attachment_id)})}else b=e("#attachment"+a
.ajaxData.attachment_id),
b.length||(b=e(a.ajaxData.templateHtml).xfInsert("appendTo",c.find(".AttachmentL
ist.New"),null,h));c.trigger("AttachmentsChanged")}});var f=e.context(this,"setV
isibility");e("#QuickReply").bind("QuickReplyComplete",function(){c.find(".Attac
hmentList.New li:not(#AttachedFileTemplate)").xfRemove().promise().always(f)});c
.bind("AttachmentsChanged",f)};XenForo.AttachmentInserter=function(c){c.click(fu
nction(f){var a=c.closest(".AttachedFile").find(".Thumbnail a"),b=a.data("attach
mentid"),d;d=a.find("img").attr("src");
a=a.attr("href");f.preventDefault();c.attr("name")=="thumb"?(f="[ATTACH]"+b+"[/A
TTACH] ",d='<img src="'+d+'" class="attachThumb bbCodeImage" alt="attachThumb'+b
+'" /> '):(f="[ATTACH=full]"+b+"[/ATTACH] ",d='<img src="'+a+'" class="attachFul
l bbCodeImage" alt="attachFull'+b+'" /> ');if(b=XenForo.getEditorInForm(c.closes
t("form"),":not(.NoAttachment)"))if(b.$editor){b.insertHtml(d);var e=b.$editor.d
ata("xenForoElastic");e&&(setTimeout(function(){e()},250),setTimeout(function(){
e()},1E3))}else b.val(b.val()+
f)})};XenForo.AttachmentDeleter=function(c){c.css("display","block").click(funct
ion(c){var a=e(c.target),b=a.attr("href")||a.data("href"),d=a.closest(".Attached
File"),c=a.closest(".AttachedFile").find(".Thumbnail a").data("attachmentid");if
(b){d.xfFadeUp(XenForo.speed.normal,null,g,"swing");XenForo.ajax(b,"",function(a
){if(XenForo.hasResponseError(a))return d.xfFadeDown(XenForo.speed.normal),!1;va
r b=d.closest(".AttachmentEditor");d.xfRemove(null,function(){b.trigger("Attachm
entsChanged")},g,"swing")});
if(c&&(a=XenForo.getEditorInForm(a.closest("form"),":not(.NoAttachment)"))&&a.$e
ditor)a.$editor.find("img[alt=attachFull"+c+"], img[alt=attachThumb"+c+"]").remo
ve(),(c=a.$editor.data("xenForoElastic"))&&c();return!1}console.warn("Unable to
locate href for attachment deletion from %o",a)})};XenForo.AttachmentInsertAll=f
unction(c){c.click(function(){e(".AttachmentInserter[name="+c.attr("name")+"]").
each(function(c,a){e(a).trigger("click")})})};XenForo.AttachmentDeleteAll=functi
on(c){c.click(function(){e(".AttachmentDeleter").each(function(c,
a){e(a).trigger("click")})})};XenForo.register(".AttachmentUploader","XenForo.At
tachmentUploader");XenForo.register(".AttachmentEditor","XenForo.AttachmentEdito
r");XenForo.register(".AttachmentInserter","XenForo.AttachmentInserter");XenForo
.register(".AttachmentDeleter","XenForo.AttachmentDeleter");XenForo.register(".A
ttachmentInsertAll","XenForo.AttachmentInsertAll");XenForo.register(".Attachment
DeleteAll","XenForo.AttachmentDeleteAll");e.browser.mozilla&&e(function(){var c=
XenForo.isRTL()?"9999em":

"-9999em",f=e('<object width="100" height="100" type="application/x-shockwave-fl


ash" style="visibility: hidden; position: absolute; top: 0; left: '+c+'" />').ap
pendTo("body");setTimeout(function(){f.remove()},250)})})(jQuery,this,document);

Das könnte Ihnen auch gefallen