All Downloads are FREE. Search and download functionalities are using the official Maven repository.

assets.js.libs.atmosphere-min.js Maven / Gradle / Ivy

Go to download

GroupDocs.Annotation is an HTML5-based document & image annotator designed to be easily integrated into web, mobile and desktop apps. It allows developers to provide end users with the ability to annotate documents and images of more than 50 file formats, including PDF and Microsoft Office documents, Visio diagrams, CAD and raster images.

There is a newer version: 18.4
Show newest version
(function(root,factory){if(typeof define==="function"&&define.amd){define(factory);}else{root.atmosphere=factory();}}(this,function(){var version="2.2.5-javascript",atmosphere={},guid,requests=[],callbacks=[],uuid=0,hasOwn=Object.prototype.hasOwnProperty;atmosphere={onError:function(response){},onClose:function(response){},onOpen:function(response){},onReopen:function(response){},onMessage:function(response){},onReconnect:function(request,response){},onMessagePublished:function(response){},onTransportFailure:function(errorMessage,_request){},onLocalMessage:function(response){},onFailureToReconnect:function(request,response){},onClientTimeout:function(request){},onOpenAfterResume:function(request){},WebsocketApiAdapter:function(request){var _socket,_adapter;request.onMessage=function(e){_adapter.onmessage({data:e.responseBody});};request.onMessagePublished=function(e){_adapter.onmessage({data:e.responseBody});};request.onOpen=function(e){_adapter.onopen(e);};_adapter={close:function(){_socket.close();},send:function(data){_socket.push(data);},onmessage:function(e){},onopen:function(e){},onclose:function(e){},onerror:function(e){}};_socket=new atmosphere.subscribe(request);return _adapter;},AtmosphereRequest:function(options){var _request={timeout:300000,method:"GET",headers:{},contentType:"",callback:null,url:"",data:"",suspend:true,maxRequest:-1,reconnect:true,maxStreamingLength:10000000,lastIndex:0,logLevel:"info",requestCount:0,fallbackMethod:"GET",fallbackTransport:"streaming",transport:"long-polling",webSocketImpl:null,webSocketBinaryType:null,dispatchUrl:null,webSocketPathDelimiter:"@@",enableXDR:false,rewriteURL:false,attachHeadersAsQueryString:true,executeCallbackBeforeReconnect:false,readyState:0,withCredentials:false,trackMessageLength:false,messageDelimiter:"|",connectTimeout:-1,reconnectInterval:0,dropHeaders:true,uuid:0,async:true,shared:false,readResponsesHeaders:false,maxReconnectOnClose:5,enableProtocol:true,pollingInterval:0,heartbeat:{client:null,server:null},ackInterval:0,closeAsync:false,reconnectOnServerError:true,onError:function(response){},onClose:function(response){},onOpen:function(response){},onMessage:function(response){},onReopen:function(request,response){},onReconnect:function(request,response){},onMessagePublished:function(response){},onTransportFailure:function(reason,request){},onLocalMessage:function(request){},onFailureToReconnect:function(request,response){},onClientTimeout:function(request){},onOpenAfterResume:function(request){}};var _response={status:200,reasonPhrase:"OK",responseBody:"",messages:[],headers:[],state:"messageReceived",transport:"polling",error:null,request:null,partialMessage:"",errorHandled:false,closedByClientTimeout:false,ffTryingReconnect:false};var _websocket=null;var _sse=null;var _activeRequest=null;var _ieStream=null;var _jqxhr=null;var _subscribed=true;var _requestCount=0;var _heartbeatPadding=" ";var _abordingConnection=false;var _localSocketF=null;var _storageService;var _localStorageService=null;var guid=atmosphere.util.now();var _traceTimer;var _sharingKey;_subscribe(options);function _init(){_subscribed=true;_abordingConnection=false;_requestCount=0;_websocket=null;_sse=null;_activeRequest=null;_ieStream=null;}function _reinit(){_clearState();_init();}function _verifyStreamingLength(ajaxRequest,rq){if(_response.partialMessage===""&&(rq.transport==="streaming")&&(ajaxRequest.responseText.length>rq.maxStreamingLength)){return true;}return false;}function _disconnect(){if(_request.enableProtocol&&!_request.firstMessage){var query="X-Atmosphere-Transport=close&X-Atmosphere-tracking-id="+_request.uuid;atmosphere.util.each(_request.headers,function(name,value){var h=atmosphere.util.isFunction(value)?value.call(this,_request,_request,_response):value;if(h!=null){query+="&"+encodeURIComponent(name)+"="+encodeURIComponent(h);}});var url=_request.url.replace(/([?&])_=[^&]*/,query);url=url+(url===_request.url?(/\?/.test(_request.url)?"&":"?")+query:"");var rq={connected:false};var closeR=new atmosphere.AtmosphereRequest(rq);closeR.attachHeadersAsQueryString=false;closeR.dropHeaders=true;closeR.url=url;closeR.contentType="text/plain";closeR.transport="polling";closeR.method="GET";closeR.data="";if(_request.enableXDR){closeR.enableXDR=_request.enableXDR;}closeR.async=rq.closeAsync;_pushOnClose("",closeR);}}function _close(){if(_request.logLevel==="debug"){atmosphere.util.debug("Closing");}_abordingConnection=true;if(_request.reconnectId){clearTimeout(_request.reconnectId);delete _request.reconnectId;}if(_request.heartbeatTimer){clearTimeout(_request.heartbeatTimer);}_request.reconnect=false;_response.request=_request;_response.state="unsubscribe";_response.responseBody="";_response.status=408;_response.partialMessage="";_invokeCallback();_disconnect();_clearState();}function _clearState(){_response.partialMessage="";if(_request.id){clearTimeout(_request.id);}if(_request.heartbeatTimer){clearTimeout(_request.heartbeatTimer);}if(_ieStream!=null){_ieStream.close();_ieStream=null;}if(_jqxhr!=null){_jqxhr.abort();_jqxhr=null;}if(_activeRequest!=null){_activeRequest.abort();_activeRequest=null;}if(_websocket!=null){if(_websocket.canSendMessage){_websocket.close();}_websocket=null;}if(_sse!=null){_sse.close();_sse=null;}_clearStorage();}function _clearStorage(){if(_storageService!=null){clearInterval(_traceTimer);document.cookie=_sharingKey+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";_storageService.signal("close",{reason:"",heir:!_abordingConnection?guid:(_storageService.get("children")||[])[0]});_storageService.close();}if(_localStorageService!=null){_localStorageService.close();}}function _subscribe(options){_reinit();_request=atmosphere.util.extend(_request,options);_request.mrequest=_request.reconnect;if(!_request.reconnect){_request.reconnect=true;}}function _supportWebsocket(){return _request.webSocketImpl!=null||window.WebSocket||window.MozWebSocket;}function _supportSSE(){return window.EventSource;}function _execute(){if(_request.shared){_localStorageService=_local(_request);if(_localStorageService!=null){if(_request.logLevel==="debug"){atmosphere.util.debug("Storage service available. All communication will be local");}if(_localStorageService.open(_request)){return;}}if(_request.logLevel==="debug"){atmosphere.util.debug("No Storage service available.");}_localStorageService=null;}_request.firstMessage=uuid==0?true:false;_request.isOpen=false;_request.ctime=atmosphere.util.now();if(_request.uuid===0){_request.uuid=uuid;}_response.closedByClientTimeout=false;if(_request.transport!=="websocket"&&_request.transport!=="sse"){_executeRequest(_request);}else{if(_request.transport==="websocket"){if(!_supportWebsocket()){_reconnectWithFallbackTransport("Websocket is not supported, using request.fallbackTransport ("+_request.fallbackTransport+")");}else{_executeWebSocket(false);}}else{if(_request.transport==="sse"){if(!_supportSSE()){_reconnectWithFallbackTransport("Server Side Events(SSE) is not supported, using request.fallbackTransport ("+_request.fallbackTransport+")");}else{_executeSSE(false);}}}}}function _local(request){var trace,connector,orphan,name="atmosphere-"+request.url,connectors={storage:function(){function onstorage(event){if(event.key===name&&event.newValue){listener(event.newValue);}}if(!atmosphere.util.storage){return;}var storage=window.localStorage,get=function(key){return atmosphere.util.parseJSON(storage.getItem(name+"-"+key));},set=function(key,value){storage.setItem(name+"-"+key,atmosphere.util.stringifyJSON(value));};return{init:function(){set("children",get("children").concat([guid]));atmosphere.util.on(window,"storage",onstorage);return get("opened");},signal:function(type,data){storage.setItem(name,atmosphere.util.stringifyJSON({target:"p",type:type,data:data}));},close:function(){var children=get("children");atmosphere.util.off(window,"storage",onstorage);if(children){if(removeFromArray(children,request.id)){set("children",children);}}}};},windowref:function(){var win=window.open("",name.replace(/\W/g,""));if(!win||win.closed||!win.callbacks){return;}return{init:function(){win.callbacks.push(listener);win.children.push(guid);return win.opened;},signal:function(type,data){if(!win.closed&&win.fire){win.fire(atmosphere.util.stringifyJSON({target:"p",type:type,data:data}));}},close:function(){if(!orphan){removeFromArray(win.callbacks,listener);removeFromArray(win.children,guid);}}};}};function removeFromArray(array,val){var i,length=array.length;for(i=0;i1000){return;}connector=connectors.storage()||connectors.windowref();if(!connector){return;}return{open:function(){var parentOpened;_traceTimer=setInterval(function(){var oldTrace=trace;trace=findTrace();if(!trace||oldTrace.ts===trace.ts){listener(atmosphere.util.stringifyJSON({target:"c",type:"close",data:{reason:"error",heir:oldTrace.heir}}));}},1000);parentOpened=connector.init();if(parentOpened){setTimeout(function(){_open("opening","local",request);},50);}return parentOpened;},send:function(event){connector.signal("send",event);},localSend:function(event){connector.signal("localSend",atmosphere.util.stringifyJSON({id:guid,event:event}));},close:function(){if(!_abordingConnection){clearInterval(_traceTimer);connector.signal("close");connector.close();}}};}function share(){var storageService,name="atmosphere-"+_request.url,servers={storage:function(){function onstorage(event){if(event.key===name&&event.newValue){listener(event.newValue);}}if(!atmosphere.util.storage){return;}var storage=window.localStorage;return{init:function(){atmosphere.util.on(window,"storage",onstorage);},signal:function(type,data){storage.setItem(name,atmosphere.util.stringifyJSON({target:"c",type:type,data:data}));},get:function(key){return atmosphere.util.parseJSON(storage.getItem(name+"-"+key));},set:function(key,value){storage.setItem(name+"-"+key,atmosphere.util.stringifyJSON(value));},close:function(){atmosphere.util.off(window,"storage",onstorage);storage.removeItem(name);storage.removeItem(name+"-opened");storage.removeItem(name+"-children");}};},windowref:function(){var neim=name.replace(/\W/g,""),container=document.getElementById(neim),win;if(!container){container=document.createElement("div");container.id=neim;container.style.display="none";container.innerHTML='