-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathprogressStep.min.js
More file actions
1 lines (1 loc) · 3.07 KB
/
progressStep.min.js
File metadata and controls
1 lines (1 loc) · 3.07 KB
1
(function(e){e.fn.progressStep=function(t){function a(e,t,r){e.circle.attr({cx:t,cy:r});e.highlight.attr({cx:t,cy:r});e.label.attr({x:t,y:r+n.labelOffset,"font-size":n["font-size"]});e.number.attr({x:t,y:r,"font-size":n.radius})}function f(e,t){var r=0;var i=n.strokeColor;var s=n.strokeColor;if(t){r=100;i=n.activeColor;s=n.fillColor}else if(e.visited){e.circle.attr("fill",n.visitedFillColor)}e.highlight.attr("opacity",r);e.label.attr("fill",i);e.number.attr("fill",s);e.active=t}if(this.getSteps){return this}var n=e.extend({},e.fn.progressStep.defaults,t);var r=[];var i=-1;var s=true;var o=this;var u=Raphael(this.get(0),this.width(),this.height());this.getClickEnabled=function(){return s};this.setClickEnabled=function(e){s=e};this.getOptions=function(){return n};this.getSteps=function(){return r};this.getCurrentStep=function(){return i};this.getStep=function(e){var t=null;if(e>=0&&e<r.length){t=r[e]}return t};this.setCurrentStep=function(e){if(e==i){}else{var t=true;var n=this.getStep(i);if(n){t=n.beforeExit(n);if(t){f(n,false)}}if(t){var r=this.getStep(e);if(r){t=r.beforeEntry.call(r);if(t){f(r,true);r.setVisited(true);i=e;r.afterEntry.call(r)}}else{i=-1}if(n){if(t){n.afterExit.call(n)}}}}};this.addStep=function(e){if(e==undefined){e=""}var t=u.circle(0,0,n.radius-1);t.attr({fill:n.fillColor,stroke:n.strokeColor,"stroke-width":2});var i=u.circle(0,0,n.radius-3);i.attr({fill:n.activeColor,"stroke-width":0,opacity:0});var a=u.text(0,0,e);a.attr({"text-anchor":"middle",stroke:"none",fill:n.strokeColor,"font-family":n["font-family"],"font-size":n["font-size"],"font-weight":n["font-weight"]});var f=r.length;var l=u.text(0,0,f+1);l.attr({"text-anchor":"middle",stroke:"none",fill:n.strokeColor,"font-family":n["font-family"],"font-size":n.radius,"font-weight":n["font-weight"]});var c={name:e,circle:t,highlight:i,label:a,number:l,active:false,visited:false,index:f,onClick:function(){return false},beforeEntry:function(){return true},afterEntry:function(){},beforeExit:function(){return true},afterExit:function(){},setVisited:function(e){if(this.active){}else{var t=n.fillColor;if(e){t=n.visitedFillColor}this.circle.attr("fill",t)}this.visited=e}};var h=function(){if(s){if(c.onClick.call(c)){o.setCurrentStep(c.index)}}};t.click(h);i.click(h);l.click(h);r.push(c);return c};this.refreshLayout=function(){u.setSize(this.width(),this.height());if(this.connector){this.connector.remove()}var e=r.length;if(e==0){}else if(e==1){var t=Math.floor((u.width-u._left)/2);var i=Math.floor((u.height-u._top)/2);var s=r[0];a(s,t,i)}else{var i=Math.floor((u.height-u._top)/2);var o=u.width-u._left-2*(n.margin+n.radius);var f=Math.floor(o/(e-1));var t=u._left+n.margin+n.radius;this.connector=u.path("M"+t+","+i+"L"+(t+o)+","+i);this.connector.attr("stroke",n.strokeColor);this.connector.toBack();for(var l=0;l<e;l++){var s=r[l];a(s,t,i);t+=f}}};return this};e.fn.progressStep.defaults={activeColor:"#4a9a49",strokeColor:"#d4d4d4",fillColor:"#ffffff",visitedFillColor:"#dddddd",margin:10,radius:15,labelOffset:30,"font-family":"'Helvetica Neue', 'Helvetica', Arial, sans-serif","font-size":10,"font-weight":"normal"}})(jQuery)