From: Matteo Nastasi (mop) Date: Tue, 19 Nov 2013 07:26:04 +0000 (+0100) Subject: add multi-button choice to notify_document class X-Git-Tag: v4.11.0~30 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=e22dc9f5d5b482780e577ca5f8c5a08c8cc9bc84;p=brisk.git add multi-button choice to notify_document class --- diff --git a/web/commons.js b/web/commons.js index 192094d..82fd5fe 100644 --- a/web/commons.js +++ b/web/commons.js @@ -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; diff --git a/web/notidoc_test.php b/web/notidoc_test.php index b309c58..b892ccb 100644 --- a/web/notidoc_test.php +++ b/web/notidoc_test.php @@ -12,6 +12,7 @@ var subst = ""; var gst = new globst(); var nd; + var tva; window.onload = function() { var i, sss = ""; @@ -20,7 +21,9 @@ sss += "solo una prova
"; } - nd = new notify_document(gst, sss, 4000, "pippo", 200, 200, true, 2000); + nd = new notify_document(gst, sss, 4000, [ "pippo", "pluto", "paperino" ], 200, 200, true, 2000); + + tva = setInterval(function(ndd){ console.log("nd.ret = "+ndd.ret_get()); }, 3000, nd); } //-->