http://gyazo.com/6f14b84000ff50e5f6e9b2c323bae217
var UI = {
maxZindex: 10000,
Window: function(title, data, options) {
var conf = {close: true, width: 'auto', height: 'auto', visible: true},
container = document.createElement('div'),
header = document.createElement('table'),
tr = document.createElement('tr'),
heading = document.createElement('td'),
buttons = document.createElement('td'),
content = document.createElement('div');
addEvent(header, 'mousedown', function() {
container.style.zIndex = this.maxZindex++;
});
this.show = function() {
container.style.display = 'block';
return false;
}
this.hide = function() {
container.style.display = 'none';
return false;
}
conf = extend(conf, options || {});
if (!conf.visible) {
this.hide();
}
container.className = 'ui-window-container';
header.className = 'ui-window-header';
heading.className = 'ui-window-heading';
buttons.className = 'ui-window-buttons';
heading.appendChild(document.createTextNode(title));
tr.appendChild(heading);
if (conf.close) {
var img = new Image();
img.src = '../img/close.png';
img.onclick = this.hide;
buttons.appendChild(img);
}
tr.appendChild(buttons);
header.appendChild(tr);
container.appendChild(header);
content.style.width = options.width;
content.style.height = options.height;
content.className = 'ui-window-content';
content.innerHTML = data;
container.appendChild(content);
document.body.appendChild(container);
makeMovable(container, header);
}
};
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/page.css">
<link rel="stylesheet" type="text/css" href="css/ui.css">
<script type="text/javascript" src="../js/base.js"></script>
<script type="text/javascript" src="../js/ui.js"></script>
<script type="text/javascript">
window.onload = function() {
var w = new UI.Window('Заголовок окна', '<p>Содержимое окна.</p>', {width: '10em', visible: false});
ge('clickme').onclick = w.show;
}
</script>
</head>
<body>
<div id="page">
<h1>Перетаскивание элементов</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<a id="clickme">Показать окно</a>
</div>
</body>
</html>