jQuery实现网页进度显示插件方法

时间:2020-11-09 17:30:03 jQuery Mobile 我要投稿

jQuery实现网页进度显示插件方法

  使用js编写 可以灵活的生成进度条 方便进对一些工作进度进行图形显示

  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”);

  //使用工具对页面绘制相关流程步骤图形显示

  StepTool.drawStep(currentStep,stepListJson);

  //回调函数

  function mycall(restult){

  // alert(“mycall”+result.value+“:“+result.text);

  StepTool.drawStep(result.value,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");

  //使用工具对页面绘制相关流程步骤图形显示

  StepTool.drawStep(currentStep,stepListJson);

  //回调函数

  function mycall(restult){

  // alert("mycall"+result.value+":"+result.text);

  StepTool.drawStep(result.value,stepListJson);

  //TODO...这里可以填充点击步骤的后加载相对应数据的代码

  }

  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={

  /**

  * 绘制到目标位置

  */

  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+="

  ";

  for (var i=0; i<this.Steps.length;i++){

  this.stepAllHtml+=this.Steps[i].htmlCode;

  }

  this.stepAllHtml+="";

  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=""+this.StepNum+"";

  stepHtml=stepHtml+""+this.StepText+"";

  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){//当前步骤,下一个未进行,并且不是最后一个

  classSype="coressStep";

  }else if(this.currStep==this.StepNum&&this.StepNum==this.totalCount){//当前步骤 并且是最后一步

  classSype="finshlast";

  }else if(this.currStep<this.StepNum&&this.StepNum==this.totalCount){//未进行步骤,并且是最后一个

  classSype="last";

  } else if(this.currStep<this.StepNum){//未进行的步骤

  classSype="loadStep";

  } else if(this.currStep>this.StepNum){//已进行的步骤

  classSype="finshStep";

  }

  stepHtml="

  "+stepHtml+"";

  this.htmlCode=stepHtml;

  }

  }


【 jQuery实现网页进度显示插件方法】相关文章:

1.关于jQuery实现高亮显示的方法介绍

2.jQuery定义插件的方法

3.关于jQuery实现页面顶部显示的进度条效果完整实例

4.jQuery插件扩展extend的简单实现原理介绍

5.关于jquery简单图片切换显示效果实现方法介绍

6.关于jQuery实现鼠标单击网页文字后在文本框显示的方法介绍

7.纯CSS和jQuery实现的在页面顶部显示的进度条效果

8.关于Jquery插件编写