App-ZofCMS
view release on metacpan or search on metacpan
lib/App/ZofCMS/Plugin/PreferentialOrder.pm view on Meta::CPAN
total_height += els_list[i].getSize().y;
}
$$('.ppof_list').set({'styles': {'min-height': total_height}});
var mySortables = new Sortables('#ppof_order, #ppof_order_disabled', {
'constraint': true,
'clone': true,
'opacity': 0.3
});
mySortables.attach();
$('ppof_order').zof_sortables = mySortables;
$('plug_preferential_order_form').onsubmit = add_sorted_list_input;
}
function add_sorted_list_input() {
var result = $('ppof_order').zof_sortables.serialize(
0,
function(element, index){
return element.getProperty('id').replace('ppof_order_item_','');
}
).join(',');
var result_el = new Element ('input', {
'type': 'hidden',
'name': 'ppof_order',
'value': result
});
result_el.inject(this);
var result_disabled = $('ppof_order').zof_sortables.serialize(
1,
function(element, index){
return element.getProperty('id').replace('ppof_order_item_','');
}
).join(',');
var result_el_disabled = new Element ('input', {
'type': 'hidden',
'name': 'ppof_order_disabled',
'value': result_disabled
});
result_el_disabled.inject(this);
return true;
}
=head1 SAMPLE CSS CODE USED BY THE PLUGIN
This is just a quick and ugly sample CSS code to give your lists some
structure for you to quickly play with the plugin to decide if you need it:
#ppof_enabled_container,
#ppof_disabled_container {
width: 400px;
float: left;
}
.ppof_label {
text-align: center;
font-size: 90%;
font-weight: bold;
letter-spacing: -1px;
padding: 0;
margin: 0;
}
.success-message {
color: #aa0;
font-weight: bold;
font-size: 90%;
}
.ppof_list {
list-style: none;
border: 1px solid #ccc;
min-height: 20px;
padding: 0;
margin: 0 0 7px;
background: #ffd;
}
.ppof_list li {
padding: 10px;
background: #ddd;
border: 1px solid #aaa;
position: relative;
}
#plug_preferential_order_form .input_submit {
clear: both;
display: block;
}
=head1 HTML CODE GENERATED BY THE PLUGIN
=head2 Sorting Form
<!-- Double list (has_disabled is set to a true value) -->
<form action="" method="POST" id="plug_preferential_order_form">
<div>
<input type="hidden" name="page" value="/index">
<input type="hidden" name="ppof_save_order" value="1">
<div id="ppof_enabled_container">
<p class="ppof_label">Enabled items</p>
<ul id="ppof_order" class="ppof_list">
<li id="ppof_order_item_forum4">Last forum ":)"</li>
<li id="ppof_order_item_forum">First forum ":)"</li>
</ul>
</div>
<div id="ppof_enabled_container">
<p class="ppof_label">Disabled items</p>
<ul id="ppof_order_disabled" class="ppof_list">
<li id="ppof_order_item_forum2">Second forum ":)"</li>
<li id="ppof_order_item_forum3">forum3</li>
</ul>
</div>
<input type="submit" class="input_submit" value="Save">
</div>
</form>
<!-- Single list (has_disabled is set to a false value) -->
<form action="" method="POST" id="plug_preferential_order_form">
<div>
<input type="hidden" name="page" value="/index">
<input type="hidden" name="ppof_save_order" value="1">
( run in 0.792 second using v1.01-cache-2.11-cpan-39bf76dae61 )