-WCF.Attachment={};WCF.Attachment.Upload=WCF.Upload.extend({_objectType:"",_objectID:0,_tmpHash:"",_parentObjectID:0,_wysiwygContainerID:"",init:function(c,g,a,h,d,e,f,b){this._super(c,g,"wcf\\data\\attachment\\AttachmentAction",{multiple:true,maxUploads:f});this._objectType=a;this._objectID=h;this._tmpHash=d;this._parentObjectID=e;this._wysiwygContainerID=b;this._buttonSelector.children("p.button").click($.proxy(this._validateLimit,this));this._fileListSelector.find(".jsButtonInsertAttachment").click($.proxy(this._insert,this))},_validateLimit:function(){var c=this._buttonSelector.next("small.innerError");var a=this._options.maxUploads-this._fileListSelector.children("li:not(.uploadFailed)").length;var d=(this._fileUpload)?this._fileUpload.prop("files").length:0;if(a<=0||a<d){var b=(a<=0)?WCF.Language.get("wcf.attachment.upload.error.reachedLimit"):WCF.Language.get("wcf.attachment.upload.error.reachedRemainingLimit").replace(/#remaining#/,a);if(!c.length){c=$('<small class="innerError" />').insertAfter(this._buttonSelector)}c.html(b);return false}c.remove();return true},_upload:function(){if(this._validateLimit()){this._super()}if(this._fileUpload){this._removeButton();this._createButton()}},_createUploadMatrix:function(a){this._fileListSelector.children("li.uploadFailed").remove();return this._super(a)},_getParameters:function(){return{objectType:this._objectType,objectID:this._objectID,tmpHash:this._tmpHash,parentObjectID:this._parentObjectID}},_initFile:function(a){var b=$('<li class="box48"><span class="icon icon48 icon-spinner" /><div><div><p>'+a.name+'</p><small><progress max="100"></progress></small></div><ul></ul></div></li>');this._fileListSelector.append(b);this._fileListSelector.show();return b},_success:function(b,c){for(var i=0;i<this._uploadMatrix[b].length;i++){var g=this._uploadMatrix[b][i];g.find("progress").remove();var h=g.data("filename");if(c.returnValues&&c.returnValues.attachments[h]){if(c.returnValues.attachments[h]["tinyURL"]){g.children(".icon-spinner").replaceWith($('<img src="'+c.returnValues.attachments[h]["tinyURL"]+'" alt="" class="attachmentTinyThumbnail" />'))}else{g.children(".icon-spinner").removeClass("icon-spinner").addClass("icon-paper-clip")}var e=$('<a href=""></a>');e.text(h).attr("href",c.returnValues.attachments[h]["url"]);if(c.returnValues.attachments[h]["isImage"]!=0){console.debug(c.returnValues.attachments[h]["isImage"]);e.addClass("jsImageViewer").attr("title",h)}g.find("p").empty().append(e);g.find("small").append(c.returnValues.attachments[h]["formattedFilesize"]);var f=$('<li><span class="icon icon16 icon-remove pointer jsTooltip jsDeleteButton" title="'+WCF.Language.get("wcf.global.button.delete")+'" data-object-id="'+c.returnValues.attachments[h]["attachmentID"]+'" data-confirm-message="'+WCF.Language.get("wcf.attachment.delete.sure")+'" /></li>');g.find("ul").append(f);var a=$('<li><span class="icon icon16 icon-paste pointer jsTooltip jsButtonInsertAttachment" title="'+WCF.Language.get("wcf.attachment.insert")+'" data-object-id="'+c.returnValues.attachments[h]["attachmentID"]+'" /></li>');a.children(".jsButtonInsertAttachment").click($.proxy(this._insert,this));g.find("ul").append(a)}else{g.children(".icon-spinner").removeClass("icon-spinner").addClass("icon-ban-circle");var d="";if(c.returnValues&&c.returnValues.errors[h]){d=c.returnValues.errors[h]["errorType"]}else{d="uploadFailed"}g.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error."+d)+"</small>"));g.addClass("uploadFailed")}g.css("display","block")}WCF.DOMNodeInsertedHandler.execute()},_insert:function(e){var d=$(e.currentTarget).data("objectID");var c="[attach="+d+"][/attach]";var a=$("#"+this._wysiwygContainerID).ckeditorGet();if(a.mode==="wysiwyg"){a.insertText(c)}else{var g=$("#"+this._wysiwygContainerID).next(".cke_editor_text").find("textarea");var b=g.val();if(b.length==0){g.val(c)}else{var f=g.getCaret();g.val(b.substr(0,f)+c+b.substr(f))}}},_error:function(){this._fileListSelector.find("li").each(function(a,c){var b=$(c);if(b.children(".icon-spinner").length){b.addClass("uploadFailed").children(".icon-spinner").removeClass("icon-spinner").addClass("icon-ban-circle");b.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error.uploadFailed")+"</small>"))}})}});
\ No newline at end of file
+WCF.Attachment={};WCF.Attachment.Upload=WCF.Upload.extend({_objectType:"",_objectID:0,_tmpHash:"",_parentObjectID:0,_wysiwygContainerID:"",init:function(c,g,a,h,d,e,f,b){this._super(c,g,"wcf\\data\\attachment\\AttachmentAction",{multiple:true,maxUploads:f});this._objectType=a;this._objectID=h;this._tmpHash=d;this._parentObjectID=e;this._wysiwygContainerID=b;this._buttonSelector.children("p.button").click($.proxy(this._validateLimit,this));this._fileListSelector.find(".jsButtonInsertAttachment").click($.proxy(this._insert,this));WCF.DOMNodeRemovedHandler.addCallback("WCF.Attachment.Upload",$.proxy(this._removeLimitError,this))},_validateLimit:function(){var c=this._buttonSelector.next("small.innerError");var a=this._options.maxUploads-this._fileListSelector.children("li:not(.uploadFailed)").length;var d=(this._fileUpload)?this._fileUpload.prop("files").length:0;if(a<=0||a<d){var b=(a<=0)?WCF.Language.get("wcf.attachment.upload.error.reachedLimit"):WCF.Language.get("wcf.attachment.upload.error.reachedRemainingLimit").replace(/#remaining#/,a);if(!c.length){c=$('<small class="innerError" />').insertAfter(this._buttonSelector)}c.html(b);return false}c.remove();return true},_removeLimitError:function(b){var a=$(b.target);if(a.is("li.box48")&&a.parent().wcfIdentify()===this._fileListSelector.wcfIdentify()){this._buttonSelector.next("small.innerError").remove()}},_upload:function(){if(this._validateLimit()){this._super()}if(this._fileUpload){this._removeButton();this._createButton()}},_createUploadMatrix:function(a){this._fileListSelector.children("li.uploadFailed").remove();return this._super(a)},_getParameters:function(){return{objectType:this._objectType,objectID:this._objectID,tmpHash:this._tmpHash,parentObjectID:this._parentObjectID}},_initFile:function(a){var b=$('<li class="box48"><span class="icon icon48 icon-spinner" /><div><div><p>'+a.name+'</p><small><progress max="100"></progress></small></div><ul></ul></div></li>');this._fileListSelector.append(b);this._fileListSelector.show();return b},_success:function(b,c){for(var i=0;i<this._uploadMatrix[b].length;i++){var g=this._uploadMatrix[b][i];g.find("progress").remove();var h=g.data("filename");if(c.returnValues&&c.returnValues.attachments[h]){if(c.returnValues.attachments[h]["tinyURL"]){g.children(".icon-spinner").replaceWith($('<img src="'+c.returnValues.attachments[h]["tinyURL"]+'" alt="" class="attachmentTinyThumbnail" />'))}else{g.children(".icon-spinner").removeClass("icon-spinner").addClass("icon-paper-clip")}var e=$('<a href=""></a>');e.text(h).attr("href",c.returnValues.attachments[h]["url"]);if(c.returnValues.attachments[h]["isImage"]!=0){console.debug(c.returnValues.attachments[h]["isImage"]);e.addClass("jsImageViewer").attr("title",h)}g.find("p").empty().append(e);g.find("small").append(c.returnValues.attachments[h]["formattedFilesize"]);var f=$('<li><span class="icon icon16 icon-remove pointer jsTooltip jsDeleteButton" title="'+WCF.Language.get("wcf.global.button.delete")+'" data-object-id="'+c.returnValues.attachments[h]["attachmentID"]+'" data-confirm-message="'+WCF.Language.get("wcf.attachment.delete.sure")+'" /></li>');g.find("ul").append(f);var a=$('<li><span class="icon icon16 icon-paste pointer jsTooltip jsButtonInsertAttachment" title="'+WCF.Language.get("wcf.attachment.insert")+'" data-object-id="'+c.returnValues.attachments[h]["attachmentID"]+'" /></li>');a.children(".jsButtonInsertAttachment").click($.proxy(this._insert,this));g.find("ul").append(a)}else{g.children(".icon-spinner").removeClass("icon-spinner").addClass("icon-ban-circle");var d="";if(c.returnValues&&c.returnValues.errors[h]){d=c.returnValues.errors[h]["errorType"]}else{d="uploadFailed"}g.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error."+d)+"</small>"));g.addClass("uploadFailed")}g.css("display","block")}WCF.DOMNodeInsertedHandler.execute()},_insert:function(e){var d=$(e.currentTarget).data("objectID");var c="[attach="+d+"][/attach]";var a=$("#"+this._wysiwygContainerID).ckeditorGet();if(a.mode==="wysiwyg"){a.insertText(c)}else{var g=$("#"+this._wysiwygContainerID).next(".cke_editor_text").find("textarea");var b=g.val();if(b.length==0){g.val(c)}else{var f=g.getCaret();g.val(b.substr(0,f)+c+b.substr(f))}}},_error:function(){this._fileListSelector.find("li").each(function(a,c){var b=$(c);if(b.children(".icon-spinner").length){b.addClass("uploadFailed").children(".icon-spinner").removeClass("icon-spinner").addClass("icon-ban-circle");b.find("div > div").append($('<small class="innerError">'+WCF.Language.get("wcf.attachment.upload.error.uploadFailed")+"</small>"))}})}});
\ No newline at end of file