add multi-button choice to notify_document class
[brisk.git] / web / commons.js
index 192094d..82fd5fe 100644 (file)
@@ -613,6 +613,200 @@ function div_show(div)
     div.style.visibility = "visible";
 }
 
+function notify_document(st, text, tout, butt, w, h, is_opa, block_time)
+{
+    var clo, clodiv_ctx, clodiv_wai, box;
+    var i, t = this;
+
+    this.st = st;
+
+    this.ancestor = document.body;
+
+    this.st.st_loc_new++;
+
+    clodiv_ctx = document.createElement("div");
+    clodiv_ctx.className = "notify_clo";
+
+    for (i = 0 ; i < butt.length ; i++) {
+        clo = document.createElement("input");
+        clo.type = "submit";
+        clo.className = "button";
+        clo.style.bottom = "4px";
+        clo.obj = this;
+        clo.value = butt[i];
+        clo.onclick = function () { this.obj.hide() };
+        formsub_hilite(clo);
+        clodiv_ctx.appendChild(clo);
+    }
+
+
+    // if (block_time > 0) {
+    //     clo.value = "leggere, prego.";
+    //     this.butt = butt;
+    // }
+    // else {
+    //     this.clodiv = clodiv_ctx;
+    //     // this.clo = clo;
+    // }
+
+
+
+
+
+    // this.clo = clo;
+    this.clodiv = clodiv_ctx;
+
+
+    cont = document.createElement("div");
+
+    cont.style.borderBottomStyle = "solid";
+    cont.style.borderBottomWidth = "1px";
+    cont.style.borderBottomColor = "gray";
+    cont.style.height = (h - 30)+"px";
+    cont.style.overflow = "auto";
+    cont.innerHTML = text;
+
+    box =  document.createElement("div");
+    if (is_opa)
+        box.className = "notify_opaque";
+    else
+        box.className = "notify";
+
+    box.style.zIndex = 200;
+    box.style.width  = w+"px";
+    box.style.marginLeft  = -parseInt(w/2)+"px";
+    box.style.height = h+"px";
+    box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
+    box.appendChild(cont);
+    box.appendChild(this.clodiv);
+    box.style.visibility = "visible";
+
+    this.notitag = box;
+
+    this.ancestor.appendChild(box);
+
+    this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
+
+    // if (block_time != 0) {
+    //     this.tblkid = setTimeout(function(obj){ obj.clo.value = obj.butt; obj.clo.onclick = obj.input_hide; formsub_hilite(obj.clo); obj.clo.focus(); }, block_time, this);
+    // }
+    // else {
+    // formsub_hilite(clo);
+    // clo.focus();
+    // }
+
+}
+
+
+function notify_document_old(st, text, tout, butt, w, h, is_opa, block_time)
+{
+    var clo, clodiv, box;
+    var t = this;
+
+    this.st = st;
+
+    this.ancestor = document.body;
+
+    this.st.st_loc_new++;
+
+    clo = document.createElement("input");
+    clo.type = "submit";
+    clo.className = "button";
+    clo.style.bottom = "4px";
+    clo.obj = this;
+    if (block_time > 0) {
+        clo.value = "leggere, prego.";
+        this.butt = butt;
+    }
+    else {
+        clo.value = butt;
+        clo.onclick = this.input_hide;
+    }
+
+    clodiv = document.createElement("div");
+    clodiv.className = "notify_clo";
+    this.clo = clo;
+    this.clodiv = clodiv;
+
+    clodiv.appendChild(clo);
+
+    cont = document.createElement("div");
+
+    cont.style.borderBottomStyle = "solid";
+    cont.style.borderBottomWidth = "1px";
+    cont.style.borderBottomColor = "gray";
+    cont.style.height = (h - 30)+"px";
+    cont.style.overflow = "auto";
+    cont.innerHTML = text;
+
+    box =  document.createElement("div");
+    if (is_opa)
+        box.className = "notify_opaque";
+    else
+        box.className = "notify";
+
+    box.style.zIndex = 200;
+    box.style.width  = w+"px";
+    box.style.marginLeft  = -parseInt(w/2)+"px";
+    box.style.height = h+"px";
+    box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
+    box.appendChild(cont);
+    box.appendChild(clodiv);
+    box.style.visibility = "visible";
+
+    this.notitag = box;
+
+    this.ancestor.appendChild(box);
+
+    this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
+
+    if (block_time != 0) {
+        this.tblkid = setTimeout(function(obj){ obj.clo.value = obj.butt; obj.clo.onclick = obj.input_hide; formsub_hilite(obj.clo); obj.clo.focus(); }, block_time, this);
+    }
+    else {
+        formsub_hilite(clo);
+        clo.focus();
+    }
+
+}
+
+notify_document.prototype = {
+    ancestor: null,
+    st: null,
+    notitag: null,
+    toutid: null,
+    clo: null,
+    clodiv: null,
+    butt: null,
+    tblkid: null,
+
+    ret: -1,
+
+    ret_get: function()
+    {
+        // alert("quiz: "+this.rett);
+        return this.ret;
+    },
+
+    unblock: function()
+    {
+       if (this.st.st_loc < this.st.st_loc_new) {
+           this.st.st_loc++;
+       }
+    },
+
+    hide: function()
+    {
+        this.ret = 1;
+       clearTimeout(this.toutid);
+       this.ancestor.removeChild(this.notitag);
+       this.unblock();
+    }
+}
+
+
+
+
 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
 {
     var clo, box;