/**
 * @author meg mei
 * @date 2014-4-11
 * @content deal with the context menu
 */
var WindowPanel = (function(window, undefined) {
    var WindowPanel = function() {
        var arguments = arguments, length = arguments.length;
        if(length === 0) {
            this._title = '';
            this._content = undefined;
        } else if(length === 1) {
            this._title = '';
            this._content = arguments[0];
        }
        else if(length === 2) {
            this._title = arguments[0];
            this._content = arguments[1];
        }
    };

    /**
     * alert function
     * @param events
     */
    WindowPanel.prototype.alert = function(events) {
        var div = document.createElement('div');
        div.id = 'alertPanel';
        div.className = 'alertpanel';
        var header = document.createElement('header');
        header.innerText = '';
        var ul = document.createElement('ul');
        var contentLi = document.createElement('div');
        contentLi.className = 'panelcontent';
        contentLi.innerText = this._content;
        var cancelLi = document.createElement('li');
        cancelLi.className = 'ok';
        cancelLi.innerHTML = '<div>Ok</div>';
        cancelLi.addEventListener('click', function () {
            this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
        });
        ul.appendChild(cancelLi);
        div.appendChild(header);
        div.appendChild(contentLi);
        div.appendChild(ul);
        document.body.appendChild(div);
    };

    /**
     * confirm function
     * @param events
     */
    WindowPanel.prototype.confirm = function(events) {
        if(null == document.getElementById('confirmPanel')) {
            var div = document.createElement('div');
            div.id = 'confirmPanel';
            div.className = 'confirmpanel';
            var header = document.createElement('header');
            header.innerText = this._title;
            var ul = document.createElement('ul');
            var contentLi = document.createElement('div');
            contentLi.className = 'panelcontent';
            contentLi.innerText = this._content;
            var sureLi = document.createElement('li');
            var cancelLi = document.createElement('li');
            sureLi.className = 'confirmsure';
            sureLi.innerHTML = '<div>Sure</div>';
            cancelLi.className = 'confirmcancel';
            cancelLi.innerHTML = '<div>Cancel</div>';
            for (var key in events) { //register event
                sureLi.addEventListener(key, events[key]);
            }
            sureLi.addEventListener('click', function () {
                this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
            });
            cancelLi.addEventListener('click', function () {
                this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
            });
            ul.appendChild(sureLi);
            ul.appendChild(cancelLi);
            div.appendChild(header);
            div.appendChild(contentLi);
            div.appendChild(ul);
            document.body.appendChild(div);
        }
    };

    /**
     * setTitle function
     * @param title
     */
    WindowPanel.prototype.setTitle = function(title){
        if(undefined == title){
            console.error('title is undefined !');
        }else{
            this._title = title;
        }
    };

    /**
     * setContent function
     * @param content
     */
    WindowPanel.prototype.setContent = function(content){
        if(undefined == content){
            console.error('content is undefined !');
        }else{
            this._content = content;
        }
    };



    return WindowPanel;
})(window);


@@ -177,22 +177,16 @@
  var arg
-uments
  = argum
@@ -405,30 +405,24 @@
 ontent = arg
-uments
 %5B0%5D;%0A       
@@ -485,22 +485,16 @@
 le = arg
-uments
 %5B0%5D;%0A   
@@ -521,22 +521,16 @@
 nt = arg
-uments
 %5B1%5D;%0A   
@@ -648,32 +648,97 @@
 ction(events) %7B%0A
+        if(null === document.getElementById('alertPanel')) %7B%0A    
         var div 
@@ -770,32 +770,36 @@
 'div');%0A        
+  
+  
 div.id = 'alertP
@@ -797,32 +797,36 @@
 = 'alertPanel';%0A
+    
         div.clas
@@ -847,32 +847,36 @@
 panel';%0A        
+    
 var header = doc
@@ -906,32 +906,36 @@
 ader');%0A        
+ 
+   
 header.innerText
@@ -937,24 +937,28 @@
 rText = '';%0A
+    
         var 
@@ -992,32 +992,36 @@
 ('ul');%0A        
+   
+ 
 var contentLi = 
@@ -1051,32 +1051,36 @@
 'div');%0A        
+    
 contentLi.classN
@@ -1101,32 +1101,36 @@
 ntent';%0A        
+ 
+   
 contentLi.innerT
@@ -1150,32 +1150,36 @@
 ontent;%0A        
+  
+  
 var cancelLi = d
@@ -1207,32 +1207,36 @@
 ('li');%0A        
+    
 cancelLi.classNa
@@ -1246,16 +1246,20 @@
 = 'ok';%0A
+    
         
@@ -1296,32 +1296,36 @@
 /div%3E';%0A        
+    
 cancelLi.addEven
@@ -1349,32 +1349,36 @@
 , function () %7B%0A
+    
             this
@@ -1452,36 +1452,44 @@
 tNode);%0A        
+   
+ 
 %7D);%0A
+    
         ul.appen
@@ -1506,32 +1506,36 @@
 celLi);%0A        
+    
 div.appendChild(
@@ -1543,32 +1543,36 @@
 eader);%0A        
+ 
+   
 div.appendChild(
@@ -1583,32 +1583,36 @@
 entLi);%0A        
+    
 div.appendChild(
@@ -1608,32 +1608,36 @@
 ppendChild(ul);%0A
+    
         document
@@ -1656,24 +1656,34 @@
 Child(div);%0A
+        %7D%0A
     %7D;%0A%0A    
@@ -1812,16 +1812,17 @@
 (null ==
+=
  documen
@@ -3469,16 +3469,17 @@
 fined ==
+=
  title)%7B
@@ -3742,16 +3742,17 @@
 fined ==
+=
  content

update navigation and finish remote context menu