fixed key to option
This commit is contained in:
parent
a217567b9b
commit
70eec8731c
|
@ -28,7 +28,8 @@ angular.module('view-form')
|
|||
}
|
||||
return 0;
|
||||
};
|
||||
}).value('supportedFields', [
|
||||
})
|
||||
.value('supportedFields', [
|
||||
'textfield',
|
||||
'textarea',
|
||||
'date',
|
||||
|
@ -42,7 +43,14 @@ angular.module('view-form')
|
|||
'yes_no',
|
||||
'number',
|
||||
'natural'
|
||||
]).constant('VIEW_FORM_URL', '/forms/:formId/render');
|
||||
])
|
||||
.constant('VIEW_FORM_URL', '/forms/:formId/render')
|
||||
.filter('indexToAlphabet', function(){
|
||||
return function(index){
|
||||
var char = String.fromCharCode(index + 65);
|
||||
return char;
|
||||
};
|
||||
})
|
||||
|
||||
//Angular-Scroll Settings
|
||||
angular.module('view-form').value('duScrollActiveClass', 'activeField')
|
||||
|
|
|
@ -15,7 +15,7 @@ angular.module('view-form').directive('submitFormDirective', ['$http', 'TimeCoun
|
|||
templateUrl: 'form_modules/forms/base/views/directiveViews/form/submit-form.client.view.html',
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
myform:'='
|
||||
myform: '='
|
||||
},
|
||||
controller: function($document, $window, $scope){
|
||||
var FORM_ACTION_ID = 'submit_field';
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
style="margin: 0.5em; padding-left:30px"
|
||||
ng-class="{activeBtn: field.fieldValue == field.fieldOptions[$index].option_value}">
|
||||
<div class="letter" style="float:left">
|
||||
{{$index+1}}
|
||||
{{$index | indexToAlphabet}}
|
||||
</div>
|
||||
<input ng-style="{'color': design.colors.answerColor, 'border-color': design.colors.answerColor}"
|
||||
name="{{field.fieldType}}{{index}}"
|
||||
|
|
|
@ -9,15 +9,20 @@ angular.module('view-form').directive('keyToOption', ['$rootScope', function($ro
|
|||
link: function($scope, $element, $attrs) {
|
||||
$('body').on('keypress', function(event) {
|
||||
var keyCode = event.which || event.keyCode;
|
||||
var index = parseInt(String.fromCharCode(keyCode))-1;
|
||||
|
||||
if (index < $scope.field.fieldOptions.length) {
|
||||
var index = -1;
|
||||
if(keyCode <= 122 && keyCode >= 97){
|
||||
index = keyCode - 97;
|
||||
} else if (keyCode <= 90 && keyCode >= 65){
|
||||
index = keyCode - 65;
|
||||
}
|
||||
|
||||
if (index !== -1 && index < $scope.field.fieldOptions.length) {
|
||||
event.preventDefault();
|
||||
$scope.$apply(function () {
|
||||
$scope.field.fieldValue = $scope.field.fieldOptions[index].option_value;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue