jQuery實現網頁進度顯示插件方法

來源:文萃谷 9.75K

使用js編寫 可以靈活的生成進度條 方便進對一些工作進度進行圖形顯示

 jQuery實現網頁進度顯示插件方法

1、簡單的調用

//所有步驟的.數據

var stepListJson=[{StepNum:1,StepText:“第一步”},

{StepNum:2,StepText:"第二步"},

{StepNum:3,StepText:"第三步"},

{StepNum:4,StepText:"第四步"},

{StepNum:5,StepText:"第五步"},

{StepNum:6,StepText:"第六步"},

{StepNum:7,StepText:"第七步"}];

//當前進行到第幾步

var currentStep=5;

//new一個工具類

var StepTool = new Step_Tool_dc(“test”,“mycall”);

//使用工具對頁面繪製相關流程步驟圖形顯示

Step(currentStep,stepListJson);

//回調函數

function mycall(restult){

// alert(“mycall”+e+“:“+);

Step(e,stepListJson);

//TODO…這裏可以填充點擊步驟的後加載相對應數據的代碼

}

2、自定義皮膚修改

插件提供了兩套皮膚科共選擇如果不能滿足您的要求,則自己編寫CSS代碼即可

html代碼

複製代碼 代碼如下:

當前步驟:第步重新生成

//所有步驟的數據

var stepListJson=[{StepNum:1,StepText:"第一步"},

{StepNum:2,StepText:"第二步"},

{StepNum:3,StepText:"第三步"},

{StepNum:4,StepText:"第四步"},

{StepNum:5,StepText:"第五步"},

{StepNum:6,StepText:"第六步"},

{StepNum:7,StepText:"第七步"}];

//當前進行到第幾步

var currentStep=5;

//new一個工具類

var StepTool = new Step_Tool_dc("test","mycall");

//使用工具對頁面繪製相關流程步驟圖形顯示

Step(currentStep,stepListJson);

//回調函數

function mycall(restult){

// alert("mycall"+e+":"+);

Step(e,stepListJson);

//TODO...這裏可以填充點擊步驟的後加載相對應數據的代碼

}

javascript代碼

複製代碼 代碼如下:

/**

* @auther DangChengcheng 請保留作者

* @mailTo

*/

var Step_Tool_dc =function(ClassName,callFun){

sName=ClassName,

Fun=callFun,

s = new Array(),

AllHtml="";

}

Step_Tool_otype={

/**

* 繪製到目標位置

*/

createStepArray:function(currStep,stepListJson){

Step=currStep;

for (var i=0; i<th;i++){

var Step_Obj =new Step( Step,stepListJson[i]Num,stepListJson[i]Text,th);

Step_teStepHtml();

(Step_Obj);

}

},

drawStep:function(currStep,stepListJson){

r();

teStepArray(currStep,stepListJson);

if(th>0){

AllHtml+="

";

for (var i=0; i<th;i++){

AllHtml+=s[i]Code;

}

AllHtml+="";

jQuery("."+sName)(AllHtml);

teEvent();

} else{

jQuery("."+sName)("沒有任何步驟");

}

},createEvent:function(){

var self=this;

jQuery("."+sName+" ul li a")k(function(){

var num=jQuery(this)("data-value");

var text=jQuery(this)("data-text");

result={value:num,text:text} ;

eval(Fun+"(result)");

});

}

,clear:function(){

s=new Array();

jQuery("."+sName)("");

AllHtml="";

}

}

var Step=function(currStep,StepNum,StepText,totalCount){

Step=currStep,

Num=StepNum ,

Text=StepText,

lCount=totalCount,

Code="";

}

otype={

createStepHtml:function(){

var stepHtml=""+Num+"";

stepHtml=stepHtml+""+Text+"";

if(Step>lCount){

Step=lCount;

}else if(Step<=0){Step=1;}

if(Step>Num&&Num==1){

classSype="firstFinshStep";

} else if(Step==Num&&Num==1){

classSype="firstFinshStep_curr1";

}

else if(Step==Num&&Step!=lCount){//當前步驟,下一個未進行,並且不是最後一個

classSype="coressStep";

}else if(Step==Num&&Num==lCount){//當前步驟 並且是最後一步

classSype="finshlast";

}else if(Step<Num&&Num==lCount){//未進行步驟,並且是最後一個

classSype="last";

} else if(Step<Num){//未進行的步驟

classSype="loadStep";

} else if(Step>Num){//已進行的步驟

classSype="finshStep";

}

stepHtml="

"+stepHtml+"";

Code=stepHtml;

}

}

熱門標籤