var pk = pk || {};
(function(pk) {
    pk.modal = function(opt) {
        var e = opt.context || document.body;
        var h = opt.header;
        var c = opt.content;
        if (!e) {
            return;
        }
        var content = document.createElement('div');
        var mask = document.createElement('div');
        var box = document.createElement('div');
        var close = document.createElement('span');
        var header = document.createElement('div');
        var boxH = 0;
        header.innerHTML = h;
        content.innerHTML = c;
        pk.addClass(box, 'pk-modal-box');
        pk.addClass(close, 'pk-modal-close');
        pk.addClass(header, 'pk-modal-header').appendChild(close);
        pk.addClass(content, 'pk-modal-content');
        box.appendChild(header);
        box.appendChild(content);
        pk.addClass(mask, 'pk-modal-mask').appendChild(box);

        if (document.body.children.length > 0) {
            document.body.insertBefore(mask, document.body.children[0]);
        } else {
            document.body.appendChild(mask);
        }

        function closeModal() {
            pk.removeClass(mask, 'pk-show');
            setTimeout(function() {
                mask.parentNode.removeChild(mask);
            }, 500);
        }
        pk.bindEvent("click", mask, function(e) {
            if (e.target !== mask) {
                return;
            }
            closeModal();
        });
        pk.bindEvent("click", close, closeModal);
        pk.bindEvent("resize", window, function() {
            pk.center(box);
        });
        setTimeout(function() {
            pk.addClass(mask, 'pk-show');
        }, 10);

        boxH = box.offsetHeight;
        setInterval(function() {
            var boxHN = box.offsetHeight;
            if (boxH !== boxHN) {
                pk.center(box);
                boxH = boxHN;
            }
        }, 500);
        pk.center(box);

        if (opt.drag !== false && pk.drag) {
            pk.drag({
                element: box,
                handle: header,
                move: true
            });
        }
    };
    return pk;
})(pk);

@@ -63,54 +63,8 @@
 ) %7B%0A
-        var e = opt.context %7C%7C document.body;%0A
     
@@ -85,26 +85,29 @@
 t.header
-;%0A
+,%0A   
         
 var c = 
@@ -98,19 +98,16 @@
         
-var
  c = opt
@@ -120,726 +120,384 @@
 nt;%0A
-        if (!e) %7B%0A            return;%0A        %7D%0A        var content = document.createElement('div');%0A        var mask = document.createElement('div');%0A        var box = document.createElement('div');%0A        var close = document.createElement('span');%0A        var header = document.createElement('div');%0A        var boxH = 0;%0A        header.innerHTML = h;%0A        content.innerHTML = c;%0A        pk.addClass(box, 'pk-modal-box');%0A        pk.addClass(close, 'pk-modal-close');%0A        pk.addClass(header, 'pk-modal-header').appendChild(close);%0A        pk.addClass(content, 'pk-modal-content');%0A        box.appendChild(header);%0A        box.appendChild(content);%0A        pk.addClass(mask, 'pk-modal-mask').appendChild(box)
+%0A        var tpl = %22%3Cdiv class='pk-modal-mask'%3E%5C%0A%09%09%09%3Cdiv class='pk-modal-box'%3E%5C%0A%09%09%09%09%3Cdiv class='pk-modal-header'%3E%22 + h + %22%3Cspan class='pk-modal-close'%3E%3C/span%3E%3C/div%3E%5C%0A%09%09%09%09%3Cdiv class='pk-modal-content'%3E%22 + c + %22%3C/div%3E%5C%0A%09%09%09%3C/div%3E%5C%0A%09%09%3C/div%3E%22;%0A%0A        var el = pk.createEl(tpl),%0A         box = el.children%5B0%5D,%0A         header = box.children%5B0%5D,%0A         close = header.children%5B0%5D
 ;%0A%0A 
@@ -583,20 +583,18 @@
 tBefore(
-mask
+el
 , docume
@@ -666,28 +666,26 @@
 appendChild(
-mask
+el
 );%0A        %7D
@@ -741,28 +741,26 @@
 removeClass(
-mask
+el
 , 'pk-show')
@@ -813,20 +813,18 @@
         
-mask
+el
 .parentN
@@ -839,20 +839,18 @@
 veChild(
-mask
+el
 );%0A     
@@ -905,20 +905,18 @@
 click%22, 
-mask
+el
 , functi
@@ -952,20 +952,18 @@
 get !== 
-mask
+el
 ) %7B%0A    
@@ -1232,20 +1232,18 @@
 ddClass(
-mask
+el
 , 'pk-sh
@@ -1265,32 +1265,36 @@
 , 10);%0A%0A        
+var 
 boxH = box.offse
@@ -1292,32 +1292,37 @@
 box.offsetHeight
+ %7C%7C 0
 ;%0A        setInt

Update modal.js