aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/javascripts/protovis-msie.js
blob: 1965ae18a9f72c46bce8e970af14c868004d804d (plain)
1
2
3
4
5
6
7
8
9
/*
 * Protovis MSIE VML shim
 * (c) 2011 DataMarket (datamarket@datamarket.com)
 *
 * Note that this library is now hosted at https://github.com/DataMarket/protovis-msie
 * but we can't upgrade due to a limitation in the timeline widget. Mouse moving is not
 * correctly detected.
 */
pv.have_SVG=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,pv.have_VML=function(a,b,c){b=a.createElement("div"),b.innerHTML='<v:shape adj="1" />',c=b.firstChild,c.style.behavior="url(#default#VML)";return c?typeof c.adj==="object":!0}(document),!pv.have_SVG&&pv.have_VML&&function(){function B(a){var b=a;a=new A(b);for(var c=0,d=z.length;c<d;c++){var e=z[c];a[e]=b[e]}a.target||(a.target=a.srcElement||document),a.target.nodeType===3&&(a.target=a.target.parentNode),!a.relatedTarget&&a.fromElement&&(a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement);if(a.pageX==null&&a.clientX!=null){var f=document.documentElement,g=document.body;a.pageX=a.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=a.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)}a.which==null&&(a.charCode!=null||a.keyCode!=null)&&(a.which=a.charCode!=null?a.charCode:a.keyCode),!a.metaKey&&a.ctrlKey&&(a.metaKey=a.ctrlKey),!a.which&&a.button!==undefined&&(a.which=a.button&1?1:a.button&2?3:a.button&4?2:0);return a}function A(a){if(a&&a.type){this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=y;if(a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault())this.isDefaultPrevented=x}else this.type=a;this.timeStamp=new Date*1}function m(a,b){var c=a.getElementsByTagName("stroke")[0];c||(c=j("stroke"),a.appendChild(c)),!b.stroke||b.stroke==="none"?(c.on="false",c.weight="0"):(c.on="true",c.weight=parseFloat(b["stroke-width"]||"1")/1.25,c.color=f(b.stroke)||"black",c.opacity=parseFloat(b["stroke-opacity"]||"1")||"1",c.joinstyle=v[b["stroke-linejoin"]]||"miter")}function l(a,b){var c=a.getElementsByTagName("fill")[0];c||(c=j("fill"),a.appendChild(c)),!b.fill||b.fill==="none"?c.on=!1:(c.on="true",c.color=f(b.fill),c.opacity=parseFloat(b["fill-opacity"]||"1")||"1")}function k(a,b){var c=b||{};c.translate_x=0,c.translate_y=0;if(a.transform){var d=/translate\((\d+(?:\.\d+)?)(?:,(\d+(?:\.\d+)?))?\)/.exec(a.transform);d&&d[1]&&(c.translate_x=parseFloat(d[1])),d&&d[2]&&(c.translate_y=parseFloat(d[2]));var e=/rotate\((\d+\.\d+|\d+)\)/.exec(a.transform);e&&(c.rotation=parseFloat(e[1])%360)}c.x=parseFloat(a.x||0),c.y=parseFloat(a.y||0),"width"in a&&(c.width=parseInt(a.width,10)),"height"in a&&(c.height=parseInt(a.height,10));return c}function j(a){a in i||(i[a]=document.createElement(q+a+r));return i[a].cloneNode(!1)}function h(a,b){var c=0,d=0,e=Math.round;a=a.replace(/(\d*)((\.*\d*)(e ?-?\d*))/g,"$1");if(a in g)return g[a];var f=a.match(/([MLHVCSQTAZ].*?)(?=[MLHVCSQTAZ]|$)/gi),h=[];for(var i=0,j=f.length;i<j;i++){var k=f[i],l=k.charAt(0),m=k.substring(1).split(/[, ]/);switch(l){case"M":l="m",c=e(m[0]),d=e(m[1]),m=[c,d];break;case"m":l="m",c+=e(m[0]),d+=e(m[1]),m=[c,d];break;case"A":c=e(m[5]),d=e(m[6]),l="l",m=[c,d];break;case"L":l="l",c=e(m[0]),d=e(m[1]),m=[c,d];break;case"l":l="l",c+=e(m[0]),d+=e(m[1]),m=[c,d];break;case"H":l="l",c=e(m[0]),m=[c,d];break;case"h":l="l",c+=e(m[0]),m=[c,d];break;case"V":l="l",d=e(m[0]),m=[c,d];break;case"v":l="l",d+=e(m[0]),m=[c,d];break;case"C":l="l",c=e(m[4]),d=e(m[5]),m=[c,d];break;case"c":l="l",c+=e(m[4]),d+=e(m[5]),m=[c,d];break;case"Z":case"z":l="xe",m=[];default:}h.push(l+m.join(","))}return g[a]=h.join("")+"e"}function f(a,b){!(a in c)&&(b=/^rgb\((\d+),(\d+),(\d+)\)$/i.exec(a))&&(c[a]="#"+d[b[1]]+d[b[2]]+d[b[3]]);return c[a]||a}pv.VmlScene={scale:1,events:["DOMMouseScroll","mousewheel","mousedown","mouseup","mouseover","mouseout","mousemove","click","dblclick"],implicit:{css:{font:"10px sans-serif"}}};for(var a in pv.SvgScene)a in pv.SvgScene&&typeof pv.SvgScene[a]==="function"&&!(a in pv.VmlScene)&&(pv.VmlScene[a]=pv.SvgScene[a]);pv.Scene=pv.VmlScene;var b={crosshair:1,pointer:1,move:1,hand:"pointer",text:1,wait:1,help:1,progress:1,"n-resize":1,"ne-resize":1,"nw-resize":1,"s-resize":1,"se-resize":1,"sw-resize":1,"e-resize":1,"w-resize":1},c={},d=[];for(var e=0;e<256;e++)d[e]=e===0?"00":e<16?"0"+e.toString(16):e.toString(16);var g={},i={span:document.createElement("span"),div:document.createElement("div")},n=Math.PI*2/360,o=null,p=null,q="<v:",r=' class="msvml">',s="px",t={group:1,shape:1,shapetype:1,line:1,polyline:1,curve:1,rect:1,roundrect:1,oval:1,arc:1,image:1},u={butt:"flat",round:"round",square:"square",flat:"flat"},v={bevel:"bevel",round:"round",miter:"miter"},w={g:{rewrite:"div",attr:function(a,b,c){var d=k(a);c.style.position="absolute",c.style.zoom=1,c.style.left=d.translate_x+d.x+s,c.style.top=d.translate_y+d.y+s}},line:{rewrite:"shape",attr:function(a,b,c){var d=parseFloat(a.x1||0),e=parseFloat(a.y1||0),f=parseFloat(a.x2||0),g=parseFloat(a.y2||0);c.style.top=0+s,c.style.left=0+s,c.style.width=1e3+s,c.style.height=1e3+s;var h=c.getElementsByTagName("path")[0];h||(h=j("path"),c.appendChild(h));var i=Math.round;h.v="M "+i(d)+" "+i(e)+" L "+i(f)+" "+i(g)+" E",m(c,a)}},rect:{rewrite:"rect",attr:function(a,b,c){var d=k(a),e=c.style;e.position="absolute",e.left=d.translate_x+d.x+s,e.top=d.translate_y+d.y+s,d.width&&(e.width=d.width+s),d.height&&(e.height=d.height+s),l(c,a),m(c,a)}},path:{rewrite:"shape",attr:function(a,b,c){var d=k(a);c.style.left=d.translate_x+d.x+s,c.style.top=d.translate_y+d.y+s,c.style.width=1e3+s,c.style.height=1e3+s;var e=c.getElementsByTagName("path")[0];e||(e=j("path"),c.appendChild(e)),e.v=h(a.d),l(c,a),m(c,a)}},circle:{rewrite:"oval",attr:function(a,b,c){var d=k(a),e=parseFloat(a.cx||0),f=parseFloat(a.cy||0),g=parseFloat(a.r||0);c.style.top=d.translate_y+f-g+s,c.style.left=d.translate_x+e-g+s,c.style.width=g*2+s,c.style.height=g*2+s,l(c,a),m(c,a)}},text:{rewrite:"span"},svg:{rewrite:"span",oncreate:function(a){p||(p=document.createElement("span"),p.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline-block;white-space:nowrap;",document.body.appendChild(p));if(!b){var b=document.createElement("style");b.id="protovis_vml_styles",document.documentElement.firstChild.appendChild(b),b.styleSheet.addRule(".msvml","behavior:url(#default#VML);"),b.styleSheet.addRule(".msvml_block","position:absolute;top:0;left:0;");try{document.namespaces.v||document.namespaces.add("v","urn:schemas-microsoft-com:vml")}catch(c){q="<",r=' class="msvml" xmlns="urn:schemas-microsoft.com:vml">'}}},css:"position:relative;overflow:hidden;display:inline-block;~display:block;"}},x=function(){return!0},y=function(){return!1},z=["altKey","attrChange","attrName","bubbles","button","cancelable","charCode","clientX","clientY","ctrlKey","currentTarget","data","detail","eventPhase","fromElement","handler","keyCode","layerX","layerY","metaKey","newValue","offsetX","offsetY","pageX","pageY","prevValue","relatedNode","relatedTarget","screenX","screenY","shiftKey","srcElement","target","toElement","view","wheelDelta","which"];A.prototype={preventDefault:function(){this.isDefaultPrevented=x;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=x;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=x,this.stopPropagation()},isDefaultPrevented:y,isPropagationStopped:y,isImmediatePropagationStopped:y},pv.listener=function(a,b){return a.$listener||(a.$listener=function(b){try{pv.event=B(b||window.event);if(1)return a.call(this,pv.event)}finally{delete pv.event}})},pv.listen=function(a,b,c){c=pv.listener(c,a);return a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)},pv.VmlScene.updateAll=function(a){if(a.length&&a[0].reverse&&a.type!="line"&&a.type!="area"){var b=pv.extend(a);for(var c=0,d=a.length-1;d>=0;c++,d--)b[c]=a[d];a=b}this.removeSiblings(this[a.type](a))},pv.VmlScene.create=function(a){var b;if(a in w){var c=w[a]||{},d=c.rewrite||a;b=j(d),b.style.cssText=c.css||"";if(d in t||a==="span"||a==="div")b.className+=" msvml_block";"oncreate"in c&&c.oncreate(b)}else b=j(d),a in t&&(b.className+=" msvml_block");a!==d&&(b.svgtype=a);return b},pv.VmlScene.expect=function(a,c,d,e){e=e||{};var f=w[c]||{},g=f.rewrite||c;if(a){if(a.tagName.toUpperCase()!==g.toUpperCase()){var h=this.create(c);a.parentNode.replaceChild(h,a),a=h}}else a=this.create(c);f.attr&&f.attr(d,e,a),d.cursor in b&&(e.cursor=b[d.cursor]===1?d.cursor:b[d.cursor]);for(var i in e){var j=e[i];j==null?a.style.removeAttribute(i):a.style[i]=j}return a},pv.VmlScene.append=function(a,b,c){a.$scene={scenes:b,index:c},a=this.title(a,b[c]);if(!a.parentNode||a.parentNode.nodeType===11){b.$g.appendChild(a);var d=w[a.svgtype];d&&typeof d.onappend==="function"&&d.onappend(a,b[c])}return a.nextSibling},pv.VmlScene.title=function(a,b){b.title&&(a.title=b.title);return a},pv.VmlScene.dispatch=pv.listener(function(a){var b=a.target.$scene;if(b){var c=a.type;switch(c){case"DOMMouseScroll":c="mousewheel",a.wheel=-480*a.detail;break;case"mousewheel":a.wheel=(window.opera?12:1)*a.wheelDelta}pv.Mark.dispatch(c,b.scenes,b.index)&&a.preventDefault()}}),pv.VmlScene.panel=function(a){var b=a.$g,c=b&&b.firstChild;for(var d=0;d<a.length;d++){var e=a[d];if(!e.visible)continue;if(!a.parent){e.canvas.style.display="inline-block",e.canvas.style.zoom=1,b&&b.parentNode!=e.canvas&&(b=e.canvas.firstChild,c=b&&b.firstChild);if(!b){b=e.canvas.appendChild(this.create("svg"));for(var f=0;f<this.events.length;f++)b.addEventListener?b.addEventListener(this.events[f],this.dispatch,!1):b.attachEvent("on"+this.events[f],this.dispatch);c=b.firstChild}a.$g=b;var g=e.width+e.left+e.right,h=e.height+e.top+e.bottom;b.style.width=g+s,b.style.height=h+s,b.style.clip="rect(0 "+g+s+" "+h+s+" 0)"}c=this.fill(c,a,d);var i=this.scale,j=e.transform,k=e.left+j.x,l=e.top+j.y;this.scale*=j.k;for(var f=0;f<e.children.length;f++){e.children[f].$g=c=this.expect(c,"g",{transform:"translate("+k+","+l+")"+(j.k!=1?" scale("+j.k+")":"")}),this.updateAll(e.children[f]);if(!c.parentNode||c.parentNode.nodeType===11){b.appendChild(c);var m=w[c.svgtype];m&&typeof m.onappend==="function"&&m.onappend(c,a[d])}c=c.nextSibling}this.scale=i,c=this.stroke(c,a,d)}return c},pv.VmlScene.image=function(a){var b=a.$g.firstChild;for(var c=0;c<a.length;c++){var d=a[c];if(!d.visible)continue;b=this.fill(b,a,c);if(!d.image){b=new Image,b.src=d.url;var e=b.style;e.position="absolute",e.top=d.top,e.left=d.left,e.width=d.width,e.height=d.height,e.cursor=d.cursor,e.msInterpolationMode="bicubic"}b=this.append(b,a,c),b=this.stroke(b,a,c)}return b},pv.VmlScene.label=function(a){var b=a.$g.firstChild;for(var c=0;c<a.length;c++){var d=a[c];if(!d.visible)continue;var e=d.textStyle;if(!e.opacity||!d.text)continue;var g={};d.cursor&&(g.cursor=d.cursor),b=this.expect(b,"text",g,{font:d.font,textDecoration:d.textDecoration,top:d.top+s,left:d.left+s,position:"absolute",display:"block",lineHeight:1,whiteSpace:"nowrap",zoom:1,cursor:"default",color:f(e.color)||"black"});var h=180*d.textAngle/Math.PI;if(h){var i=~~h%360*n,j=Math.cos(i),k=Math.sin(i);b.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11="+j.toFixed(8)+","+"M12="+ -k.toFixed(8)+","+"M21="+k.toFixed(8)+","+"M22="+j.toFixed(8)+",sizingMethod='auto expand')\";"}var l=d.text.replace(/\s+/g," ");p.style.font=d.font,p.innerText=l;var m=b.style;d.textAlign==="center"?m.marginLeft=-Math.ceil(p.offsetWidth/2)+s:d.textAlign==="right"?m.marginLeft=-(p.offsetWidth+d.textMargin)+s:d.textAlign==="left"&&(m.marginLeft=d.textMargin+s),d.textBaseline==="middle"?m.marginTop=-Math.floor(p.offsetHeight*.45)+s:d.textBaseline==="top"?m.marginTop=1+s:d.textBaseline==="bottom"&&(m.marginTop=-p.offsetHeight+s),b.innerText=l,b=this.append(b,a,c)}return b},"now"in Date||(Date.now=function(){return(new Date).valueOf()})}()