@@ -, +, @@
fields
---
.../intranet-tmpl/lib/koha/cateditor/widget.js | 37 ++++++++++++++++------
koha-tmpl/intranet-tmpl/prog/css/cateditor.css | 5 ++-
2 files changed, 31 insertions(+), 11 deletions(-)
--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/widget.js
+++ a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/widget.js
@@ -61,10 +61,11 @@ define( [ 'resources' ], function( Resources ) {
// Fixed field utils
bindFixed: function( sel, start, end ) {
var $node = $( this.node ).find( sel );
- $node.val( this.getFixed( start, end ) );
+ var val = this.getFixed( start, end );
+ $node.val( val );
var widget = this;
- var $collapsed = $( '' + $node.val() + '' ).insertAfter( $node );
+ var $collapsed = $( '' + val + '' ).insertAfter( $node );
function show() {
$collapsed.hide();
@@ -75,7 +76,8 @@ define( [ 'resources' ], function( Resources ) {
function hide() {
$node.hide();
- $collapsed.text( Widget.PadStringRight( $node.val(), end - start ) ).show();
+ var val = $node.val();
+ $collapsed.text( Widget.PadStringRight( val === null ? '' : val, end - start ) ).show();
}
$node.on( 'change keyup', function() {
@@ -92,6 +94,9 @@ define( [ 'resources' ], function( Resources ) {
},
setFixed: function( start, end, value, source ) {
+ if ( null === value ) {
+ value = '';
+ }
this.setText( this.text.substring( 0, start ) + Widget.PadStringRight( value.toString().substr( 0, end - start ), end - start ) + this.text.substring( end ), source );
},
@@ -118,6 +123,7 @@ define( [ 'resources' ], function( Resources ) {
$matSelect.change( function() {
widget.loadXMLMaterial( materialInfo[ $matSelect.val() ] );
+ widget.nodeChanged();
} ).change();
} );
},
@@ -169,11 +175,12 @@ define( [ 'resources' ], function( Resources ) {
$inputs.each( function( i ) {
$(this).on( 'keydown.marc-tab', function( e ) {
- // Cheap hack to disable backspace and special keys
- if ( ( this.nodeName.toLowerCase() == 'select' && e.which == 9 ) || e.ctrlKey ) {
- e.preventDefault();
- return;
- } else if ( e.which != 9 ) { // Tab
+ // Handle tab/shift-tab
+ if ( e.which != 9 ) { // 9 = Tab
+ // Cheap hack to disable backspace and special keys
+ if ( e.ctrlKey ) {
+ e.preventDefault();
+ }
return;
}
@@ -182,7 +189,12 @@ define( [ 'resources' ], function( Resources ) {
if ( e.shiftKey ) {
if ( i > 0 ) {
- $inputs.eq(i - 1).trigger( 'focus' );
+ var $input = $inputs.eq( i - 1 );
+ if ( $input.is( ':visible' ) ) {
+ $input.focus();
+ } else {
+ $input.next('span').click();
+ }
} else {
editor.cm.setCursor( span.from );
// FIXME: ugly hack
@@ -191,7 +203,12 @@ define( [ 'resources' ], function( Resources ) {
}
} else {
if ( i < $inputs.length - 1 ) {
- $inputs.eq(i + 1).trigger( 'focus' );
+ var $input = $inputs.eq( i + 1 );
+ if ( $input.is( ':visible' ) ) {
+ $input.focus();
+ } else {
+ $input.next('span').click();
+ }
} else {
editor.cm.setCursor( span.to );
editor.focus();
--- a/koha-tmpl/intranet-tmpl/prog/css/cateditor.css
+++ a/koha-tmpl/intranet-tmpl/prog/css/cateditor.css
@@ -125,7 +125,7 @@ body {
font-family: inherit;
line-height: 2.75;
margin: 3px 0;
- padding: 4px;
+ padding: 2px;
}
#editor .subfield-widget select, #editor .subfield-widget input {
@@ -139,6 +139,9 @@ body {
#editor .fixed-widget input {
width: 4em;
+ padding: 0;
+ border-radius: 2px;
+ border-width: 1px;
}
#editor .fixed-widget select {
--