contextItemGenerator: '=',
max: '@',
itype: '@',
- selectOnFocus: '='
+ selectOnFocus: '=',
+ advanceFocusAfterInput: '='
},
controller : ['$scope',
function ( $scope ) {
element.bind('focus', function () { element.select() });
}
+ function findCaretTarget(id, itype) {
+ var tgt = null;
+ if (itype == 'tag') {
+ tgt = id.replace(/tag$/, 'i1');
+ } else if (itype == 'ind') {
+ if (id.match(/i1$/)) {
+ tgt = id.replace(/i1$/, 'i2');
+ } else if (id.match(/i2$/)) {
+ tgt = id.replace(/i2$/, 's0code');
+ }
+ } else if (itype == 'sfc') {
+ tgt = id.replace(/code$/, 'value');
+ }
+ return tgt;
+ }
+ if (Boolean(scope.advanceFocusAfterInput)) {
+ element.bind('input', function (e) {
+ if (scope.content.length == scope.max) {
+ var tgt = findCaretTarget(e.currentTarget.id, scope.itype);
+ if (tgt) {
+ var element = $('#' + tgt).get(0);
+ if (element) {
+ element.focus();
+ }
+ }
+ }
+ });
+ }
+
element.bind('change', function (e) { element.size = scope.max || parseInt(scope.content.length * 1.1) });
element.bind('contextmenu', {scope : scope}, scope.showContext);
'>‡</label><eg-marc-edit-editable '+
'itype="sfc" '+
'select-on-focus="true" '+
+ 'advance-focus-after-input="true" '+
'class="marcedit marcsf marcsfcode" '+
'field="field" '+
'subfield="subfield" '+
'itype="ind" '+
'class="marcedit marcind" '+
'select-on-focus="true" '+
+ 'advance-focus-after-input="true" '+
'field="field" '+
'content="ind" '+
'max="1" '+
'itype="tag" '+
'class="marcedit marctag" '+
'select-on-focus="true" '+
+ 'advance-focus-after-input="true" '+
'field="field" '+
'content="tag" '+
'max="3" '+