daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // PROGRESS BAR DYNAMIC CLASS
  2.  
  3. defineDynamicClass("dprogressbar", function(el){
  4.   var value = parseFloat(el.dataset.value); //value: 0 -> 1
  5.   var color = el.dataset.color; //color: css color
  6.   var bgcolor = el.dataset.bgcolor; //bgcolor: css color
  7.   var content = el.innerHTML;
  8.   el.innerHTML = "";
  9.  
  10.   var inner = document.createElement("div");
  11.   inner.classList.add("inner");
  12.   el.appendChild(inner);
  13.  
  14.   var label = document.createElement("div");
  15.   label.classList.add("label");
  16.   label.innerHTML = content;
  17.   el.appendChild(label);
  18.  
  19.   el.style.backgroundColor = bgcolor;
  20.   inner.style.backgroundColor = color;
  21.  
  22.   //set label font size
  23.   label.style.fontSize = "1em";
  24.  
  25.   inner.style.width = Math.round(value*100)+"%";
  26. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top