onmouseup="end('mywindow_rBottom_corner');">
onmouseup="end('mywindow_top_drag');">
onmouseup="end('mywindow_bottom_drag');">
function MyWindow() {
/* 背景左下右下上 div */
var bgDiv = null;
var leftDiv = null;
var rightDiv = null;
varbottomDiv = null;
var topDiv = null;
/* ウィンドウの古い値 */
var oldTop = 100;
var oldLeft = 200;
var oldWidth = 500;
var oldHeight = 400;
var clickTopDivX = null;
var clickTopDivY = null;
/* 最大サイズかどうかを記録します */
var maxSize = false;
/* 調整するかどうかを記録します */
varAdjust = true;
/* ウィンドウ内でクリックしたかどうかを記録します */
var clickInWindow = false;
/* レコード追加オブジェクト */
var addObj = null;
/* マウスがダウンしているかどうかを記録します*/
var down = 0;
/*
* ウィンドウの 5 つの div を設定します
*/
this.setBackgroundDiv = function(idName) {
bgDiv = document.getElementById(idName);
};
this.setLeftDiv = function(idName) {
leftDiv = document.getElementById(idName);
};
this.setRightDiv = function(idName) {
rightDiv = document.getElementById(idName);
};
this.setBottomDiv = function(idName) {
bottomDiv = document.getElementById(idName);
}
this.setTopDiv = function(idName) {
topDiv = document.getElementById(idName);
}
/* ウィンドウのサイズを変更するかどうかを設定します */
this.setAdjust = function(Boolean) {
adjust = Boolean;
}
/* ウィンドウ div のイベントを初期化します */
this.initialEvent = function() {
document.onclick = judgeClick;
var close = document.getElementById("top_close_button");
close.onmouseover = closeMouseOver;
close.onmouseout = closeMouseOut;
close.onmousedown = closeMouseDown;
close.onclick = this.removeWindow;
var max = document.getElementById("top_max_button");
max.onmouseover = maxMouseOver;
max.onmouseout = maxMouseOut;
max.onmousedown = maxMouseDown;
max.onclick = showNormalOrMax;
var min = document.getElementById("top_min_button");
min.onmouseover = minMouseOver;
min.onmouseout = minMouseOut;
min.onmousedown = minMouseDown;
min.onclick = hiddenWindow;
}
/* 隠しウィンドウ */
this.hidden = function() {
bgDiv.style.display="none";
};
/* ウィンドウを表示 */
this.show = function() {
bgDiv.style.display="";
};
/*
* オブジェクトをウィンドウに追加し、削除します
*/
this.addObject = function(){
if (addObj == null) {
addObj = document.createElement("p");
addObj.innerHTML = "公鸡中の战斗机、OYE! 你太有才了!";
document.getElementById("central").appendChild(addObj);
}
}
this.deleteObject = function() {
addObj.parentNode.removeChild(addObj);
addObj = null;
}
/*
* ウィンドウ サイズ変更関数
* curTop curLeft: 新しい左上隅の座標
* curRight curBottom: 新しい右下隅の座標
* curWidth curHeight : 新しい幅と高さ
* ブール値: 新しいデータを記録するかどうか
*/
function changeWindowSize(curTop, curLeft, curWidth, curHeight, Boolean) {
bgDiv.style.top = curTop;
bgDiv.style.left = curLeft;
bgDiv.style.width = curWidth;
bgDiv.style.height = curHeight;
/* 新しいデータを記録します */
if (Boolean) {
oldTop = curTop;
oldLeft = curLeft;
oldWidth = curWidth;
oldHeight = curHeight;
}
bottomDiv.style.top = curHeight - 26;
var bDivRCorner = document.getElementById("mywindow_botton_right_corner");
bDivRCorner.style.left = curWidth - 12;
var tDivMiddleButtom = document.getElementById("mywindow_top_middle");
tDivMiddleButtom.style.left = curWidth - 72;
var tDivRightCorner = document.getElementById("mywindow_top_right_corner");
tDivRightCorner.style.left = curWidth - 2;
}
/* assign idName の画像を変更 */
function changeImage(idName, imgSrc) {
var image = document.getElementById(idName);
image.src = imgSrc;
}
/* ウィンドウの最大サイズを表示 */
this.showMaxSize = function() {
if (調整) {
maxSize = true;
changeImage("top_max_button", "image/window_control_resile_normall.bmp");
var maxWidth = screen.availWidth;
var maxHeight = screen.availHeight;
changeWindowSize(0, 0, maxWidth, maxHeight, false);
}
}
/* ウィンドウを削除 */
this.removeWindow = function() {
if (bgDiv != null)
bgDiv.parentNode.removeChild( bgDiv);
}
/*
* ウィンドウの上、左、幅、高さの値を取得
*/
this.getTop = function() {
alert("Myウィンドウの最上位ピクセルは次のとおりです: " bgDiv.offsetTop);
}
this.getLeft = function() {
alert("ウィンドウの左側のピクセルは次のとおりです: " bgDiv.offsetLeft);
}
this.getWidth = function() {
alert("ウィンドウの幅ピクセルは次のとおりです: " bgDiv.offsetWidth);
}
this.getHeight = function() {
alert("ウィンドウの高さのピクセルは次のとおりです: " bgDiv.offsetHeight);
}
/*
* マウスの位置を取得
* return [x, y]: マウスの x および y 座標
*/
function getMouseXY() {
var x = イベント。ページ X || (event.clientX
(document.documentElement.scrollLeft
|| document.body.scrollLeft
)
);
var y= イベント.pageY || (event.clientY
(document.documentElement.scrollTop
|| document.body.scrollTop
)
);
return [x, y];
}
/*
* マウスのクリックがウィンドウ内であるかどうかを判断します
* つまり、ウィンドウが生きているかどうかを判断します
*/
function subjectClick() {
/* マウスクリックサイトを取得 */
var coor = getMouseXY();
/* ウィンドウ内かどうかを判断します */
var myW = document.getElementById("mywindow");
var closeImage = document.getElementById("top_close_button");
var maxImage = document.getElementById("top_max_button");
var minImage = document.getElementById("top_min_button");
if (coor[0] >= myW.offsetLeft && coor[0] <= (myW.offsetLeft myW.offsetWidth)
&& coor[1] >= myW.offsetTop && coor [1] <= (myW.offsetHeight myW.offsetTop)) {
clickInWindow = true;
closeImage.src = "image/window_control_close_normall.bmp";
if(maxSize == true) {
maxImage.src = "image/window_control_resile_normall.bmp";
} else {
maxImage.src = "image/window_control_max_normall.bmp";
}
minImage.src = "image/window_control_min_normall.bmp";
} else {
clickInWindow = false;
closeImage.src = "image/window_control_close_blur.bmp";
if(maxSize == true) {
maxImage.src = "image/window_control_resile_blur.bmp";
} else {
maxImage.src = "image/window_control_max_blur.bmp";
}
minImage.src = "image/window_control_min_blur.bmp";
}
}
/*
* トップボタンイベント関数
* マウスダウン、マウス移動、マウスアップ、マウス移動があります
*/
関数closeMouseDown() {
changeImage("top_close_button", "image/window_control_close_mousedown.bmp");
}
function closeMouseOver() {
if(clickInWindow == true) {
changeImage("top_close_button", "image/window_control_close_mouseon.bmp");
} else {
changeImage("top_close_button", "image/window_control_close_blur.bmp");
}
}
function closeMouseOut() {
if(clickInWindow == true) {
changeImage("top_close_button", "image/window_control_close_normall.bmp");
} else {
changeImage("top_close_button", "image/window_control_close_blur.bmp");
}
}
function maxMouseDown(){
if (maxSize == true) {
changeImage("top_max_button", "image/window_control_resile_mousedown.bmp");
}
else {
changeImage("top_max_button", "image/window_control_max_mousedown.bmp");
}
}
function maxMouseOver() {
if (clickInWindow == true) {
if (maxSize == true) {
changeImage("top_max_button", "image/window_control_resile_mouseon.bmp");
}
else {
changeImage("top_max_button", "image/window_control_max_mouseon.bmp");
}
}
else {
if (maxSize == true) {
changeImage("top_max_button", "image/window_control_resile_blur.bmp");
}
else {
changeImage("top_max_button", "image/window_control_max_blur.bmp");
}
}
}
function maxMouseOut() {
if(clickInWindow == true) {
if (maxSize == true) {
changeImage( "top_max_button"、"image/window_control_resile_normall.bmp");
} else {
changeImage("top_max_button", "image/window_control_max_normall.bmp");
}
} else {
if (maxSize == true) {
changeImage("top_max_button", "image/window_control_resile_blur.bmp");
} else {
changeImage("top_max_button", "image/window_control_max_blur.bmp");
}
}
}
/* 最大マウス クリック イベント関数 */
function showNormalOrMax(){
if (maxSize &&Adjust) {
maxSize =間違い;
changeWindowSize(oldTop, oldLeft, oldWidth, oldHeight, true);
} else {
showMaxSize();
}
}
function minMouseDown() {
changeImage("top_min_button", "image/window_control_min_mousedown.bmp");
}
function minMouseOver() {
if(clickInWindow == true) {
changeImage("top_min_button", "image/window_control_min_mouseon.bmp");
} else {
changeImage("top_min_button", "image/window_control_min_blur.bmp");
}
}
function minMouseOut() {
if(clickInWindow == true) {
changeImage("top_min_button", "image/window_control_min_normall.bmp");
} else {
changeImage("top_min_button", "image/window_control_min_blur.bmp");
}
}
/*
* ドラッグイベント function
*/
this.start = function(idName) {
if(idName == "mywindow_top ") {
var coor = getMouseXY();
clickTopDivX = coor[0];
clickTopDivY = coor[1];
}
document.getElementById(idName).setCapture();
下 = 1;
}
this.move = function(idName) {
var curTop = oldTop;
var curLeft = oldLeft;
var curWidth = oldWidth;
var curHeight = oldHeight;
var coor = getMouseXY();
if (向下 && 調整 && !maxSize) {
if(idName == "mywindow_rBottom_corner") {
curLeft = coor[0];
curWidth = oldLeft - curLeft;
curHeight = coor[1] - oldTop;
if(curWidth curLeft = oldLeft oldWidth - 80;
}
} else if(idName == "mywindow_left_corner") {
curTop = coor[1];
curLeft = coor[0];
curWidth = oldLeft - curLeft;
curHeight = oldTop - curTop;
if(curHeight curTop = oldTop oldHeight - 40;
}
if(curWidth curLeft = oldLeft oldWidth - 80;
}
} else if(idName == "mywindow_right_corner") {
curTop = coor[1];
curWidth = coor[0] - curLeft;
curHeight = oldHeight oldTop - curTop;
if(curHeight curTop = oldTop oldHeight - 40;
}
} else if(idName == "mywindow_top") {
curTop = curTop coor[1] - clickTopDivY;
curLeft = curLeft coor[0] - clickTopDivX;
clickTopDivX = coor[0];
clickTopDivY = coor[1];
} else if(idName == "mywindow_right") {
curWidth = coor[0] - oldLeft;
} else if(idName == "mywindow_left") {
curLeft = coor[0];
curWidth = oldLeft - curLeft;
if(curWidth curLeft = oldLeft oldWidth - 80;
}
} else if(idName == "mywindow_top_drag") {
curTop = coor[1];
curHeight = oldTop - curTop;
if(curHeight curTop = oldTop oldHeight - 40;
}
} else if(idName == "mywindow_bottom_drag"){
curHeight = coor[1] - oldTop;
} else {
//拖曳視窗右角
curWidth = coor[0] - oldLeft;
curHeight = coor[1] - oldTop;
}
if(curWidth curWidth = 80;
}
if(curHeight curHeight = 40;
}
changeWindowSize(curTop, curLeft, curWidth, curHeight, true);
}
}
this.end = function(idName) {
down = 0;
document.getElementById(idName).releaseCapture();
}
}