https://github.com/nitayneeman/ng-prevent
An AngularJS directive which provides the ability to disable common behaviors of elements
https://github.com/nitayneeman/ng-prevent
angularjs
Last synced: 3 months ago
JSON representation
An AngularJS directive which provides the ability to disable common behaviors of elements
- Host: GitHub
- URL: https://github.com/nitayneeman/ng-prevent
- Owner: nitayneeman
- License: mit
- Created: 2015-03-25T15:30:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-08-22T15:42:09.000Z (almost 9 years ago)
- Last Synced: 2023-04-10T05:51:43.764Z (over 3 years ago)
- Topics: angularjs
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ng-prevent [](https://travis-ci.org/nitayneeman/ng-prevent)
##### An AngularJS directive which provides the ability to disable common behaviors of elements.
## DEPRECATED
This repository is not maintained anymore.
## Features
* Disabling of user-select.
* Disabling of context menu.
* Disabling of specific key action.
* Disabling of console actions.
* Showing alerts on console.
## Getting started
#### Dependencies
AngularJS v1.0.3, or a newer version.
#### Usage
1. Add one of dist files (original / min) to main file sources of project.
2. Inject 'ngPrevent' as a dependency of your angular module.
3. Start to prevent on any element you want!
#### Options
When you define prevent options on scope - you can use the following options:
* userSelect
`true`: Preventing a user selection on the element.
`false`: Allowing a user selection on the element.
* contextMenu
`true`: Preventing a context menu on the element.
`false`: Allowing a context menu on the element.
* keys
`[]`: Preventing a key press on the element.
Acceptable values are: `BACKSPACE`, `TAB`, `ENTER`, `WIN_KEY`, `F11` and `F12`.
* console
`[]`: Preventing an actions on console.
The values of array are messages to console.
A message object pattern: `{ text: 'Message', style: 'CSS properties'}`
## Samples
Add a prevent attribute on your element:
```html
Text
```
myPreventOptions should be on scope:
```js
demoModule.controller('MainController', function ($scope) {
$scope.myPreventOptions = {
userSelect: true,
contextMenu: false
};
});
```
Alternatively, definiton of preventOptions can be on rootScope:
```js
demoModule.run(function ($rootScope) {
$rootScope.preventOptions = {
userSelect: true,
contextMenu: true,
console: [
{
text: 'Stop!',
style: 'color: red; font-size: 35pt'
},
{
text: 'Not allowed here!',
style: 'color: white; font-size: 30pt'
}
],
keys: [
'F12',
'F11',
'WIN_KEY'
]
};
});
```
**Important note:** *Defintion of preventOptions on rootScope is overrides any other definition on children scopes. Use rootScope only if you want to prevent on the HTML tag. Any other mode, define on the appropriate scope.*