my ($self, $selector, @slurp) = @_;
my %params = _hashify(@slurp);
- my %attributes = ( helper => <<JAVASCRIPT );
+ my %attributes = ( distance => 5,
+ helper => <<'JAVASCRIPT' );
function(event, ui) {
ui.children().each(function() {
- \$(this).width(\$(this).width());
+ $(this).width($(this).width());
});
return ui;
}
JAVASCRIPT
}
+ $attributes{handle} = "'$params{handle}'" if $params{handle};
+
my $attr_str = join(', ', map { "${_}: $attributes{$_}" } keys %attributes);
my $code = <<JAVASCRIPT;
<script type="text/javascript">
\$(function() {
- \$( "${selector}" ).sortable({ ${attr_str} }).disableSelection();
+ \$( "${selector}" ).sortable({ ${attr_str} })
});
</script>
JAVASCRIPT
Sets the POST parameter name for AJAX request after dropping an
element (see C<$params{with}>).
+=item C<handle>
+
+An optional jQuery selector specifying which part of the child element
+is dragable. If nothing is given then the whole child element is
+dragable, and clicks through to underlying elements like inputs or
+links might not work.
+
=back
Example:
<tbody>
[% FOREACH row = UNITS %]
<tr class="listrow[% loop.count % 2 %]" id="unit_id_[% row.id %]">
- <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
+ <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
[% IF row.in_use %]
<td>
<input type="hidden" name="unchangeable_[% loop.count %]" value="1">
</form>
- [% L.sortable_element('#unit_list tbody', 'url' => 'controller.pl?action=Unit/reorder', 'with' => 'unit_id') %]
+ [% L.sortable_element('#unit_list tbody', 'url' => 'controller.pl?action=Unit/reorder', 'with' => 'unit_id', handle => '.dragdrop') %]
</body>
</html>
[% FOREACH factor = PRICE_FACTORS %]
<tr class="listrow[% loop.count % 2 %]" id="price_factor_id_[% factor.id %]">
- <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
+ <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
<td><a href="[% url_base %]&action=edit_price_factor&id=[% HTML.url(factor.id) %]">[% HTML.escape(factor.description) %]</a></td>
<td>[% HTML.escape(factor.factor) %]</td>
</tr>
</form>
</p>
- [% L.sortable_element('#price_factor_list tbody', 'url' => 'controller.pl?action=PriceFactor/reorder', 'with' => 'price_factor_id') %]
+ [% L.sortable_element('#price_factor_list tbody', 'url' => 'controller.pl?action=PriceFactor/reorder', 'with' => 'price_factor_id', handle => '.dragdrop') %]
</body>
</html>
[% FOREACH warehouse = WAREHOUSES %]
<tr class="listrow[% loop.count % 2 %]" id="warehouse_id_[% warehouse.id %]">
- <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
+ <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
<td><a href="[% url_base %]&action=edit_warehouse&id=[% HTML.url(warehouse.id) %]">[% HTML.escape(warehouse.description) %]</a></td>
<td>[% HTML.escape(warehouse.number_of_bins) %]</td>
<td>[% IF warehouse.invalid %][% 'Yes' | $T8 %][% ELSE %][% 'No' | $T8 %][% END %]</td>
</form>
</p>
- [% L.sortable_element('#warehouse_list tbody', 'url' => 'controller.pl?action=Warehouse/reorder', 'with' => 'warehouse_id') %]
+ [% L.sortable_element('#warehouse_list tbody', 'url' => 'controller.pl?action=Warehouse/reorder', 'with' => 'warehouse_id', handle => '.dragdrop') %]
</body>
</html>
[%- FOREACH cfg = CONFIGS %]
<tr class="listrow[% loop.count % 2 %]" id="cvarcfg_id_[% cfg.id %]">
- <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
+ <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
<td>
<a href="amcvar.pl?action=edit_cvar_config&module=[% HTML.url(module) %]&id=[% HTML.url(cfg.id) %]&callback=[% HTML.url(callback) %]">
</p>
</form>
- [% L.sortable_element('#cvarcfg_list tbody', 'url' => 'controller.pl?action=CustomVariableConfig/reorder', 'with' => 'cvarcfg_id') %]
+ [% L.sortable_element('#cvarcfg_list tbody', 'url' => 'controller.pl?action=CustomVariableConfig/reorder', 'with' => 'cvarcfg_id', handle => '.dragdrop') %]
</body>
</html>