diff options
Diffstat (limited to 'apiroute/apiroute-service/src/main/resources/api-doc/js')
3 files changed, 1073 insertions, 0 deletions
diff --git a/apiroute/apiroute-service/src/main/resources/api-doc/js/iframeResizer/iframeResizer.contentWindow.min.js b/apiroute/apiroute-service/src/main/resources/api-doc/js/iframeResizer/iframeResizer.contentWindow.min.js new file mode 100644 index 0000000..9330e0f --- /dev/null +++ b/apiroute/apiroute-service/src/main/resources/api-doc/js/iframeResizer/iframeResizer.contentWindow.min.js @@ -0,0 +1,10 @@ +/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v3.5.3 - 2016-02-23 + * Desc: Include this file in any page being loaded into an iframe + * to force the iframe to resize to the content size. + * Requires: iframeResizer.min.js on host page. + * Copyright: (c) 2016 David J. Bradshaw - dave@bradshaw.net + * License: MIT + */ + +!function(a){"use strict";function b(b,c,d){"addEventListener"in a?b.addEventListener(c,d,!1):"attachEvent"in a&&b.attachEvent("on"+c,d)}function c(b,c,d){"removeEventListener"in a?b.removeEventListener(c,d,!1):"detachEvent"in a&&b.detachEvent("on"+c,d)}function d(a){return a.charAt(0).toUpperCase()+a.slice(1)}function e(a){var b,c,d,e=null,f=0,g=function(){f=Fa(),e=null,d=a.apply(b,c),e||(b=c=null)};return function(){var h=Fa();f||(f=h);var i=xa-(h-f);return b=this,c=arguments,0>=i||i>xa?(e&&(clearTimeout(e),e=null),f=h,d=a.apply(b,c),e||(b=c=null)):e||(e=setTimeout(g,i)),d}}function f(a){return ma+"["+oa+"] "+a}function g(b){la&&"object"==typeof a.console&&console.log(f(b))}function h(b){"object"==typeof a.console&&console.warn(f(b))}function i(){j(),g("Initialising iFrame ("+location.href+")"),k(),n(),m("background",W),m("padding",$),A(),s(),t(),o(),C(),u(),ia=B(),N("init","Init message from host page"),Da()}function j(){function a(a){return"true"===a?!0:!1}var b=ha.substr(na).split(":");oa=b[0],X=void 0!==b[1]?Number(b[1]):X,_=void 0!==b[2]?a(b[2]):_,la=void 0!==b[3]?a(b[3]):la,ja=void 0!==b[4]?Number(b[4]):ja,U=void 0!==b[6]?a(b[6]):U,Y=b[7],fa=void 0!==b[8]?b[8]:fa,W=b[9],$=b[10],ua=void 0!==b[11]?Number(b[11]):ua,ia.enable=void 0!==b[12]?a(b[12]):!1,qa=void 0!==b[13]?b[13]:qa,Aa=void 0!==b[14]?b[14]:Aa}function k(){function b(){var b=a.iFrameResizer;g("Reading data from page: "+JSON.stringify(b)),Ca="messageCallback"in b?b.messageCallback:Ca,Da="readyCallback"in b?b.readyCallback:Da,ta="targetOrigin"in b?b.targetOrigin:ta,fa="heightCalculationMethod"in b?b.heightCalculationMethod:fa,Aa="widthCalculationMethod"in b?b.widthCalculationMethod:Aa}"iFrameResizer"in a&&Object===a.iFrameResizer.constructor&&b(),g("TargetOrigin for parent set to: "+ta)}function l(a,b){return-1!==b.indexOf("-")&&(h("Negative CSS value ignored for "+a),b=""),b}function m(a,b){void 0!==b&&""!==b&&"null"!==b&&(document.body.style[a]=b,g("Body "+a+' set to "'+b+'"'))}function n(){void 0===Y&&(Y=X+"px"),m("margin",l("margin",Y))}function o(){document.documentElement.style.height="",document.body.style.height="",g('HTML & body height set to "auto"')}function p(e){function f(){N(e.eventName,e.eventType)}var h={add:function(c){b(a,c,f)},remove:function(b){c(a,b,f)}};e.eventNames&&Array.prototype.map?(e.eventName=e.eventNames[0],e.eventNames.map(h[e.method])):h[e.method](e.eventName),g(d(e.method)+" event listener: "+e.eventType)}function q(a){p({method:a,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),p({method:a,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),p({method:a,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),p({method:a,eventType:"Input",eventName:"input"}),p({method:a,eventType:"Mouse Up",eventName:"mouseup"}),p({method:a,eventType:"Mouse Down",eventName:"mousedown"}),p({method:a,eventType:"Orientation Change",eventName:"orientationchange"}),p({method:a,eventType:"Print",eventName:["afterprint","beforeprint"]}),p({method:a,eventType:"Ready State Change",eventName:"readystatechange"}),p({method:a,eventType:"Touch Start",eventName:"touchstart"}),p({method:a,eventType:"Touch End",eventName:"touchend"}),p({method:a,eventType:"Touch Cancel",eventName:"touchcancel"}),p({method:a,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),p({method:a,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),p({method:a,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===qa&&p({method:a,eventType:"IFrame Resized",eventName:"resize"})}function r(a,b,c,d){return b!==a&&(a in c||(h(a+" is not a valid option for "+d+"CalculationMethod."),a=b),g(d+' calculation method set to "'+a+'"')),a}function s(){fa=r(fa,ea,Ga,"height")}function t(){Aa=r(Aa,za,Ha,"width")}function u(){!0===U?(q("add"),F()):g("Auto Resize disabled")}function v(){g("Disable outgoing messages"),ra=!1}function w(){g("Remove event listener: Message"),c(a,"message",S)}function x(){null!==Z&&Z.disconnect()}function y(){q("remove"),x(),clearInterval(ka)}function z(){v(),w(),!0===U&&y()}function A(){var a=document.createElement("div");a.style.clear="both",a.style.display="block",document.body.appendChild(a)}function B(){function c(){return{x:void 0!==a.pageXOffset?a.pageXOffset:document.documentElement.scrollLeft,y:void 0!==a.pageYOffset?a.pageYOffset:document.documentElement.scrollTop}}function d(a){var b=a.getBoundingClientRect(),d=c();return{x:parseInt(b.left,10)+parseInt(d.x,10),y:parseInt(b.top,10)+parseInt(d.y,10)}}function e(a){function b(a){var b=d(a);g("Moving to in page link (#"+c+") at x: "+b.x+" y: "+b.y),R(b.y,b.x,"scrollToOffset")}var c=a.split("#")[1]||a,e=decodeURIComponent(c),f=document.getElementById(e)||document.getElementsByName(e)[0];void 0!==f?b(f):(g("In page link (#"+c+") not found in iFrame, so sending to parent"),R(0,0,"inPageLink","#"+c))}function f(){""!==location.hash&&"#"!==location.hash&&e(location.href)}function i(){function a(a){function c(a){a.preventDefault(),e(this.getAttribute("href"))}"#"!==a.getAttribute("href")&&b(a,"click",c)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),a)}function j(){b(a,"hashchange",f)}function k(){setTimeout(f,ba)}function l(){Array.prototype.forEach&&document.querySelectorAll?(g("Setting up location.hash handlers"),i(),j(),k()):h("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}return ia.enable?l():g("In page linking not enabled"),{findTarget:e}}function C(){g("Enable public methods"),Ba.parentIFrame={autoResize:function(a){return!0===a&&!1===U?(U=!0,u()):!1===a&&!0===U&&(U=!1,y()),U},close:function(){R(0,0,"close"),z()},getId:function(){return oa},getPageInfo:function(a){"function"==typeof a?(Ea=a,R(0,0,"pageInfo")):(Ea=function(){},R(0,0,"pageInfoStop"))},moveToAnchor:function(a){ia.findTarget(a)},reset:function(){Q("parentIFrame.reset")},scrollTo:function(a,b){R(b,a,"scrollTo")},scrollToOffset:function(a,b){R(b,a,"scrollToOffset")},sendMessage:function(a,b){R(0,0,"message",JSON.stringify(a),b)},setHeightCalculationMethod:function(a){fa=a,s()},setWidthCalculationMethod:function(a){Aa=a,t()},setTargetOrigin:function(a){g("Set targetOrigin: "+a),ta=a},size:function(a,b){var c=""+(a?a:"")+(b?","+b:"");N("size","parentIFrame.size("+c+")",a,b)}}}function D(){0!==ja&&(g("setInterval: "+ja+"ms"),ka=setInterval(function(){N("interval","setInterval: "+ja)},Math.abs(ja)))}function E(){function b(a){function b(a){!1===a.complete&&(g("Attach listeners to "+a.src),a.addEventListener("load",f,!1),a.addEventListener("error",h,!1),k.push(a))}"attributes"===a.type&&"src"===a.attributeName?b(a.target):"childList"===a.type&&Array.prototype.forEach.call(a.target.querySelectorAll("img"),b)}function c(a){k.splice(k.indexOf(a),1)}function d(a){g("Remove listeners from "+a.src),a.removeEventListener("load",f,!1),a.removeEventListener("error",h,!1),c(a)}function e(a,b,c){d(a.target),N(b,c+": "+a.target.src,void 0,void 0)}function f(a){e(a,"imageLoad","Image loaded")}function h(a){e(a,"imageLoadFailed","Image load failed")}function i(a){N("mutationObserver","mutationObserver: "+a[0].target+" "+a[0].type),a.forEach(b)}function j(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return m=new l(i),g("Create body MutationObserver"),m.observe(a,b),m}var k=[],l=a.MutationObserver||a.WebKitMutationObserver,m=j();return{disconnect:function(){"disconnect"in m&&(g("Disconnect body MutationObserver"),m.disconnect(),k.forEach(d))}}}function F(){var b=0>ja;a.MutationObserver||a.WebKitMutationObserver?b?D():Z=E():(g("MutationObserver not supported in this browser!"),D())}function G(a,b){function c(a){var c=/^\d+(px)?$/i;if(c.test(a))return parseInt(a,V);var d=b.style.left,e=b.runtimeStyle.left;return b.runtimeStyle.left=b.currentStyle.left,b.style.left=a||0,a=b.style.pixelLeft,b.style.left=d,b.runtimeStyle.left=e,a}var d=0;return b=b||document.body,"defaultView"in document&&"getComputedStyle"in document.defaultView?(d=document.defaultView.getComputedStyle(b,null),d=null!==d?d[a]:0):d=c(b.currentStyle[a]),parseInt(d,V)}function H(a){a>xa/2&&(xa=2*a,g("Event throttle increased to "+xa+"ms"))}function I(a,b){for(var c=b.length,e=0,f=0,h=d(a),i=Fa(),j=0;c>j;j++)e=b[j].getBoundingClientRect()[a]+G("margin"+h,b[j]),e>f&&(f=e);return i=Fa()-i,g("Parsed "+c+" HTML elements"),g("Element position calculated in "+i+"ms"),H(i),f}function J(a){return[a.bodyOffset(),a.bodyScroll(),a.documentElementOffset(),a.documentElementScroll()]}function K(a,b){function c(){return h("No tagged elements ("+b+") found on page"),da}var d=document.querySelectorAll("["+b+"]");return 0===d.length?c():I(a,d)}function L(){return document.querySelectorAll("body *")}function M(a,b,c,d){function e(){da=l,ya=m,R(da,ya,a)}function f(){function a(a,b){var c=Math.abs(a-b)<=ua;return!c}return l=void 0!==c?c:Ga[fa](),m=void 0!==d?d:Ha[Aa](),a(da,l)||_&&a(ya,m)}function h(){return!(a in{init:1,interval:1,size:1})}function i(){return fa in pa||_&&Aa in pa}function j(){g("No change in size detected")}function k(){h()&&i()?Q(b):a in{interval:1}||j()}var l,m;f()||"init"===a?(O(),e()):k()}function N(a,b,c,d){function e(){a in{reset:1,resetPage:1,init:1}||g("Trigger event: "+b)}function f(){return va&&a in aa}f()?g("Trigger event cancelled: "+a):(e(),Ia(a,b,c,d))}function O(){va||(va=!0,g("Trigger event lock on")),clearTimeout(wa),wa=setTimeout(function(){va=!1,g("Trigger event lock off"),g("--")},ba)}function P(a){da=Ga[fa](),ya=Ha[Aa](),R(da,ya,a)}function Q(a){var b=fa;fa=ea,g("Reset trigger event: "+a),O(),P("reset"),fa=b}function R(a,b,c,d,e){function f(){void 0===e?e=ta:g("Message targetOrigin: "+e)}function h(){var f=a+":"+b,h=oa+":"+f+":"+c+(void 0!==d?":"+d:"");g("Sending message to host page ("+h+")"),sa.postMessage(ma+h,e)}!0===ra&&(f(),h())}function S(b){function c(){return ma===(""+b.data).substr(0,na)}function d(){ha=b.data,sa=b.source,i(),ca=!1,setTimeout(function(){ga=!1},ba)}function e(){ga?g("Page reset ignored by init"):(g("Page size reset by host page"),P("resetPage"))}function f(){N("resizeParent","Parent window requested size check")}function j(){var a=l();ia.findTarget(a)}function k(){return b.data.split("]")[1].split(":")[0]}function l(){return b.data.substr(b.data.indexOf(":")+1)}function m(){return"iFrameResize"in a}function n(){var a=l();g("MessageCallback called from parent: "+a),Ca(JSON.parse(a)),g(" --")}function o(){var a=l();g("PageInfoFromParent called from parent: "+a),Ea(JSON.parse(a)),g(" --")}function p(){return b.data.split(":")[2]in{"true":1,"false":1}}function q(){switch(k()){case"reset":e();break;case"resize":f();break;case"moveToAnchor":j();break;case"message":n();break;case"pageInfo":o();break;default:m()||p()||h("Unexpected message ("+b.data+")")}}function r(){!1===ca?q():p()?d():g('Ignored message of type "'+k()+'". Received before initialization.')}c()&&r()}function T(){"loading"!==document.readyState&&a.parent.postMessage("[iFrameResizerChild]Ready","*")}var U=!0,V=10,W="",X=0,Y="",Z=null,$="",_=!1,aa={resize:1,click:1},ba=128,ca=!0,da=1,ea="bodyOffset",fa=ea,ga=!0,ha="",ia={},ja=32,ka=null,la=!1,ma="[iFrameSizer]",na=ma.length,oa="",pa={max:1,min:1,bodyScroll:1,documentElementScroll:1},qa="child",ra=!0,sa=a.parent,ta="*",ua=0,va=!1,wa=null,xa=16,ya=1,za="scroll",Aa=za,Ba=a,Ca=function(){h("MessageCallback function not defined")},Da=function(){},Ea=function(){},Fa=Date.now||function(){return(new Date).getTime()},Ga={bodyOffset:function(){return document.body.offsetHeight+G("marginTop")+G("marginBottom")},offset:function(){return Ga.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,J(Ga))},min:function(){return Math.min.apply(null,J(Ga))},grow:function(){return Ga.max()},lowestElement:function(){return Math.max(Ga.bodyOffset(),I("bottom",L()))},taggedElement:function(){return K("bottom","data-iframe-height")}},Ha={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(Ha.bodyScroll(),Ha.documentElementScroll())},max:function(){return Math.max.apply(null,J(Ha))},min:function(){return Math.min.apply(null,J(Ha))},rightMostElement:function(){return I("right",L())},taggedElement:function(){return K("right","data-iframe-width")}},Ia=e(M);b(a,"message",S),T()}(window||{}); +//# sourceMappingURL=iframeResizer.contentWindow.map
\ No newline at end of file diff --git a/apiroute/apiroute-service/src/main/resources/api-doc/js/iframeResizer/iframeResizer.min.js b/apiroute/apiroute-service/src/main/resources/api-doc/js/iframeResizer/iframeResizer.min.js new file mode 100644 index 0000000..e8f4bcb --- /dev/null +++ b/apiroute/apiroute-service/src/main/resources/api-doc/js/iframeResizer/iframeResizer.min.js @@ -0,0 +1,9 @@ +/*! iFrame Resizer (iframeSizer.min.js ) - v3.5.3 - 2016-02-23 + * Desc: Force cross domain iframes to size to content. + * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame. + * Copyright: (c) 2016 David J. Bradshaw - dave@bradshaw.net + * License: MIT + */ + +!function(a){"use strict";function b(b,c,d){"addEventListener"in a?b.addEventListener(c,d,!1):"attachEvent"in a&&b.attachEvent("on"+c,d)}function c(b,c,d){"removeEventListener"in a?b.removeEventListener(c,d,!1):"detachEvent"in a&&b.detachEvent("on"+c,d)}function d(){var b,c=["moz","webkit","o","ms"];for(b=0;b<c.length&&!N;b+=1)N=a[c[b]+"RequestAnimationFrame"];N||h("setup","RequestAnimationFrame not supported")}function e(b){var c="Host page: "+b;return a.top!==a.self&&(c=a.parentIFrame&&a.parentIFrame.getId?a.parentIFrame.getId()+": "+b:"Nested host page: "+b),c}function f(a){return K+"["+e(a)+"]"}function g(a){return P[a]?P[a].log:G}function h(a,b){k("log",a,b,g(a))}function i(a,b){k("info",a,b,g(a))}function j(a,b){k("warn",a,b,!0)}function k(b,c,d,e){!0===e&&"object"==typeof a.console&&console[b](f(c),d)}function l(d){function e(){function a(){s(V),p(W)}g("Height"),g("Width"),t(a,V,"init")}function f(){var a=U.substr(L).split(":");return{iframe:P[a[0]].iframe,id:a[0],height:a[1],width:a[2],type:a[3]}}function g(a){var b=Number(P[W]["max"+a]),c=Number(P[W]["min"+a]),d=a.toLowerCase(),e=Number(V[d]);h(W,"Checking "+d+" is in range "+c+"-"+b),c>e&&(e=c,h(W,"Set "+d+" to min value")),e>b&&(e=b,h(W,"Set "+d+" to max value")),V[d]=""+e}function k(){function a(){function a(){var a=0,d=!1;for(h(W,"Checking connection is from allowed list of origins: "+c);a<c.length;a++)if(c[a]===b){d=!0;break}return d}function d(){var a=P[W].remoteHost;return h(W,"Checking connection is from: "+a),b===a}return c.constructor===Array?a():d()}var b=d.origin,c=P[W].checkOrigin;if(c&&""+b!="null"&&!a())throw new Error("Unexpected message received from: "+b+" for "+V.iframe.id+". Message was: "+d.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function l(){return K===(""+U).substr(0,L)&&U.substr(L).split(":")[0]in P}function w(){var a=V.type in{"true":1,"false":1,undefined:1};return a&&h(W,"Ignoring init message from meta parent page"),a}function y(a){return U.substr(U.indexOf(":")+J+a)}function z(a){h(W,"MessageCallback passed: {iframe: "+V.iframe.id+", message: "+a+"}"),N("messageCallback",{iframe:V.iframe,message:JSON.parse(a)}),h(W,"--")}function A(){var b=document.body.getBoundingClientRect(),c=V.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:c.height,iframeWidth:c.width,clientHeight:Math.max(document.documentElement.clientHeight,a.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,a.innerWidth||0),offsetTop:parseInt(c.top-b.top,10),offsetLeft:parseInt(c.left-b.left,10),scrollTop:a.pageYOffset,scrollLeft:a.pageXOffset})}function B(a,b){function c(){u("Send Page Info","pageInfo:"+A(),a,b)}x(c,32)}function C(){function d(b,c){function d(){P[g]?B(P[g].iframe,g):e()}["scroll","resize"].forEach(function(e){h(g,b+e+" listener for sendPageInfo"),c(a,e,d)})}function e(){d("Remove ",c)}function f(){d("Add ",b)}var g=W;f(),P[g].stopPageInfo=e}function D(){P[W]&&P[W].stopPageInfo&&(P[W].stopPageInfo(),delete P[W].stopPageInfo)}function E(){var a=!0;return null===V.iframe&&(j(W,"IFrame ("+V.id+") not found"),a=!1),a}function F(a){var b=a.getBoundingClientRect();return o(W),{x:Math.floor(Number(b.left)+Number(M.x)),y:Math.floor(Number(b.top)+Number(M.y))}}function G(b){function c(){M=g,H(),h(W,"--")}function d(){return{x:Number(V.width)+f.x,y:Number(V.height)+f.y}}function e(){a.parentIFrame?a.parentIFrame["scrollTo"+(b?"Offset":"")](g.x,g.y):j(W,"Unable to scroll to requested position, window.parentIFrame not found")}var f=b?F(V.iframe):{x:0,y:0},g=d();h(W,"Reposition requested from iFrame (offset x:"+f.x+" y:"+f.y+")"),a.top!==a.self?e():c()}function H(){!1!==N("scrollCallback",M)?p(W):q()}function I(b){function c(){var a=F(g);h(W,"Moving to in page link (#"+e+") at x: "+a.x+" y: "+a.y),M={x:a.x,y:a.y},H(),h(W,"--")}function d(){a.parentIFrame?a.parentIFrame.moveToAnchor(e):h(W,"In page link #"+e+" not found and window.parentIFrame not found")}var e=b.split("#")[1]||"",f=decodeURIComponent(e),g=document.getElementById(f)||document.getElementsByName(f)[0];g?c():a.top!==a.self?d():h(W,"In page link #"+e+" not found")}function N(a,b){return m(W,a,b)}function O(){switch(P[W].firstRun&&T(),V.type){case"close":n(V.iframe);break;case"message":z(y(6));break;case"scrollTo":G(!1);break;case"scrollToOffset":G(!0);break;case"pageInfo":B(P[W].iframe,W),C();break;case"pageInfoStop":D();break;case"inPageLink":I(y(9));break;case"reset":r(V);break;case"init":e(),N("initCallback",V.iframe),N("resizedCallback",V);break;default:e(),N("resizedCallback",V)}}function Q(a){var b=!0;return P[a]||(b=!1,j(V.type+" No settings for "+a+". Message was: "+U)),b}function S(){for(var a in P)u("iFrame requested init",v(a),document.getElementById(a),a)}function T(){P[W].firstRun=!1}var U=d.data,V={},W=null;"[iFrameResizerChild]Ready"===U?S():l()?(V=f(),W=R=V.id,!w()&&Q(W)&&(h(W,"Received: "+U),E()&&k()&&O())):i(W,"Ignored: "+U)}function m(a,b,c){var d=null,e=null;if(P[a]){if(d=P[a][b],"function"!=typeof d)throw new TypeError(b+" on iFrame["+a+"] is not a function");e=d(c)}return e}function n(a){var b=a.id;h(b,"Removing iFrame: "+b),a.parentNode.removeChild(a),m(b,"closedCallback",b),h(b,"--"),delete P[b]}function o(b){null===M&&(M={x:void 0!==a.pageXOffset?a.pageXOffset:document.documentElement.scrollLeft,y:void 0!==a.pageYOffset?a.pageYOffset:document.documentElement.scrollTop},h(b,"Get page position: "+M.x+","+M.y))}function p(b){null!==M&&(a.scrollTo(M.x,M.y),h(b,"Set page position: "+M.x+","+M.y),q())}function q(){M=null}function r(a){function b(){s(a),u("reset","reset",a.iframe,a.id)}h(a.id,"Size reset requested by "+("init"===a.type?"host page":"iFrame")),o(a.id),t(b,a,"reset")}function s(a){function b(b){a.iframe.style[b]=a[b]+"px",h(a.id,"IFrame ("+e+") "+b+" set to "+a[b]+"px")}function c(b){H||"0"!==a[b]||(H=!0,h(e,"Hidden iFrame detected, creating visibility listener"),y())}function d(a){b(a),c(a)}var e=a.iframe.id;P[e]&&(P[e].sizeHeight&&d("height"),P[e].sizeWidth&&d("width"))}function t(a,b,c){c!==b.type&&N?(h(b.id,"Requesting animation frame"),N(a)):a()}function u(a,b,c,d){function e(){var e=P[d].targetOrigin;h(d,"["+a+"] Sending msg to iframe["+d+"] ("+b+") targetOrigin: "+e),c.contentWindow.postMessage(K+b,e)}function f(){i(d,"["+a+"] IFrame("+d+") not found"),P[d]&&delete P[d]}function g(){c&&"contentWindow"in c&&null!==c.contentWindow?e():f()}d=d||c.id,P[d]&&g()}function v(a){return a+":"+P[a].bodyMarginV1+":"+P[a].sizeWidth+":"+P[a].log+":"+P[a].interval+":"+P[a].enablePublicMethods+":"+P[a].autoResize+":"+P[a].bodyMargin+":"+P[a].heightCalculationMethod+":"+P[a].bodyBackground+":"+P[a].bodyPadding+":"+P[a].tolerance+":"+P[a].inPageLinks+":"+P[a].resizeFrom+":"+P[a].widthCalculationMethod}function w(a,c){function d(){function b(b){1/0!==P[w][b]&&0!==P[w][b]&&(a.style[b]=P[w][b]+"px",h(w,"Set "+b+" = "+P[w][b]+"px"))}function c(a){if(P[w]["min"+a]>P[w]["max"+a])throw new Error("Value for min"+a+" can not be greater than max"+a)}c("Height"),c("Width"),b("maxHeight"),b("minHeight"),b("maxWidth"),b("minWidth")}function e(){var a=c&&c.id||S.id+F++;return null!==document.getElementById(a)&&(a+=F++),a}function f(b){return R=b,""===b&&(a.id=b=e(),G=(c||{}).log,R=b,h(b,"Added missing iframe ID: "+b+" ("+a.src+")")),b}function g(){h(w,"IFrame scrolling "+(P[w].scrolling?"enabled":"disabled")+" for "+w),a.style.overflow=!1===P[w].scrolling?"hidden":"auto",a.scrolling=!1===P[w].scrolling?"no":"yes"}function i(){("number"==typeof P[w].bodyMargin||"0"===P[w].bodyMargin)&&(P[w].bodyMarginV1=P[w].bodyMargin,P[w].bodyMargin=""+P[w].bodyMargin+"px")}function k(){var b=P[w].firstRun,c=P[w].heightCalculationMethod in O;!b&&c&&r({iframe:a,height:0,width:0,type:"init"})}function l(){Function.prototype.bind&&(P[w].iframe.iFrameResizer={close:n.bind(null,P[w].iframe),resize:u.bind(null,"Window resize","resize",P[w].iframe),moveToAnchor:function(a){u("Move to anchor","inPageLink:"+a,P[w].iframe,w)},sendMessage:function(a){a=JSON.stringify(a),u("Send Message","message:"+a,P[w].iframe,w)}})}function m(c){function d(){u("iFrame.onload",c,a),k()}b(a,"load",d),u("init",c,a)}function o(a){if("object"!=typeof a)throw new TypeError("Options is not an object")}function p(a){for(var b in S)S.hasOwnProperty(b)&&(P[w][b]=a.hasOwnProperty(b)?a[b]:S[b])}function q(a){return""===a||"file://"===a?"*":a}function s(b){b=b||{},P[w]={firstRun:!0,iframe:a,remoteHost:a.src.split("/").slice(0,3).join("/")},o(b),p(b),P[w].targetOrigin=!0===P[w].checkOrigin?q(P[w].remoteHost):"*"}function t(){return w in P&&"iFrameResizer"in a}var w=f(a.id);t()?j(w,"Ignored iFrame, already setup."):(s(c),g(),d(),i(),m(v(w)),l())}function x(a,b){null===Q&&(Q=setTimeout(function(){Q=null,a()},b))}function y(){function b(){function a(a){function b(b){return"0px"===P[a].iframe.style[b]}function c(a){return null!==a.offsetParent}c(P[a].iframe)&&(b("height")||b("width"))&&u("Visibility change","resize",P[a].iframe,a)}for(var b in P)a(b)}function c(a){h("window","Mutation observed: "+a[0].target+" "+a[0].type),x(b,16)}function d(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},d=new e(c);d.observe(a,b)}var e=a.MutationObserver||a.WebKitMutationObserver;e&&d()}function z(a){function b(){B("Window "+a,"resize")}h("window","Trigger event: "+a),x(b,16)}function A(){function a(){B("Tab Visable","resize")}"hidden"!==document.visibilityState&&(h("document","Trigger event: Visiblity change"),x(a,16))}function B(a,b){function c(a){return"parent"===P[a].resizeFrom&&P[a].autoResize&&!P[a].firstRun}for(var d in P)c(d)&&u(a,b,document.getElementById(d),d)}function C(){b(a,"message",l),b(a,"resize",function(){z("resize")}),b(document,"visibilitychange",A),b(document,"-webkit-visibilitychange",A),b(a,"focusin",function(){z("focus")}),b(a,"focus",function(){z("focus")})}function D(){function a(a,c){function d(){if(!c.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==c.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+c.tagName+">")}c&&(d(),w(c,a),b.push(c))}var b;return d(),C(),function(c,d){switch(b=[],typeof d){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(d||"iframe"),a.bind(void 0,c));break;case"object":a(c,d);break;default:throw new TypeError("Unexpected data type ("+typeof d+")")}return b}}function E(a){a.fn.iFrameResize=function(a){return this.filter("iframe").each(function(b,c){w(c,a)}).end()}}var F=0,G=!1,H=!1,I="message",J=I.length,K="[iFrameSizer]",L=K.length,M=null,N=a.requestAnimationFrame,O={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},P={},Q=null,R="Host Page",S={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,widthCalculationMethod:"scroll",closedCallback:function(){},initCallback:function(){},messageCallback:function(){j("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}};a.jQuery&&E(jQuery),"function"==typeof define&&define.amd?define([],D):"object"==typeof module&&"object"==typeof module.exports?module.exports=D():a.iFrameResize=a.iFrameResize||D()}(window||{}); +//# sourceMappingURL=iframeResizer.map
\ No newline at end of file diff --git a/apiroute/apiroute-service/src/main/resources/api-doc/js/tools.js b/apiroute/apiroute-service/src/main/resources/api-doc/js/tools.js new file mode 100644 index 0000000..21ecd51 --- /dev/null +++ b/apiroute/apiroute-service/src/main/resources/api-doc/js/tools.js @@ -0,0 +1,1054 @@ +/* + * Copyright (C) 2015 ZTE, Inc. and others. All rights reserved. (ZTE) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +////合并hk.min.js +/*! store2 - v2.3.0 - 2015-05-22 +* Copyright (c) 2015 Nathan Bubna; Licensed MIT, GPL */ +;(function(window, define) { + var _ = { + version: "2.3.0", + areas: {}, + apis: {}, + + // utilities + inherit: function(api, o) { + for (var p in api) { + if (!o.hasOwnProperty(p)) { + o[p] = api[p]; + } + } + return o; + }, + stringify: function(d) { + return d === undefined || typeof d === "function" ? d+'' : JSON.stringify(d); + }, + parse: function(s) { + // if it doesn't parse, return as is + try{ return JSON.parse(s); }catch(e){ return s; } + }, + + // extension hooks + fn: function(name, fn) { + _.storeAPI[name] = fn; + for (var api in _.apis) { + _.apis[api][name] = fn; + } + }, + get: function(area, key){ return area.getItem(key); }, + set: function(area, key, string){ area.setItem(key, string); }, + remove: function(area, key){ area.removeItem(key); }, + key: function(area, i){ return area.key(i); }, + length: function(area){ return area.length; }, + clear: function(area){ area.clear(); }, + + // core functions + Store: function(id, area, namespace) { + var store = _.inherit(_.storeAPI, function(key, data, overwrite) { + if (arguments.length === 0){ return store.getAll(); } + if (data !== undefined){ return store.set(key, data, overwrite); } + if (typeof key === "string"){ return store.get(key); } + if (!key){ return store.clear(); } + return store.setAll(key, data);// overwrite=data, data=key + }); + store._id = id; + try { + var testKey = '_safariPrivate_'; + area.setItem(testKey, 'sucks'); + store._area = area; + area.removeItem(testKey); + } catch (e) {} + if (!store._area) { + store._area = _.inherit(_.storageAPI, { items: {}, name: 'fake' }); + } + store._ns = namespace || ''; + if (!_.areas[id]) { + _.areas[id] = store._area; + } + if (!_.apis[store._ns+store._id]) { + _.apis[store._ns+store._id] = store; + } + return store; + }, + storeAPI: { + // admin functions + area: function(id, area) { + var store = this[id]; + if (!store || !store.area) { + store = _.Store(id, area, this._ns);//new area-specific api in this namespace + if (!this[id]){ this[id] = store; } + } + return store; + }, + namespace: function(namespace, noSession) { + if (!namespace){ + return this._ns ? this._ns.substring(0,this._ns.length-1) : ''; + } + var ns = namespace, store = this[ns]; + if (!store || !store.namespace) { + store = _.Store(this._id, this._area, this._ns+ns+'.');//new namespaced api + if (!this[ns]){ this[ns] = store; } + if (!noSession){ store.area('session', _.areas.session); } + } + return store; + }, + isFake: function(){ return this._area.name === 'fake'; }, + toString: function() { + return 'store'+(this._ns?'.'+this.namespace():'')+'['+this._id+']'; + }, + + // storage functions + has: function(key) { + if (this._area.has) { + return this._area.has(this._in(key));//extension hook + } + return !!(this._in(key) in this._area); + }, + size: function(){ return this.keys().length; }, + each: function(fn, and) { + for (var i=0, m=_.length(this._area); i<m; i++) { + var key = this._out(_.key(this._area, i)); + if (key !== undefined) { + if (fn.call(this, key, and || this.get(key)) === false) { + break; + } + } + if (m > _.length(this._area)) { m--; i--; }// in case of removeItem + } + return and || this; + }, + keys: function() { + return this.each(function(k, list){ list.push(k); }, []); + }, + get: function(key, alt) { + var s = _.get(this._area, this._in(key)); + return s !== null ? _.parse(s) : alt || s;// support alt for easy default mgmt + }, + getAll: function() { + return this.each(function(k, all){ all[k] = this.get(k); }, {}); + }, + set: function(key, data, overwrite) { + var d = this.get(key); + if (d != null && overwrite === false) { + return data; + } + return _.set(this._area, this._in(key), _.stringify(data), overwrite) || d; + }, + setAll: function(data, overwrite) { + var changed, val; + for (var key in data) { + val = data[key]; + if (this.set(key, val, overwrite) !== val) { + changed = true; + } + } + return changed; + }, + remove: function(key) { + var d = this.get(key); + _.remove(this._area, this._in(key)); + return d; + }, + clear: function() { + if (!this._ns) { + _.clear(this._area); + } else { + this.each(function(k){ _.remove(this._area, this._in(k)); }, 1); + } + return this; + }, + clearAll: function() { + var area = this._area; + for (var id in _.areas) { + if (_.areas.hasOwnProperty(id)) { + this._area = _.areas[id]; + this.clear(); + } + } + this._area = area; + return this; + }, + + // internal use functions + _in: function(k) { + if (typeof k !== "string"){ k = _.stringify(k); } + return this._ns ? this._ns + k : k; + }, + _out: function(k) { + return this._ns ? + k && k.indexOf(this._ns) === 0 ? + k.substring(this._ns.length) : + undefined : // so each() knows to skip it + k; + } + },// end _.storeAPI + storageAPI: { + length: 0, + has: function(k){ return this.items.hasOwnProperty(k); }, + key: function(i) { + var c = 0; + for (var k in this.items){ + if (this.has(k) && i === c++) { + return k; + } + } + }, + setItem: function(k, v) { + if (!this.has(k)) { + this.length++; + } + this.items[k] = v; + }, + removeItem: function(k) { + if (this.has(k)) { + delete this.items[k]; + this.length--; + } + }, + getItem: function(k){ return this.has(k) ? this.items[k] : null; }, + clear: function(){ for (var k in this.list){ this.removeItem(k); } }, + toString: function(){ return this.length+' items in '+this.name+'Storage'; } + }// end _.storageAPI + }; + + // setup the primary store fn + if (window.store){ _.conflict = window.store; } + var store = + // safely set this up (throws error in IE10/32bit mode for local files) + _.Store("local", (function(){try{ return localStorage; }catch(e){}})()); + store.local = store;// for completeness + store._ = _;// for extenders and debuggers... + // safely setup store.session (throws exception in FF for file:/// urls) + store.area("session", (function(){try{ return sessionStorage; }catch(e){}})()); + + //Expose store to the global object + window.store = store; + + if (typeof define === 'function' && define.amd !== undefined) { + define(function () { + return store; + }); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = store; + } + +})(this, null); + +// XHook - v1.3.3 - https://github.com/jpillora/xhook +// Jaime Pillora <dev@jpillora.com> - MIT Copyright 2015 +(function(window,undefined) { +var AFTER, BEFORE, COMMON_EVENTS, EventEmitter, FIRE, FormData, NativeFormData, NativeXMLHttp, OFF, ON, READY_STATE, UPLOAD_EVENTS, XHookFormData, XHookHttpRequest, XMLHTTP, convertHeaders, depricatedProp, document, fakeEvent, mergeObjects, msie, proxyEvents, slice, xhook, _base, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; + +document = window.document; + +BEFORE = 'before'; + +AFTER = 'after'; + +READY_STATE = 'readyState'; + +ON = 'addEventListener'; + +OFF = 'removeEventListener'; + +FIRE = 'dispatchEvent'; + +XMLHTTP = 'XMLHttpRequest'; + +FormData = 'FormData'; + +UPLOAD_EVENTS = ['load', 'loadend', 'loadstart']; + +COMMON_EVENTS = ['progress', 'abort', 'error', 'timeout']; + +msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]); + +if (isNaN(msie)) { + msie = parseInt((/trident\/.*; rv:(\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]); +} + +(_base = Array.prototype).indexOf || (_base.indexOf = function(item) { + var i, x, _i, _len; + for (i = _i = 0, _len = this.length; _i < _len; i = ++_i) { + x = this[i]; + if (x === item) { + return i; + } + } + return -1; +}); + +slice = function(o, n) { + return Array.prototype.slice.call(o, n); +}; + +depricatedProp = function(p) { + return p === "returnValue" || p === "totalSize" || p === "position"; +}; + +mergeObjects = function(src, dst) { + var k, v; + for (k in src) { + v = src[k]; + if (depricatedProp(k)) { + continue; + } + try { + dst[k] = src[k]; + } catch (_error) {} + } + return dst; +}; + +proxyEvents = function(events, src, dst) { + var event, p, _i, _len; + p = function(event) { + return function(e) { + var clone, k, val; + clone = {}; + for (k in e) { + if (depricatedProp(k)) { + continue; + } + val = e[k]; + clone[k] = val === src ? dst : val; + } + return dst[FIRE](event, clone); + }; + }; + for (_i = 0, _len = events.length; _i < _len; _i++) { + event = events[_i]; + if (dst._has(event)) { + src["on" + event] = p(event); + } + } +}; + +fakeEvent = function(type) { + var msieEventObject; + if (document.createEventObject != null) { + msieEventObject = document.createEventObject(); + msieEventObject.type = type; + return msieEventObject; + } else { + try { + return new Event(type); + } catch (_error) { + return { + type: type + }; + } + } +}; + +EventEmitter = function(nodeStyle) { + var emitter, events, listeners; + events = {}; + listeners = function(event) { + return events[event] || []; + }; + emitter = {}; + emitter[ON] = function(event, callback, i) { + events[event] = listeners(event); + if (events[event].indexOf(callback) >= 0) { + return; + } + i = i === undefined ? events[event].length : i; + events[event].splice(i, 0, callback); + }; + emitter[OFF] = function(event, callback) { + var i; + if (event === undefined) { + events = {}; + return; + } + if (callback === undefined) { + events[event] = []; + } + i = listeners(event).indexOf(callback); + if (i === -1) { + return; + } + listeners(event).splice(i, 1); + }; + emitter[FIRE] = function() { + var args, event, i, legacylistener, listener, _i, _len, _ref; + args = slice(arguments); + event = args.shift(); + if (!nodeStyle) { + args[0] = mergeObjects(args[0], fakeEvent(event)); + } + legacylistener = emitter["on" + event]; + if (legacylistener) { + legacylistener.apply(undefined, args); + } + _ref = listeners(event).concat(listeners("*")); + for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { + listener = _ref[i]; + listener.apply(undefined, args); + } + }; + emitter._has = function(event) { + return !!(events[event] || emitter["on" + event]); + }; + if (nodeStyle) { + emitter.listeners = function(event) { + return slice(listeners(event)); + }; + emitter.on = emitter[ON]; + emitter.off = emitter[OFF]; + emitter.fire = emitter[FIRE]; + emitter.once = function(e, fn) { + var fire; + fire = function() { + emitter.off(e, fire); + return fn.apply(null, arguments); + }; + return emitter.on(e, fire); + }; + emitter.destroy = function() { + return events = {}; + }; + } + return emitter; +}; + +xhook = EventEmitter(true); + +xhook.EventEmitter = EventEmitter; + +xhook[BEFORE] = function(handler, i) { + if (handler.length < 1 || handler.length > 2) { + throw "invalid hook"; + } + return xhook[ON](BEFORE, handler, i); +}; + +xhook[AFTER] = function(handler, i) { + if (handler.length < 2 || handler.length > 3) { + throw "invalid hook"; + } + return xhook[ON](AFTER, handler, i); +}; + +xhook.enable = function() { + window[XMLHTTP] = XHookHttpRequest; + if (NativeFormData) { + window[FormData] = XHookFormData; + } +}; + +xhook.disable = function() { + window[XMLHTTP] = xhook[XMLHTTP]; + window[FormData] = NativeFormData; +}; + +convertHeaders = xhook.headers = function(h, dest) { + var header, headers, k, name, v, value, _i, _len, _ref; + if (dest == null) { + dest = {}; + } + switch (typeof h) { + case "object": + headers = []; + for (k in h) { + v = h[k]; + name = k.toLowerCase(); + headers.push("" + name + ":\t" + v); + } + return headers.join('\n'); + case "string": + headers = h.split('\n'); + for (_i = 0, _len = headers.length; _i < _len; _i++) { + header = headers[_i]; + if (/([^:]+):\s*(.+)/.test(header)) { + name = (_ref = RegExp.$1) != null ? _ref.toLowerCase() : void 0; + value = RegExp.$2; + if (dest[name] == null) { + dest[name] = value; + } + } + } + return dest; + } +}; + +NativeFormData = window[FormData]; + +XHookFormData = function(form) { + var entries; + this.fd = form ? new NativeFormData(form) : new NativeFormData(); + this.form = form; + entries = []; + Object.defineProperty(this, 'entries', { + get: function() { + var fentries; + fentries = !form ? [] : slice(form.querySelectorAll("input,select")).filter(function(e) { + var _ref; + return ((_ref = e.type) !== 'checkbox' && _ref !== 'radio') || e.checked; + }).map(function(e) { + return [e.name, e.type === "file" ? e.files : e.value]; + }); + return fentries.concat(entries); + } + }); + this.append = (function(_this) { + return function() { + var args; + args = slice(arguments); + entries.push(args); + return _this.fd.append.apply(_this.fd, args); + }; + })(this); +}; + +if (NativeFormData) { + xhook[FormData] = NativeFormData; + window[FormData] = XHookFormData; +} + +NativeXMLHttp = window[XMLHTTP]; + +xhook[XMLHTTP] = NativeXMLHttp; + +XHookHttpRequest = window[XMLHTTP] = function() { + var ABORTED, currentState, emitFinal, emitReadyState, facade, hasError, hasErrorHandler, readBody, readHead, request, response, setReadyState, status, transiting, writeBody, writeHead, xhr; + ABORTED = -1; + xhr = new xhook[XMLHTTP](); + request = {}; + status = null; + hasError = void 0; + transiting = void 0; + response = void 0; + readHead = function() { + var key, name, val, _ref; + response.status = status || xhr.status; + if (!(status === ABORTED && msie < 10)) { + response.statusText = xhr.statusText; + } + if (status !== ABORTED) { + _ref = convertHeaders(xhr.getAllResponseHeaders()); + for (key in _ref) { + val = _ref[key]; + if (!response.headers[key]) { + name = key.toLowerCase(); + response.headers[name] = val; + } + } + } + }; + readBody = function() { + if (!xhr.responseType || xhr.responseType === "text") { + response.text = xhr.responseText; + response.data = xhr.responseText; + } else if (xhr.responseType === "document") { + response.xml = xhr.responseXML; + response.data = xhr.responseXML; + } else { + response.data = xhr.response; + } + try{ + if(response.data){ + // checked login time out reload to login + var data = $.parseJSON(response.data); + if(data.source && data.redirect_uri && data.source === "smagent"){ + var redirect_uri = data.redirect_uri; + if(top){ + top.location = redirect_uri.replace('$1', encodeURIComponent(top.location)); + }else{ + window.location = redirect_uri.replace('$1', encodeURIComponent(window.location)); + } + } + } + }catch(e){} + + if ("responseURL" in xhr) { + response.finalUrl = xhr.responseURL; + } + }; + writeHead = function() { + facade.status = response.status; + facade.statusText = response.statusText; + }; + writeBody = function() { + if ('text' in response) { + facade.responseText = response.text; + } + if ('xml' in response) { + facade.responseXML = response.xml; + } + if ('data' in response) { + facade.response = response.data; + } + if ('finalUrl' in response) { + facade.responseURL = response.finalUrl; + } + }; + emitReadyState = function(n) { + while (n > currentState && currentState < 4) { + facade[READY_STATE] = ++currentState; + if (currentState === 1) { + facade[FIRE]("loadstart", {}); + } + if (currentState === 2) { + writeHead(); + } + if (currentState === 4) { + writeHead(); + writeBody(); + } + facade[FIRE]("readystatechange", {}); + if (currentState === 4) { + setTimeout(emitFinal, 0); + } + } + }; + emitFinal = function() { + if (!hasError) { + facade[FIRE]("load", {}); + } + facade[FIRE]("loadend", {}); + if (hasError) { + facade[READY_STATE] = 0; + } + }; + currentState = 0; + setReadyState = function(n) { + var hooks, process; + if (n !== 4) { + emitReadyState(n); + return; + } + hooks = xhook.listeners(AFTER); + process = function() { + var hook; + if (!hooks.length) { + return emitReadyState(4); + } + hook = hooks.shift(); + if (hook.length === 2) { + hook(request, response); + return process(); + } else if (hook.length === 3 && request.async) { + return hook(request, response, process); + } else { + return process(); + } + }; + process(); + }; + facade = request.xhr = EventEmitter(); + xhr.onreadystatechange = function(event) { + try { + if (xhr[READY_STATE] === 2) { + readHead(); + } + } catch (_error) {} + if (xhr[READY_STATE] === 4) { + transiting = false; + readHead(); + readBody(); + } + setReadyState(xhr[READY_STATE]); + }; + hasErrorHandler = function() { + hasError = true; + }; + facade[ON]('error', hasErrorHandler); + facade[ON]('timeout', hasErrorHandler); + facade[ON]('abort', hasErrorHandler); + facade[ON]('progress', function() { + if (currentState < 3) { + setReadyState(3); + } else { + facade[FIRE]("readystatechange", {}); + } + }); + if ('withCredentials' in xhr || xhook.addWithCredentials) { + facade.withCredentials = false; + } + facade.status = 0; + facade.open = function(method, url, async, user, pass) { + currentState = 0; + hasError = false; + transiting = false; + request.headers = {}; + request.headerNames = {}; + request.status = 0; + response = {}; + response.headers = {}; + request.method = method; + request.url = url; + request.async = async !== false; + request.user = user; + request.pass = pass; + setReadyState(1); + }; + facade.send = function(body) { + var hooks, k, modk, process, send, _i, _len, _ref; + _ref = ['type', 'timeout', 'withCredentials']; + if(navigator.userAgent.indexOf("Firefox/") != -1){http://atmosphere-framework.2306103.n4.nabble.com/Atmosphere-js-withCredentials-true-does-not-work-in-Firefox-td4656661.html + _ref = ['type', 'timeout']; + } + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + k = _ref[_i]; + modk = k === "type" ? "responseType" : k; + if (modk in facade) { + request[k] = facade[modk]; + } + } + request.body = body; + send = function() { + var header, value, _j, _len1, _ref1, _ref2; + proxyEvents(COMMON_EVENTS, xhr, facade); + if (facade.upload) { + proxyEvents(COMMON_EVENTS.concat(UPLOAD_EVENTS), xhr.upload, facade.upload); + } + transiting = true; + xhr.open(request.method, request.url, request.async, request.user, request.pass); + _ref1 = ['type', 'timeout', 'withCredentials']; + if(navigator.userAgent.indexOf("Firefox/") != -1){//http://atmosphere-framework.2306103.n4.nabble.com/Atmosphere-js-withCredentials-true-does-not-work-in-Firefox-td4656661.html + _ref1 = ['type', 'timeout']; + } + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + k = _ref1[_j]; + modk = k === "type" ? "responseType" : k; + if (k in request) { + xhr[modk] = request[k]; + } + } + _ref2 = request.headers; + for (header in _ref2) { + value = _ref2[header]; + xhr.setRequestHeader(header, value); + } + if (request.body instanceof XHookFormData) { + request.body = request.body.fd; + } + xhr.send(request.body); + }; + hooks = xhook.listeners(BEFORE); + process = function() { + var done, hook; + if (!hooks.length) { + return send(); + } + done = function(userResponse) { + if (typeof userResponse === 'object' && (typeof userResponse.status === 'number' || typeof response.status === 'number')) { + mergeObjects(userResponse, response); + if (__indexOf.call(userResponse, 'data') < 0) { + userResponse.data = userResponse.response || userResponse.text; + } + setReadyState(4); + return; + } + process(); + }; + done.head = function(userResponse) { + mergeObjects(userResponse, response); + return setReadyState(2); + }; + done.progress = function(userResponse) { + mergeObjects(userResponse, response); + return setReadyState(3); + }; + hook = hooks.shift(); + if (hook.length === 1) { + return done(hook(request)); + } else if (hook.length === 2 && request.async) { + return hook(request, done); + } else { + return done(); + } + }; + process(); + }; + facade.abort = function() { + status = ABORTED; + if (transiting) { + xhr.abort(); + } else { + facade[FIRE]('abort', {}); + } + }; + facade.setRequestHeader = function(header, value) { + var lName, name; + lName = header != null ? header.toLowerCase() : void 0; + name = request.headerNames[lName] = request.headerNames[lName] || header; + if (request.headers[name]) { + value = request.headers[name] + ', ' + value; + } + request.headers[name] = value; + }; + facade.getResponseHeader = function(header) { + var name; + name = header != null ? header.toLowerCase() : void 0; + return response.headers[name]; + }; + facade.getAllResponseHeaders = function() { + return convertHeaders(response.headers); + }; + if (xhr.overrideMimeType) { + facade.overrideMimeType = function() { + return xhr.overrideMimeType.apply(xhr, arguments); + }; + } + if (xhr.upload) { + facade.upload = request.upload = EventEmitter(); + } + return facade; +}; +/* +if (typeof this.define === "function" && this.define.amd) { + define("xhook", [], function() { + return xhook; + }); +} else {*/ + (this.exports || this).xhook = xhook; +//} + +}.call(this,window)); + +xhook.before(function(request) { + var zte_headers = store('zte_http_headers'); + if (zte_headers && zte_headers.length > 0) { + for (i = 0; i < zte_headers.length; i++) { + if (zte_headers[i].store === true) { + if ( !! store(zte_headers[i].value)) { + request.headers[zte_headers[i].key] = store(zte_headers[i].value); + } + } else { + request.headers[zte_headers[i].key] = zte_headers[i].value; + } + } + } +}); +/** + * 初始化脚本文件装载工具 + * zongying 2010.12 + * modify: + */ +$Boot = {}; + +/** + * 创建命名空间 + * @param {Object} name + * @param {Object} object + */ +$Boot.createNamespace = function(name, object) { + var splits = name.split("."); + var parent = window; + //document.window浏览器内置对象 + var part = splits[0]; + for (var i = 0, len = splits.length - 1; i < len; i++, part = splits[i]) { + if (!parent[part]) { + parent = parent[part] = {}; + } else { + parent = parent[part]; + } + } + // 存放对象 + parent[part] = object; + // 返回 last part name (例如:classname) + return part; +} + +$Boot.isDefined = function(o) { + return typeof (o) != "undefined" +} +/** + * 启动配置类 + */ +$Boot.Config = function() { + + function isDefined(o) { + return typeof (o) != "undefined" + } + + //用户应用当前目录 + if (!isDefined(window.$userAppDir)) { + window.$userAppDir = './' + } + //组件库目录 + if (!isDefined(window.$userFrameDir)) { + window.$userFrameDir = '/common/' + } + //用户i18文件目录 + if (!isDefined(window.$userI18nDir)) { + window.$userI18nDir = './' + } + + //当前语言 默认为英语 + var language = "zh-CN"; + //var languageList = ['ar', 'ba', 'cr', 'cs', 'de', 'el', 'es', 'fi', 'fr', 'fr-FR', 'hu-HU', 'id', 'it', 'ja', 'nb-NO', 'nl', 'pl', 'pl-PL', 'pt', 'pt-BR', 'ro-RO', 'ru-RU', 'sk', 'sr', 'sr-Latn', 'sv-SE', 'en-US','uk-UA', 'zh-CN', 'zh-TW']; + var languageList = ['en-US', 'zh-CN']; + + //从服务端取客户端接受语言类型 + var getAcceptLangFromServer = true; + + + /** + * 创建XMLHttpRequest对象 + */ + function createXMLHttpRequest() { + if (window.ActiveXObject) { + return new ActiveXObject("Microsoft.XMLHTTP"); + } else if (window.XMLHttpRequest) { + return new XMLHttpRequest(); + } else { + throw new Error("This Brower do not support XMLHTTP!!"); + } + } + + + /** + * 同步发送xml http 请求 + * @param {Object} url + * @param {Object} data + * @param {Object} method + */ + function httpRequest(method, url, data) { + var xmlhttp; + xmlhttp = createXMLHttpRequest(); + var sendData = null; + if (method == "get") { + url = url + "?" + data; + + } else if (method == "post") { + sendData = data; + } + xmlhttp.open(method, url, false); + xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + xmlhttp.setRequestHeader("If-Modified-Since", "0"); + xmlhttp.send(sendData); + if (xmlhttp.status == 200) + return xmlhttp.responseText; + } + + /** + * 同步发送xml http 请求(给外部调用) + * @param {Object} url + * @param {Object} data + * @param {Object} method + */ + this.httpRequestStatic = function(method, url, data) { + var xmlhttp; + xmlhttp = createXMLHttpRequest(); + var sendData = null; + if (method == "get") { + url = url + "?" + data; + + } else if (method == "post") { + sendData = data; + } + xmlhttp.open(method, url, false); + xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + xmlhttp.setRequestHeader("If-Modified-Since", "0"); + xmlhttp.send(sendData); + if (xmlhttp.status == 200) + return xmlhttp.responseText; + } + + function inArray(array, obj) { + for (var i = 0; i < array.length; i++) { + if (array[i] == obj) { + return true; + } + } + return false; + + } + + /** + * 取得浏览器语言信息 + */ + this.getLanguage = function() { + var rtnLanguage = localStorage.getItem("language-option"); + if( rtnLanguage == "null" || rtnLanguage == null ){ + rtnLanguage = window.navigator.userLanguage||window.navigator.language; + } + if( rtnLanguage == '"zh-CN"' || rtnLanguage == "zh-CN" ){ + return "zh-CN"; + }else{ + return "en-US"; + } + //return "en-US"; + } + + this.getUrlParam=function(name){ + var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 + var search =decodeURIComponent(location.search.substring(1)); //decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。 + var r =search.match(reg); //匹配目标参数 + if (r != null) return unescape(r[2]); //unescape() 函数可对通过 escape() 编码的字符串进行解码。 + return null; //返回参数值 + } + + +} + +//创建命名空间 +$Boot.createNamespace("com.zte.ums.aos.framework.BootConfig", $Boot.Config); +//创建基础配置对象实例 +$Boot.bootConfig = new com.zte.ums.aos.framework.BootConfig(); + +function getLanguage(){ + return $Boot.bootConfig.getLanguage(); +} + +function getStringWidth(text,fontSize) +{ + var span = document.getElementById("_ictframework_getwidth"); + if (span == null) { + span = document.createElement("span"); + span.id = "_ictframework_getwidth"; + document.body.appendChild(span); + } + span.innerText = text; + span.style.whiteSpace = "nowrap"; + $("#_ictframework_getwidth").attr('style','font-size:'+fontSize+'px;'); + var width = span.offsetWidth; + $("#_ictframework_getwidth").attr('style','display:none'); + return width; +} + +function getUrlParam(name){ + return $Boot.bootConfig.getUrlParam(name); +} + +function httpRequest(method, url, data) { + return $Boot.bootConfig.httpRequestStatic(method, url, data) +} + +// 定义JQUERY AJAX 完成函数,判断返回状态,如果状态正常,但HEADER头里有session超时信息,则刷新重登录 +// 如果状态为 401, 也刷新重登录 +// 注意如果在$.ajax() 函数中定义了 complete,则覆盖了这里预定义complete内容,以$.ajax()函数中定义的为准,这里预定义的函数则失效,如果 +// 要继续判断session超时,则需要在 $.ajax()函数中定义的complete函数中加入这里预定义内容。 +if (jQuery) { + $.ajaxSetup({ + complete:function(XMLHttpRequest,textStatus){ + if (XMLHttpRequest.status == 401) { + window.location.replace("login.html"); + } + // if (XMLHttpRequest.status == 200) { + // var sessionstatus=XMLHttpRequest.getResponseHeader("sessionstatus"); ////通过XMLHttpRequest取得响应头,sessionstatus, + // if(sessionstatus=="timeout"){ + // window.location.replace("/"); + // } + // } else if (XMLHttpRequest.status == 401) { + // window.location.replace("/"); + // } + } + }); +}
\ No newline at end of file |