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 ) { // 9 = Tab |
174 |
e.preventDefault(); |
180 |
// Cheap hack to disable backspace and special keys |
175 |
return; |
181 |
if ( e.ctrlKey ) { |
176 |
} else if ( e.which != 9 ) { // Tab |
182 |
e.preventDefault(); |
|
|
183 |
} |
177 |
return; |
184 |
return; |
178 |
} |
185 |
} |
179 |
|
186 |
|
Lines 182-188
define( [ 'resources' ], function( Resources ) {
Link Here
|
182 |
|
189 |
|
183 |
if ( e.shiftKey ) { |
190 |
if ( e.shiftKey ) { |
184 |
if ( i > 0 ) { |
191 |
if ( i > 0 ) { |
185 |
$inputs.eq(i - 1).trigger( 'focus' ); |
192 |
var $input = $inputs.eq( i - 1 ); |
|
|
193 |
if ( $input.is( ':visible' ) ) { |
194 |
$input.focus(); |
195 |
} else { |
196 |
$input.next('span').click(); |
197 |
} |
186 |
} else { |
198 |
} else { |
187 |
editor.cm.setCursor( span.from ); |
199 |
editor.cm.setCursor( span.from ); |
188 |
// FIXME: ugly hack |
200 |
// FIXME: ugly hack |
Lines 191-197
define( [ 'resources' ], function( Resources ) {
Link Here
|
191 |
} |
203 |
} |
192 |
} else { |
204 |
} else { |
193 |
if ( i < $inputs.length - 1 ) { |
205 |
if ( i < $inputs.length - 1 ) { |
194 |
$inputs.eq(i + 1).trigger( 'focus' ); |
206 |
var $input = $inputs.eq( i + 1 ); |
|
|
207 |
if ( $input.is( ':visible' ) ) { |
208 |
$input.focus(); |
209 |
} else { |
210 |
$input.next('span').click(); |
211 |
} |
195 |
} else { |
212 |
} else { |
196 |
editor.cm.setCursor( span.to ); |
213 |
editor.cm.setCursor( span.to ); |
197 |
editor.focus(); |
214 |
editor.focus(); |