GithubHelp home page GithubHelp logo

guochen-whu / pattern-lock Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 26 KB

A bootstrap style pattern lock component. Responsive to both mouse and touch event.

Home Page: https://guochen-whu.github.io/pattern-lock/example/general/

HTML 14.94% JavaScript 82.15% CSS 2.90%

pattern-lock's Introduction

pattern-lock

A bootstrap style pattern lock component. Responsive to both mouse and touch event.

Install

Include jquery and pattern-lock.js in your html.

Usage

Via data attributes

Set class="pattern-lock" on a container element, along with options like data-mode="validate", data-min-length=5.

<div class="pattern-lock" data-mode="validate" data-min-length=5></div>

Via Javascript

$('#lock').patternLock(options);

Options

As in bootstrap, options can be passed via data attributes or JavaScript.

mode

Values: set(default) or validate

Whether the component is waiting for user to set a password or to validate.

correctPassword

Only useful when mode is set to validate, it determines the password to compare with.

minLength

Values: An interger between 0-9

The minimum length of a valid password.

lineWidth

Values: An Interger.

Width of the track line.

lineColor

Values: A css style color string

Color of the track line.

defaultCircleColor

Values: A css style color string

The stroke color of the circle by default.

activatedCircleColor

Values: A css style color string

The stroke color of the circle when activated.

pointColor

Values: A css style color string

The fill color of the circle when activated.

Methods

.patternLock('set')

Set the component mode to 'set'.

.patternLock('validate')

Set the component mode to 'validate'.

.patternLock('disable')

Disable the component temporarily.

.patternLock('enable')

Enable the component again.

Events

The component fires several events including:

short.patternLock

The event fires when the user set a too short password.

init.patternLock

The event fires after the user set a password for the first time.

diff.patternLock

The event fires after the user set a password different from the first one.

set.patternLock

The event fires after the user set a password successfully.

wrong.patternLock

The event fires when a validation is failed.

correct.patternLock

The event fires when user input a correct password.

You can listen to those events via

$(document).on('wrong.patternLock', function (e) {
  // do something
})

Example

general example

https://guochen-whu.github.io/pattern-lock/example/general/

set password

https://guochen-whu.github.io/pattern-lock/example/set/

validate password

https://guochen-whu.github.io/pattern-lock/example/validate/

pattern-lock's People

Contributors

guochen-whu avatar

Stargazers

Zhang Yuan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.