function masonry_add_options_to_form in Masonry API 7.2
Same name and namespace in other branches
- 7.3 masonry.module \masonry_add_options_to_form()
Add Masonry options to an existing form.
Parameters
$form: A form array to add Masonry options to.
$default_values: An array of default form values.
File
- ./
masonry.module, line 109 - Provides an API for integrating the jQuery Masonry plugin with Drupal.
Code
function masonry_add_options_to_form(&$form, $default_values) {
$form['masonry_column_width'] = array(
'#type' => 'textfield',
'#title' => t('Column width'),
'#description' => t("The width of each column."),
'#default_value' => $default_values['masonry_column_width'],
'#size' => 5,
'#maxlength' => 4,
);
$form['masonry_column_width_units'] = array(
'#type' => 'radios',
'#title' => t('Column width units'),
'#description' => t("The units to use for the column width."),
'#options' => array(
'px' => t("Pixels"),
'%' => t("Percentage (of container's width)"),
),
'#default_value' => $default_values['masonry_column_width_units'],
);
$form['masonry_gutter_width'] = array(
'#type' => 'textfield',
'#title' => t('Gutter width'),
'#description' => t("The spacing between each column."),
'#default_value' => $default_values['masonry_gutter_width'],
'#size' => 4,
'#maxlength' => 3,
'#field_suffix' => t('px'),
);
$form['masonry_resizable'] = array(
'#type' => 'checkbox',
'#title' => t('Resizable'),
'#description' => t("Automatically rearrange items when the container is resized."),
'#default_value' => $default_values['masonry_resizable'],
);
$form['masonry_animated'] = array(
'#type' => 'checkbox',
'#title' => t('Animated'),
'#description' => t("Animate item rearrangements."),
'#default_value' => $default_values['masonry_animated'],
'#states' => array(
'visible' => array(
'input.form-checkbox[name$="[masonry_resizable]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['masonry_animation_duration'] = array(
'#type' => 'textfield',
'#title' => t('Animation duration'),
'#description' => t("The duration of animations (1000 ms = 1 sec)."),
'#default_value' => $default_values['masonry_animation_duration'],
'#size' => 5,
'#maxlength' => 4,
'#field_suffix' => t('ms'),
'#states' => array(
'visible' => array(
'input.form-checkbox[name$="[masonry_resizable]"]' => array(
'checked' => TRUE,
),
'input.form-checkbox[name$="[masonry_animated]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['masonry_fit_width'] = array(
'#type' => 'checkbox',
'#title' => t('Fit width'),
'#description' => t("Sets the width of the container to the nearest column. Ideal for centering Masonry layouts. See the <a href='http://masonry.desandro.com/demos/centered.html'>'Centered' demo</a> for more information."),
'#default_value' => $default_values['masonry_fit_width'],
);
$form['masonry_rtl'] = array(
'#type' => 'checkbox',
'#title' => t('RTL layout'),
'#description' => t("Display items from right-to-left."),
'#default_value' => $default_values['masonry_rtl'],
);
$form['masonry_images_first'] = array(
'#type' => 'checkbox',
'#title' => t('Load images first'),
'#description' => t("Load all images first before triggering Masonry."),
'#default_value' => $default_values['masonry_images_first'],
);
// Allow other modules to alter the form
drupal_alter('masonry_options_form', $form, $default_values);
}