acknowledgments update
[openemr.git] / phpmyadmin / js / tbl_gis_visualization.js
blob41b356d4ae464b243af39b2530b00fc23b1cdeee
1 var zoomFactor=1.5;var defaultX=0;var defaultY=0;var x;var y;var scale;var svg;function zoomAndPan(){var c=svg.getElementById("groupPanel");c.setAttribute("transform","translate("+x+", "+y+") scale("+scale+")");var e;var d;$("circle.vector").each(function(){e=$(this).attr("id");d=svg.getElementById(e);svg.change(d,{r:(3/scale),"stroke-width":(2/scale)})});var a;$("polyline.vector").each(function(){e=$(this).attr("id");a=svg.getElementById(e);svg.change(a,{"stroke-width":(2/scale)})});var b;$("path.vector").each(function(){e=$(this).attr("id");b=svg.getElementById(e);svg.change(b,{"stroke-width":(0.5/scale)})})}function selectVisualization(){if($("#choice").prop("checked")!=true){$("#openlayersmap").hide()}else{$("#placeholder").hide()}}function styleOSM(){var a=$("#placeholder");var b={border:"1px solid #aaa",width:a.width(),height:a.height(),"float":"right"};$("#openlayersmap").css(b)}function loadSVG(){var a=$("#placeholder");a.svg({onLoad:function(b){svg=b}});a.find("svg:nth-child(2)").remove()}function addZoomPanControllers(){var b=$("#placeholder");if($("#placeholder svg").length>0){var a=$("#pmaThemeImage").val();$('<img class="button" id="left_arrow" src="'+a+'west-mini.png">').appendTo(b);$('<img class="button" id="right_arrow" src="'+a+'east-mini.png">').appendTo(b);$('<img class="button" id="up_arrow" src="'+a+'north-mini.png">').appendTo(b);$('<img class="button" id="down_arrow" src="'+a+'south-mini.png">').appendTo(b);$('<img class="button" id="zoom_in" src="'+a+'zoom-plus-mini.png">').appendTo(b);$('<img class="button" id="zoom_world" src="'+a+'zoom-world-mini.png">').appendTo(b);$('<img class="button" id="zoom_out" src="'+a+'zoom-minus-mini.png">').appendTo(b)}}function resizeGISVisualization(){var b=$("#placeholder");var a=b.width();var c=$("#div_view_options").width()-48;b.width(c);$("svg").attr("width",c);defaultX=(c-a)/2;x=defaultX;y=0;scale=1}function initGISVisualization(){selectVisualization();resizeGISVisualization();styleOSM();drawOpenLayers();loadSVG();addZoomPanControllers();zoomAndPan()}function getRelativeCoords(b){var a=$("#placeholder").offset();return{x:b.pageX-a.left,y:b.pageY-a.top}}AJAX.registerTeardown("tbl_gis_visualization.js",function(){$("#choice").die("click");$("#placeholder").die("mousewheel");$("svg").die("dragstart");$("svg").die("mouseup");$("svg").die("drag");$("#placeholder").die("dblclick");$("#zoom_in").die("click");$("#zoom_world").die("click");$("#zoom_out").die("click");$("#left_arrow").die("click");$("#right_arrow").die("click");$("#up_arrow").die("click");$("#down_arrow").die("click");$(".vector").unbind("mousemove").unbind("mouseout")});AJAX.registerOnload("tbl_gis_visualization.js",function(){if($("table.gis_table").length>0){initGISVisualization()}$("#choice").live("click",function(){if($(this).prop("checked")==false){$("#placeholder").show();$("#openlayersmap").hide()}else{$("#placeholder").hide();$("#openlayersmap").show()}});$("#placeholder").live("mousewheel",function(c,e){var d=getRelativeCoords(c);if(e>0){scale*=zoomFactor;x=d.x-(d.x-x)*zoomFactor;y=d.y-(d.y-y)*zoomFactor;zoomAndPan()}else{scale/=zoomFactor;x=d.x-(d.x-x)/zoomFactor;y=d.y-(d.y-y)/zoomFactor;zoomAndPan()}return true});var b=0;var a=0;$("svg").live("dragstart",function(d,c){$("#placeholder").addClass("placeholderDrag");b=Math.round(c.offsetX);a=Math.round(c.offsetY)});$("svg").live("mouseup",function(c){$("#placeholder").removeClass("placeholderDrag")});$("svg").live("drag",function(d,c){newX=Math.round(c.offsetX);x+=newX-b;b=newX;newY=Math.round(c.offsetY);y+=newY-a;a=newY;zoomAndPan()});$("#placeholder").live("dblclick",function(c){scale*=zoomFactor;var d=getRelativeCoords(c);x=d.x-(d.x-x)*zoomFactor;y=d.y-(d.y-y)*zoomFactor;zoomAndPan()});$("#zoom_in").live("click",function(c){c.preventDefault();scale*=zoomFactor;width=$("#placeholder svg").attr("width");height=$("#placeholder svg").attr("height");x=width/2-(width/2-x)*zoomFactor;y=height/2-(height/2-y)*zoomFactor;zoomAndPan()});$("#zoom_world").live("click",function(c){c.preventDefault();scale=1;x=defaultX;y=defaultY;zoomAndPan()});$("#zoom_out").live("click",function(c){c.preventDefault();scale/=zoomFactor;width=$("#placeholder svg").attr("width");height=$("#placeholder svg").attr("height");x=width/2-(width/2-x)/zoomFactor;y=height/2-(height/2-y)/zoomFactor;zoomAndPan()});$("#left_arrow").live("click",function(c){c.preventDefault();x+=100;zoomAndPan()});$("#right_arrow").live("click",function(c){c.preventDefault();x-=100;zoomAndPan()});$("#up_arrow").live("click",function(c){c.preventDefault();y+=100;zoomAndPan()});$("#down_arrow").live("click",function(c){c.preventDefault();y-=100;zoomAndPan()});$(".vector").bind("mousemove",function(d){var c=$.trim(escapeHtml($(this).attr("name")));$("#tooltip").remove();if(c!=""){$('<div id="tooltip">'+c+"</div>").css({position:"absolute",top:d.pageY+10,left:d.pageX+10,border:"1px solid #fdd",padding:"2px","background-color":"#fee",opacity:0.9}).appendTo("body").fadeIn(200)}});$(".vector").bind("mouseout",function(c){$("#tooltip").remove()})});