X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fslick%2Fslick.api.php;h=4620e0f708f82405dd857e52bb541723ff2f32e9;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=468b11aa24e94b0e334ce8a5dfe892b7ef5da92b;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website
diff --git a/web/modules/contrib/slick/slick.api.php b/web/modules/contrib/slick/slick.api.php
index 468b11aa2..4620e0f70 100644
--- a/web/modules/contrib/slick/slick.api.php
+++ b/web/modules/contrib/slick/slick.api.php
@@ -3,13 +3,16 @@
/**
* @file
* Hooks and API provided by the Slick module.
- *
- * Modules may implement any of the available hooks to interact with Slick.
*/
/**
- * Slick may be configured using the web interface via sub-modules.
+ * @defgroup slick_api Slick API
+ * @{
+ * Information about the Slick usages.
*
+ * Modules may implement any of the available hooks to interact with Slick.
+ *
+ * Slick may be configured using the web interface via sub-modules.
* However below is a few sample coded ones. The simple API is to achieve
* consistent markups working for various skins, and layouts for both coded
* and sub-modules implementations.
@@ -18,77 +21,74 @@
* - items: A required array of slick contents: text, image or media.
* - options: An optional array of key:value pairs of custom JS options.
* - optionset: An optional optionset object to avoid multiple invocations.
- * - settings: An array of key:value pairs of HTML/layout related settings.
+ * - settings: An array of key:value pairs of HTML/layout related settings
+ * which may contain optionset ID if no optionset above is provided.
*
* @see \Drupal\slick\Plugin\Field\FieldFormatter\SlickImageFormatter
* @see \Drupal\slick_views\Plugin\views\style\SlickViews
- */
-
-/**
- * Quick sample #1.
*
+ * @section sec_quick Quick sample #1
+ *
+ * Returns the renderable array of a slick instance.
+ * @code
+ * function my_module_render_slick() {
+ * // Invoke the plugin class, or use a DI service container accordingly.
+ * $slick = \Drupal::service('slick.manager');
+ *
+ * // Access the formatter service for image-related methods:
+ * $formatter = \Drupal::service('slick.formatter');
+ *
+ * $build = [];
+ *
+ * // Caption contains: alt, data, link, overlay, title.
+ * // Each item has keys: slide, caption, settings.
+ * $items[] = [
+ * // Use $formatter->getImage($element) to have lazyLoad where $element
+ * // contains:
+ * // item: Drupal\image\Plugin\Field\FieldType\ImageItem.
+ * 'slide' => '',
+ * 'caption' => ['title' => t('Description #1')],
+ * ];
+ *
+ * $items[] = [
+ * 'slide' => '
',
+ * 'caption' => ['title' => t('Description #2')],
+ * ];
+ *
+ * $items[] = [
+ * 'slide' => '
',
+ * 'caption' => ['title' => t('Description #3')],
+ * ];
+ *
+ * // Pass the $items to the array.
+ * $build['items'] = $items;
+ *
+ * // If no optionset name is provided via $build['settings'], slick will
+ * // fallback to 'default'.
+ * // Optionally override 'default' optionset with custom JS options.
+ * $build['options'] = [
+ * 'autoplay' => TRUE,
+ * 'dots' => TRUE,
+ * 'arrows' => FALSE,
+ * ];
+ *
+ * // Build the slick.
+ * $element = $slick->build($build);
+ *
+ * // Prepare $variables to pass into a .twig.html file.
+ * $variables['slick'] = $element;
+ *
+ * // Render the slick at a .twig.html file.
+ * // {{ slick }}
+ * // Or simply return the $element if a renderable array is expected.
+ * return $element;
+ * }
+ * @endcode
* @see \Drupal\slick\SlickManager::build()
* @see template_preprocess_slick_wrapper()
* @see template_preprocess_slick()
*
- * @return array
- * The renderable array of a slick instance.
- */
-function my_module_render_slick() {
- // Invoke the plugin class, or use a DI service container accordingly.
- $slick = \Drupal::service('slick.manager');
-
- // Access the formatter service for image-related methods:
- $formatter = \Drupal::service('slick.formatter');
-
- $build = [];
-
- // Caption contains: alt, data, link, overlay, title.
- // Each item has keys: slide, caption, settings.
- $items[] = [
- // Use $formatter->getImage($element) to have lazyLoad where $element
- // contains:
- // item: Drupal\image\Plugin\Field\FieldType\ImageItem.
- 'slide' => '
',
- 'caption' => ['title' => t('Description #1')],
- ];
-
- $items[] = [
- 'slide' => '
',
- 'caption' => ['title' => t('Description #2')],
- ];
-
- $items[] = [
- 'slide' => '
',
- 'caption' => ['title' => t('Description #3')],
- ];
-
- // Pass the $items to the array.
- $build['items'] = $items;
-
- // If no optionset name is provided via $build['settings'], slick will
- // fallback to 'default'.
- // Optionally override 'default' optionset with custom JS options.
- $build['options'] = [
- 'autoplay' => TRUE,
- 'dots' => TRUE,
- 'arrows' => FALSE,
- ];
-
- // Build the slick.
- $element = $slick->build($build);
-
- // Prepare $variables to pass into a .twig.html file.
- $variables['slick'] = $element;
-
- // Render the slick at a .twig.html file.
- // {{ slick }}
- // Or simply return the $element if a renderable array is expected.
- return $element;
-}
-
-/**
- * Detailed sample #2.
+ * @section sec_detail Detailed sample #2
*
* This can go to some hook_preprocess() of a target html.twig, or any relevant
* PHP file.
@@ -97,111 +97,112 @@ function my_module_render_slick() {
* First, create an unformatted Views block, says 'Ticker' containing ~ 10
* titles, or any data for the contents -- using EFQ, or static array will do.
*
- * @return array
- * The renderable array of a slick instance.
- */
-function my_module_render_slick_detail() {
- // Invoke the plugin class, or use a DI service container accordingly.
- $slick = \Drupal::service('slick.manager');
-
- // Access the formatter service for image related methods:
- $formatter = \Drupal::service('slick.formatter');
-
- $build = [];
-
- // 1.
- // Optional $settings, can be removed.
- // Provides HTML settings with optionset name and ID, none of JS related.
- // To add JS key:value pairs, use #options below instead.
- // @see \Drupal\slick\SlickDefault for most supported settings.
- $build['settings'] = [
- // Optional optionset name, otherwise fallback to default.
- // 'optionset' => 'blog',
- // Optional skin name fetched from hook_slick_skins_info(), otherwise none.
- // 'skin' => 'fullwidth',
- // Define the main ID. The rest are managed by the module.
- // If you provide ID, be sure unique per instance as it is cached.
- // Leave empty to be provided by the module.
- 'id' => 'slick-ticker',
-
- // Define the cache max-age, default to -1 (Cache::PERMANENT) to permanently
- // cache the results. Hence a 1 hour is passed. Be sure it is an integer!
- 'cache' => 3600,
- ];
-
- // 3.
- // Obligatory #items, as otherwise empty slick.
- // Prepare #items contents, note the 'slide' key is to hold the actual slide
- // which can be pure and simple text, or any image/media file.
- // Meaning $rows can be text only, or image/audio/video, or a combination
- // of both.
- // To add caption/overlay, use 'caption' key with the supported sub-keys:
- // alt, data, link, overlay, title for complex content.
- // Sanitize each sub-key content accordingly.
- // @see template_preprocess_slick_slide() for more info.
- $items = [];
- foreach ($rows as $key => $row) {
- // Each item has keys: slide, caption, settings.
- $items[] = [
- 'slide' => $row,
-
- // Optional caption contains: alt, data, link, overlay, title.
- // If the above slide is an image, to add text caption, use:
- 'caption' => ['title' => 'some-caption data'],
-
- // Optional slide settings to manipulate layout, can be removed.
- // Individual slide supports some useful settings like layout, classes,
- // etc.
- // Meaning each slide can have different layout, or classes.
- // @see src/Plugin/Field/README.txt
- 'settings' => [
-
- // Optionally add a custom layout, can be a static uniform value, or
- // dynamic one based on the relevant field value.
- // @see src/Plugin/Field/README.txt for the supported layout keys.
- 'layout' => 'bottom',
-
- // Optionally add a custom class, can be a static uniform class, or
- // dynamic one based on the relevant field value.
- 'class' => 'slide--custom-class--' . $key,
- ],
- ];
- }
-
- // Pass the $items to the array.
- $build['items'] = $items;
-
- // 4.
- // Optional specific JS options, to re-use one optionset, can be removed.
- // Play with speed and options to achieve desired result.
- // @see config/install/slick.optionset.default.yml
- $build['options'] = [
- 'arrows' => FALSE,
- 'autoplay' => TRUE,
- 'vertical' => TRUE,
- 'draggable' => FALSE,
- ];
-
- // 5.
- // Build the slick with the arguments as described above.
- $element = $slick->build($build);
-
- // Prepare $variables to pass into a .twig.html file.
- $variables['slick'] = $element;
-
- // Render the slick at a .twig.html file.
- // {{ slick }}
- // Or simply return the $element if a renderable array is expected.
- return $element;
-}
-
-/**
- * AsNavFor sample #3.
+ * Returns the renderable array of a slick instance.
+ * @code
+ * function my_module_render_slick_detail() {
+ * // Invoke the plugin class, or use a DI service container accordingly.
+ * $slick = \Drupal::service('slick.manager');
+ *
+ * // Access the formatter service for image related methods:
+ * $formatter = \Drupal::service('slick.formatter');
+ *
+ * $build = [];
+ *
+ * // 1.
+ * // Optional $settings, can be removed.
+ * // Provides HTML settings with optionset name and ID, none of JS related.
+ * // To add JS key:value pairs, use #options below instead.
+ * // @see \Drupal\slick\SlickDefault for most supported settings.
+ * $build['settings'] = [
+ * // Optional optionset name, otherwise fallback to default.
+ * // 'optionset' => 'blog',
+ * // Optional skin name fetched from hook_slick_skins_info(), else none.
+ * // 'skin' => 'fullwidth',
+ * // Define the main ID. The rest are managed by the module.
+ * // If you provide ID, be sure unique per instance as it is cached.
+ * // Leave empty to be provided by the module.
+ * 'id' => 'slick-ticker',
+ *
+ * // Define cache max-age, default to -1 (Cache::PERMANENT) to permanently
+ * // cache the results. Hence a 1 hour is passed. Be sure it is an integer!
+ * 'cache' => 3600,
+ * ];
+ *
+ * // 3.
+ * // Obligatory #items, as otherwise empty slick.
+ * // Prepare #items, note the 'slide' key is to hold the actual slide
+ * // which can be pure and simple text, or any image/media file.
+ * // Meaning $rows can be text only, or image/audio/video, or a combination
+ * // of both.
+ * // To add caption/overlay, use 'caption' key with the supported sub-keys:
+ * // alt, data, link, overlay, title for complex content.
+ * // Sanitize each sub-key content accordingly.
+ * // @see template_preprocess_slick_slide() for more info.
+ * $items = [];
+ * foreach ($rows as $key => $row) {
+ * // Each item has keys: slide, caption, settings.
+ * $items[] = [
+ * 'slide' => $row,
+ *
+ * // Optional caption contains: alt, data, link, overlay, title.
+ * // If the above slide is an image, to add text caption, use:
+ * 'caption' => ['title' => 'some-caption data'],
*
- * The only requirement for asNavFor is:
+ * // Optional slide settings to manipulate layout, can be removed.
+ * // Individual slide supports some useful settings like layout, classes,
+ * // etc.
+ * // Meaning each slide can have different layout, or classes.
+ * // @see src/Plugin/Field/README.txt
+ * 'settings' => [
+ *
+ * // Optionally add a custom layout, can be a static uniform value, or
+ * // dynamic one based on the relevant field value.
+ * // @see src/Plugin/Field/README.txt for the supported layout keys.
+ * 'layout' => 'bottom',
+ *
+ * // Optionally add a custom class, can be a static uniform class, or
+ * // dynamic one based on the relevant field value.
+ * 'class' => 'slide--custom-class--' . $key,
+ * ],
+ * ];
+ * }
+ *
+ * // Pass the $items to the array.
+ * $build['items'] = $items;
+ *
+ * // 4.
+ * // Optional specific JS options, to re-use one optionset, can be removed.
+ * // Play with speed and options to achieve desired result.
+ * // @see config/install/slick.optionset.default.yml
+ * $build['options'] = [
+ * 'arrows' => FALSE,
+ * 'autoplay' => TRUE,
+ * 'vertical' => TRUE,
+ * 'draggable' => FALSE,
+ * ];
+ *
+ * // 5.
+ * // Build the slick with the arguments as described above.
+ * $element = $slick->build($build);
+ *
+ * // Prepare $variables to pass into a .twig.html file.
+ * $variables['slick'] = $element;
+ *
+ * // Render the slick at a .twig.html file.
+ * // {{ slick }}
+ * // Or simply return the $element if a renderable array is expected.
+ * return $element;
+ * }
+ * @endcode
+ * @see \Drupal\slick\SlickManager::build()
+ * @see template_preprocess_slick_wrapper()
+ *
+ * @section sec_asnavfor AsNavFor sample #3
+ *
+ * The only requirement for asNavFor is optionset and optionset_thumbnail IDs:
* @code
- * $build['settings']['optionset'] = 'optionset_name';
- * $build['settings']['optionset_thumbnail'] = 'optionset_thumbnail_name';
+ * $build['settings']['optionset'] = 'optionset_name';
+ * $build['settings']['optionset_thumbnail'] = 'optionset_thumbnail_name';
* @endcode
*
* The rest are optional, and will fallback to default:
@@ -217,126 +218,261 @@ function my_module_render_slick_detail() {
* See the HTML structure below to get a clear idea.
*
* 1. Main slider:
- * \n @code
+ * @code
*