基于jQuery實(shí)現(xiàn)網(wǎng)頁進(jìn)度顯示插件
相信大家都見過類似的網(wǎng)站功能,這種形式的進(jìn)度顯示可以很方便的讓用戶去理解和操作,
以下是插件的測試截圖 ,提供了兩個皮膚
使用js編寫 可以靈活的生成進(jìn)度條 方便進(jìn)對一些工作進(jìn)度進(jìn)行圖形顯示
1、簡單的調(diào)用
//所有步驟的數(shù)據(jù)
var stepListJson=[{StepNum:1,StepText:“第一步”},
{StepNum:2,StepText:"第二步"},
{StepNum:3,StepText:"第三步"},
{StepNum:4,StepText:"第四步"},
{StepNum:5,StepText:"第五步"},
{StepNum:6,StepText:"第六步"},
{StepNum:7,StepText:"第七步"}];
//當(dāng)前進(jìn)行到第幾步
var currentStep=5;
//new一個工具類
var StepTool = new Step_Tool_dc(“test”,“mycall”);
//使用工具對頁面繪制相關(guān)流程步驟圖形顯示
StepTool.drawStep(currentStep,stepListJson);
//回調(diào)函數(shù)
function mycall(restult){
// alert(“mycall”+result.value+“:“+result.text);
StepTool.drawStep(result.value,stepListJson);
//TODO…這里可以填充點(diǎn)擊步驟的后加載相對應(yīng)數(shù)據(jù)的代碼
}
2、自定義皮膚修改
插件提供了兩套皮膚科共選擇如果不能滿足您的要求,則自己編寫CSS代碼即可
html代碼
<title>無標(biāo)題文檔</title>
<!--<link rel="stylesheet" href="css/step-dc-style1.css" />-->
<link rel="stylesheet" href="css/step-dc-style1.css" />
<script type="text/javascript" src="./step-jquery-dc.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
<div class="step_context test">
</div>
當(dāng)前步驟:第<input type="text" value="5" id="currentStepVal" />步 <button onclick="StepTool.drawStep(jQuery('#currentStepVal').val(),stepListJson);" type="button">重新生成</button>
</body>
</html>
<script>
//所有步驟的數(shù)據(jù)
var stepListJson=[{StepNum:1,StepText:"第一步"},
{StepNum:2,StepText:"第二步"},
{StepNum:3,StepText:"第三步"},
{StepNum:4,StepText:"第四步"},
{StepNum:5,StepText:"第五步"},
{StepNum:6,StepText:"第六步"},
{StepNum:7,StepText:"第七步"}];
//當(dāng)前進(jìn)行到第幾步
var currentStep=5;
//new一個工具類
var StepTool = new Step_Tool_dc("test","mycall");
//使用工具對頁面繪制相關(guān)流程步驟圖形顯示
StepTool.drawStep(currentStep,stepListJson);
//回調(diào)函數(shù)
function mycall(restult){
// alert("mycall"+result.value+":"+result.text);
StepTool.drawStep(result.value,stepListJson);
//TODO...這里可以填充點(diǎn)擊步驟的后加載相對應(yīng)數(shù)據(jù)的代碼
}
</script>
javascript代碼
/**
* @auther DangChengcheng 請保留作者
* @mailTo dc2002007@163.com
*/
var Step_Tool_dc =function(ClassName,callFun){
this.ClassName=ClassName,
this.callFun=callFun,
this.Steps = new Array(),
this.stepAllHtml="";
}
Step_Tool_dc.prototype={
/**
* 繪制到目標(biāo)位置
*/
createStepArray:function(currStep,stepListJson){
this.currStep=currStep;
for (var i=0; i<stepListJson.length;i++){
var Step_Obj =new Step( this.currStep,stepListJson[i].StepNum,stepListJson[i].StepText,stepListJson.length);
Step_Obj.createStepHtml();
this.Steps.push(Step_Obj);
}
},
drawStep:function(currStep,stepListJson){
this.clear();
this.createStepArray(currStep,stepListJson);
if(this.Steps.length>0){
this.stepAllHtml+="<ul>";
for (var i=0; i<this.Steps.length;i++){
this.stepAllHtml+=this.Steps[i].htmlCode;
}
this.stepAllHtml+="</ul>";
jQuery("."+this.ClassName).html(this.stepAllHtml);
this.createEvent();
} else{
jQuery("."+this.ClassName).html("沒有任何步驟");
}
},createEvent:function(){
var self=this;
jQuery("."+this.ClassName+" ul li a").click(function(){
var num=jQuery(this).attr("data-value");
var text=jQuery(this).attr("data-text");
result={value:num,text:text} ;
eval(self.callFun+"(result)");
});
}
,clear:function(){
this.Steps=new Array();
jQuery("."+this.ClassName).html("");
this.stepAllHtml="";
}
}
var Step=function(currStep,StepNum,StepText,totalCount){
this.currStep=currStep,
this.StepNum=StepNum ,
this.StepText=StepText,
this.totalCount=totalCount,
this.htmlCode="";
}
Step.prototype={
createStepHtml:function(){
var stepHtml="\<span\>"+this.StepNum+"\</span\>";
stepHtml=stepHtml+"\<a href=\"#\" data-value=\""+this.StepNum+"\" data-text=\""+this.StepText+"\" \>"+this.StepText+"\</a\>";
if(this.currStep>this.totalCount){
this.currStep=this.totalCount;
}else if(this.currStep<=0){this.currStep=1;}
if(this.currStep>this.StepNum&&this.StepNum==1){
classSype="firstFinshStep";
} else if(this.currStep==this.StepNum&&this.StepNum==1){
classSype="firstFinshStep_curr1";
}
else if(this.currStep==this.StepNum&&this.currStep!=this.totalCount){//當(dāng)前步驟,下一個未進(jìn)行,并且不是最后一個
classSype="coressStep";
}else if(this.currStep==this.StepNum&&this.StepNum==this.totalCount){//當(dāng)前步驟 并且是最后一步
classSype="finshlast";
}else if(this.currStep<this.StepNum&&this.StepNum==this.totalCount){//未進(jìn)行步驟,并且是最后一個
classSype="last";
} else if(this.currStep<this.StepNum){//未進(jìn)行的步驟
classSype="loadStep";
} else if(this.currStep>this.StepNum){//已進(jìn)行的步驟
classSype="finshStep";
}
stepHtml="\<li class=\""+classSype+"\"\>"+stepHtml+"\</a\>";
this.htmlCode=stepHtml;
}
}
附上源碼下載 http://xiazai.jb51.net/201503/yuanma/step-jquery-dc(jb51.net).rar
以上就是本文的全部內(nèi)容了,希望大家能夠喜歡。
- C#中常使用進(jìn)度條的代碼
- asp.net(c#)開發(fā)中的文件上傳組件uploadify的使用方法(帶進(jìn)度條)
- Android文件下載進(jìn)度條的實(shí)現(xiàn)代碼
- 6款新穎的jQuery和CSS3進(jìn)度條插件推薦
- C#控制臺輸出進(jìn)度和百分比的實(shí)例代碼
- c#進(jìn)度條 progressBar 使用方法的小例子
- C# cmd中修改顯示(顯示進(jìn)度變化效果)的方法
- c#根據(jù)文件大小顯示文件復(fù)制進(jìn)度條實(shí)例
- android自定義進(jìn)度條漸變色View的實(shí)例代碼
- Jquery Uploadify上傳帶進(jìn)度條的簡單實(shí)例
- C# Winform下載文件并顯示進(jìn)度條的實(shí)現(xiàn)代碼
- Android中實(shí)現(xiàn)Webview頂部帶進(jìn)度條的方法
- php上傳文件并顯示上傳進(jìn)度的方法
- python下載文件時顯示下載進(jìn)度的方法
- C#進(jìn)度軸控件分享
相關(guān)文章
jquery ui resize 中border-box的bug修正
本文給大家分享的是jQuery ui resize中的一個樣式的小bug的解決方法,官方并沒有修復(fù),這里推薦給大家,有需要的小伙伴可以參考下。2015-04-04jquery中map函數(shù)與each函數(shù)的區(qū)別實(shí)例介紹
​jquery中的each函數(shù)和map函數(shù)的用法看起來差不多,但其實(shí)還是有一點(diǎn)區(qū)別的,each返回的是原來的數(shù)組,并不會新創(chuàng)建一個數(shù)組。而map方法會返回一個新的數(shù)組2014-06-06jQuery學(xué)習(xí)筆記之Ajax用法實(shí)例詳解
這篇文章主要介紹了jQuery學(xué)習(xí)筆記之Ajax用法,結(jié)合實(shí)例形式較為詳細(xì)的分析總結(jié)了jQuery中ajax的相關(guān)使用技巧,包括ajax請求、載入、處理、傳遞等,需要的朋友可以參考下2015-12-12基于Bootstrap和JQuery實(shí)現(xiàn)動態(tài)打開和關(guān)閉tab頁的實(shí)例代碼
這篇文章主要介紹了基于Bootstrap和JQuery實(shí)現(xiàn)動態(tài)打開和關(guān)閉tab頁的實(shí)例代碼,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-06-06淺析JQuery中的html(),text(),val()區(qū)別
jQuery中.html()用為讀取和修改元素的HTML標(biāo)簽,.text()用來讀取或修改元素的純文本內(nèi)容,.val()用來讀取或修改表單元素的value值。2014-09-09