Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1b522616

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

Verbesserte Kompatibilität mit Opera, FireFox, InternetExplorer bei Drag & Drop

Wenn Textauswahl mit ".disableSelection()" deaktiviert ist, so kann
man bei den genannten Browsern Text-Eingabefelder nicht mehr
anklicken.

Statt dessen sind nun nur noch die Pfeile drag&drop-bar, der Rest der
Zeile nicht mehr.

Unterschiede anzeigen:

SL/Template/Plugin/L.pm
400 400
  my ($self, $selector, @slurp) = @_;
401 401
  my %params                    = _hashify(@slurp);
402 402

  
403
  my %attributes = ( helper => <<JAVASCRIPT );
403
  my %attributes = ( distance => 5,
404
                     helper   => <<'JAVASCRIPT' );
404 405
    function(event, ui) {
405 406
      ui.children().each(function() {
406
        \$(this).width(\$(this).width());
407
        $(this).width($(this).width());
407 408
      });
408 409
      return ui;
409 410
    }
......
422 423
JAVASCRIPT
423 424
  }
424 425

  
426
  $attributes{handle} = "'$params{handle}'" if $params{handle};
427

  
425 428
  my $attr_str = join(', ', map { "${_}: $attributes{$_}" } keys %attributes);
426 429

  
427 430
  my $code = <<JAVASCRIPT;
428 431
<script type="text/javascript">
429 432
  \$(function() {
430
    \$( "${selector}" ).sortable({ ${attr_str} }).disableSelection();
433
    \$( "${selector}" ).sortable({ ${attr_str} })
431 434
  });
432 435
</script>
433 436
JAVASCRIPT
......
676 679
Sets the POST parameter name for AJAX request after dropping an
677 680
element (see C<$params{with}>).
678 681

  
682
=item C<handle>
683

  
684
An optional jQuery selector specifying which part of the child element
685
is dragable. If nothing is given then the whole child element is
686
dragable, and clicks through to underlying elements like inputs or
687
links might not work.
688

  
679 689
=back
680 690

  
681 691
Example:
templates/webpages/am/edit_units.html
100 100
  <tbody>
101 101
  [% FOREACH row = UNITS %]
102 102
   <tr class="listrow[% loop.count % 2 %]" id="unit_id_[% row.id %]">
103
    <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
103
    <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
104 104
    [% IF row.in_use %]
105 105
     <td>
106 106
      <input type="hidden" name="unchangeable_[% loop.count %]" value="1">
......
145 145

  
146 146
 </form>
147 147

  
148
 [% L.sortable_element('#unit_list tbody', 'url' => 'controller.pl?action=Unit/reorder', 'with' => 'unit_id') %]
148
 [% L.sortable_element('#unit_list tbody', 'url' => 'controller.pl?action=Unit/reorder', 'with' => 'unit_id', handle => '.dragdrop') %]
149 149

  
150 150
</body>
151 151
</html>
templates/webpages/am/list_price_factors.html
19 19

  
20 20
   [% FOREACH factor = PRICE_FACTORS %]
21 21
   <tr class="listrow[% loop.count % 2 %]" id="price_factor_id_[% factor.id %]">
22
    <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
22
    <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
23 23
    <td><a href="[% url_base %]&action=edit_price_factor&id=[% HTML.url(factor.id) %]">[% HTML.escape(factor.description) %]</a></td>
24 24
    <td>[% HTML.escape(factor.factor) %]</td>
25 25
   </tr>
......
38 38
  </form>
39 39
 </p>
40 40

  
41
 [% L.sortable_element('#price_factor_list tbody', 'url' => 'controller.pl?action=PriceFactor/reorder', 'with' => 'price_factor_id') %]
41
 [% L.sortable_element('#price_factor_list tbody', 'url' => 'controller.pl?action=PriceFactor/reorder', 'with' => 'price_factor_id', handle => '.dragdrop') %]
42 42

  
43 43
</body>
44 44
</html>
templates/webpages/am/list_warehouses.html
20 20

  
21 21
   [% FOREACH warehouse = WAREHOUSES %]
22 22
   <tr class="listrow[% loop.count % 2 %]" id="warehouse_id_[% warehouse.id %]">
23
    <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
23
    <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
24 24
    <td><a href="[% url_base %]&action=edit_warehouse&id=[% HTML.url(warehouse.id) %]">[% HTML.escape(warehouse.description) %]</a></td>
25 25
    <td>[% HTML.escape(warehouse.number_of_bins) %]</td>
26 26
    <td>[% IF warehouse.invalid %][% 'Yes' | $T8 %][% ELSE %][% 'No' | $T8 %][% END %]</td>
......
39 39
  </form>
40 40
 </p>
41 41

  
42
 [% L.sortable_element('#warehouse_list tbody', 'url' => 'controller.pl?action=Warehouse/reorder', 'with' => 'warehouse_id') %]
42
 [% L.sortable_element('#warehouse_list tbody', 'url' => 'controller.pl?action=Warehouse/reorder', 'with' => 'warehouse_id', handle => '.dragdrop') %]
43 43

  
44 44
</body>
45 45
</html>
templates/webpages/amcvar/list_cvar_configs.html
39 39

  
40 40
    [%- FOREACH cfg = CONFIGS %]
41 41
    <tr class="listrow[% loop.count % 2 %]" id="cvarcfg_id_[% cfg.id %]">
42
     <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
42
     <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
43 43

  
44 44
     <td>
45 45
      <a href="amcvar.pl?action=edit_cvar_config&module=[% HTML.url(module) %]&id=[% HTML.url(cfg.id) %]&callback=[% HTML.url(callback) %]">
......
89 89
  </p>
90 90
 </form>
91 91

  
92
 [% L.sortable_element('#cvarcfg_list tbody', 'url' => 'controller.pl?action=CustomVariableConfig/reorder', 'with' => 'cvarcfg_id') %]
92
 [% L.sortable_element('#cvarcfg_list tbody', 'url' => 'controller.pl?action=CustomVariableConfig/reorder', 'with' => 'cvarcfg_id', handle => '.dragdrop') %]
93 93

  
94 94
</body>
95 95
</html>

Auch abrufbar als: Unified diff