|
Lines 61-70
define( [ 'resources' ], function( Resources ) {
Link Here
|
| 61 |
// Fixed field utils |
61 |
// Fixed field utils |
| 62 |
bindFixed: function( sel, start, end ) { |
62 |
bindFixed: function( sel, start, end ) { |
| 63 |
var $node = $( this.node ).find( sel ); |
63 |
var $node = $( this.node ).find( sel ); |
| 64 |
$node.val( this.getFixed( start, end ) ); |
64 |
var val = this.getFixed( start, end ); |
|
|
65 |
$node.val( val ); |
| 65 |
|
66 |
|
| 66 |
var widget = this; |
67 |
var widget = this; |
| 67 |
var $collapsed = $( '<span class="fixed-collapsed" title="' + $node.attr('title') + '">' + $node.val() + '</span>' ).insertAfter( $node ); |
68 |
var $collapsed = $( '<span class="fixed-collapsed" title="' + $node.attr('title') + '">' + val + '</span>' ).insertAfter( $node ); |
| 68 |
|
69 |
|
| 69 |
function show() { |
70 |
function show() { |
| 70 |
$collapsed.hide(); |
71 |
$collapsed.hide(); |
|
Lines 75-81
define( [ 'resources' ], function( Resources ) {
Link Here
|
| 75 |
|
76 |
|
| 76 |
function hide() { |
77 |
function hide() { |
| 77 |
$node.hide(); |
78 |
$node.hide(); |
| 78 |
$collapsed.text( Widget.PadStringRight( $node.val(), end - start ) ).show(); |
79 |
var val = $node.val(); |
|
|
80 |
$collapsed.text( Widget.PadStringRight( val === null ? '' : val, end - start ) ).show(); |
| 79 |
} |
81 |
} |
| 80 |
|
82 |
|
| 81 |
$node.on( 'change keyup', function() { |
83 |
$node.on( 'change keyup', function() { |
|
Lines 92-97
define( [ 'resources' ], function( Resources ) {
Link Here
|
| 92 |
}, |
94 |
}, |
| 93 |
|
95 |
|
| 94 |
setFixed: function( start, end, value, source ) { |
96 |
setFixed: function( start, end, value, source ) { |
|
|
97 |
if ( null === value ) { |
| 98 |
value = ''; |
| 99 |
} |
| 95 |
this.setText( this.text.substring( 0, start ) + Widget.PadStringRight( value.toString().substr( 0, end - start ), end - start ) + this.text.substring( end ), source ); |
100 |
this.setText( this.text.substring( 0, start ) + Widget.PadStringRight( value.toString().substr( 0, end - start ), end - start ) + this.text.substring( end ), source ); |
| 96 |
}, |
101 |
}, |
| 97 |
|
102 |
|
|
Lines 118-123
define( [ 'resources' ], function( Resources ) {
Link Here
|
| 118 |
|
123 |
|
| 119 |
$matSelect.change( function() { |
124 |
$matSelect.change( function() { |
| 120 |
widget.loadXMLMaterial( materialInfo[ $matSelect.val() ] ); |
125 |
widget.loadXMLMaterial( materialInfo[ $matSelect.val() ] ); |
|
|
126 |
widget.nodeChanged(); |
| 121 |
} ).change(); |
127 |
} ).change(); |
| 122 |
} ); |
128 |
} ); |
| 123 |
}, |
129 |
}, |
|
Lines 169-179
define( [ 'resources' ], function( Resources ) {
Link Here
|
| 169 |
|
175 |
|
| 170 |
$inputs.each( function( i ) { |
176 |
$inputs.each( function( i ) { |
| 171 |
$(this).on( 'keydown.marc-tab', function( e ) { |
177 |
$(this).on( 'keydown.marc-tab', function( e ) { |
| 172 |
// Cheap hack to disable backspace and special keys |
178 |
// Handle tab/shift-tab |
| 173 |
if ( ( this.nodeName.toLowerCase() == 'select' && e.which == 9 ) || e.ctrlKey ) { |
179 |
if ( e.which != 9 ) { // Tab |
| 174 |
e.preventDefault(); |
|
|
| 175 |
return; |
| 176 |
} else if ( e.which != 9 ) { // Tab |
| 177 |
return; |
180 |
return; |
| 178 |
} |
181 |
} |
| 179 |
|
182 |
|
|
Lines 182-188
define( [ 'resources' ], function( Resources ) {
Link Here
|
| 182 |
|
185 |
|
| 183 |
if ( e.shiftKey ) { |
186 |
if ( e.shiftKey ) { |
| 184 |
if ( i > 0 ) { |
187 |
if ( i > 0 ) { |
| 185 |
$inputs.eq(i - 1).trigger( 'focus' ); |
188 |
var $input = $inputs.eq( i - 1 ); |
|
|
189 |
if ( $input.is( ':visible' ) ) { |
| 190 |
$input.focus(); |
| 191 |
} else { |
| 192 |
$input.next('span').click(); |
| 193 |
} |
| 186 |
} else { |
194 |
} else { |
| 187 |
editor.cm.setCursor( span.from ); |
195 |
editor.cm.setCursor( span.from ); |
| 188 |
// FIXME: ugly hack |
196 |
// FIXME: ugly hack |
|
Lines 191-197
define( [ 'resources' ], function( Resources ) {
Link Here
|
| 191 |
} |
199 |
} |
| 192 |
} else { |
200 |
} else { |
| 193 |
if ( i < $inputs.length - 1 ) { |
201 |
if ( i < $inputs.length - 1 ) { |
| 194 |
$inputs.eq(i + 1).trigger( 'focus' ); |
202 |
var $input = $inputs.eq( i + 1 ); |
|
|
203 |
if ( $input.is( ':visible' ) ) { |
| 204 |
$input.focus(); |
| 205 |
} else { |
| 206 |
$input.next('span').click(); |
| 207 |
} |
| 195 |
} else { |
208 |
} else { |
| 196 |
editor.cm.setCursor( span.to ); |
209 |
editor.cm.setCursor( span.to ); |
| 197 |
editor.focus(); |
210 |
editor.focus(); |