Commit 77d3e25a authored by Mike Keran's avatar Mike Keran
Browse files

Issue #2560295 by m.lebedev: Advanced autosubmit

parent 15bfaa99
......@@ -251,6 +251,18 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
),
'#description' => t('Places this element in the secondary options portion of the exposed form.'),
);
$bef_options['sort']['advanced']['autosubmit'] = array(
'#type' => 'checkbox',
'#title' => t('Autosubmit'),
'#default_value' => $existing['sort']['advanced']['autosubmit'],
'#states' => array(
'disabled' => array(
':input[name="exposed_form_options[autosubmit]"]' => array('checked' => TRUE),
),
),
'#description' => t('Automatically submit the form once a sort element is changed. This option is not available if you enabled autosubmit option for the whole form.'),
);
}
/*
......@@ -621,6 +633,19 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
);
}
// Individual element autosubmit option.
$bef_options[$label]['more_options']['autosubmit'] = array(
'#type' => 'checkbox',
'#title' => t('Autosubmit'),
'#default_value' => $existing[$label]['more_options']['autosubmit'],
'#states' => array(
'disabled' => array(
':input[name="exposed_form_options[autosubmit]"]' => array('checked' => TRUE),
),
),
'#description' => t('Automatically submit the form once a filter element is changed. This option is not available if you enabled autosubmit option for the whole form.'),
);
// Allow any filter to be moved into the secondary options fieldset.
$bef_options[$label]['more_options']['is_secondary'] = array(
'#type' => 'checkbox',
......@@ -780,6 +805,7 @@ dateFormat: "dd-mm-yy"
'datepicker' => FALSE,
'slider' => FALSE,
'settings' => array(),
'autosubmit' => FALSE,
);
// Some widgets will require additional CSS.
......@@ -1054,6 +1080,16 @@ dateFormat: "dd-mm-yy"
}
}
}
// Apply autosubmit sort values.
if (empty($this->options['autosubmit']) && !empty($settings['sort']['advanced']['autosubmit'])) {
$bef_js['autosubmit'] = TRUE;
foreach (array($settings['sort']['advanced']['combine_param'], 'sort_by', 'sort_order') as $elem) {
if (!empty($form[$elem])) {
$form[$elem] = array_merge_recursive($form[$elem], array('#attributes' => array('class' => array('ctools-auto-submit'))));
}
}
}
/* Ends: if (isset($settings['sort'])) { */
/*
......@@ -1674,6 +1710,19 @@ dateFormat: "dd-mm-yy"
}
/* Ends switch ($options['bef_format']) */
// Apply autosubmit filter values.
if (empty($this->options['autosubmit']) && !empty($options['more_options']['autosubmit'])) {
$bef_js['autosubmit'] = TRUE;
// Check type form element.
if (isset($form[$filter_id]['value'])) {
$form[$filter_id]['value'] = array_merge_recursive($form[$filter_id]['value'], array('#attributes' => array('class' => array('ctools-auto-submit'))));
}
else {
$form[$filter_id] = array_merge_recursive($form[$filter_id], array('#attributes' => array('class' => array('ctools-auto-submit'))));
}
}
// Override "Any" label, if applicable.
if (!empty($options['more_options']['any_label']) && !empty($form[$filter_id]['#options']['All'])) {
$form[$filter_id]['#options']['All'] = $options['more_options']['any_label'];
......@@ -1743,6 +1792,11 @@ dateFormat: "dd-mm-yy"
if ($bef_js['slider']) {
drupal_add_library('system', 'ui.slider');
}
if ($bef_js['autosubmit']) {
$form['submit']['#attributes']['class'][] = 'ctools-use-ajax';
$form['submit']['#attributes']['class'][] = 'ctools-auto-submit-click';
$form['#attached']['js'][] = drupal_get_path('module', 'ctools') . '/js/auto-submit.js';
}
drupal_add_js(array('better_exposed_filters' => $bef_js), 'setting');
drupal_add_js(drupal_get_path('module', 'better_exposed_filters') . '/better_exposed_filters.js');
......@@ -1896,6 +1950,7 @@ dateFormat: "dd-mm-yy"
'reset' => FALSE,
'reset_label' => '',
'is_secondary' => FALSE,
'autosubmit' => FALSE,
),
),
'pager' => array(
......@@ -1923,6 +1978,7 @@ dateFormat: "dd-mm-yy"
'bef_filter_description' => '',
'any_label' => '',
'bef_term_description' => FALSE,
'autosubmit' => FALSE,
'tokens' => array(
'list' => array(),
'available' => array(),
......
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