Archived
Fix drag'n drop in plugin configs
As discussed in #65. Uses a simpler approach to detect the order of the items and their activation at the same time
This commit is contained in:
@@ -90,25 +90,18 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
|
|||||||
$value = $_POST['serendipity']['plugin'][$config_item];
|
$value = $_POST['serendipity']['plugin'][$config_item];
|
||||||
|
|
||||||
$validate = $plugin->validate($config_item, $cbag, $value);
|
$validate = $plugin->validate($config_item, $cbag, $value);
|
||||||
|
|
||||||
if ($validate === true) {
|
if ($validate === true) {
|
||||||
// echo $config_item . " validated: $validate<br />\n";
|
|
||||||
|
|
||||||
if (!empty($_POST['serendipity']['plugin']['override'][$config_item])) {
|
if (!empty($_POST['serendipity']['plugin']['override'][$config_item])) {
|
||||||
$value = $_POST['serendipity']['plugin']['override'][$config_item];
|
$value = $_POST['serendipity']['plugin']['override'][$config_item];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($_POST['serendipity']['plugin']['activate'][$config_item])) {
|
if (is_array($_POST['serendipity']['plugin']['activate'][$config_item])) {
|
||||||
$values = explode(',', $value);
|
$active_values = array();
|
||||||
$out_values = array();
|
foreach($_POST['serendipity']['plugin']['activate'][$config_item] as $ordered_item_value) {
|
||||||
foreach($values AS $out_value) {
|
$ordered_item_value;
|
||||||
if (!isset($_POST['serendipity']['plugin']['activate'][$config_item][$out_value])) {
|
$active_values[] = $ordered_item_value;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$out_values[] = $out_value;
|
|
||||||
}
|
}
|
||||||
$value = implode(',', $out_values);
|
$value = implode(',', $active_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
$plugin->set_config($config_item, $value);
|
$plugin->set_config($config_item, $value);
|
||||||
|
|||||||
Vendored
+1
@@ -1,6 +1,7 @@
|
|||||||
$("document").ready(function() {
|
$("document").ready(function() {
|
||||||
$('.pluginmanager_sidebar .pluginmanager_container').sortable(getDragdropConfiguration('plugins_sidebar'));
|
$('.pluginmanager_sidebar .pluginmanager_container').sortable(getDragdropConfiguration('plugins_sidebar'));
|
||||||
$('.pluginmanager_event .pluginmanager_container').sortable(getDragdropConfiguration('plugins_event'));
|
$('.pluginmanager_event .pluginmanager_container').sortable(getDragdropConfiguration('plugins_event'));
|
||||||
|
$('.configuration_group .pluginmanager_container').sortable(getDragdropConfiguration('plugins_event'));
|
||||||
|
|
||||||
function getDragdropConfiguration(group) {
|
function getDragdropConfiguration(group) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -27,6 +27,11 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{* Those are only needed if the plugin contains a config item of type sequence, liek the entryproperty-plugin *}
|
||||||
|
<script src="{serendipity_getFile file="admin/js/jquery.autoscroll.js"}"></script>
|
||||||
|
<script src="{serendipity_getFile file="admin/js/jquery.sortable.js"}"></script>
|
||||||
|
<script src="{serendipity_getFile file="admin/js/dragdrop.js"}"></script>
|
||||||
{foreach $OUT_STACK_REST as $out_stack_config_item}
|
{foreach $OUT_STACK_REST as $out_stack_config_item}
|
||||||
<div class="configuration_group {cycle values='odd,even'}">
|
<div class="configuration_group {cycle values='odd,even'}">
|
||||||
{$out_stack_config_item}
|
{$out_stack_config_item}
|
||||||
|
|||||||
@@ -63,15 +63,12 @@
|
|||||||
{if $cdesc != ''}<span id="{$postKey}_{$config_item}_info" class="field_info additional_info">{$cdesc}</span>{/if}
|
{if $cdesc != ''}<span id="{$postKey}_{$config_item}_info" class="field_info additional_info">{$cdesc}</span>{/if}
|
||||||
</div>
|
</div>
|
||||||
{elseif $ctype == 'sequence'}
|
{elseif $ctype == 'sequence'}
|
||||||
{if !$sequencejs_output}
|
|
||||||
<script src="{serendipity_getFile file="admin/js/dragdrop.js"}"></script>
|
|
||||||
{/if}
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><span>{$cname}{if $cdesc != ''} <button class="toggle_info button_link" type="button" data-href="#{$config_item}_info"><span class="icon-info-circled"></span><span class="visuallyhidden"> More</span></button>{/if}</span></legend>
|
<legend><span>{$cname}{if $cdesc != ''} <button class="toggle_info button_link" type="button" data-href="#{$config_item}_info"><span class="icon-info-circled"></span><span class="visuallyhidden"> More</span></button>{/if}</span></legend>
|
||||||
<input id="{$config_item}_value" name="serendipity[{$postKey}][{$config_item}]" type="hidden" value="{$value}">
|
<input id="{$config_item}_value" name="serendipity[{$postKey}][{$config_item}]" type="hidden" value="{$value}">
|
||||||
|
|
||||||
<noscript>
|
<noscript>
|
||||||
<!-- Replace standard submit button when using up/down submits -->
|
{* Replace standard submit button when using up/down submits *}
|
||||||
<input name="SAVECONF" type="hidden" value="Save">
|
<input name="SAVECONF" type="hidden" value="Save">
|
||||||
</noscript>
|
</noscript>
|
||||||
|
|
||||||
@@ -83,7 +80,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{if $checkable}
|
{if $checkable}
|
||||||
<div class="form_check">
|
<div class="form_check">
|
||||||
<input id="activate_{$orid['id']}" name="serendipity[{$postKey}][activate][{$config_item}][{$orid['id']}]" {(in_array($orid['id'], $store_order)) ? ' checked="checked" ' : ''} type="checkbox" onclick="sort_{$config_item}_Sequence();" value="true">
|
<input id="activate_{$orid['id']}" name="serendipity[{$postKey}][activate][{$config_item}][{$orid['id']}]" {(in_array($orid['id'], $store_order)) ? ' checked="checked" ' : ''} type="checkbox" value="{$orid['id']}">
|
||||||
<label for="activate_{$orid['id']}" class="visuallyhidden">Activate</label> {* i18n *}
|
<label for="activate_{$orid['id']}" class="visuallyhidden">Activate</label> {* i18n *}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -113,36 +110,4 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{if $cdesc != ''}<span id="{$config_item}_info" class="field_info additional_info">{$cdesc}</span>{/if}
|
{if $cdesc != ''}<span id="{$config_item}_info" class="field_info additional_info">{$cdesc}</span>{/if}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<script>
|
|
||||||
function sort_{$config_item}_Sequence() {
|
|
||||||
//var seq = DragDrop.serData('{$config_item}_group', null);
|
|
||||||
var seq = DragDrop.serData(null, '{$config_item}');
|
|
||||||
var start = seq.indexOf("(");
|
|
||||||
var end = seq.indexOf(")");
|
|
||||||
seq = seq.slice((start + 1), end);
|
|
||||||
checkable_seq = seq.split(",");
|
|
||||||
out_seq = '';
|
|
||||||
for (i in checkable_seq) {
|
|
||||||
if (document.getElementById('activate_' + checkable_seq[i]) && !document.getElementById('activate_' + checkable_seq[i]).checked) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
if (out_seq != '') {
|
|
||||||
out_seq += ',';
|
|
||||||
}
|
|
||||||
out_seq += checkable_seq[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var order = document.getElementById("{$config_item}_value");
|
|
||||||
order.value = out_seq;
|
|
||||||
}
|
|
||||||
|
|
||||||
function init_{$config_item}_Sequence() {
|
|
||||||
var lst = document.getElementById("{$config_item}");
|
|
||||||
DragDrop.makeListContainer(lst, '{$config_item}_group');
|
|
||||||
lst.onDragOut = function() {
|
|
||||||
sort_{$config_item}_Sequence();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
addLoadEvent(init_{$config_item}_Sequence);
|
|
||||||
</script>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user