Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- netupApp.directive('between', function(Validators) {
- return {
- restrict: 'A',
- require: 'ngModel',
- scope: {
- min: '@min',
- max: '@max',
- inclusive: '@inclusive'
- },
- link: function(scope, element, attrs, ctrl) {
- var properties = {
- min: scope.min,
- max: scope.max,
- inclusive: scope.inclusive
- };
- ctrl.$validators.between = function(modelValue, viewValue) {
- return Validators.between(properties).isValid(modelValue);
- };
- }
- };
- });
- netupApp.factory('Validators', function () {
- return {
- between: function(properties) {
- var validator = {
- inclusive: !!properties.inclusive,
- min: Number(properties.min),
- max: Number(properties.max),
- isValid: function(value) {
- if (isNaN(parseFloat(value)) || !isFinite(value)) {
- return false;
- }
- if (this.inclusive) {
- return (value >= this.min && value <= this.max);
- } else {
- return (value > this.min && value < this.max);
- }
- }
- };
- return validator;
- }
- }
- });
- <input name="video_bitrate_max" between
- min="{{parameters.video_bitrate_max.validators.between.parameters.min}}"
- max="{{parameters.video_bitrate_max.validators.between.parameters.max}}"
- inclusive="{{parameters.video_bitrate_max.validators.between.parameters.inclusive}}"
- type="number" class="form-control input-xs"
- ng-model="preset.parameters.common.video_bitrate_max"
- ng-disabled="preset.parameters.common.rate_control === 'CBR'">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement