summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/context_reaction_block.css7
-rw-r--r--plugins/context_reaction_block.inc16
-rw-r--r--plugins/context_reaction_block.js24
-rw-r--r--theme/context_reaction_block.theme.inc6
4 files changed, 37 insertions, 16 deletions
diff --git a/plugins/context_reaction_block.css b/plugins/context_reaction_block.css
index ce7d8ef..f1087bc 100644
--- a/plugins/context_reaction_block.css
+++ b/plugins/context_reaction_block.css
@@ -162,9 +162,6 @@ div.block div.context-block-empty {
#context-blockform td.blocks div.label { background:#eee; }
#context-blockform td.blocks div.label a { float:right; }
-#context-blockform td.blocks div.form-item,
-#context-blockform td.blocks input.block-weight { display:none; }
-
#context-ui-items #context-blockform {
font-size:11px;
line-height:15px;
@@ -192,3 +189,7 @@ div.block div.context-block-empty {
display:block;
border:0px;
}
+
+#context-blockform .tabledrag-toggle-weight-wrapper {
+ margin-bottom:0;
+ }
diff --git a/plugins/context_reaction_block.inc b/plugins/context_reaction_block.inc
index 997859e..5344e1c 100644
--- a/plugins/context_reaction_block.inc
+++ b/plugins/context_reaction_block.inc
@@ -70,7 +70,7 @@ class context_reaction_block extends context_reaction {
'#weight' => $block->weight,
'#type' => 'markup',
'#tree' => TRUE,
- 'weight' => array('#type' => 'weight', '#delta' => $weight_delta, '#default_value' => 0),
+ 'weight' => array('#type' => 'weight', '#delta' => $weight_delta, '#default_value' => $block->weight),
);
}
}
@@ -93,14 +93,14 @@ class context_reaction_block extends context_reaction {
$edited = array();
}
- foreach ($edited as $region => $bids) {
- foreach ($bids as $position => $bid) {
- if (isset($block_info[$bid])) {
- $blocks[$bid] = array(
- 'module' => $block_info[$bid]->module,
- 'delta' => $block_info[$bid]->delta,
+ foreach ($edited as $region => $block_data) {
+ foreach ($block_data as $position => $data) {
+ if (isset($block_info[$data->bid])) {
+ $blocks[$data->bid] = array(
+ 'module' => $block_info[$data->bid]->module,
+ 'delta' => $block_info[$data->bid]->delta,
'region' => $region,
- 'weight' => $position,
+ 'weight' => $data->weight,
);
}
}
diff --git a/plugins/context_reaction_block.js b/plugins/context_reaction_block.js
index 171b514..6326afd 100644
--- a/plugins/context_reaction_block.js
+++ b/plugins/context_reaction_block.js
@@ -54,7 +54,8 @@ DrupalContextBlockForm = function(blockForm) {
var blocks = [];
$('tr', $(this)).each(function() {
var bid = $(this).attr('id');
- blocks.push(bid);
+ var weight = $(this).find('select').val();
+ blocks.push({'bid' : bid, 'weight' : weight});
});
Drupal.contextBlockForm.state[region] = blocks;
});
@@ -76,6 +77,11 @@ DrupalContextBlockForm = function(blockForm) {
});
};
+ // make sure we update the state right before submits, this takes care of an
+ // apparent race condition between saving the state and the weights getting set
+ // by tabledrag
+ $('#ctools-export-ui-edit-item-form').submit(function() { Drupal.contextBlockForm.setState(); });
+
// Tabledrag
// Add additional handlers to update our blocks.
$.each(Drupal.settings.tableDrag, function(base) {
@@ -99,13 +105,27 @@ DrupalContextBlockForm = function(blockForm) {
// create new block markup
var block = document.createElement('tr');
var text = $(this).parents('div.form-item').eq(0).hide().children('label').text();
+ var select = '<div class="form-item form-type-select"><select class="tabledrag-hide form-select">';
+ var i;
+ for (i = -10; i < 10; ++i) {
+ select += '<option>' + i + '</option>';
+ }
+ select += '</select></div>';
$(block).attr('id', $(this).attr('value')).addClass('draggable');
- $(block).html("<td>"+ text + "<input class='block-weight' /></td><td><a href='' class='remove'>X</a></td>");
+ $(block).html("<td>"+ text + "</td><td>" + select + "</td><td><a href='' class='remove'>X</a></td>");
// add block item to region
var base = "context-blockform-region-"+ region;
Drupal.tableDrag[base].makeDraggable(block);
$('table#'+base).append(block);
+ if ($.cookie('Drupal.tableDrag.showWeight') == 1) {
+ $('table#'+base).find('.tabledrag-hide').css('display', '');
+ $('table#'+base).find('.tabledrag-handle').css('display', 'none');
+ }
+ else {
+ $('table#'+base).find('.tabledrag-hide').css('display', 'none');
+ $('table#'+base).find('.tabledrag-handle').css('display', '');
+ }
Drupal.attachBehaviors($('table#'+base));
Drupal.contextBlockForm.setState();
diff --git a/theme/context_reaction_block.theme.inc b/theme/context_reaction_block.theme.inc
index 47c2fd4..aeabda9 100644
--- a/theme/context_reaction_block.theme.inc
+++ b/theme/context_reaction_block.theme.inc
@@ -37,14 +37,14 @@ function theme_context_block_regions_form($vars) {
'id' => "context-blockform-region-{$region}",
'class' => array("context-blockform-region"),
);
- drupal_add_tabledrag($attr['id'], 'order', 'sibling', 'block-weight', NULL, NULL, FALSE);
+ drupal_add_tabledrag($attr['id'], 'order', 'sibling', 'tabledrag-hide', NULL, NULL, FALSE);
$rows = array();
foreach (element_children($form[$region]) as $id) {
- $form[$region][$id]['weight']['#attributes'] = array('class' => array('block-weight'));
+ $form[$region][$id]['weight']['#attributes'] = array('class' => array('tabledrag-hide'));
$label = $form[$region][$id]['#value'];
$remove = l('X', $_GET['q'], array('fragment' => 'remove', 'attributes' => array('class' => array('remove'))));
$rows[] = array(
- 'data' => array($label . drupal_render($form[$region][$id]['weight']), $remove),
+ 'data' => array($label, drupal_render($form[$region][$id]['weight']), $remove),
'class' => array('draggable'),
'id' => $id,
);