电力项目十三--js添加浮动框

修改page/menu/loading.jsp页面
首先,页面中引入浮动窗样式css
<!-- 浮动窗口样式css begin -->
<style type="text/css">
#msg_win{border:1px solid #A67901;background:#EAEAEA;width:240px;position:absolute;right:;font-size:12px;font-family:Arial;margin:0px;display:none;overflow:hidden;z-index:;}
#msg_win .icos{position:absolute;top:2px;*top:0px;right:2px;z-index:;}
.icos a{float:left;color:#833B02;margin:1px;text-align:center;font-weight:bold;width:14px;height:22px;line-height:22px;padding:1px;text-decoration:none;font-family:webdings;}
.icos a:hover{color:#fff;}
#msg_title{background:#BBDEF6;border-bottom:1px solid #A67901;border-top:1px solid #FFF;border-left:1px solid #FFF;color:#;height:25px;line-height:25px;text-indent:5px;}
#msg_content{margin:5px;margin-right:;width:230px;height:126px;overflow:hidden;}
</style>
<!-- 浮动窗口样式css end -->
然后在</body>之前添加浮动窗代码:
<!-- 浮动窗口html代码 begin -->
<hr>
<div id="msg_win" style="display:block;top:490px;visibility:visible;opacity:1;">
<div class="icos">
<a id="msg_min" title="最小化" href="javascript:void 0">_</a><a id="msg_close" title="关闭" href="javascript:void 0">×
</a>
</div>
<div id="msg_title">
设备运行情况-->
</div>
<div id="msg_content" style="overflow:auto;height:150px;width:100%;white-space:nowrap">
<s:property value="devRun" escape="false"/>
</div>
</div>
<!-- 浮动窗口html代码 end -->
最后在末尾添加浮动窗的js:
<!-- 浮动窗口js,必须要放置到最后 begin-->
<script language="javascript">
var Message={
set: function() {//最小化与恢复状态切换
var set=this.minbtn.status == ?[,,'block',this.char[],'最小化']:[,,'none',this.char[],'展开'];
this.minbtn.status=set[];
this.win.style.borderBottomWidth=set[];
this.content.style.display =set[];
this.minbtn.innerHTML =set[]
this.minbtn.title = set[];
this.win.style.top = this.getY().top;
},
close: function() {//关闭
this.win.style.display = 'none';
window.onscroll = null;
},
setOpacity: function(x) {//设置透明度
var v = x >= ? '': 'Alpha(opacity=' + x + ')';
this.win.style.visibility = x<=?'hidden':'visible';//IE有绝对或相对定位内容不随父透明度变化的bug
this.win.style.filter = v;
this.win.style.opacity = x / ;
},
show: function() {//渐显
clearInterval(this.timer2);
var me = this,fx = this.fx(, , 0.1),t = ;
this.timer2 = setInterval(function() {
t = fx();
me.setOpacity(t[]);
if (t[] == ) {clearInterval(me.timer2) }
},);
},
fx: function(a, b, c) {//缓冲计算
var cMath = Math[(a - b) > ? "floor": "ceil"],c = c || 0.1;
return function() {return [a += cMath((b - a) * c), a - b]}
},
getY: function() {//计算移动坐标
var d = document,b = document.body, e = document.documentElement;
var s = Math.max(b.scrollTop, e.scrollTop);
var h = /BackCompat/i.test(document.compatMode)?b.clientHeight:e.clientHeight;
var h2 = this.win.offsetHeight;
return {foot: s + h + h2 + +'px',top: s + h - h2 - +'px'}
},
moveTo: function(y) {//移动动画
clearInterval(this.timer);
var me = this,a = parseInt(this.win.style.top)||;
var fx = this.fx(a, parseInt(y));
var t = ;
this.timer = setInterval(function() {
t = fx();
me.win.style.top = t[]+'px';
if (t[] == ) {
clearInterval(me.timer);
me.bind();
}
},);
},
bind:function (){//绑定窗口滚动条与大小变化事件
var me=this,st,rt;
window.onscroll = function() {
clearTimeout(st);
clearTimeout(me.timer2);
me.setOpacity();
st = setTimeout(function() {
me.win.style.top = me.getY().top;
me.show();
},);
};
window.onresize = function (){
clearTimeout(rt);
rt = setTimeout(function() {me.win.style.top = me.getY().top},);
}
},
init: function() {//创建HTML
function $(id) {return document.getElementById(id)};
this.win=$('msg_win');
var set={minbtn: 'msg_min',closebtn: 'msg_close',title: 'msg_title',content: 'msg_content'};
for (var Id in set) {this[Id] = $(set[Id])};
var me = this;
this.minbtn.onclick = function() {me.set();this.blur()};
this.closebtn.onclick = function() {me.close()};
this.char=navigator.userAgent.toLowerCase().indexOf('firefox')+?['_','::','×']:['','','r'];//FF不支持webdings字体
this.minbtn.innerHTML=this.char[];
this.closebtn.innerHTML=this.char[];
setTimeout(function() {//初始化最先位置
me.win.style.display = 'block';
me.win.style.top = me.getY().foot;
me.moveTo(me.getY().top);
},);
return this;
}
};
Message.init();
</script>
<!-- 浮动窗口js end-->
然后在控制层添加传递数据的代码:
public String loading(){
//查询设备运行情况,放置到浮动框中
//1:查询数据库运行监控表的数据,返回惟一ElecCommonMsg
ElecCommonMsg commonMsg = elecCommonMsgService.findCommonMsg();
//2:将ElecCommonMsg对象压入栈顶,支持表单回显
ValueUtils.putValueStack(commonMsg);
return "loading";
}
电力项目十三--js添加浮动框的更多相关文章
- 电力项目十一--js添加浮动框
1.添加浮动窗口样式 <!-- 浮动窗口样式css begin --> <style type="text/css"> #msg_win{border:1p ...
- 用JS添加文本框案例代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 电力项目七--js控制文字内容过长的显示和文本字数的显示
当文本框中文字内容过长时,需要调整显示的样式 如上图所示的样式 对应的代码为: <div id="showInfomation" style="visibility ...
- js实现浮动框跟随页面滚动,最后停留在原来位置
左边悬浮的二维码会跟随页面向上或者向下滚动,最后停留在原来的位置. <div style="background:red; width:1000px; height:7000px; m ...
- Ionic Js十四:浮动框
$ionicPopover $ionicPopover 是一个可以浮在app内容上的一个视图框. 实例 HTML 代码 <p> <button ng-click="open ...
- SSH电力项目
第一步:创建测试表Elec_Text: create table Elec_Text(textID varchar(50) not null primary key,textName varchar( ...
- hover时显示可跟随鼠标移动的浮动框,运用函数节流与去抖进行优化
在很多笔试面试题中总能看到js函数去抖和函数节流,看过很多关于这两者的讨论,最近终于在一个需求中使用了函数去抖(debounce)和函数节流(throttle). 需要完成的效果是,鼠标在表格的单元格 ...
- 非常强大的jQuery万能浮动框插件
支持hover, click, focus以及无事件触发:支持多达12种位置的定位,出界自动调整:支持页面元素加载,Ajax加载,下拉列表,提示层效果,tip类效果等:可自定义装载容器:内置UI不错的 ...
- SSH电力项目一 搭建Hibernate框架
Hibernate所需要的基本文件: ElectText.java ElecText.hbm.xml hibernate.cfg.xml 第一步:创建测试表Elec_Text: create tabl ...
随机推荐
- JavaScript之Web通讯
web通信,一个特别大的topic,涉及面也是很广的.因最近学习了 javascript 中一些 web 通信知识,在这里总结下.文中应该会有理解错误或者表述不清晰的地方,还望斧正! 一.前言 1. ...
- python中unicode和unicodeescape
在python中,unicode是内存编码集,一般我们将数据存储到文件时,需要将数据先编码为其他编码集,比如utf-8.gbk等. 读取数据的时候再通过同样的编码集进行解码即可. #python3 & ...
- 检查是否是移动端(Mobile)、ipad、iphone、微信、QQ等
<script type="text/javascript"> //判断访问终端 var browser={ versions:function(){ var u = ...
- 深入浅出Spring(一)Spring概述
现在很多的企业级项目中基本上都会用到了Spring框架,那么为什么会出现Spring,Spring是什么?这次的博文我主要为大家简单介绍一下Spring. Java EE优缺点 我们都知道在2003年 ...
- MySQL 5.7.16 zip包配置
截止2016/10/16 最新版本Mysql为5.7.16,之前写过一篇APMW搭建的文章(传送门:http://www.cnblogs.com/airoot/p/4131906.html)里面介绍的 ...
- Tomcat性能优化(二) 启动参数设置
一.tomcat绿色版设置方法 进入tomcat/bin目录下,找到catalina.bat文件在文件首行中插入下面这段配置即可. set JAVA_OPTS=-server -Djava.awt.h ...
- Python高级编程之生成器(Generator)与coroutine(二):coroutine介绍
原创作品,转载请注明出处:点我 上一篇文章Python高级编程之生成器(Generator)与coroutine(一):Generator中,我们介绍了什么是Generator,以及写了几个使用Gen ...
- shell中日期操作
1. date -d操作 date +"%Y%m%d" -d "+n days" #今天的后n天日期 date +"%Y%m%d" -d & ...
- 原生Orcale数据库连接
package tj.test.demo; import java.sql.Connection;import java.sql.DriverManager;import java.sql.Prepa ...
- 京东阅读PDF导出
适用平台:windows 需要软件:FastStone Capture(截图软件),TinyTask(操作录制软件) 1.打开京东阅读 2.设置截图软件 (1)设置截图区域(FastStone Cap ...