/** Toggle pane show/hide button **/
Drupal.Panels.bindClickToggleHidden = function (o) {
$('input.pane-toggle-hidden').unbind('click');
$('input.pane-toggle-hidden').click(function() {
var id = $(this)[0].id.replace('edit-button-', '').replace('-show-hide', '');
var op = $(this)[0].title.replace(' this pane', '');
$.ajax({
type: "POST",
url: Drupal.settings.panelsAjaxURL + "/toggle-hidden/" + $('#panel-did').val() + '/' + id + '/' + op,
data: '',
global: true,
success: Drupal.Panels.Subform.bindAjaxResponse,
error: function() { alert("An error occurred while attempting to toggle the pane's hidden status.")},
dataType: 'json'
});
return false;
});
}
// it's just the extra else if I added, but i included the whole thing for completeness
Drupal.Panels.Subform.bindAjaxResponse = function(data) {
// On success, append the returned HTML to the panel's element.
if (data.type == 'display') {
// append the output
$('#modalContent span.modal-title').html(data.title);
$('#modalContent div.modal-content').html(data.output);
// TODO this is the code that we want to see go away
var url = data.url;
if (!url) {
url = Drupal.settings.panelsAjaxURL + '/submit-form/' + $('#panel-did').val();
}
// Bind forms to ajax submit.
$('div.panels-modal-content form').unbind('submit'); // be safe here.
$('div.panels-modal-content form').submit(function() {
$(this).ajaxSubmit({
url: url,
data: '',
method: 'post',
after: Drupal.Panels.Subform.bindAjaxResponse,
dataType: 'json'
});
return false;
});
// Bind links to ajax links.
$('a.panels-modal-add-config').click(Drupal.Panels.Subform.bindClickAddLink);
if ($('#override-title-checkbox').size()) {
Drupal.Panels.Checkboxes.bindCheckbox('#override-title-checkbox', ['#override-title-textfield']);
}
if ($('#use-pager-checkbox').size()) {
Drupal.Panels.Checkboxes.bindCheckbox('#use-pager-checkbox', ['#use-pager-textfield']);
}
// hack: allow collapsible textareas to work
Drupal.Panels.Subform.bindCollapsible();
Drupal.Panels.Subform.bindAutocomplete();
}
else if (data.type == 'add') {
// Give it all the goodies that our existing panes have.
$('#panel-pane-' + data.region).append(data.output);
Drupal.Panels.attachPane('#panel-pane-' + data.id);
Drupal.Panels.changed($('#panel-pane-' + data.id));
// dismiss the dialog
$('#panels-modal').unmodalContent();
}
else if (data.type == 'replace') {
$('#panel-pane-' + data.id + ' .panel-pane-collapsible')
.html(data.output)
.each(Drupal.Panels.bindPortlet);
Drupal.Panels.changed($('#panel-pane-' + data.id));
// dismiss the dialog
$('#panels-modal').unmodalContent();
}
else if (data.type == 'toggle-hidden') {
if (data.op == '1') {
var verb = 'Hide';
}
else {
var verb = 'Show';
}
$('#panel-pane-' + data.id).toggleClass('hidden-pane');
$('#panel-pane-' + data.id + ' input.pane-hidden').attr({
title: verb + " this pane",
alt: verb + " this pane",
src: "icon-" + data.output + "pane.png"
});
Drupal.Panels.changed($('#panel-pane-' + data.id));
}
else {
// just dismiss the dialog.
$('#panels-modal').unmodalContent();
}
}