blob: 61660e18d02c9499638394b4c7858ed185d1a785 [file] [log] [blame]
(function(){if(window.google&&google.gears){return }var A=null;if(typeof GearsFactory!="undefined"){A=new GearsFactory()}else{try{A=new ActiveXObject("Gears.Factory");if(A.getBuildInfo().indexOf("ie_mobile")!=-1){A.privateSetGlobalObject(this)}}catch(B){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){A=document.createElement("object");A.style.display="none";A.width=0;A.height=0;A.type="application/x-googlegears";document.documentElement.appendChild(A)}}}if(!A){return }if(!window.google){google={}}if(!google.gears){google.gears={factory:A}}})();
AJS.DragAndDrop={};(function(C){var F,E,B,A=/^\w+:\/\/[^\/?#]+/.exec(location.href);try{E=new XMLHttpRequest();B=!!(E.sendAsBinary||E.upload)&&!(jQuery.browser.mozilla&&jQuery.browser.version.indexOf("1.9.1")>-1)}catch(D){B=false}E=null;AJS.DragAndDropUtils={hasXhrSupport:B,base:A,getCachingUrl:function(H){var I=C("script[src*='drag-and-drop']:last");if(H&&H.indexOf("/")!=0){H="/"+H}if(!I.length){AJS.log("ERROR: Cannot find drag and drop caching url");return Confluence.getContextPath()+(H||"/")}var J=I.attr("src");var G=J.replace(/\/_\/download\/.*/,"/_"+(H||"/"));AJS.log("DragAndDropUtils: computed cache URL: "+G);return G},init:function(G){if(AJS.DragAndDrop.i18n){G&&G(B)}else{AJS.log("Drag and Drop: requesting translation");C.getJSON(this.getCachingUrl("/plugins/drag-and-drop/i18n.action?locale="+AJS.params.userLocale),function(H){AJS.DragAndDrop.i18n=H;G&&G(B)})}},bindDragEnter:function(G,I){if(G.addEventListener){I=(this.isFireFox35OrLater()?this.firefox35DragEnterAndOverCallbackWrapper(I):I);I&&G.addEventListener("dragenter",I,false)}else{if(G.attachEvent){var H=this.ieDragEnterAndDragOverCallbackWrapper(I);G.attachEvent("ondragenter",H);C(window).unload(function(){G.detachEvent("ondragenter",H)})}}},bindDragOver:function(G,I){if(G.addEventListener){if(this.isFireFox35OrLater()){I=this.firefox35DragEnterAndOverCallbackWrapper(I)}else{if(C.browser.safari){I=this.safariDragOverCallbackWrapper(I)}}I&&G.addEventListener("dragover",I,false)}else{if(G.attachEvent){var H=this.ieDragEnterAndDragOverCallbackWrapper(I);G.attachEvent("ondragover",H);C(window).unload(function(){G.detachEvent("ondragover",H)})}}},bindDragLeave:function(G,H){if(!H){return }if(C.browser.safari||this.isFireFox35OrLater()){G.addEventListener("dragleave",H,false)}else{if(C.browser.mozilla){G.addEventListener("dragexit",H,false)}else{if(C.browser.msie){G.attachEvent("ondragleave",H);C(window).unload(function(){G.detachEvent("ondragleave",H)})}}}},bindDrop:function(H,J){if(C.browser.mozilla){var G=(this.isFireFox35OrLater()?"drop":"dragdrop");
H.addEventListener(G,this.mozillaDropCallbackWrapper(J),false)}else{if(C.browser.msie){if(J){var I=function(K){J(K);AJS.DragAndDropUtils.stopPropagation(K)};H.attachEvent("ondrop",I);C(window).unload(function(){H.detachEvent("ondrop",I)})}}else{if(C.browser.safari){J&&H.addEventListener("drop",function(K){J(K);AJS.DragAndDropUtils.stopPropagation(K)},false)}}}},niceSize:function(G){var J=[" b"," Kb"," Mb"," Gb"," Tb"," Pb"," Eb"," Zb"," Yb"];for(var H=0,I=J.length;H<I;H++){if(G<Math.pow(2,10*(H+1))){return(!H?G:(G/Math.pow(2,10*H)).toFixed(2))+J[H]}}return(G/Math.pow(2,10*(H+1))).toFixed(2)+J[J.length-1]},ieDragEnterAndDragOverCallbackWrapper:function(G){return function(H){H=H||window.event;if(!H){return }G&&G(H);C.browser.msie&&(H.returnValue=false)}},safariDragOverCallbackWrapper:function(G){return function(H){H=H||window.event;if(!H){return }if(H.target.type=="file"){return }G&&G(H);(C.inArray("public.file-url",H.dataTransfer.types)!=-1)&&H.preventDefault()}},mozillaDropCallbackWrapper:function(G){return function(H){if(!H){return }G&&G(H);H.preventDefault();if(AJS.DragAndDropUtils.isFireFox35OrLater()){AJS.DragAndDropUtils.firefox35FileDataInEvent(H)&&H.stopPropagation()}else{H.stopPropagation()}}},firefox35DragEnterAndOverCallbackWrapper:function(G){return function(H){if(!H){return }G&&G(H);AJS.DragAndDropUtils.firefox35FileDataInEvent(H)&&H.preventDefault()}},firefox35FileDataInEvent:function(G){return C.inArray("application/x-moz-file",G.dataTransfer.types)!=-1},stopPropagation:function(G){G=G||window.event;if(!G){return }if(G.stopPropagation){G.stopPropagation()}else{G.cancelBubble=true}},preventDefault:function(G){G=G||window.event;if(!G){return }if(G.preventDefault){G.preventDefault()}else{G.returnValue=false}},isGearsInstalledNoPrompt:function(){try{return !!window.google&&!!google.gears&&!!google.gears.factory.create("beta.desktop")}catch(G){return false}},isGearsInstalledWithPermissions:function(G){var I={returnUrl:location.href};G=C.extend({},I,G);if(AJS.DragAndDropUtils.isGearsInstalledNoPrompt()){return google.gears.factory.getPermission("Confluence",contextPath+"/images/logo/confluence_64.png",AJS.DragAndDrop.i18n["confirm.gears.permissions"])
}else{var H=confirm(AJS.DragAndDrop.i18n["confirm.install.gears"]);if(H){location.href="http://gears.google.com/?action=install&name=Confluence&message=Install gears for drag-and-drop file upload functionality&return="+encodeURIComponent(G.returnUrl)}else{return false}}},isFireFox35OrLater:function(){return !this.isFireFox30()&&C.browser.version.indexOf("1.9.")!=-1},isFireFox30:function(){return C.browser.version.indexOf("1.9.0")!=-1},enableDropZoneOn:function(G,H){if(!G){throw new Error("Cannot enable drop zone on invalid container. Received: "+G)}H=H||AJS.DragAndDrop.defaultDropHandler;this.bindDragEnter(G);this.bindDragOver(G);this.bindDragLeave(G);this.bindDrop(G,H)},getFilesFromDropEvent:function(H){if(AJS.DragAndDropUtils.isFolderDropEvent(H)){AJS.DragAndDropUtils.displayMessageDialog(AJS.DragAndDrop.i18n["folder.warning"]);return[]}var I=this.getDesktopInstance().getDragData(H,"application/x-gears-files");var G;try{G=I&&I.files}catch(J){AJS.log("Error retrieving file data from drop event")}return G||[]},isFolderDropEvent:function(G){try{return(this.getDesktopInstance().getDragData(G,"application/x-gears-files")||{}).count==0}catch(H){AJS.log("Error retrieving file data from drop event")}},displayMessageDialog:function(H){var G=new AJS.Dialog(600,200,"drag-and-drop-message-dialog");G.addHeader(AJS.DragAndDrop.i18n["message.dialog.header"]).addPanel("Panel 1","<div>"+H+"</div>").addButton(AJS.DragAndDrop.i18n["http://10.20.160.198/wiki/s/en/2166/34/1.0.16/_/download/batch/com.atlassian.confluence.plugins.drag-and-drop:support/dialog.button.done"],function(I){G.remove()});G.show()},getDesktopInstance:function(){if(!F){F=google.gears.factory.create("beta.desktop")}return F}}})(AJS.$);
AJS.ObservableArrayList=function(){this._data=[];this._pushObservers=[]};AJS.ObservableArrayList.prototype={push:function(A){this._data.push(A);this._notifyPushObservers(A)},length:function(){return this._data.length},remove:function(B,A){return this._remove.call(this._data,B,A)},_remove:function(C,B){var A=this.slice((B||C)+1||this.length);this.length=C<0?this.length+C:C;return this.push.apply(this,A)},shift:function(){return this._data.shift()},removeByPredicate:function(B){var D=[],A=this._data.length;for(var C=0;C<A;C++){if(!B(this._data[C])){D.push(this._data[C])}}this._data=D;return A-this._data.length},addPushObserver:function(A){if(AJS.$.isFunction(A)){this._pushObservers.push(A)}else{throw new Error("Attempting to add an observer that is not a function: "+A)}},_notifyPushObservers:function(C){for(var A=0,B=this._pushObservers.length;A<B;A++){this._pushObservers[A](C)}}};
(function(){var D=0,I=[],K={},G={},A={"<":"lt",">":"gt","&":"amp",'"':"quot","'":"#39"},J=/[<>&\"\']/g,B,C=window.setTimeout;function F(){this.returnValue=false}function H(){this.cancelBubble=true}(function(L){var M=L.split(/,/),N,P,O;for(N=0;N<M.length;N+=2){O=M[N+1].split(/ /);for(P=0;P<O.length;P++){G[O[P]]=M[N]}}})("application/msword,doc dot,application/pdf,pdf,application/pgp-signature,pgp,application/postscript,ps ai eps,application/rtf,rtf,application/vnd.ms-excel,xls xlb,application/vnd.ms-powerpoint,ppt pps pot,application/zip,zip,application/x-shockwave-flash,swf swfl,application/vnd.openxmlformats,docx pptx xlsx,audio/mpeg,mpga mpega mp2 mp3,audio/x-wav,wav,image/bmp,bmp,image/gif,gif,image/jpeg,jpeg jpg jpe,image/png,png,image/svg+xml,svg svgz,image/tiff,tiff tif,text/html,htm html xhtml,text/rtf,rtf,video/mpeg,mpeg mpg mpe,video/quicktime,qt mov,video/x-flv,flv,video/vnd.rn-realvideo,rv,text/plain,asc txt text diff log,application/octet-stream,exe");var E={STOPPED:1,STARTED:2,QUEUED:1,UPLOADING:2,FAILED:4,DONE:5,CANCELLED:6,GENERIC_ERROR:-100,HTTP_ERROR:-200,IO_ERROR:-300,SECURITY_ERROR:-400,INIT_ERROR:-500,FILE_SIZE_ERROR:-600,FILE_EXTENSION_ERROR:-700,mimeTypes:G,extend:function(L){E.each(arguments,function(M,N){if(N>0){E.each(M,function(P,O){L[O]=P})}});return L},getElement:function(L){return L&&L.nodeType==1?L:document.getElementById(L)},cleanName:function(L){var M,N;N=[/[\300-\306]/g,"A",/[\340-\346]/g,"a",/\307/g,"C",/\347/g,"c",/[\310-\313]/g,"E",/[\350-\353]/g,"e",/[\314-\317]/g,"I",/[\354-\357]/g,"i",/\321/g,"N",/\361/g,"n",/[\322-\330]/g,"O",/[\362-\370]/g,"o",/[\331-\334]/g,"U",/[\371-\374]/g,"u"];for(M=0;M<N.length;M+=2){L=L.replace(N[M],N[M+1])}L=L.replace(/\s+/g,"_");L=L.replace(/[^a-z0-9_\-\.]+/gi,"");return L},addRuntime:function(L,M){M.name=L;I[L]=M;I.push(M);return M},guid:function(){var L=new Date().getTime().toString(32),M;for(M=0;M<5;M++){L+=Math.floor(Math.random()*65535).toString(32)}return(E.guidPrefix||"p")+L+(D++).toString(32)},buildUrl:function(M,L){var N="";
E.each(L,function(P,O){N+=(N?"&":"")+encodeURIComponent(O)+"="+encodeURIComponent(P)});if(N){M+=(M.indexOf("?")>0?"&":"?")+N}return M},each:function(O,P){var N,M,L;if(O){N=O.length;if(N===B){for(M in O){if(O.hasOwnProperty(M)){if(P(O[M],M)===false){return }}}}else{for(L=0;L<N;L++){if(P(O[L],L)===false){return }}}}},formatSize:function(L){if(L===B){return E.translate("N/A")}if(L>1048576){return Math.round(L/1048576,1)+" MB"}if(L>1024){return Math.round(L/1024,1)+" KB"}return L+" b"},getPos:function(M,Q){var R=0,P=0,T,S=document,N,O;M=M;Q=Q||S.body;function L(X){var V,W,U=0,Y=0;if(X){W=X.getBoundingClientRect();V=S.compatMode==="CSS1Compat"?S.documentElement:S.body;U=W.left+V.scrollLeft;Y=W.top+V.scrollTop}return{x:U,y:Y}}if(M.getBoundingClientRect&&(navigator.userAgent.indexOf("MSIE")>0&&S.documentMode!==8)){N=L(M);O=L(Q);return{x:N.x-O.x,y:N.y-O.y}}T=M;while(T&&T!=Q&&T.nodeType){R+=T.offsetLeft||0;P+=T.offsetTop||0;T=T.offsetParent}T=M.parentNode;while(T&&T!=Q&&T.nodeType){R-=T.scrollLeft||0;P-=T.scrollTop||0;T=T.parentNode}return{x:R,y:P}},getSize:function(L){return{w:L.clientWidth||L.offsetWidth,h:L.clientHeight||L.offsetHeight}},parseSize:function(L){var M;if(typeof (L)=="string"){L=/^([0-9]+)([mgk]+)$/.exec(L.toLowerCase().replace(/[^0-9mkg]/g,""));M=L[2];L=+L[1];if(M=="g"){L*=1073741824}if(M=="m"){L*=1048576}if(M=="k"){L*=1024}}return L},xmlEncode:function(L){return L?(""+L).replace(J,function(M){return A[M]?"&"+A[M]+";":M}):L},toArray:function(N){var M,L=[];for(M=0;M<N.length;M++){L[M]=N[M]}return L},addI18n:function(L){return E.extend(K,L)},translate:function(L){return K[L]||L},addEvent:function(M,L,N){if(M.attachEvent){M.attachEvent("on"+L,function(){var O=window.event;if(!O.target){O.target=O.srcElement}O.preventDefault=F;O.stopPropagation=H;N(O)})}else{if(M.addEventListener){M.addEventListener(L,N,false)}}}};E.Uploader=function(O){var M={},R,Q=[],S,N;R=new E.QueueProgress();O=E.extend({chunk_size:0,multipart:true,multi_selection:true,file_data_name:"file",filters:[]},O);
function P(){var T;if(this.state==E.STARTED&&S<Q.length){T=Q[S++];if(T.status==E.QUEUED){this.trigger("BeforeUpload",T);this.trigger("UploadFile",T)}else{P.call(this)}}else{this.trigger("UploaderIdle");this.stop()}}function L(){var U,T;R.reset();for(U=0;U<Q.length;U++){T=Q[U];if(T.size!==B){R.size+=T.size;R.loaded+=T.loaded}else{R.size=B}if(T.status==E.DONE){R.uploaded++}else{if(T.status==E.FAILED){R.failed++}else{R.queued++}}}if(R.size===B){R.percent=Q.length>0?Math.ceil(R.uploaded/Q.length*100):0}else{R.bytesPerSec=Math.ceil(R.loaded/((+new Date()-N||1)/1000));R.percent=R.size>0?Math.ceil(R.loaded/R.size*100):0}}E.extend(this,{state:E.STOPPED,features:{},files:Q,settings:O,total:R,id:E.guid(),init:function(){var Y=this,Z,V,U,X=0,W;if(typeof (O.preinit)=="function"){O.preinit(Y)}else{E.each(O.preinit,function(b,a){Y.bind(a,b)})}O.page_url=O.page_url||document.location.pathname.replace(/\/[^\/]+$/g,"/");if(!/^(\w+:\/\/|\/)/.test(O.url)){O.url=O.page_url+O.url}O.chunk_size=E.parseSize(O.chunk_size);O.max_file_size=E.parseSize(O.max_file_size);Y.bind("FilesAdded",function(a,d){var c,b,f=0,g,e=O.filters;if(e&&e.length){g=[];E.each(e,function(h){E.each(h.extensions.split(/,/),function(i){g.push("\\."+i.replace(new RegExp("["+("/^$.*+?|()[]{}\\".replace(/./g,"\\$&"))+"]","g"),"\\$&"))})});g=new RegExp(g.join("|")+"$","i")}for(c=0;c<d.length;c++){b=d[c];b.loaded=0;b.percent=0;b.status=E.QUEUED;if(g&&!g.test(b.name)){a.trigger("Error",{code:E.FILE_EXTENSION_ERROR,message:"File extension error.",file:b});continue}if(b.size!==B&&b.size>O.max_file_size){a.trigger("Error",{code:E.FILE_SIZE_ERROR,message:"File size error.",file:b});continue}Q.push(b);f++}if(f){C(function(){Y.trigger("QueueChanged");Y.refresh()})}else{return false}});if(O.unique_names){Y.bind("UploadFile",function(a,b){var d=b.name.match(/\.([^.]+)$/),c="tmp";if(d){c=d[1]}b.target_name=b.id+"."+c})}Y.bind("UploadProgress",function(a,b){if(b.status==E.QUEUED){b.status=E.UPLOADING}b.percent=b.size>0?Math.ceil(b.loaded/b.size*100):100;
L()});Y.bind("StateChanged",function(a){if(a.state==E.STARTED){N=(+new Date())}});Y.bind("QueueChanged",L);Y.bind("ActiveFileCancelled",function(){S--;C(function(){P.call(Y)})});Y.bind("Error",function(a,b){if(b.file){b.file.status=E.FAILED;L();C(function(){P.call(Y)})}});Y.bind("FileUploaded",function(a,b){b.status=E.DONE;b.loaded=b.size;a.trigger("UploadProgress",b);C(function(){P.call(Y)})});if(O.runtimes){V=[];W=O.runtimes.split(/\s?,\s?/);for(Z=0;Z<W.length;Z++){if(I[W[Z]]){V.push(I[W[Z]])}}}else{V=I}function T(){var d=V[X++],c,a,b;if(d){c=d.getFeatures();a=Y.settings.required_features;if(a){a=a.split(",");for(b=0;b<a.length;b++){if(!c[a[b]]){T();return }}}d.init(Y,function(e){if(e&&e.success){Y.features=c;Y.trigger("Init",{runtime:d.name});Y.trigger("PostInit");Y.refresh()}else{T()}})}else{Y.trigger("Error",{code:E.INIT_ERROR,message:"Init error."})}}T();if(typeof (O.init)=="function"){O.init(Y)}else{E.each(O.init,function(b,a){Y.bind(a,b)})}},refresh:function(){this.trigger("Refresh")},start:function(){if(this.state!=E.STARTED){S=0;this.state=E.STARTED;this.trigger("StateChanged");P.call(this)}},stop:function(){if(this.state!=E.STOPPED){this.state=E.STOPPED;this.trigger("StateChanged")}},getFile:function(U){var T;for(T=Q.length-1;T>=0;T--){if(Q[T].id===U){return Q[T]}}},cancelFile:function(U){var T;for(T=Q.length-1;T>=0;T--){if(Q[T].id===U.id){if(Q[T].status==E.UPLOADING){this.trigger("ActiveFileCancelled",Q[T])}Q[T].status=E.CANCELLED;return this.splice(T,1)[0]}}},removeFile:function(U){var T;for(T=Q.length-1;T>=0;T--){if(Q[T].id===U.id){return this.splice(T,1)[0]}}},splice:function(Y,W){function U(){for(var Z=Q.length-1;Z>=0;Z--){if(Q[Z].status==E.QUEUED||Q[Z].status==E.UPLOADING){return true}}return false}var X,T;X=Q.splice(Y===B?0:Y,W===B?Q.length:W);this.trigger("FilesRemoved",X);this.trigger("QueueChanged");if(!U()){var V=this;C(function(){V.trigger("UploaderIdle")})}return X},trigger:function(U){var W=M[U.toLowerCase()],V,T;if(W){T=Array.prototype.slice.call(arguments);
T[0]=this;for(V=0;V<W.length;V++){if(W[V].func.apply(W[V].scope,T)===false){return false}}}return true},bind:function(T,V,U){var W;T=T.toLowerCase();W=M[T]||[];W.push({func:V,scope:U||this});M[T]=W},unbind:function(T,V){var W=M[T.toLowerCase()],U;if(W){for(U=W.length-1;U>=0;U--){if(W[U].func===V){W.splice(U,1)}}}}})};E.File=function(O,M,N){var L=this;L.id=O;L.name=M;L.size=N;L.loaded=0;L.percent=0;L.status=0};E.Runtime=function(){this.getFeatures=function(){};this.init=function(L,M){}};E.QueueProgress=function(){var L=this;L.size=0;L.loaded=0;L.uploaded=0;L.failed=0;L.queued=0;L.percent=0;L.bytesPerSec=0;L.reset=function(){L.size=L.loaded=L.uploaded=L.failed=L.queued=L.percent=L.bytesPerSec=0}};E.runtimes={};window.plupload=E})();
(function(D){var E,C;function B(G,H){var F;if("FileReader" in window){F=new FileReader();F.readAsDataURL(G);F.onload=function(){H(F.result)}}else{return H(G.getAsDataURL())}}function A(L,N,K,F,M){var H,G,J,I;B(L,function(O){H=document.createElement("canvas");H.style.display="none";document.body.appendChild(H);G=H.getContext("2d");J=new Image();J.onload=function(){var S,P,Q,R,T;I=Math.min(N/J.width,K/J.height);if(I<1){S=Math.round(J.width*I);P=Math.round(J.height*I);H.width=S;H.height=P;G.drawImage(J,0,0,S,P);T=new C();T.init(atob(O.substring(O.indexOf("base64,")+7)));R=T.APP1({width:S,height:P});O=H.toDataURL(F);O=O.substring(O.indexOf("base64,")+7);O=atob(O);if(R){T.init(O);T.setAPP1(R);O=T.getBinary()}H.parentNode.removeChild(H);M({success:true,data:O})}else{M({success:false})}};J.src=O})}D.runtimes.Html5=D.addRuntime("html5",{getFeatures:function(){var K,G,J,H,F,I=window;G=J=H=F=false;if(I.XMLHttpRequest){K=new XMLHttpRequest();J=!!K.upload;G=!!(K.sendAsBinary||K.upload)}if(G){H=!!(File&&(File.prototype.getAsDataURL||I.FileReader)&&K.sendAsBinary);F=!!(File&&File.prototype.slice)}E=navigator.userAgent.indexOf("Safari")>0&&navigator.userAgent.indexOf("Chrome")<0;return{html5:G,dragdrop:I.mozInnerScreenX!==undefined||F||E,jpgresize:H,pngresize:H,multipart:H||!!I.FileReader||!!I.FormData,progress:J,chunking:F||H}},init:function(I,J){var F={},G;function H(N){var L,K,M=[],O;for(K=0;K<N.length;K++){L=N[K];O=D.guid();F[O]=L;if(L.fileSize>0){M.push(new D.File(O,L.fileName,L.fileSize))}}if(M.length){I.trigger("FilesAdded",M)}}G=this.getFeatures();if(!G.html5){J({success:false});return }I.bind("Init",function(O){var S,Q=[],N,R,L=O.settings.filters,M,P,K=document.body;S=document.createElement("div");S.id=O.id+"_html5_container";for(N=0;N<L.length;N++){M=L[N].extensions.split(/,/);for(R=0;R<M.length;R++){P=D.mimeTypes[M[R]];if(P){Q.push(P)}}}D.extend(S.style,{position:"absolute",background:I.settings.shim_bgcolor||"transparent",width:"100px",height:"100px",overflow:"hidden",zIndex:99999,opacity:I.settings.shim_bgcolor?"":0});
S.className="plupload html5";if(I.settings.container){K=document.getElementById(I.settings.container);K.style.position="relative"}K.appendChild(S);S.innerHTML='<input id="'+I.id+'_html5" style="width:100%;" type="file" accept="'+Q.join(",")+'" '+(I.settings.multi_selection?'multiple="multiple"':"")+" />";document.getElementById(I.id+"_html5").onchange=function(){H(this.files);this.value=""}});I.bind("PostInit",function(){var K=D.getElement(I.settings.drop_element),L,M;if(K){L=K.ownerDocument;if(E){D.addEvent(K,"dragenter",function(P){var N,O;M=L.getElementById(I.id+"_drop");if(!M){M=L.createElement("input");M.setAttribute("type","file");M.setAttribute("id",I.id+"_drop");M.setAttribute("multiple","multiple")}M.onchange=function(){H(this.files);this.value="";M&&M.parentElement.removeChild(M);M=null};N=D.getPos(K,document.getElementById(I.settings.container));O=D.getSize(K);D.extend(M.style,{position:"absolute",display:"block",top:N.y+"px",left:N.x+"px",width:O.w+"px",height:O.h+"px",opacity:0});K.appendChild(M);return })}D.addEvent(K,"dragover",function(N){N.preventDefault()});D.addEvent(K,"drop",function(O){var N=O.dataTransfer;if(N&&N.files){H(N.files)}M&&M.parentElement.removeChild(M);M=null;O.preventDefault();if(I.settings.stop_propagation){if(O.cancelBubble){O.cancelBubble=true}else{O.stopPropagation()}}})}});I.bind("Refresh",function(K){var L,M,N;L=D.getElement(I.settings.browse_button);M=D.getPos(L,D.getElement(K.settings.container));N=D.getSize(L);D.extend(document.getElementById(I.id+"_html5_container").style,{top:M.y+"px",left:M.x+"px",width:N.w+"px",height:N.h+"px"})});I.bind("UploadFile",function(K,M){var N=K.settings,P,L;function O(Q){var T=0,S=0;function R(){var Z=Q,h,i,d,e,f=0,W="----pluploadboundary"+D.guid(),Y,b,X="--",g="\r\n",c="",V,U=K.settings.url;if(M.status==D.DONE||M.status==D.FAILED||M.status==D.CANCELLED||K.state==D.STOPPED){M.status==(D.FAILED||D.CANCELLED)&&h&&h.abort();return }e={name:M.target_name||M.name};if(N.chunk_size&&G.chunking){Y=N.chunk_size;
d=Math.ceil(M.size/Y);b=Math.min(Y,M.size-(T*Y));if(typeof (Q)=="string"){Z=Q.substring(T*Y,T*Y+b)}else{Z=Q.slice(T*Y,b)}e.chunk=T;e.chunks=d}else{b=M.size}h=new XMLHttpRequest();i=h.upload;if(i){i.onprogress=function(j){M.loaded=Math.min(M.size,S+j.loaded-f);if(M.status==D.CANCELLED){h.abort();return }K.trigger("UploadProgress",M)}}if(!K.settings.multipart||!G.multipart){U=D.buildUrl(K.settings.url,e)}else{e.name=M.target_name||M.name}h.open("post",U,true);h.onreadystatechange=function(){var j,l;if(M.status==D.FAILED||M.status==D.CANCELLED){return }if(h.readyState==4){try{j=h.status}catch(k){j=0}if(j>=400){K.trigger("Error",{code:D.HTTP_ERROR,message:"HTTP Error.",file:M,status:j,response:h.responseText||""})}else{if(d){l={chunk:T,chunks:d,response:h.responseText,status:j};K.trigger("ChunkUploaded",M,l);S+=b;if(l.cancelled){M.status=D.FAILED;return }M.loaded=Math.min(M.size,(T+1)*Y)}else{M.loaded=M.size}K.trigger("UploadProgress",M);if(!d||++T>=d){M.status=D.DONE;K.trigger("FileUploaded",M,{response:h.responseText,status:j})}else{R()}}}};D.each(K.settings.headers,function(k,j){h.setRequestHeader(j,k)});if(K.settings.multipart&&G.multipart){if(!h.sendAsBinary){var a=new FormData();D.each(D.extend(e,K.settings.multipart_params),function(k,j){a.append(j,k)});a.append(K.settings.file_data_name,Z);h.send(a);return }h.setRequestHeader("Content-Type","multipart/form-data; boundary="+W);D.each(D.extend(e,K.settings.multipart_params),function(k,j){c+=X+W+g+'Content-Disposition: form-data; name="'+j+'"'+g+g;c+=k+g});V=D.mimeTypes[M.name.replace(/^.+\.([^.]+)/,"$1")]||"application/octet-stream";c+=X+W+g+'Content-Disposition: form-data; name="'+K.settings.file_data_name+'"; filename="'+M.name+'"'+g+"Content-Type: "+V+g+g+Z+g+X+W+X+g;f=c.length-Z.length;Z=c}else{h.setRequestHeader("Content-Type","application/octet-stream")}if(h.sendAsBinary){h.sendAsBinary(Z)}else{h.send(Z)}}R()}P=F[M.id];L=K.settings.resize;if(G.jpgresize){if(L&&/\.(png|jpg|jpeg)$/i.test(M.name)){A(P,L.width,L.height,/\.png$/i.test(M.name)?"image/png":"image/jpeg",function(Q){if(Q.success){M.size=Q.data.length;
O(Q.data)}else{O(P.getAsBinary())}})}else{O(P.getAsBinary())}}else{O(P)}});J({success:true})}});C=function(){var H,I,Z,R,S,M,Q,T,d,O,a,W,J,c,F,U,b,Y,K,G;function N(){var g=false;function h(k,m){var j=g?0:-8*(m-1),n=0,l;for(l=0;l<m;l++){n|=(U.charCodeAt(k+l)<<Math.abs(j+l*8))}return n}function e(i,k,j){U=U.substr(0,i)+k+U.substr((j===true?k.length:0)+i)}function f(k,l,n){var o="",j=g?0:-8*(n-1),m;for(m=0;m<n;m++){o+=String.fromCharCode((l>>Math.abs(j+m*8))&255)}e(k,o,true)}return{II:function(i){if(i===F){return g}else{g=i}},init:function(i){U=i},SEGMENT:function(i,k,j){if(!arguments.length){return U}if(typeof k=="number"){return U.substr(parseInt(i,10),k)}e(i,k,j)},BYTE:function(i){return h(i,1)},SHORT:function(i){return h(i,2)},LONG:function(i,j){if(j===F){return h(i,4)}else{f(i,j,4)}},SLONG:function(i){var j=h(i,4);return(j>2147483647?j-4294967296:j)},STRING:function(i,j){var k="";for(j+=i;i<j;i++){k+=String.fromCharCode(h(i,1))}return k}}}d=new N();b={274:"Orientation",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"};Y={36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"};K={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"};G={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire.",1:"Flash fired.",5:"Strobe return light not detected.",7:"Strobe return light detected.",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}};
function P(e,m){var g=d.SHORT(e),j,p,r,l,k,f,h,n,o=[],q={};for(j=0;j<g;j++){h=f=e+12*j+2;r=m[d.SHORT(h)];if(r===F){continue}l=d.SHORT(h+=2);k=d.LONG(h+=2);h+=4;o=[];switch(l){case 1:case 7:if(k>4){h=d.LONG(h)+c}for(p=0;p<k;p++){o[p]=d.BYTE(h+p)}break;case 2:if(k>4){h=d.LONG(h)+c}q[r]=d.STRING(h,k-1);continue;case 3:if(k>2){h=d.LONG(h)+c}for(p=0;p<k;p++){o[p]=d.SHORT(h+p*2)}break;case 4:if(k>1){h=d.LONG(h)+c}for(p=0;p<k;p++){o[p]=d.LONG(h+p*4)}break;case 5:h=d.LONG(h)+c;for(p=0;p<k;p++){o[p]=d.LONG(h+p*4)/d.LONG(h+p*4+4)}break;case 9:h=d.LONG(h)+c;for(p=0;p<k;p++){o[p]=d.SLONG(h+p*4)}break;case 10:h=d.LONG(h)+c;for(p=0;p<k;p++){o[p]=d.SLONG(h+p*4)/d.SLONG(h+p*4+4)}break;default:continue}n=(k==1?o[0]:o);if(G.hasOwnProperty(r)&&typeof n!="object"){q[r]=G[r][n]}else{q[r]=n}}return q}function X(){var e=T+4;c+=T;if(d.STRING(e,4).toUpperCase()!=="EXIF"||d.SHORT(e+=4)!==0){return }d.II(d.SHORT(e+=2)==18761);if(d.SHORT(e+=2)!==42){return }J=c+d.LONG(e+=2);H=P(J,b);a=("ExifIFDPointer" in H?c+H.ExifIFDPointer:F);W=("GPSInfoIFDPointer" in H?c+H.GPSInfoIFDPointer:F);return true}function L(e,k,j){var h=e.SHORT(j),g,f;for(f=0;f<h;f++){g=j+12*f+2;if(e.SHORT(g)==k){return g+8}}}function V(h,f){var g,i,j=a!=F?a-T:F,e=new N();e.init(Q);e.II(d.II());if(j===F){return }g=L(e,40962,j);if(g!==F){e.LONG(g,h)}i=L(e,40963,j);if(i!==F){e.LONG(i,f)}Q=e.SEGMENT()}return{init:function(e){c=10;H=I=Z=R=S=M=Q=T=O=F;d.init(e);if(d.SHORT(0)!==65496){return false}switch(d.SHORT(2)){case 65504:S=2;M=d.SHORT(4)+2;if(d.SHORT(M)==65505){T=M;O=d.SHORT(M+2)+2}break;case 65505:T=2;O=d.SHORT(4)+2;break;default:return false}if(O!==F){X()}},APP1:function(e){if(T===F&&O===F){return }Q=Q||(Q=d.SEGMENT(T,O));if(e!==F&&"width" in e&&"height" in e){V(e.width,e.height)}return Q},EXIF:function(){I=P(a,Y);I.ExifVersion=String.fromCharCode(I.ExifVersion[0],I.ExifVersion[1],I.ExifVersion[2],I.ExifVersion[3]);return I},GPS:function(){Z=P(W,K);Z.GPSVersionID=Z.GPSVersionID.join(".");return Z},setAPP1:function(e){if(T!==F){return false
}d.SEGMENT((S?S+M:2),e)},getBinary:function(){return d.SEGMENT()}}}})(plupload);
(function(B){var C={};function A(I,E,K,J,D){var L,G,F,H;G=google.gears.factory.create("beta.canvas");G.decode(I);H=Math.min(E/G.width,K/G.height);if(H<1){E=Math.round(G.width*H);K=Math.round(G.height*H)}else{E=G.width;K=G.height}G.resize(E,K);return G.encode(D,{quality:J/100})}B.runtimes.Gears=B.addRuntime("gears",{getFeatures:function(){return{dragdrop:true,jpgresize:true,pngresize:true,chunks:true,progress:true,multipart:true}},init:function(F,H){var G;if(!window.google||!google.gears){return H({success:false})}try{G=google.gears.factory.create("beta.desktop")}catch(E){return H({success:false})}function D(K){var J,I,L=[],M;for(I=0;I<K.length;I++){J=K[I];M=B.guid();C[M]=J.blob;L.push(new B.File(M,J.name,J.blob.length))}F.trigger("FilesAdded",L)}F.bind("PostInit",function(){var J=F.settings,I=B.getElement(F.settings.drop_element);if(I){B.addEvent(I,"dragover",function(K){G.setDropEffect(K,"copy");K.preventDefault()});B.addEvent(I,"drop",function(L){var K=G.getDragData(L,"application/x-gears-files");if(K){D(K.files)}L.preventDefault()});I=0}B.addEvent(B.getElement(F.settings.browse_button),"click",function(O){var N=[],L,K,M;O.preventDefault();for(L=0;L<J.filters.length;L++){M=J.filters[L].extensions.split(",");for(K=0;K<M.length;K++){N.push("."+M[K])}}G.openFiles(D,{singleFile:!J.multi_selection,filter:N})})});F.bind("UploadFile",function(O,L){var Q=0,P,M,N=0,K=O.settings.resize,I;M=O.settings.chunk_size;I=M>0;P=Math.ceil(L.size/M);if(!I){M=L.size;P=1}if(K&&/\.(png|jpg|jpeg)$/i.test(L.name)){C[L.id]=A(C[L.id],K.width,K.height,K.quality||90,/\.png$/i.test(L.name)?"image/png":"image/jpeg")}L.size=C[L.id].length;function J(){var V,X,S=O.settings.multipart,R=0,W={name:L.target_name||L.name},T=O.settings.url;function U(Z){var Y,e="----pluploadboundary"+B.guid(),b="--",d="\r\n",a,c;if(S){V.setRequestHeader("Content-Type","multipart/form-data; boundary="+e);Y=google.gears.factory.create("beta.blobbuilder");B.each(B.extend(W,O.settings.multipart_params),function(g,f){Y.append(b+e+d+'Content-Disposition: form-data; name="'+f+'"'+d+d);
Y.append(g+d)});c=B.mimeTypes[L.name.replace(/^.+\.([^.]+)/,"$1")]||"application/octet-stream";Y.append(b+e+d+'Content-Disposition: form-data; name="'+O.settings.file_data_name+'"; filename="'+L.name+'"'+d+"Content-Type: "+c+d+d);Y.append(Z);Y.append(d+b+e+b+d);a=Y.getAsBlob();R=a.length-Z.length;Z=a}V.send(Z)}if(L.status==B.DONE||L.status==B.FAILED||O.state==B.STOPPED){return }if(I){W.chunk=Q;W.chunks=P}X=Math.min(M,L.size-(Q*M));if(!S){T=B.buildUrl(O.settings.url,W)}V=google.gears.factory.create("beta.httprequest");V.open("POST",T);if(!S){V.setRequestHeader("Content-Disposition",'attachment; filename="'+L.name+'"');V.setRequestHeader("Content-Type","application/octet-stream")}B.each(O.settings.headers,function(Z,Y){V.setRequestHeader(Y,Z)});V.upload.onprogress=function(Y){L.loaded=N+Y.loaded-R;O.trigger("UploadProgress",L)};V.onreadystatechange=function(){var Y;if(V.readyState==4){if(V.status==200){Y={chunk:Q,chunks:P,response:V.responseText,status:V.status};O.trigger("ChunkUploaded",L,Y);if(Y.cancelled){L.status=B.FAILED;return }N+=X;if(++Q>=P){L.status=B.DONE;O.trigger("FileUploaded",L,{response:V.responseText,status:V.status})}else{J()}}else{O.trigger("Error",{code:B.HTTP_ERROR,message:"HTTP Error.",file:L,chunk:Q,chunks:P,status:V.status})}}};if(Q<P){U(C[L.id].slice(Q*M,X))}}J()});H({success:true})}})})(plupload);
AJS.GearsUploadWork=function(A,B){if(!A){throw new Error("workId must be valid. Received: "+A)}if(!B){throw new Error("file must be valid. Received: "+B)}this.id=A;this.file=B};
AJS.GearsFileStatus=function(A,D,B,C){this.workId=A;this.file=D;this.fileSize=D.blob.length;this.status=B;if(C){this.errorMessage=C}};AJS.GearsFileStatus.QUEUED={name:"QUEUED"};AJS.GearsFileStatus.TOO_LARGE={name:"TOO_LARGE"};AJS.GearsFileStatus.INVALID_CHARS={name:"INVALID_CHARS"};
(function(A){AJS.DragAndDropProgressDialog=function(B){var C=this;var D={header:AJS.DragAndDrop.i18n["progress.dialog.header"],width:600,height:400};this._options=A.extend({},D,B);this.id="drag-and-drop-progress-dialog";this._dialog=new AJS.Dialog(this._options.width,this._options.height,this.id);this._dialog.addHeader(this._options.header).addPanel("Panel 1",'<ul id="upload-statuses"></ul>').addButton(AJS.DragAndDrop.i18n["http://10.20.160.198/wiki/s/en/2166/34/1.0.16/_/download/batch/com.atlassian.confluence.plugins.drag-and-drop:support/dialog.button.done"],function(){C.hide();C.clearRenderOutput()},"all-file-uploads-complete");this._dialog.getCurrentPanel().setPadding(0);this._$closeButton=A(".all-file-uploads-complete");A(document).keydown(function(E){if(E.which==27){if(!C._$closeButton.attr("disabled")){C.hide();C.clearRenderOutput()}return AJS.stopEvent(E)}});this._$container=A("#upload-statuses");this._fileStatusesRendered=0;this._workIdsOfFilesInProgress=[];this.cancelListeners=[];this.onShowListeners=[];this._hidden=true};AJS.DragAndDropProgressDialog.prototype={show:function(){if(this._hidden){this._dialog.show();this._hidden=false;A.each(this.onShowListeners,function(B,C){C()})}},hide:function(){if(!this._hidden){this._dialog.hide();this._hidden=true}},_getProgressElementId:function(B){return"file-"+B+"-progress"},render:function(C){this._workIdsOfFilesInProgress.push(C.workId);this._$container.append("<li"+(this._fileStatusesRendered++===0?' class="first"':"")+"><label>"+C.file.name+'</label><div class="file-upload-progress-block"><div class="aui-progressbar" id="'+this._getProgressElementId(C.workId)+'"></div>'+(C.status===AJS.GearsFileStatus.QUEUED||C.status==plupload.QUEUED?AJS.format('<div id="cancel-or-success-placeholder-{0}" class="cancel-or-success-placeholder ui-state-default"><span id="file-upload-cancel-{0}" class="ui-icon ui-icon-circle-close" title="{1}"></span></div>',C.workId.toString(),AJS.DragAndDrop.i18n["cancel.upload.tooltip"]):"")+'</div><div id="file-upload-progress-text-'+C.workId+'" class="file-upload-progress-text">'+AJS.DragAndDrop.i18n["waiting.in.queue"]+" ...</div></li>");
A("#cancel-or-success-placeholder-"+C.workId).hover(function(){A(this).addClass("ui-state-hover")},function(){A(this).removeClass("ui-state-hover")});var B=A("#"+this._getProgressElementId(C.workId));B.progressbar({value:100});B.addClass("aui-progressbar-animated");if(C.status===AJS.GearsFileStatus.QUEUED||C.status==plupload.QUEUED){A("#file-upload-cancel-"+C.workId).click((function(D){return function(E){A.each(D,function(F,G){G(E,C)})}})(this.cancelListeners))}else{this.renderError(C.workId,C.errorMessage)}},renderError:function(D,C){if(A.inArray(D,this._workIdsOfFilesInProgress)==-1){throw new Error("No file status found with id: "+D)}var B=A("#"+this._getProgressElementId(D));B.hasClass("aui-progressbar-animated")&&B.removeClass("aui-progressbar-animated");B.progressbar("option","value",100);B.addClass("aui-progressbar-error");A("#file-upload-progress-text-"+D).html(C);A("#cancel-or-success-placeholder-"+D).hide()},hasErrors:function(){return !!A("#upload-statuses .aui-progressbar-error").length},renderUpdateToBytesUploaded:function(H,G,B){if(A.inArray(H,this._workIdsOfFilesInProgress)==-1){throw new Error("No file status found with id: "+H)}var D=AJS.DragAndDropUtils.niceSize(G);var F=A("#file-"+H+"-uploaded");if(!!F.length){F.text(D)}else{A("#file-upload-progress-text-"+H).html('<span id="file-'+H+'-uploaded">'+D+"</span> of "+AJS.DragAndDropUtils.niceSize(B))}var E=Math.round(G*100/B);var C=A("#"+this._getProgressElementId(H));C.hasClass("aui-progressbar-animated")&&C.removeClass("aui-progressbar-animated");C.progressbar("option","value",E)},renderComplete:function(B){if(A.inArray(B,this._workIdsOfFilesInProgress)==-1){throw new Error("No file status found with id: "+B)}A("#cancel-or-success-placeholder-"+B).html("<span class='ui-icon ui-icon-circle-check'></span>")},renderCancelled:function(C){if(A.inArray(C,this._workIdsOfFilesInProgress)==-1){throw new Error("No file status found with id: "+C)}var B=A("#"+this._getProgressElementId(C));if(B.progressbar("option","value")==0){B.progressbar("option","value",100)
}B.hasClass("aui-progressbar-animated")&&B.removeClass("aui-progressbar-animated");B.progressbar("disable");A("#file-upload-progress-text-"+C).html(AJS.DragAndDrop.i18n["upload.cancelled"]);A("#cancel-or-success-placeholder-"+C).hide()},clearRenderOutput:function(){this._$container.empty();this._fileStatusesRendered=0;this._workIdsOfFilesInProgress=[]},enableCloseButton:function(B){this._$closeButton.removeAttr("disabled");this.closeButtonText(B)},disableCloseButton:function(B){if(!this._$closeButton.attr("disabled")){this._$closeButton.attr("disabled","disabled");this.closeButtonText(B)}},closeButtonText:function(B){B&&this._$closeButton.html(B)}}})(AJS.$);
AJS.GearsWorkerPool=function(A,D,C){if(typeof A!="number"){throw new Error("A valid number for numWorkers must be specified. Received: "+A)}if(typeof C!="string"){throw new Error("A valid string for workerUrl must be specified. Received: "+C)}if(!AJS.$.isFunction(D)){throw new Error("A valid function for messageHandler must be specified. Received: "+D)}this._numWorkers=A;try{this._workerPool=google.gears.factory.create("beta.workerpool")}catch(E){throw new Error("Could not construct Gears worker pool.")}this._workerPool.onmessage=D;this._workerIds=new AJS.ObservableArrayList();for(var B=0;B<this._numWorkers;B++){this._workerIds.push(this._workerPool.createWorkerFromUrl(C))}};AJS.GearsWorkerPool.prototype={sendMessage:function(B,A){this._workerPool.sendMessage(B,A)},workerAvailable:function(){return !!this._workerIds.length()},checkoutWorker:function(){if(this.workerAvailable()){return this._workerIds.shift()}else{throw new Error("Attempt to checkout worker when no workers available. Please check workerAvailable() first.")}},checkinWorker:function(A){this._workerIds.push(A)},addWorkerCheckedInObserver:function(A){this._workerIds.addPushObserver(A)}};
AJS.GearsUploadManager=function(B,D,A){this._MAX_WORKERS=2;this._idCounter=1;this._uploadsInProgress=0;this._onErrorHandlers=[];this._onSuccessHandlers=[];this._onCancelHandlers=[];this._onProgressHandlers=[];this._otherMessageHandlers=[];this._onIdleHandlers=[];var C=this._generateUploadObserver(this);this._workerPool=D||new AJS.GearsWorkerPool(this._MAX_WORKERS,this._generateOnmessageHandler(this),B);this._workerPool.addWorkerCheckedInObserver(C);this._workQueue=A||new AJS.ObservableArrayList();this._workQueue.addPushObserver(C);this._workIdToWorkerIdHash={}};AJS.GearsUploadManager.prototype={upload:function(G){var F=[];for(var D=0,E=G.length;D<E;D++){var H=G[D];var A=this._idCounter++;var B=new AJS.GearsUploadWork(A,H);if(this._fileTooLarge(H)){var C=AJS.format(AJS.DragAndDrop.i18n["validation.file.too.large"],AJS.DragAndDropUtils.niceSize(H.blob.length).toString(),AJS.DragAndDropUtils.niceSize(AJS.params.globalSettingsAttachmentMaxSize).toString());F.push(new AJS.GearsFileStatus(A,H,AJS.GearsFileStatus.TOO_LARGE,C))}else{if(this._filenameContainsInvalidCharacters(H.name)){F.push(new AJS.GearsFileStatus(A,H,AJS.GearsFileStatus.INVALID_CHARS,AJS.DragAndDrop.i18n["validation.filename.invalid.chars"]))}else{this._workQueue.push(B);F.push(new AJS.GearsFileStatus(A,H,AJS.GearsFileStatus.QUEUED))}}}return F},cancel:function(B){if(this.uploadInProgress(B)){var C=this._workIdToWorkerIdHash[B];this._workerPool.sendMessage({action:{name:"cancel",workId:B}},C)}else{var A=this._workQueue.removeByPredicate(function(D){return D.id===B});if(!A){throw new Error("File with workId: "+C+" could not be cancelled.")}AJS.$.each(this._onCancelHandlers,function(D,E){E(B)})}},uploadInProgress:function(A){return A in this._workIdToWorkerIdHash},isIdle:function(){return !this._workQueue.length()&&!this._uploadsInProgress},addOnErrorHandler:function(A){if(AJS.$.isFunction(A)){this._onErrorHandlers.push(A)}else{throw new Error("Called addOnErrorHandler with non-function object. Received: "+A)
}},addOnProgressHandler:function(A){if(AJS.$.isFunction(A)){this._onProgressHandlers.push(A)}else{throw new Error("Called addOnProgressHandler with non-function object. Received: "+A)}},addOnSuccessHandler:function(A){if(AJS.$.isFunction(A)){this._onSuccessHandlers.push(A)}else{throw new Error("Called addOnSuccessHandler with non-function object. Received: "+A)}},addOnCancelHandler:function(A){if(AJS.$.isFunction(A)){this._onCancelHandlers.push(A)}else{throw new Error("Called onCancelHandlers with non-function object. Received: "+A)}},addOtherMessageHandler:function(A){if(AJS.$.isFunction(A)){this._otherMessageHandlers.push(A)}else{throw new Error("Called addOtherMessageHandler with non-function object. Received: "+A)}},addOnIdleHandler:function(A){if(AJS.$.isFunction(A)){this._onIdleHandlers.push(A)}else{throw new Error("Called addOnIdleHandler with non-function object. Received: "+A)}},_generateUploadObserver:function(A){return function(){if(A._workerPool.workerAvailable()&&A._workQueue.length()>0){var G=A._workerPool.checkoutWorker();var D=A._workQueue.shift();var E=D.file;var C=D.id;var B=E.blob.length;AJS.log("Uploading file with workId: "+C+" and size: "+AJS.DragAndDropUtils.niceSize(B));var F=AJS.DragAndDropUtils.getDesktopInstance().extractMetaData(E.blob);A._workerPool.sendMessage({action:{name:"upload",workId:C,contextPath:contextPath,pageId:AJS.params.pageId,draftType:AJS.params.draftType,mimeType:F.mimeType,filename:E.name,fileSize:B,fileBlob:E.blob}},G);A._workIdToWorkerIdHash[C]=G;A._uploadsInProgress++}}},_generateOnmessageHandler:function(A){return function(D,B,E){var C=E.body.status;if(C){if(C.error){AJS.$.each(A._onErrorHandlers,function(F,G){G(C)});A._onWorkerFinishedProcessingWorkItem.call(A,E.sender,C.workId)}else{if(C.complete){if(C.action=="upload"){AJS.$.each(A._onSuccessHandlers,function(F,G){G(C)})}else{if(C.action=="cancel"){AJS.$.each(A._onCancelHandlers,function(F,G){G(C.workId)})}}A._onWorkerFinishedProcessingWorkItem.call(A,E.sender,C.workId)
}else{if(C.progress){AJS.$.each(A._onProgressHandlers,function(F,G){G(C)})}}}}else{AJS.$.each(A._otherMessageHandlers,function(F,G){G(E)})}}},_fileTooLarge:function(A){return A.blob.length>(AJS.params.globalSettingsAttachmentMaxSize||Number.MAX_VALUE)},_filenameContainsInvalidCharacters:function(A){return A.indexOf("+")!=-1||A.indexOf("&")!=-1||A.indexOf("#")!=-1},_onWorkerFinishedProcessingWorkItem:function(B,A){this._workerPool.checkinWorker(B);delete this._workIdToWorkerIdHash[A];this._uploadsInProgress--;if(this.isIdle()){AJS.$.each(this._onIdleHandlers,function(C,D){D()})}}};
(function(A){A.widget("ui.progressbar",{_init:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this._valueMin(),"aria-valuemax":this._valueMax(),"aria-valuenow":this._value()});this.valueDiv=A('<div class="ui-progressbar-value ui-widget-header ui-corner-left"></div>').appendTo(this.element);this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow").removeData("progressbar").unbind(".progressbar");this.valueDiv.remove();A.widget.prototype.destroy.apply(this,arguments)},value:function(B){if(B===undefined){return this._value()}this._setData("value",B);return this},_setData:function(B,C){switch(B){case"value":this.options.value=C;this._refreshValue();this._trigger("change",null,{});break}A.widget.prototype._setData.apply(this,arguments)},_value:function(){var B=this.options.value;if(B<this._valueMin()){B=this._valueMin()}if(B>this._valueMax()){B=this._valueMax()}return B},_valueMin:function(){var B=0;return B},_valueMax:function(){var B=100;return B},_refreshValue:function(){var B=this.value();this.valueDiv[B==this._valueMax()?"addClass":"removeClass"]("ui-corner-right");this.valueDiv.width(B+"%");this.element.attr("aria-valuenow",B)}});A.extend(A.ui.progressbar,{version:"1.7.2",defaults:{value:0}})})(jQuery);