noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 116/323: Improve progress_bar : add a blockin


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 116/323: Improve progress_bar : add a blocking div
Date: Wed, 14 Mar 2018 17:38:35 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 78fd828aa4241ea9e91f43a796154f92e568c3e8
Author: Dany De Bontridder <address@hidden>
Date:   Sat Feb 3 15:28:27 2018 +0100

    Improve progress_bar : add a blocking div
---
 html/js/scripts.js                 | 26 ++++++++++++++++++++++----
 include/lib/progress_bar.class.php | 14 +++++++++++++-
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/html/js/scripts.js b/html/js/scripts.js
index a212591..6595ca9 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -3405,10 +3405,19 @@ var progressIdx = 0;
  * @param {string} p_taskid id to monitor
  * @param {int} p_dossier
  */
-function progress_bar_start(p_taskid)
+function progress_bar_start(p_taskid,p_message)
 {
     try {
         progressIdx++;
+        // block the window
+        var message="Un instant svp";
+        if ( p_message) {
+            message=p_message;
+        }
+        add_div({id:"blocking"+progressIdx,cssclass:"smoke-base smoke-visible 
"});
+        
+        
add_div({id:"message"+progressIdx,cssclass:"inner_box",style:"z-index:1000;position:fixed;top:30%;width:40%;left:30%"});
+        $("message"+progressIdx).update(message);
         // Create a div
         add_div({id: "progressDiv" + progressIdx, cssclass: "progressbar", 
html: '<span id="progressValue">0</span>'});
         // Check status every sec.
@@ -3433,8 +3442,14 @@ function progress_bar_check(p_idx, p_taskid)
                 try 
                 {
                     var answer=req.responseText.evalJSON();
-                    
-                    var progressValue = $('progressValue');
+                    var progress_div=$("progressDiv"+progressIdx);
+                    var a_child=progress_div.childNodes;
+                    var i=0;
+                    for (  i=0;i< a_child.length;i++) {
+                        if ( a_child[i].id="progressValue") {
+                            var progressValue = a_child[i];
+                        }
+                    }
                     var progress = parseFloat(progressValue.innerHTML);
                     if ( answer.value <= progress ) {
                         return;
@@ -3445,7 +3460,10 @@ function progress_bar_check(p_idx, p_taskid)
                     if (answer.value== 100) {
                         clearInterval(progressBar[p_idx]);
                         progressValue.innerHTML="Success";
-                        
Effect.BlindUp("progressDiv"+progressIdx,{duration:1.0,scaleContent:false})
+                        
Effect.BlindUp("progressDiv"+p_idx,{duration:1.0,scaleContent:false})
+                        $("message"+p_idx).remove();
+                        $("blocking"+p_idx).remove();
+                        setTimeout(function() { 
$("progressDiv"+progressIdx).remove } , 1100);
                     }
                 } catch (e) {
                     clearInterval(progressBar[p_idx]);
diff --git a/include/lib/progress_bar.class.php 
b/include/lib/progress_bar.class.php
index 04e6f24..50b1d08 100644
--- a/include/lib/progress_bar.class.php
+++ b/include/lib/progress_bar.class.php
@@ -108,8 +108,20 @@ class Progress_Bar
         header('Content-Type: application/json');
         echo json_encode(["value"=>$this->value]);
         if ($this->value>=100) {
-            $this->db->exec_sql("delete from progress where 
p_id=$1",[$this->task_id])
+            $this->db->exec_sql("delete from progress where 
p_id=$1",[$this->task_id]);
         }
         return;
     }
+    /**
+     * increment value with $p_step
+     * @param int $p_step
+     */
+    function increment($p_step)
+    {
+        if ($this->value+$p_step > 100 ) {
+            $this->set_value(100);
+            return;
+        }
+        $this->set_value($this->value+$p_step);
+    }
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]