Commit 3955a79b authored by Daniel_Rose's avatar Daniel_Rose Committed by Joshua Kopel
Browse files

Issue #2470583 by sadashiv, daniel_rose: Can't unselect link

parent a7abcdb5
......@@ -318,21 +318,37 @@
// We have to prevent the page load triggered by the links.
event.preventDefault();
event.stopPropagation();
// Un select old select value.
$wrapper.find('select option').removeAttr('selected');
// Un select if previously seleted toogle is selected.
var link_text = $(this).text();
removed = '';
$($options).each(function(i) {
if ($(this).attr('selected')) {
if (link_text == $(this).text()) {
removed = $(this).text();
$(this).removeAttr('selected');
}
}
});
// Set the corresponding option inside the select element as selected.
var link_text = $(this).text();
$selected = $options.filter(function() {
return $(this).text() == link_text;
return $(this).text() == link_text && removed != link_text;
});
$selected.attr('selected', 'selected');
$wrapper.find('.bef-new-value').val($selected.val());
$wrapper.find('a').removeClass('active');
$wrapper.find('.bef-new-value[value=""]').attr("disabled", "disabled");
$(this).addClass('active');
// Submit the form.
$wrapper.parents('form').find('.views-submit-button *[type=submit]').click();
});
$('.bef-select-as-link').ready(function() {
$('.bef-select-as-link').find('a').removeClass('active');
$('.bef-new-value').each(function(i, val) {
id = $(this).parent().find('select').attr('id') + '-' + $(this).val();
$('#'+id).find('a').addClass('active');
});
});
});
}
};
......
......@@ -556,8 +556,11 @@ function theme_select_as_links($vars) {
// Add "active" class to the currently active filter link.
if (in_array((string) $key, $selected_options)) {
$link_options['attributes'] = array('class' => array('active'));
$url = bef_replace_query_string_arg($name, $key, $multiple, TRUE, $path);
}
else {
$url = bef_replace_query_string_arg($name, $key, $multiple, FALSE, $path);
}
$url = bef_replace_query_string_arg($name, $key, $multiple, FALSE, $path);
$elem['#children'] = l($value, $url, $link_options);
$element_output = theme('form_element', array('element' => $elem));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment