summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nodequeue_dragdrop.js36
1 files changed, 19 insertions, 17 deletions
diff --git a/nodequeue_dragdrop.js b/nodequeue_dragdrop.js
index 2ffa739..514fd05 100644
--- a/nodequeue_dragdrop.js
+++ b/nodequeue_dragdrop.js
@@ -8,6 +8,8 @@ Drupal.behaviors.nodequeueDrag = {
$('td.position').each(function(i){
$(this).html(i + 1);
});
+
+ nodequeueUpdateNodePositions();
}
}
};
@@ -20,13 +22,7 @@ Drupal.behaviors.nodequeueReverse = {
$('.nodequeue-dragdrop tbody').prepend(this);
});
- // ...and update node positions
- var size = $('.node-position').size();
- $('.node-position').each(function(i){
- var val = $(this).val();
- $(this).val(size - val + 1);
- });
-
+ nodequeueUpdateNodePositions();
nodequeueInsertChangedWarning();
nodequeueRestripeTable();
@@ -45,16 +41,7 @@ Drupal.behaviors.nodequeueShuffle = {
$('.nodequeue-dragdrop tbody').prepend(this);
});
- var reverse = Drupal.settings.nodequeue.reverse;
-
- // ...and update node positions
- var size = reverse ? $('.node-position').size() : 1;
- $('.node-position').each(function(i){
- var val = $(this).val();
- $(this).val(size);
- reverse ? size-- : size++;
- });
-
+ nodequeueUpdateNodePositions();
nodequeueInsertChangedWarning();
nodequeueRestripeTable();
@@ -123,6 +110,21 @@ Drupal.behaviors.nodequeueClearTitle = {
}
/**
+ * Updates node positions after nodequeue has been rearranged.
+ * It cares about the reverse order and populates nodes the other way round.
+ */
+function nodequeueUpdateNodePositions() {
+ // Check if reverse option is set.
+ var reverse = Drupal.settings.nodequeue.reverse;
+ var size = reverse ? $('.node-position').size() : 1;
+
+ $('.node-position').each(function(i){
+ $(this).val(size);
+ reverse ? size-- : size++;
+ });
+}
+
+/**
* Restripe the nodequeue table after removing an element or changing the
* order of the elements.
*/