"diff-96fc5f6c195e83b3caf1ebdeb4f9e39d6e24ed91R101">101
that.$ctx.lineTo(that.sList[p]["x"],that.sList[p]["y"]);
//console.log(that.sList[p]["x"],that.sList[p]["y"]);
}
}
};
this.allDraw =function(c){
if (arguments.length>0){
this.pointDraw(c);
this.lineDraw(c);
that.$ctx.stroke();
}
else {
this.pointDraw();
this.lineDraw();
}
};
this.draw=function(x,y){
that.$ctx.clearRect(0,0,that.options.width,that.options.height);
that.$ctx.beginPath();
//that.initDraw();
that.$ctx.putImageData(this.initImg,0,0);
that.$ctx.lineWidth=4;
that.pointDraw(that.options.lineColor);
that.lineDraw(that.options.lineColor);
that.$ctx.lineTo(x,y);
that.$ctx.stroke();
};
this.pointInList=function(poi,list){
for (var p in list){
if( poi["x"] == list[p]["x"] && poi["y"] == list[p]["y"]){
return ++p;
}
}
return false;
};
this.touched=false;
$(this.id).on ("mousedown touchstart",{that:that},function(e){
e.data.that.touched=true;
});
$(this.id).on ("mouseup touchend",{that:that},function(e){
e.data.that.touched=false;
that.$ctx.clearRect(0,0,that.options.width,that.options.height);
that.$ctx.beginPath();
that.$ctx.putImageData(e.data.that.initImg,0,0);
that.allDraw(that.options.lineColor);
// that.$ctx.stroke();
for(var p in that.sList){
if(e.data.that.pointInList(that.sList[p], e.data.that.pList)){
e.data.that.result= e.data.that.result+(e.data.that.pointInList(that.sList[p], e.data.that.pList)).toString();
}
}
$(element).trigger("hasPasswd",that.result);
});
//
$(this.id).on('touchmove mousemove',{that:that}, function(e) {
if(e.data.that.touched){
var x= e.pageX || e.originalEvent.targetTouches[0].pageX ;
var y = e.pageY || e.originalEvent.targetTouches[0].pageY;
x=x-that.$element.offset().left;
y=y-that.$element.offset().top;
var p = e.data.that.isIn(x, y);
//console.log(x)
if(p != 0 ){
if ( !e.data.that.pointInList(p,e.data.that.sList)){
e.data.that.sList.push(p);
}
}
//console.log( e.data.that.sList);
e.data.that.draw(x, y);
}
});
$(this.id).on('passwdWrong',{that:that}, function(e) {
that.$ctx.clearRect(0,0,that.options.width,that.options.height);
that.$ctx.beginPath();
that.$ctx.putImageData(that.initImg,0,0);
that.allDraw("#cc1c21");
that.result="";
that.pList=[];
that.sList=[];
setTimeout(function(){
that.$ctx.clearRect(0,0,that.options.width,that.options.height);
that.$ctx.beginPath();
that.initDraw()
},500)
});
$(this.id).on('passwdRight',{that:that}, function(e) {
that.$ctx.clearRect(0,0,that.options.width,that.options.height);
that.$ctx.beginPath();
that.$ctx.putImageData(that.initImg,0,0);
that.allDraw("#00a254");
that.result="";
that.pList=[];
that.sList=[];
setTimeout(function(){
that.$ctx.clearRect(0,0,that.options.width,that.options.height);
that.$ctx.beginPath();
that.initDraw()
},500)
});
$(this.id).on('passwdDIY',{that:that}, function(e, color) {
that.$ctx.clearRect(0,0,that.options.width,that.options.height);
that.$ctx.beginPath();
that.$ctx.putImageData(that.initImg,0,0);
that.allDraw(color || that.options.lineColor);
that.result="";
that.pList=[];
that.sList=[];
setTimeout(function(){
that.$ctx.clearRect(0,0,that.options.width,that.options.height);
that.$ctx.beginPath();
that.initDraw()
},500)
});
};
GesturePasswd.DEFAULTS = {
zindex :100,
roundRadii:25,
pointRadii:6,
space:30,
width:240,
height:240,
lineColor:"#00aec7",
backgroundColor:"#252736",
color:"#FFFFFF"
};
function Plugin(option,arg) {
return this.each(function () {
var $this = $(this);
var options = $.extend({}, GesturePasswd.DEFAULTS, typeof option == 'object' && option);
var data = $this.data('GesturePasswd');
var action = typeof option == 'string' ? option : NaN;
if (!data) $this.data('danmu', (data = new GesturePasswd(this, options)));
if (action) data[action](arg);
})
}
$.fn.GesturePasswd = Plugin;
$.fn.GesturePasswd.Constructor = GesturePasswd;
});
|
||
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|