Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f1c3810f

Von Sven Schöling vor fast 8 Jahren hinzugefügt

  • ID f1c3810f3ed25965f708ec96ac806bcac1b14bb7
  • Vorgänger f5df17ca
  • Nachfolger 8aa278d4

focus: Zeilenfokus in die normale Behandlung verschoben

Unterschiede anzeigen:

js/common.js
192 192
  return false;
193 193
}
194 194

  
195
$(document).ready(function () {
195
$(function () {
196 196
  $('input').focus(function(){
197 197
    if (focussable(this)) window.focused_element = this;
198 198
  });
199 199

  
200
  // Lowest priority: first focussable element in form.
201
  set_cursor_to_first_element();
202

  
203
  // Medium priority: class set in template
204
  var initial_focus = $(".initial_focus").filter(':visible')[0];
205
  if (initial_focus)
206
    $(initial_focus).focus();
200
  // setting focus inside a tabbed area fails if this is encountered before the tabbing is complete
201
  // in that case the elements count as hidden and jquery aborts .focus()
202
  setTimeout(function(){
203
    // Lowest priority: first focussable element in form.
204
    set_cursor_to_first_element();
205

  
206
    // Medium priority: class set in template
207
    var initial_focus = $(".initial_focus").filter(':visible')[0];
208
    if (initial_focus)
209
      $(initial_focus).focus();
210

  
211
    // special: honour focus_position
212
    // if no higher priority applies set focus to the appropriate element
213
    if ($("#display_row")[0] && kivi.myconfig.focus_position) {
214
      switch(kivi.myconfig.focus_position) {
215
        case 'last_partnumber'  : $('#display_row tr.row:gt(-3):lt(-1) input[name*="partnumber"]').focus(); break;
216
        case 'last_description' : $('#display_row tr.row:gt(-3):lt(-1) input[name*="description"]').focus(); break;
217
        case 'last_qty'         : $('#display_row tr.row:gt(-3):lt(-1) input[name*="qty"]').focus(); break;
218
        case 'new_partnumber'   : $('#display_row tr:gt(1) input[name*="partnumber"]').focus(); break;
219
        case 'new_description'  : $('#display_row tr:gt(1) input[name*="description"]').focus(); break;
220
        case 'new_qty'          : $('#display_row tr:gt(1) input[name*="qty"]').focus(); break;
221
      }
222
    }
207 223

  
208
  // legacy. sone forms install these
209
  if (typeof fokus == 'function') { fokus(); return; }
210
  if (focus_by_name('cursor_fokus')) return;
224
    // legacy. sone forms install these
225
    if (typeof fokus == 'function') { fokus(); return; }
226
    if (focus_by_name('cursor_fokus')) return;
227
  }, 0);
211 228
});
212 229

  
213 230
$('form').submit(function(){
templates/webpages/oe/sales_order.html
28 28
[%- FOREACH row = ROWS %]
29 29
     <tr valign="top" class="row [% IF row.error %]error_message[% ELSE %]listrow[% loop.count % 2 %][% END %]">
30 30
 [%- FOREACH row1 = row.ROW1 %]
31
      <td[% IF row1.align %] align="[% row1.align %]"[% END %][% IF row1.nowrap %] nowrap[% END %]>[% row1.value %]</td>
31
      <td[% IF row1.align %] align="[% row1.align %]"[% END %][% IF row1.nowrap %] nowrap[% END %][% IF row1.class %] class="[% row1.class %]"[% END %]>[% row1.value %]</td>
32 32
 [%- END %]
33 33
     </tr>
34 34
     <tr style='display:none'>
......
81 81
[%- END %]
82 82

  
83 83
  </table>
84

  
85
  <script type='text/javascript'>
86
    $(function() {
87
      setTimeout(function(){
88
        [% SWITCH( MYCONFIG.focus_position ) %]
89
          [% CASE 'last_partnumber' %]
90
            $('#display_row tr.row:gt(-3):lt(-1) input[name*="partnumber"]').focus();
91
          [% CASE 'last_description' %]
92
            $('#display_row tr.row:gt(-3):lt(-1) input[name*="description"]').focus();
93
          [% CASE 'new_partnumber' %]
94
            $('#display_row tr:gt(1) input[name*="partnumber"]').focus();
95
          [% CASE DEFAULT %]
96
            $('#display_row tr:gt(1) input[name*="description"]').focus();
97
        [% END %]
98
      }, 1);
99
    });
100
  </script>
101

  
102 84
 </td>
103 85
</tr>

Auch abrufbar als: Unified diff