wfsp_wev8.js
7.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//--------------------------------------
// 流程签字意见分页用javaScript
// 因此处iFrame上图片可能还没有加载完成,故把本方法中调整iFrame高度的代码去掉。
//--------------------------------------
function bodyresize(_document, iframeId, eachCnt){
try {
var objAList = _document.getElementsByTagName("A");
for(var i=0; i<objAList.length; i++){
var obj = objAList[i];
var href = obj.href;
var target = obj.target;
if(href.indexOf("javascript:") == -1){
obj.target = "_blank";
}
}
} catch (e){}
window.setTimeout(function(){
bodyresize(_document, iframeId, eachCnt);
},500);
}
//对签单意见内容中图像作调整。
function imgResize(docObj, ifrmID, imgObj){
var $imgObj = jQuery(imgObj);
//获取当前iFrame的宽度。因img标签父节点有padding属性,故需要在iFrame的宽度基础上减少一定距离。
var ifrmWidth = jQuery("#" + ifrmID).width() - 20;
var imgWidth = $imgObj.width();
var imgHeight = $imgObj.height();
//如果图片宽度大于iFrame宽度,则对图片进行等比例缩小。
if(imgWidth > ifrmWidth){
newHeight = ifrmWidth * imgHeight / imgWidth;
$imgObj.width(ifrmWidth);
$imgObj.height(newHeight);
}
ifrResize(docObj, ifrmID, 1);
}
//对存放签字意见内容的iFrame的高度作调整。
function ifrResize(docObj, ifrmID, eachCnt){
if (eachCnt >= 20) {
return;
}
eachCnt++ ;
var funObj = function(){
ifrResize(docObj, ifrmID, eachCnt);
}
//部分客户端加载比较慢,第一次调用时候iframe内body子节点的table标签的ViewForm样式(字体设置成9pt)
//可能没有应用完成。进行造成iframe的高度比 table高度大很多,而致使签字意见栏过高的问题。故在第一次
//时候,首先等待0.5秒再执行。
if (eachCnt == 2)
{
window.setTimeout(function(){
funObj();
},500);
return;
}
var bodyContentHeight = 0;
if (jQuery.client.browser == "Explorer") {
bodyContentHeight = docObj.body.scrollHeight+11;
} else if (jQuery.client.browser == "Firefox") {
bodyContentHeight = docObj.body.offsetHeight;
} else if (jQuery.client.browser == "Chrome" || jQuery.client.browser == "Safari") {
bodyContentHeight = jQuery(docObj.body).find("TABLE").height();
}
try{
var valHei = jQuery("#" + ifrmID).height();
//如果页面上当前iframe未加载完成,则等待500毫秒之后再次处理。
if(bodyContentHeight == 0){
window.setTimeout(new function(){ funObj(); } , 800);
} else {
jQuery("iframe[name=" + ifrmID+"]").height(bodyContentHeight);
//alert(jQuery(window.frames[ifrmID].document.body).find("table").get(0).offsetWidth+":"+jQuery("iframe[name=" + ifrmID+"]").parent().width());
if (jQuery(window.frames[ifrmID].document.body).find("table").get(0).offsetWidth >jQuery("iframe[name=" + ifrmID+"]").parent().width()){
jQuery("iframe[name=" + ifrmID+"]").height(bodyContentHeight+20);
}
}
jQuery("#" + ifrmID).attr("id", "");
}catch(e){
}
}
function setIframeBodyContent(_contentWindow, tmpContextDiv, iframeId, _iframeHtml) {
try {
_iframeHtml = _iframeHtml.replace(/<p><br\/><\/p>/,"").replace(/ /,"").replace("<table>","<table class='wfsigntbl'>");
jQuery(_contentWindow.document.body).html("<table style=\"border-spacing:0px !important;\" class=\"ViewForm\" width=99.9%><tr><td style=\"border:0px;border-spacing:0px !important;\">" + _iframeHtml + "</td></tr></table>");
} catch(e) {
alert(e);
}
}
function setIframeContent(_iframeId, _iframeHtml, docObj) {
try {
var _tcontentWindow = document.getElementById(_iframeId).contentWindow;
_tcontentWindow.document.write("<html ><LINK href=\"/css/Weaver_wev8.css\" type=text/css rel=STYLESHEET>"
+ "<LINK href=\"/css/rp_wev8.css\" rel=\"STYLESHEET\" type=\"text/css\">"
+ "<body style=\"border:0px;margin:0px;padding:0px;\" class='"+_iframeId+"' onclick=\"parent.triggerMouseupHandle()\" onload=\"" + "document.oncontextmenu = function () {parent.fckshowrightmenu(document, '" + _iframeId + "');return false;};document.onclick = parent.fckhiddenrightmenu;" + "\" bgColor=\"transparent\"></body></html>");
_tcontentWindow.document.close();
setIframeBodyContent(_tcontentWindow, _iframeId + "Div", _iframeId, _iframeHtml);
var len = 0;
//对签字意见内容中的手写签批图片的img标签加上 load事件。
var $imgObj = jQuery("img[alt='signture']", docObj);
$imgObj.each(function(i){
jQuery(this).bind("load", function(){
imgResize(docObj, _iframeId, this);
})
});
len += $imgObj.length;
//对签字意见内容中的电子签章图片的img标签加上 load事件。
$imgObj = jQuery("img[name='electricSignature']", docObj);
$imgObj.each(function(i){
jQuery(this).bind("load", function(){
imgResize(docObj, _iframeId, this);
})
});
len += $imgObj.length;
//对签字意见内容中的表单签章图片的object标签加上 load事件。
$imgObj = jQuery("object[name='formSignature']", docObj);
$imgObj.each(function(i){
jQuery(this).bind("load", function(){
imgResize(docObj, _iframeId, this);
})
});
len += $imgObj.length;
//如果签字意见内容不包含手写签批内容,则手动调用方法调整iFrame的高度。
if(len == 0){
ifrResize(docObj, _iframeId, 1);
}
} catch(e){}
}
function fckhiddenrightmenu(){
rightMenu.style.visibility="hidden";
if (!window.ActiveXObject) {
rightMenu.style.display = "none";
}
}
function getAbsolutePosition(_document, obj) {
var position = new Object();
position.x = 0;
position.y = 0;
var tempobj = obj;
while(tempobj != null && tempobj != _document.body) {
position.x += tempobj.offsetLeft + tempobj.clientLeft;
position.y += tempobj.offsetTop + tempobj.clientTop;
tempobj = tempobj.offsetParent;
}
position.x += document.body.scrollLeft;
if(document.getElementById("divWfBill")) {
position.y -= document.getElementById("divWfBill").scrollTop;
}
return position;
}
function fckshowrightmenu(_document, iframeId){
var event = getIframeEvent(iframeId);
var position = getAbsolutePosition(_document, document.getElementById(iframeId));
var rightedge = document.body.clientWidth - event.clientX - position.x;
var bottomedge = document.body.clientHeight - event.clientY - position.y;
if (rightedge < rightMenu.offsetWidth){
rightMenu.style.left = document.body.clientWidth - rightMenu.offsetWidth;
}else{
rightMenu.style.left = position.x + event.clientX;
}
//if (bottomedge < rightMenu.offsetHeight && document.getElementById(iframeId).offsetHeight <= document.body.clientHeight){
// rightMenu.style.top = document.body.clientHeight - rightMenu.offsetHeight;
//}else{
rightMenu.style.top = position.y + event.clientY;
//}
rightMenu.style.visibility = "visible";
if (!window.ActiveXObject) {
rightMenu.style.display = "";
}
return false
}
function getIframeEvent(iframeId) {
if (window.ActiveXObject) {
return document.getElementById(iframeId).contentWindow.event;// 如果是ie
}
func = getIframeEvent.caller;
while (func != null) {
var arg0 = func.arguments[0];
if (arg0) {
if ((arg0.constructor == Event || arg0.constructor == MouseEvent)
|| (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
return arg0;
}
}
func = func.caller;
}
return null;
}
function aboutVersion(versionid) {
alert("当前是V" + versionid + "版本");
}