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
- Host: GitHub
- URL: https://github.com/anime-db/js-controller
- Owner: anime-db
- License: mit
- Created: 2016-04-20T15:43:35.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-11T16:20:44.000Z (almost 9 years ago)
- Last Synced: 2025-02-14T21:54:58.805Z (4 months ago)
- Topics: framework, js, locker
- Language: JavaScript
- Homepage: https://github.com/gpslab/gpslab-controller
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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