From 8e3b6a3290ab7e898ecd00dccbc2f992fff6cbae Mon Sep 17 00:00:00 2001 From: zhangwenqing Date: Fri, 3 Aug 2018 19:51:56 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=97=A5=E5=BF=97=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=BF=87=E9=95=BF=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=20=20=202=E3=80=81=E7=95=8C=E9=9D=A2=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E6=82=AC=E5=81=9C=E4=BA=8B=E4=BB=B6=EF=BC=88=E6=B4=AA=E5=BA=86?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/WEB-INF/include/header.jsp | 9 +++- src/main/webapp/static/pages/css/pageLogs.css | 16 +++++++ .../webapp/static/pages/scripts/pageLogs.js | 43 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/main/webapp/static/pages/css/pageLogs.css create mode 100644 src/main/webapp/static/pages/scripts/pageLogs.js diff --git a/src/main/webapp/WEB-INF/include/header.jsp b/src/main/webapp/WEB-INF/include/header.jsp index 76e97a4bc..0032e71d5 100644 --- a/src/main/webapp/WEB-INF/include/header.jsp +++ b/src/main/webapp/WEB-INF/include/header.jsp @@ -33,6 +33,10 @@ + + + + + \ No newline at end of file diff --git a/src/main/webapp/static/pages/css/pageLogs.css b/src/main/webapp/static/pages/css/pageLogs.css new file mode 100644 index 000000000..1eb6d7ab7 --- /dev/null +++ b/src/main/webapp/static/pages/css/pageLogs.css @@ -0,0 +1,16 @@ +/* logs page */ +table.logTb { + table-layout: fixed; +} + +table.logTb td { + width: 100px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -icab-text-overflow: ellipsis; + -khtml-text-overflow: ellipsis; + -moz-text-overflow: ellipsis; + -webkit-text-overflow: ellipsis; +} \ No newline at end of file diff --git a/src/main/webapp/static/pages/scripts/pageLogs.js b/src/main/webapp/static/pages/scripts/pageLogs.js new file mode 100644 index 000000000..277519ccb --- /dev/null +++ b/src/main/webapp/static/pages/scripts/pageLogs.js @@ -0,0 +1,43 @@ +$(document).ready(function() { + // 界面鼠标悬停事件 + $("table.logTb").find("td").not(":has(a)").bind("mouseover", function(){ + this.title=$(this).html(this.innerHTML.trim()).text(); + }); + + $("table.logTb th").each(function(){ + // 判断是否支持currentStyle属性 是:IE 否:FF or Chrome + var finalStyle = this.currentStyle ? this.currentStyle : document.defaultView.getComputedStyle(this , null); + var fontSize = (finalStyle.fontSize).replace("px",""); + + var px = getPixelsCount($(this).text(),fontSize)+55; + this.setAttribute('width',px+'px'); + }); +}) + + +// 获取界面标题字符串对等的像素值 +function getPixelsCount(str, strFontSize){ + // 字符串字符个数 + var stringCharsCount = str.length; + + // 像素值 + var stringPixelsCount = 0; + + var element = document.createElement("span"); + element.style.fontSize = strFontSize; // 设置span的fontSize + element.style.visibility = "hidden"; // 设置span不可见 + element.style.display = "inline-block"; + element.style.wordBreak = "break-all !important"; + + document.body.appendChild(element); + for(var i = 0; i < stringCharsCount; i++){ + if(str[i] == " "){ + element.innerHTML = " "; + }else{ + element.innerHTML = str[i]; + } + stringPixelsCount += element.offsetWidth; + } + + return stringPixelsCount; +} \ No newline at end of file