An open API service indexing awesome lists of open source software.

https://github.com/anime-db/js-controller

[TRANSMITTED] The project is transmitted to a different vendor
https://github.com/anime-db/js-controller

framework js locker

Last synced: 2 months ago
JSON representation

[TRANSMITTED] The project is transmitted to a different vendor

Awesome Lists containing this project

README

        

# js-controller
Micro framework for JavaScript

## Require

jQuery 1.11+

## How to

Create control
```js
// ControlFormDate.js
var ControlFormDate = function() {
};

extend(ControlFormDate, ControllerControl);

ControlFormDate.prototype.bind = function(target) {
target.datepicker({dateFormat: 'yy-mm-dd'});
};
```

Add new control to controller

```js
// common.js
var cont = new Controller();
cont.addControl('form-date', new ControlFormDate());

$(function(){
cont.bind();
});
```

Use in HTML

```html


Submit

```

## Rebind

You can bind the added controls for a new content:

```js
var content = $('');
$('body').append(content);
cont.bind(content);
```

## Locker util

Util for lock page and element on page.

```js
var lock = new Locker();
lock.lock(); // add css class 'locker_wait' to body tag
lock.isLock(); // return true
lock.unlock(); // remove class 'locker_wait'
```

Lock element

```js
var el = $('.example');
var lock = new Locker();
lock.lock(el); // add class 'locker_wait' to body and add class 'locker_lock' to element
lock.unlock(el); // remove all added classes
```

Use locker from control

```js
// ControlLock.js
var ControlLock = function() {
};

extend(ControlLock, ControllerControl);

ControlLock.prototype.bind = function(target) {
var that = this;
target.keydown(function(){
that.getController.getLocker().lock(target);
}).keyup(function(){
that.getController.getLocker().unlock(target);
});
};
```

```js
// common.js
var cont = new Controller(new Locker());
cont.addControl('lock', new ControlLock());

$(function(){
cont.bind();
});
```

## License

This bundle is under the [MIT license](http://opensource.org/licenses/MIT). See the complete license in the file: LICENSE