View source
<?php
$plugin = array(
'schema' => 'layout_breakpoint',
'access' => 'administer layouts',
'menu' => array(
'menu prefix' => 'admin/structure/panels/layouts',
'menu item' => 'breakpoints',
'menu title' => 'Breakpoints',
),
'title singular' => t('breakpoint'),
'title singular proper' => t('Breakpoint'),
'title plural' => t('breakpoints'),
'title plural proper' => t('Breakpoints'),
'form' => array(
'settings' => 'layout_breakpoint_edit_form',
'validate' => 'layout_breakpoint_edit_form_validate',
),
);
function layout_breakpoint_edit_form(&$form, $form_state) {
$breakpoint = $form_state['item'];
$form['width'] = array(
'#type' => 'textfield',
'#title' => t('Breakpoint'),
'#description' => t('Width point where this breakpoint is applied. Examples: 960px, 41em. Do not mix pixel and em based widths.'),
'#default_value' => @$breakpoint->width,
);
$form['grid_name'] = array(
'#type' => 'select',
'#options' => layout_breakpoint_grid_name_list(),
'#default_value' => @$breakpoint->grid_name,
'#description' => t('Grid to be applied to this breakpoint. <a href="@editgrids">You can edit and add grids</a>.', array(
'@editgrids' => url('admin/structure/panels/layouts/grids'),
)),
);
}
function layout_breakpoint_edit_form_validate(&$form, $form_state) {
if (!preg_match('!^\\d+(px|em)$!', $form_state['values']['width'])) {
form_set_error('width', t('Only pixel or em based breakpoints are supported, for example 960px or 41em.'));
}
}
function layout_breakpoint_grid_name_list() {
$grids = gridbuilder_load_all();
$grid_list = array();
foreach ($grids as $grid) {
$grid_list[$grid->name] = $grid->admin_title;
}
return $grid_list;
}