GithubHelp home page GithubHelp logo

isabella232 / angular-input-locker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from betsol/angular-input-locker

0.0 0.0 0.0 176 KB

AngularJS module to provide form input locking

JavaScript 100.00%

angular-input-locker's Introduction

angular-input-locker 1.0.2

Description

This module for AngularJS provides you with ability to lock and unlock all inputs on the page. This is a good practice to prevent input modification when form is being processed or URL is changing. There is a way to enable locking and unlocking during route transitions automatically with a single configuration option.

Features

  • Provides service to lock and unlock all input elements on the page
  • Can lock and unlock input elements automatically during route transitions
  • You can customize the selector used to filter input elements

Demo

Feel free to play with the Demo.

Installation

Dependencies

This module requires jQuery to work.

Install library with bower

bower install --save angular-input-locker

Add library to your page

<script type="text/javascript" src="angular-input-locker/dist/angular-input-locker.js"></script>

Use minified version: angular-input-locker.min.js in production and uncompressed version: angular-input-locker.js during development/testing.

Add dependency in your application's module definition

var application = angular.module('application', [
    // ...
    'ngInputLocker'
]);

Usage

By calling setLockOnRouteChange(true) of inputLockerProvider you can enable automatic input locking during route transitions.

You can also change selector that is used to filter input elements by calling setSelector(newSelector). Although, you don't really need to do this. By default, all input controls on the page will be affected.

Example #1

angular.module('project', ['ngRoute', 'ngInputLocker'])
    .config([
        '$routeProvider', 'inputLockerProvider',
        function($routeProvider, inputLockerProvider) {
            $routeProvider
                ...
            ;
            
            inputLockerProvider.setLockOnRouteChange(true);
            
            inputLockerProvider.setSelector('input[type="text"]');
        }
    ])
;

Or you can manually call lock() or unlock() methods of inputLocker service:

Example #2

angular.module('project', ['ngInputLocker'])
    .controller('SomeCtrl', ['inputLocker', function(inputLocker) {
        inputLocker.lock();
        inputLocker.unlock();
    }])
;

API

See the examples above.

Feedback

If you have found a bug or have another issue with the library - please create an issue in this GitHub repository.

If you have a question - file it with StackOverflow and send me a link to [email protected]. I will be glad to help. Also, please create a plunk to demonstrate the issue if appropriate. You can even fork our demo plunk.

Have any ideas or propositions? Feel free to contact me by E-Mail.

Cheers!

License

The MIT License (MIT)

Copyright (c) 2014 Slava Fomin II

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

angular-input-locker's People

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.