All Components

ProgressBar / Chunk ProgressBar

Profile Completeness: 40%

HTML5/JavaScript 源码

<!DOCTYPE html>
<html>
 <head> 
  <title>Chunk ProgressBar</title> 
  <meta charset="utf-8"> 
  <link href="../content/shared/styles/examples-offline.css" rel="stylesheet"> 
  <link href="../../styles/kendo.common.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.rtl.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.default.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.default.min.css" rel="stylesheet"> 
  <script src="../../js/jquery.min.js"></script> 
  <script src="../../js/kendo.all.min.js"></script> 
  <script src="../content/shared/js/console.js"></script> 
  <script>
        
    </script> 
 </head> 
 <body> 
  <a class="offline-button" href="../index.html">Back</a> 
  <div id="example"> 
   <div class="demo-section k-content"> 
    <h4>Profile Completeness: <span id="completed">40%</span></h4> 
    <div id="profileCompleteness"></div> 
    <ul class="forms"> 
     <li> <label>First Name</label> <input type="text" name="firstName" value="" class="k-textbox" style="width: 100%;"> </li> 
     <li> <label>Last Name</label> <input type="text" name="lastName" value="" class="k-textbox" style="width: 100%;"> </li> 
     <li> <label>Birthday</label> <input id="birthdayInput" type="date" name="birthday" value="" style="width: 100%;"> </li> 
     <li> <label>Gender</label> <select id="genderInput" name="gender" style="width: 100%;"> <option value="male" selected>Male</option> <option value="female">Female</option> <option value="notsay">Rather not say</option> </select> </li> 
     <li> <label>Occupation</label> <input type="text" name="occupation" value="Software Developer" class="k-textbox" style="width: 100%;"> </li> 
    </ul> 
   </div> 
   <script>
        $(document).ready(function () {
            var pb = $("#profileCompleteness").kendoProgressBar({
                type: "chunk",
                chunkCount: 5,
                min: 0,
                max: 5,
                value: 2
            }).data("kendoProgressBar");

            $("#genderInput").kendoDropDownList();

            $("#birthdayInput").kendoDatePicker();

            $("#birthdayInput").change(function (e) {
                var currentDate = kendo.parseDate(this.value);
                if (!currentDate) {
                    this.value = "";
                }
            });

            $(".forms input").change(function () {
                var completeness = 5;
                $(".forms input").each(function () {
                    if (this.value == "") {
                        completeness--;
                    }
                });

                pb.value(completeness);
                $("#completed").text((completeness * 20) + "%");
            });
        });
    </script> 
   <style>

        #profileCompleteness {
            width: 100%;
        }

        .forms {
            list-style-type: none;
            padding: 2em 0 0;
            margin: 0;
        }
        
        .forms label {
            display: block;
            font-size: 12px;
            line-height: 1em;
            font-weight: bold;
            text-transform: uppercase;
            margin-bottom: 1em;
        }
        
        .forms li {
            margin-bottom: 1.5em;
        }
    </style> 
  </div>   
 </body>
</html>