Commit 1ef7a9c8 authored by TravisCarden's avatar TravisCarden

By TravisCarden: Made "Show/Hide descriptions" link dynamic (no page load).

parent 0be6c9c9
......@@ -6,3 +6,6 @@
font-style: italic;
opacity: 0.66;
}
#checklistapi-checklist-form.compact-mode div.description p {
display: none;
}
......@@ -2,9 +2,10 @@
Drupal.behaviors.checklistapiFieldsetSummaries = {
attach: function (context) {
// Vertical tabs summaries.
$('#checklistapi-checklist-form .vertical-tabs-panes > fieldset', context).drupalSetSummary(function (context) {
var total = $(':checkbox', context).size();
var args = {};
var total = $(':checkbox', context).size(), args = {};
if (total) {
args['@complete'] = $(':checkbox:checked', context).size();
args['@total'] = total;
......@@ -12,6 +13,18 @@ Drupal.behaviors.checklistapiFieldsetSummaries = {
return Drupal.t('@complete of @total (@percent%) complete', args);
}
});
// Compact mode link.
$('#checklistapi-checklist-form .compact-link a', context).click(function () {
var is_compact_mode = $(this).closest('#checklistapi-checklist-form').hasClass('compact-mode');
$(this)
.text((is_compact_mode) ? Drupal.t('Hide descriptions') : Drupal.t('Show descriptions'))
.attr('title', (is_compact_mode) ? Drupal.t('Compress layout by hiding descriptions.') : Drupal.t('Expand layout to include descriptions.'))
.closest('#checklistapi-checklist-form').toggleClass('compact-mode');
document.cookie = 'Drupal.visitor.checklistapi_compact_mode=' + ((is_compact_mode) ? 0 : 1);
return false;
});
}
};
......
......@@ -53,6 +53,9 @@ function checklistapi_checklist_clear_confirm_submit($form, &$form_state) {
*/
function checklistapi_checklist_form($form, &$form_state, $id) {
$form['#checklist'] = $checklist = checklistapi_checklist_load($id);
if (checklistapi_compact_mode()) {
$form['#attributes']['class'] = array('compact-mode');
}
$form['compact_mode_link'] = array(
'#markup' => theme('checklistapi_compact_link'),
);
......@@ -101,10 +104,7 @@ function checklistapi_checklist_form($form, &$form_state, $id) {
$default_value = $item['#default_value'];
}
// Get description.
$description = '';
if (!checklistapi_compact_mode() && isset($item['#description'])) {
$description = '<p>' . filter_xss_admin($item['#description']) . '</p>';
}
$description = (isset($item['#description'])) ? '<p>' . filter_xss_admin($item['#description']) . '</p>' : '';
// Append links.
$links = array();
foreach (element_children($item) as $link_key) {
......
Markdown is supported
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