responsive_preview.module in Responsive Theme Preview 8
Same filename and directory in other branches
Provides a component that previews the a page in various device dimensions.
File
responsive_preview.moduleView source
<?php
/**
* @file
* Provides a component that previews the a page in various device dimensions.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function responsive_preview_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.responsive_preview':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Responsive Preview module provides a quick way to preview a page on your site within the dimensions of many popular device and screen sizes.') . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<p>' . t('To launch a preview, first click the toolbar tab with the small device icon. The tab has the title "Preview page layout". A list of devices will appear. Selecting a device name will launch a preview of the current page within the dimensions of that device.') . '</p>';
$output .= '<p>' . t('To close the preview, click the close button signified visually by an x.') . '</p>';
return $output;
}
}
/**
* Implements hook_toolbar().
*/
function responsive_preview_toolbar() {
/** @var \Drupal\responsive_preview\ResponsivePreview $responsivePreviewService */
$responsivePreviewService = \Drupal::service('responsive_preview');
return $responsivePreviewService
->previewToolbar();
}
/**
* Implements hook_theme().
*/
function responsive_preview_theme() {
$defaultVariables = drupal_common_theme();
return [
'item_list__responsive_preview' => $defaultVariables['item_list'],
];
}
/**
* Provide processing of "item_list".
*
* @param array $variables
* An associative array.
*
* @see template_preprocess_item_list()
*/
function responsive_preview_preprocess_item_list__responsive_preview(array &$variables) {
template_preprocess_item_list($variables);
}
/**
* Implements hook_form_alter().
*/
function responsive_preview_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Add alter of form for responsive preview triggering element. So that
// responsive preview of non saved node entity is can be executed.
/** @var \Drupal\responsive_preview\ResponsivePreview $responsivePreviewService */
$responsivePreviewService = \Drupal::service('responsive_preview');
$responsivePreviewService
->formAlter($form, $form_state, $form_id);
}
Functions
Name | Description |
---|---|
responsive_preview_form_alter | Implements hook_form_alter(). |
responsive_preview_help | Implements hook_help(). |
responsive_preview_preprocess_item_list__responsive_preview | Provide processing of "item_list". |
responsive_preview_theme | Implements hook_theme(). |
responsive_preview_toolbar | Implements hook_toolbar(). |