//////////////////////////////////////////////////////////////////////////// // // // // // JavaScript Allows You Moving DIV Dialogues // // // // // // http://www.smart-fish.org/webdesign/ // // script by Vaclav Kusak // //////////////////////////////////////////////////////////////////////////// var DialogueDragging = 0; var DialogueDraggingElem = null; var MouseXPos, MouseYPos = 0; var DialogueDefaultZIndex = 10; var DialogueOpened = false; var DialogueOpenedID = null; var DialoguesOpened = new Array(); function DialogueDefineGrid(evt) { evt = (evt) ? evt : (window.event) ? window.event : ""; if( evt ) { MouseXPos = evt.clientX; MouseYPos = evt.clientY; } } function DialogueStartDragging(elem) { DialogueDraggingElem = document.getElementById(elem); if( DialogueDraggingElem ) { DialogueDragging = 1; DialogueDraggingElem.style.zIndex = DialogueDefaultZIndex+1; } } function DialogueStopDragging() { DialogueDraggingElem.style.zIndex = DialogueDefaultZIndex; DialogueDraggingElem = null; DialogueDragging = 0; } function DialogueFollowCursor() { var X,Y; if( DialogueOpenedID != null ) dgZalozky.parent = DialogueOpenedID; if( DialogueDraggingElem && DialogueDragging == 1 ) { X = MouseXPos + document.documentElement.scrollLeft; Y = MouseYPos + document.documentElement.scrollTop; if( Y > 10 ) { DialogueDraggingElem.style.top = (Y - 12) +'px'; DialogueDraggingElem.style.left = (X - parseInt(DialogueDraggingElem.offsetWidth/2) ) +'px'; } else { DialogueStopDragging(); } } } function CloseDialogue(id) { var posledni = DialoguesOpened.pop(); id = posledni; var pocetDialogu = DialoguesOpened.length; var element = document.getElementById(id); if( pocetDialogu == 0 ) { var blanket = document.getElementById('blanket'); } if( element ) { element.style.display = 'none'; if( pocetDialogu == 0 ) { blanket.style.display = 'none'; DialogueOpened = false; DialogueOpenedID = null; } else { DialogueOpened = true; DialogueOpenedID = DialoguesOpened[pocetDialogu-1]; } } } function ShowDialogue(id) { var element = document.getElementById(id); var blanket = document.getElementById('blanket'); if( element ) { element.style.display = 'block'; blanket.style.display = 'block'; var elementBody = document.getElementById(id + '-MainBody'); elementBody.style.width = (Number(element.offsetWidth)-44) + 'px'; elementBody.style.height = (Number(element.offsetHeight)-58) + 'px'; DialogueOpened = true; DialogueOpenedID = id; } } function DialogueCheckModal(ID) { if( ID != DialoguesOpened[DialoguesOpened.length-1] ) { alert('Nejprve prosím uzavřete otevřený dialog'); } } function DisplayDialogue(dgName, dgTitle, dgBody, dgWidth, dgHeight) { var dg = document.getElementById(dgName); if( dg ) { var len = DialoguesOpened.length; DialoguesOpened[len] = dgName; document.getElementById(dgName+'-Title').innerHTML = dgTitle; document.getElementById(dgName+'-Body').innerHTML = dgBody; dg.style.width = dgWidth + 36 + 'px'; dg.style.height = dgHeight + 'px'; dg.setAttribute('onmousedown','DialogueCheckModal(\''+dgName+'\');'); var velikostProstredek = document.getElementById(dgName+'-bok-prostredek'); velikostProstredek.style.width = dgWidth + 'px'; velikostProstredek.style.height = dgHeight + 'px'; var mainParent = document.getElementById('middle'); var celkemx = mainParent.offsetWidth; var celkemy = mainParent.offsetHeight; //alert(celkemx+'-'+celkemy); var velikostVrch = document.getElementById(dgName+'-dialogue-vrh'); velikostVrch.style.width = dgWidth - 10 + 'px'; var velikostVrch = document.getElementById(dgName+'-dialogue-spodek'); velikostVrch.style.width = dgWidth - 10 + 'px'; var velikostConten = document.getElementById(dgName+'-dialogue-conten'); velikostConten.style.width = dgWidth - 10 + 'px'; velikostConten.style.height = dgHeight - 10 + 'px'; var velikostBok = document.getElementById(dgName+'-dialogue-bok'); velikostBok.style.height = dgHeight - 10 + 'px'; var velikostBok = document.getElementById(dgName+'-dialogue-bok2'); velikostBok.style.height = dgHeight - 10 + 'px'; dg.style.left = Math.round(celkemx/2) - Math.round(dgWidth/2) + 'px'; dg.style.top = '60px'; ShowDialogue(dgName); } }