1.SVG的放大缩小以及元素获取
$(function(){
//如果浏览器不支持SVG图片,则会转为PNG
$('.svgimg').svgmagic();
$("#testsvg").css({"width":"60%","padding-top":"50px","padding-left":"20%"});
$("#inner").css({"position":"fixed","padding-left":"0"});
findSVGElements();
$(".svgZoomBtn").click(function(){ //控制图片放大缩小的点击事件
var zoom = $(this).attr("zoom");
var svgId = $(this).attr("svg");
var cWidth = $("#"+svgId).width();
var cHeight = $("#"+svgId).height();
if(zoom>0){
//cWidth += cWidth;
// cHeight += cHeight;
cWidth += 200;
cHeight += 200;
}else if(zoom<0){
// cWidth -= cWidth*0.5;
//cHeight -= cHeight*0.5;
cWidth -= 200;
cHeight -= 200;
}else{
cWidth = 1200;
cHeight =800;
}
$("#"+svgId).width(cWidth);
$("#"+svgId).height(cHeight);
});
});
function getSubDocument(embedding_element){ //获取svg的dom对象好对其进操作
if (embedding_element.contentDocument) {
return embedding_element.contentDocument;
}else {
var subdoc = null;
try {
subdoc = embedding_element.getSVGDocument();
} catch(e) {}
return subdoc;
}
}
function findSVGElements(){ //在这个方法里对g节点进行筛选并附加事件
var elm= document.getElementById("testsvg");
var subdoc = getSubDocument(elm);
if (subdoc){
var allGNodes_ = subdoc.querySelectorAll("svg g");
allGNodes = $(allGNodes_);
allGNodes.each(function(){
$(this).click(function(e){
if($(this).parent()[0].tagName=="g" && $(this).children("text").length==0){
//点击了文字节点
var gId=$(this).attr("id");
if(/^yc/.test(gId)){
createMenu($(this).attr("id"),e,1);
}else if(/^gz/.test(gId)){
createMenu($(this).attr("id"),e,2);
}else if(/^zd/.test(gId)){
createMenu($(this).attr("id"),e,3);
}
}
});
});
}
}
function createMenu(id,event,flag){
var e=event || window.event;//兼容ie 和FF的鼠标事件获取
$('#mouse_menu').empty();
if(flag==1){
$("#mouse_menu").menu('appendItem',{id:"ycCurve",text:"遥测曲线"});
$("#ycCurve").click(function(){
$('#ycqx').window('open');
var tab1=$("#ycqx_tabs").tabs("getTab","曲线");
var tab2=$("#ycqx_tabs").tabs("getTab","表格");
$('#ycqx_tabs').tabs('update', {
tab: tab1,
options: {
href: 'http://localhost:8080/cgsrProject/ycCurve' // the new content URL
}
});
$('#ycqx_tabs').tabs('update', {
tab: tab2,
options: {
href: 'http://localhost:8080/cgsrProject/ycTable' // the new content URL
}
});
});
$('#mouse_menu').menu('show', {
left: e.screenX-3,
top: e.screenY-118
});
}else if(flag==2){
$("#mouse_menu").menu('appendItem',{id:"yxTable",text:"遥信列表"});
$("#yxTable").click(function(){
$('#yx_Table').window('open');
});
$("#mouse_menu").menu('appendItem',{id:"ycTable",text:"遥测列表"});
$("#ycTable").click(function(){
$('#yc_Table').window('open');
});
$('#mouse_menu').menu('show', {
left: e.screenX-3,
top: e.screenY-118
});
}else{
$("#mouse_menu").menu('appendItem',{id:"yxTable",text:"遥信列表"});
$("#yxTable").click(function(){
$('#zd_yxTable').window('open');
});
$("#mouse_menu").menu('appendItem',{id:"ycTable",text:"遥测列表"});
$("#ycTable").click(function(){
$('#zd_ycTable').window('open');
});
$("#mouse_menu").menu('appendItem',{id:"ycCurve",text:"遥测曲线"});
$("#ycCurve").click(function(){
$('#zd_ycqx').window('open');
});
$("#mouse_menu").menu('appendItem',{id:"txStatis",text:"通信统计"});
$("#txStatis").click(function(){
$('#wltx').window('open');
});
$('#mouse_menu').menu('show', {
left: e.screenX-3,
top: e.screenY-118
});
};
};
2.easyui的复习
在easyui的tabs里面通过href的方式加载内容的话,他会自动的过滤掉除了body以外的内容,这样的话就不会加载head里面的内容,js的导入或者代码要放入body里,css要改成js加载,这样的话就不会使css和js失效了。
3.springmvc遇到的问题
mvc的@responsebody来返回json参数很方便,但是不要忘记<mvc:annotation-driven ></mvc:annotation-driven>标签了。
4.对自己加油,尽快学好hightchart和echarts3.