Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add partners carousel view and new view mode

  • Loading branch information...
commit 99a65cbb6c2a0bae2ccb4fa88216a611ba34d307 1 parent e743e32
@sheilaj sheilaj authored
View
6 amani/modules/contrib/jcarousel/includes/jcarousel_style_plugin.inc
@@ -67,6 +67,12 @@ class jcarousel_style_plugin extends views_plugin_style {
'#options' => $skins,
'#description' => t('Skins may be provided by other modules. Set to "None" if your theme includes carousel theming directly in style.css or another stylesheet. "None" does not include any built-in navigation, arrows, or positioning at all.'),
);
+ $form['responsive'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Responsive'),
+ '#default_value' => $this->options['responsive'],
+ '#description' => t('Select this option to have the carousel automatically adjust the number of visible items and the number of items to scroll at a time based on the available width.') . ' <strong>' . t('Changing this option will override the "Visible" and "Scroll" options and set carousel orientation to "horizontal".') . '</strong>',
+ );
$form['visible'] = array(
'#type' => 'select',
'#title' => t('Number of visible items'),
View
28 amani/modules/contrib/jcarousel/js/jcarousel.js
@@ -46,6 +46,13 @@ Drupal.behaviors.jcarousel.attach = function(context, settings) {
};
}
+ // Add responsive behavior.
+ if (options.responsive && !options.reloadCallback) {
+ options.vertical = false;
+ options.visible = null;
+ options.reloadCallback = Drupal.jcarousel.reloadCallback;
+ }
+
// Add navigation to the carousel if enabled.
if (!options.setupCallback) {
options.setupCallback = function(carousel) {
@@ -53,6 +60,9 @@ Drupal.behaviors.jcarousel.attach = function(context, settings) {
if (options.navigation) {
Drupal.jcarousel.addNavigation(carousel, options.navigation);
}
+ if (options.responsive) {
+ carousel.reload();
+ }
};
if (options.navigation && !options.itemVisibleInCallback) {
options.itemLastInCallback = {
@@ -72,6 +82,24 @@ Drupal.behaviors.jcarousel.attach = function(context, settings) {
};
Drupal.jcarousel = {};
+Drupal.jcarousel.reloadCallback = function(carousel) {
+ // Set the clip and container to auto width so that they will fill
+ // the available space.
+ carousel.container.css('width', 'auto');
+ carousel.clip.css('width', 'auto');
+ var clipWidth = carousel.clip.width();
+ var containerExtra = carousel.container.width() - carousel.clip.outerWidth(true);
+ // Determine the width of an item.
+ var itemWidth = carousel.list.find('li').first().outerWidth(true);
+ var numItems = Math.floor(carousel.clip.width() / itemWidth) || 1;
+ // Set the new scroll number.
+ carousel.options.scroll = numItems;
+ var newClipWidth = numItems * itemWidth;
+ var newContainerWidth = newClipWidth + containerExtra;
+ // Resize the clip and container.
+ carousel.clip.width(newClipWidth);
+ carousel.container.width(newContainerWidth);
+};
Drupal.jcarousel.ajaxLoadCallback = function(jcarousel, state) {
// Check if the requested items already exist.
if (state == 'init' || jcarousel.has(jcarousel.first, jcarousel.last)) {
View
33 amani/modules/features/amani_features/amani_partners/amani_partners.features.inc
@@ -22,6 +22,39 @@ function amani_partners_views_api() {
}
/**
+ * Implements hook_image_default_styles().
+ */
+function amani_partners_image_default_styles() {
+ $styles = array();
+
+ // Exported image style: 100h.
+ $styles['100h'] = array(
+ 'name' => '100h',
+ 'label' => '100h',
+ 'effects' => array(
+ 2 => array(
+ 'label' => 'Scale',
+ 'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.',
+ 'effect callback' => 'image_scale_effect',
+ 'dimensions callback' => 'image_scale_dimensions',
+ 'form callback' => 'image_scale_form',
+ 'summary theme' => 'image_scale_summary',
+ 'module' => 'image',
+ 'name' => 'image_scale',
+ 'data' => array(
+ 'width' => '',
+ 'height' => '100',
+ 'upscale' => 0,
+ ),
+ 'weight' => '1',
+ ),
+ ),
+ );
+
+ return $styles;
+}
+
+/**
* Implements hook_node_info().
*/
function amani_partners_node_info() {
View
2  amani/modules/features/amani_features/amani_partners/amani_partners.info
@@ -23,6 +23,7 @@ features[field][] = node-partner-body
features[field][] = node-partner-field_image
features[field][] = node-partner-field_media
features[field][] = node-partner-field_programs
+features[image][] = 100h
features[menu_links][] = menu-amani-main-menu:partners
features[node][] = partner
features[user_permission][] = create partner content
@@ -45,3 +46,4 @@ features[variable][] = node_options_partner
features[variable][] = node_preview_partner
features[variable][] = node_submitted_partner
features[views_view][] = partners
+features[views_view][] = partners_carousel
View
13 amani/modules/features/amani_features/amani_partners/amani_partners.module
@@ -5,3 +5,16 @@
*/
include_once 'amani_partners.features.inc';
+
+/**
+ * Implements hook_entity_info_alter().
+ */
+function amani_partners_entity_info_alter(&$entity_info) {
+
+ // Create a view mode for partner images that may come
+ // in different sizes and aspect ratios.
+ $entity_info['file']['view modes']['max_height'] = array(
+ 'label' => t('Fixed maximum height'),
+ 'custom settings' => TRUE,
+ );
+}
View
72 amani/modules/features/amani_features/amani_partners/amani_partners.views_default.inc
@@ -111,5 +111,77 @@ function amani_partners_views_default_views() {
);
$export['partners'] = $view;
+ $view = new view();
+ $view->name = 'partners_carousel';
+ $view->description = '';
+ $view->tag = 'default';
+ $view->base_table = 'node';
+ $view->human_name = 'Partners carousel';
+ $view->core = 7;
+ $view->api_version = '3.0';
+ $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+ /* Display: Master */
+ $handler = $view->new_display('default', 'Master', 'default');
+ $handler->display->display_options['use_more_always'] = FALSE;
+ $handler->display->display_options['access']['type'] = 'perm';
+ $handler->display->display_options['cache']['type'] = 'none';
+ $handler->display->display_options['query']['type'] = 'views_query';
+ $handler->display->display_options['exposed_form']['type'] = 'basic';
+ $handler->display->display_options['pager']['type'] = 'none';
+ $handler->display->display_options['style_plugin'] = 'jcarousel';
+ $handler->display->display_options['style_options']['wrap'] = 'circular';
+ $handler->display->display_options['style_options']['visible'] = '';
+ $handler->display->display_options['style_options']['auto'] = '8';
+ $handler->display->display_options['style_options']['autoPause'] = 1;
+ $handler->display->display_options['style_options']['easing'] = '';
+ $handler->display->display_options['style_options']['vertical'] = 0;
+ $handler->display->display_options['row_plugin'] = 'fields';
+ /* Field: Content: Media */
+ $handler->display->display_options['fields']['field_media']['id'] = 'field_media';
+ $handler->display->display_options['fields']['field_media']['table'] = 'field_data_field_media';
+ $handler->display->display_options['fields']['field_media']['field'] = 'field_media';
+ $handler->display->display_options['fields']['field_media']['label'] = '';
+ $handler->display->display_options['fields']['field_media']['element_label_colon'] = FALSE;
+ $handler->display->display_options['fields']['field_media']['click_sort_column'] = 'fid';
+ $handler->display->display_options['fields']['field_media']['type'] = 'file_rendered';
+ $handler->display->display_options['fields']['field_media']['settings'] = array(
+ 'file_view_mode' => 'max_height',
+ );
+ $handler->display->display_options['fields']['field_media']['delta_limit'] = '1';
+ $handler->display->display_options['fields']['field_media']['delta_offset'] = '0';
+ /* Sort criterion: Global: Random */
+ $handler->display->display_options['sorts']['random']['id'] = 'random';
+ $handler->display->display_options['sorts']['random']['table'] = 'views';
+ $handler->display->display_options['sorts']['random']['field'] = 'random';
+ /* Filter criterion: Content: Published */
+ $handler->display->display_options['filters']['status']['id'] = 'status';
+ $handler->display->display_options['filters']['status']['table'] = 'node';
+ $handler->display->display_options['filters']['status']['field'] = 'status';
+ $handler->display->display_options['filters']['status']['value'] = 1;
+ $handler->display->display_options['filters']['status']['group'] = 1;
+ $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
+ /* Filter criterion: Content: Type */
+ $handler->display->display_options['filters']['type']['id'] = 'type';
+ $handler->display->display_options['filters']['type']['table'] = 'node';
+ $handler->display->display_options['filters']['type']['field'] = 'type';
+ $handler->display->display_options['filters']['type']['value'] = array(
+ 'partner' => 'partner',
+ );
+
+ /* Display: Block */
+ $handler = $view->new_display('block', 'Block', 'block');
+ $translatables['partners_carousel'] = array(
+ t('Master'),
+ t('more'),
+ t('Apply'),
+ t('Reset'),
+ t('Sort by'),
+ t('Asc'),
+ t('Desc'),
+ t('Block'),
+ );
+ $export['partners_carousel'] = $view;
+
return $export;
}
View
24 amani/themes/peace/css/style.css
@@ -890,6 +890,30 @@ a.button:not(.launcher):not(.remove):not(.edit) {
margin-top: 0;
padding-top: 0; }
+.view-partners-carousel .jcarousel-container-horizontal {
+ width: 100%;
+ height: 120px;
+ padding: 20px 5px;
+ margin: auto; }
+ .view-partners-carousel .jcarousel-container-horizontal .jcarousel-clip-horizontal {
+ width: 80%;
+ overflow: hidden;
+ margin: auto; }
+ .view-partners-carousel .jcarousel-container-horizontal .jcarousel-clip-horizontal .jcarousel-item-horizontal,
+ .view-partners-carousel .jcarousel-container-horizontal .jcarousel-clip-horizontal .jcarousel-item {
+ margin: 0 18px;
+ padding: 0;
+ width: auto;
+ height: auto;
+ border: none;
+ background: none; }
+ .view-partners-carousel .jcarousel-container-horizontal .jcarousel-prev-horizontal {
+ top: 55px;
+ left: 0px; }
+ .view-partners-carousel .jcarousel-container-horizontal .jcarousel-next-horizontal {
+ top: 55px;
+ right: 0px; }
+
.region-donation-region {
position: fixed;
right: -10px;
View
26 amani/themes/peace/sass/_custom.sass
@@ -524,3 +524,29 @@ a.button:not(.launcher):not(.remove):not(.edit)
.container-inner
margin-top: 0
padding-top: 0
+
+// Partners carousel
+.view-partners-carousel
+ .jcarousel-container-horizontal
+ width: 100%
+ height: 120px
+ padding: 20px 5px
+ margin: auto
+ .jcarousel-clip-horizontal
+ width: 80%
+ overflow: hidden
+ margin: auto
+ .jcarousel-item-horizontal,
+ .jcarousel-item
+ margin: 0 18px
+ padding: 0
+ width: auto
+ height: auto
+ border: none
+ background: none
+ .jcarousel-prev-horizontal
+ top: 55px
+ left: 0px
+ .jcarousel-next-horizontal
+ top: 55px
+ right: 0px
View
70 patches/jcarousel-responsive-1548484-8.patch
@@ -0,0 +1,70 @@
+diff --git a/includes/jcarousel_style_plugin.inc b/includes/jcarousel_style_plugin.inc
+index 23fe069..25d8aad 100644
+--- a/includes/jcarousel_style_plugin.inc
++++ b/includes/jcarousel_style_plugin.inc
+@@ -67,6 +67,12 @@ class jcarousel_style_plugin extends views_plugin_style {
+ '#options' => $skins,
+ '#description' => t('Skins may be provided by other modules. Set to "None" if your theme includes carousel theming directly in style.css or another stylesheet. "None" does not include any built-in navigation, arrows, or positioning at all.'),
+ );
++ $form['responsive'] = array(
++ '#type' => 'checkbox',
++ '#title' => t('Responsive'),
++ '#default_value' => $this->options['responsive'],
++ '#description' => t('Select this option to have the carousel automatically adjust the number of visible items and the number of items to scroll at a time based on the available width.') . ' <strong>' . t('Changing this option will override the "Visible" and "Scroll" options and set carousel orientation to "horizontal".') . '</strong>',
++ );
+ $form['visible'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of visible items'),
+diff --git a/js/jcarousel.js b/js/jcarousel.js
+index ac1a5b8..8db72c9 100644
+--- a/js/jcarousel.js
++++ b/js/jcarousel.js
+@@ -46,6 +46,13 @@ Drupal.behaviors.jcarousel.attach = function(context, settings) {
+ };
+ }
+
++ // Add responsive behavior.
++ if (options.responsive && !options.reloadCallback) {
++ options.vertical = false;
++ options.visible = null;
++ options.reloadCallback = Drupal.jcarousel.reloadCallback;
++ }
++
+ // Add navigation to the carousel if enabled.
+ if (!options.setupCallback) {
+ options.setupCallback = function(carousel) {
+@@ -53,6 +60,9 @@ Drupal.behaviors.jcarousel.attach = function(context, settings) {
+ if (options.navigation) {
+ Drupal.jcarousel.addNavigation(carousel, options.navigation);
+ }
++ if (options.responsive) {
++ carousel.reload();
++ }
+ };
+ if (options.navigation && !options.itemVisibleInCallback) {
+ options.itemLastInCallback = {
+@@ -72,6 +82,24 @@ Drupal.behaviors.jcarousel.attach = function(context, settings) {
+ };
+
+ Drupal.jcarousel = {};
++Drupal.jcarousel.reloadCallback = function(carousel) {
++ // Set the clip and container to auto width so that they will fill
++ // the available space.
++ carousel.container.css('width', 'auto');
++ carousel.clip.css('width', 'auto');
++ var clipWidth = carousel.clip.width();
++ var containerExtra = carousel.container.width() - carousel.clip.outerWidth(true);
++ // Determine the width of an item.
++ var itemWidth = carousel.list.find('li').first().outerWidth(true);
++ var numItems = Math.floor(carousel.clip.width() / itemWidth) || 1;
++ // Set the new scroll number.
++ carousel.options.scroll = numItems;
++ var newClipWidth = numItems * itemWidth;
++ var newContainerWidth = newClipWidth + containerExtra;
++ // Resize the clip and container.
++ carousel.clip.width(newClipWidth);
++ carousel.container.width(newContainerWidth);
++};
+ Drupal.jcarousel.ajaxLoadCallback = function(jcarousel, state) {
+ // Check if the requested items already exist.
+ if (state == 'init' || jcarousel.has(jcarousel.first, jcarousel.last)) {
Please sign in to comment.
Something went wrong with that request. Please try again.