Index: contrib/views_slideshow_singleframe/views_slideshow.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_singleframe/Attic/views_slideshow.js,v retrieving revision 1.1.2.1.2.38 diff -u -p -r1.1.2.1.2.38 views_slideshow.js --- contrib/views_slideshow_singleframe/views_slideshow.js 9 Jun 2010 06:13:36 -0000 1.1.2.1.2.38 +++ contrib/views_slideshow_singleframe/views_slideshow.js 27 Jun 2010 15:17:27 -0000 @@ -163,6 +163,31 @@ Drupal.behaviors.viewsSlideshowSingleFra if (settings.start_paused) { viewsSlideshowSingleFramePause(settings); } + + // Pause if hidden. + if (settings.pause_when_hidden) { + // If the slideshow is visible and it is paused then resume. + // otherwise if the slideshow is not visible and it is not paused then + // pause it. + if (viewsSlideshowSingleFrameIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible) && settings.paused) { + viewsSlideshowSingleFrameResume(settings); + } + else if (!viewsSlideshowSingleFrameIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible) && !settings.paused) { + viewsSlideshowSingleFramePause(settings); + } + + $(window).scroll(function() { + // If the slideshow is visible and it is paused then resume. + // otherwise if the slideshow is not visible and it is not paused then + // pause it. + if (viewsSlideshowSingleFrameIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible) && settings.paused) { + viewsSlideshowSingleFrameResume(settings); + } + else if (!viewsSlideshowSingleFrameIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible) && !settings.paused) { + viewsSlideshowSingleFramePause(settings); + } + }); + } // Show image count for people who have js enabled. $('#views_slideshow_singleframe_image_count_' + settings.vss_id).show(); @@ -277,3 +302,107 @@ function readCookie(name) { function eraseCookie(name) { createCookie(name,"",-1); } + +/** + * Checks to see if the slide is visible enough. + * elem = element to check. + * type = The way to calculate how much is visible. + * amountVisible = amount that should be visible. Either in percent or px. If + * it's not defined then all of the slide must be visible. + * + * Returns true or false + */ +function viewsSlideshowSingleFrameIsVisible(elem, type, amountVisible) { + // Get the top and bottom of the window; + var docViewTop = $(window).scrollTop(); + var docViewBottom = docViewTop + $(window).height(); + var docViewLeft = $(window).scrollLeft(); + var docViewRight = docViewLeft + $(window).width(); + + // Get the top, bottom, and height of the slide; + var elemTop = $(elem).offset().top; + var elemHeight = $(elem).height(); + var elemBottom = elemTop + elemHeight; + var elemLeft = $(elem).offset().left; + var elemWidth = $(elem).width(); + var elemRight = elemLeft + elemWidth; + var elemArea = elemHeight * elemWidth; + + // Calculate what's hiding in the slide. + var missingLeft = 0; + var missingRight = 0; + var missingTop = 0; + var missingBottom = 0; + + // Find out how much of the slide is missing from the left. + if (elemLeft < docViewLeft) { + missingLeft = docViewLeft - elemLeft; + } + + // Find out how much of the slide is missing from the right. + if (elemRight > docViewRight) { + missingRight = elemRight - docViewRight; + } + + // Find out how much of the slide is missing from the top. + if (elemTop < docViewTop) { + missingTop = docViewTop - elemTop; + } + + // Find out how much of the slide is missing from the bottom. + if (elemBottom > docViewBottom) { + missingBottom = elemBottom - docViewBottom; + } + + // If there is no amountVisible defined then check to see if the whole slide + // is visible. + if (type == 'full') { + return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) + && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) + && (elemLeft >= docViewLeft) && (elemRight <= docViewRight) + && (elemLeft <= docViewRight) && (elemRight >= docViewLeft)); + } + else if(type == 'vertical') { + var verticalShowing = elemHeight - missingTop - missingBottom; + + // If user specified a percentage then find out if the current shown percent + // is larger than the allowed percent. + // Otherwise check to see if the amount of px shown is larger than the + // allotted amount. + if (amountVisible.indexOf('%')) { + return (((verticalShowing/elemHeight)*100) >= parseInt(amountVisible)); + } + else { + return (verticalShowing >= parseInt(amountVisible)); + } + } + else if(type == 'horizontal') { + var horizontalShowing = elemWidth - missingLeft - missingRight; + + // If user specified a percentage then find out if the current shown percent + // is larger than the allowed percent. + // Otherwise check to see if the amount of px shown is larger than the + // allotted amount. + if (amountVisible.indexOf('%')) { + return (((horizontalShowing/elemHeight)*100) >= parseInt(amountVisible)); + } + else { + return (horizontalShowing >= parseInt(amountVisible)); + } + } + else if(type == 'area') { + var areaShowing = (elemWidth - missingLeft - missingRight) * (elemHeight - missingTop - missingBottom); + + // If user specified a percentage then find out if the current shown percent + // is larger than the allowed percent. + // Otherwise check to see if the amount of px shown is larger than the + // allotted amount. + if (amountVisible.indexOf('%')) { + return (((areaShowing/elemArea)*100) >= parseInt(amountVisible)); + } + else { + return (areaShowing >= parseInt(amountVisible)); + } + } +} + Index: contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_singleframe/Attic/views_slideshow_singleframe.views_slideshow.inc,v retrieving revision 1.1.2.1.2.24 diff -u -p -r1.1.2.1.2.24 views_slideshow_singleframe.views_slideshow.inc --- contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc 6 Jun 2010 22:47:45 -0000 1.1.2.1.2.24 +++ contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc 27 Jun 2010 15:17:27 -0000 @@ -26,6 +26,9 @@ function views_slideshow_singleframe_vie 'random' => array('default' => 0), 'pause' => array('default' => 1), 'pause_on_click' => array('default' => 0), + 'pause_when_hidden' => array('default' => 0), + 'pasue_when_hidden_type' => array('default' => 'full'), + 'amount_allowed_visible' => array('default' => ''), 'remember_slide' => array('default' => 0), 'remember_slide_days' => array('default' => 1), 'controls' => array('default' => 0), @@ -102,6 +105,41 @@ function views_slideshow_singleframe_vie '#default_value' => $view->options['views_slideshow_singleframe']['pause_on_click'], '#description' => t('Pause when the slide is clicked.'), ); + $form['views_slideshow_singleframe']['pause_when_hidden'] = array( + '#type' => 'checkbox', + '#title' => t('Pause When the Slideshow is Not Visible'), + '#default_value' => $view->options['views_slideshow_singleframe']['pause_when_hidden'], + '#description' => t('When the slideshow is scrolled out of view this will pause the slideshow.'), + ); + $form['views_slideshow_singleframe']['pause_when_hidden_type'] = array( + '#type' => 'select', + '#title' => t('How to Calculate Amount of Slide that Needs to be Shown'), + '#options' => array( + 'full' => t('Entire slide'), + 'vertical' => t('Set amount of vertical'), + 'horizontal' => t('Set amount of horizontal'), + 'area' => t('Set total area of the slide'), + ), + '#default_value' => $view->options['views_slideshow_singleframe']['pause_when_hidden_type'], + '#description' => t('Choose how to calculate how much of the slide has to be shown. Entire Slide: All the slide has to be shown. Vertical: Set amount of height that has to be shown. Horizontal: Set amount of width that has to be shown. Area: Set total area that has to be shown.'), + '#process' => array('views_process_dependency'), + '#dependency' => array('edit-style-options-views-slideshow-singleframe-pause-when-hidden' => array(1)), + ); + $form['views_slideshow_singleframe']['amount_allowed_visible'] = array( + '#type' => 'textfield', + '#title' => t('Amount of Slide Needed to be Shown'), + '#default_value' => $view->options['views_slideshow_singleframe']['amount_allowed_visible'], + '#description' => t('The amount of the slide that needs to be shown to have it rotate. You can set a percentage such as 50% or the height in px such as 250.'), + '#size' => 4, + '#process' => array('views_process_dependency'), + '#dependency' => array( + 'edit-style-options-views-slideshow-singleframe-pause-when-hidden-type' => array( + 'vertical', + 'horizontal', + 'area', + ), + ), + ); $form['views_slideshow_singleframe']['remember_slide'] = array( '#type' => 'checkbox', '#title' => t('Start On Last Slide Viewed'), Index: contrib/views_slideshow_thumbnailhover/views_slideshow.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_thumbnailhover/Attic/views_slideshow.js,v retrieving revision 1.1.2.2.2.34 diff -u -p -r1.1.2.2.2.34 views_slideshow.js --- contrib/views_slideshow_thumbnailhover/views_slideshow.js 17 Jun 2010 03:18:02 -0000 1.1.2.2.2.34 +++ contrib/views_slideshow_thumbnailhover/views_slideshow.js 27 Jun 2010 15:17:27 -0000 @@ -148,6 +148,32 @@ Drupal.behaviors.viewsSlideshowThumbnail if (settings.start_paused) { viewsSlideshowThumbnailHoverPause(settings); } + + // Pause if hidden. + if (settings.pause_when_hidden) { + // If the slideshow is visible and it is paused then resume. + // otherwise if the slideshow is not visible and it is not paused then + // pause it. + if (viewsSlideshowThumbnailHoverIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible) && settings.paused) { + viewsSlideshowThumbnailHoverResume(settings); + } + else if (!viewsSlideshowThumbnailHoverIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible) && !settings.paused) { + viewsSlideshowThumbnailHoverPause(settings); + } + + // Check when scrolled. + $(window).scroll(function() { + // If the slideshow is visible and it is paused then resume. + // otherwise if the slideshow is not visible and it is not paused then + // pause it. + if (viewsSlideshowThumbnailHoverIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible) && settings.paused) { + viewsSlideshowThumbnailHoverResume(settings); + } + else if (!viewsSlideshowThumbnailHoverIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible) && !settings.paused) { + viewsSlideshowThumbnailHoverPause(settings); + } + }); + } // Show image count for people who have js enabled. $('#views_slideshow_thumbnailhover_image_count_' + settings.vss_id).show(); @@ -267,3 +293,104 @@ function eraseCookie(name) { createCookie(name,"",-1); } +/** + * Checks to see if the slide is visible enough. + * elem = element to check. + * amountVisible = amount that should be visible. Either in percent or px. If + * it's not defined then all of the slide must be visible. + * + * Returns true or false + */ +function viewsSlideshowThumbnailHoverIsVisible(elem, type, amountVisible) { + // Get the top and bottom of the window; + var docViewTop = $(window).scrollTop(); + var docViewBottom = docViewTop + $(window).height(); + var docViewLeft = $(window).scrollLeft(); + var docViewRight = docViewLeft + $(window).width(); + + // Get the top, bottom, and height of the slide; + var elemTop = $(elem).offset().top; + var elemHeight = $(elem).height(); + var elemBottom = elemTop + elemHeight; + var elemLeft = $(elem).offset().left; + var elemWidth = $(elem).width(); + var elemRight = elemLeft + elemWidth; + var elemArea = elemHeight * elemWidth; + + // Calculate what's hiding in the slide. + var missingLeft = 0; + var missingRight = 0; + var missingTop = 0; + var missingBottom = 0; + + // Find out how much of the slide is missing from the left. + if (elemLeft < docViewLeft) { + missingLeft = docViewLeft - elemLeft; + } + + // Find out how much of the slide is missing from the right. + if (elemRight > docViewRight) { + missingRight = elemRight - docViewRight; + } + + // Find out how much of the slide is missing from the top. + if (elemTop < docViewTop) { + missingTop = docViewTop - elemTop; + } + + // Find out how much of the slide is missing from the bottom. + if (elemBottom > docViewBottom) { + missingBottom = elemBottom - docViewBottom; + } + + // If there is no amountVisible defined then check to see if the whole slide + // is visible. + if (type == 'full') { + return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) + && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) + && (elemLeft >= docViewLeft) && (elemRight <= docViewRight) + && (elemLeft <= docViewRight) && (elemRight >= docViewLeft)); + } + else if(type == 'vertical') { + var verticalShowing = elemHeight - missingTop - missingBottom; + + // If user specified a percentage then find out if the current shown percent + // is larger than the allowed percent. + // Otherwise check to see if the amount of px shown is larger than the + // allotted amount. + if (amountVisible.indexOf('%')) { + return (((verticalShowing/elemHeight)*100) >= parseInt(amountVisible)); + } + else { + return (verticalShowing >= parseInt(amountVisible)); + } + } + else if(type == 'horizontal') { + var horizontalShowing = elemWidth - missingLeft - missingRight; + + // If user specified a percentage then find out if the current shown percent + // is larger than the allowed percent. + // Otherwise check to see if the amount of px shown is larger than the + // allotted amount. + if (amountVisible.indexOf('%')) { + return (((horizontalShowing/elemHeight)*100) >= parseInt(amountVisible)); + } + else { + return (horizontalShowing >= parseInt(amountVisible)); + } + } + else if(type == 'area') { + var areaShowing = (elemWidth - missingLeft - missingRight) * (elemHeight - missingTop - missingBottom); + + // If user specified a percentage then find out if the current shown percent + // is larger than the allowed percent. + // Otherwise check to see if the amount of px shown is larger than the + // allotted amount. + if (amountVisible.indexOf('%')) { + return (((areaShowing/elemArea)*100) >= parseInt(amountVisible)); + } + else { + return (areaShowing >= parseInt(amountVisible)); + } + } +} Index: contrib/views_slideshow_thumbnailhover/views_slideshow_thumbnailhover.views_slideshow.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_slideshow/contrib/views_slideshow_thumbnailhover/Attic/views_slideshow_thumbnailhover.views_slideshow.inc,v retrieving revision 1.1.2.1.2.24 diff -u -p -r1.1.2.1.2.24 views_slideshow_thumbnailhover.views_slideshow.inc --- contrib/views_slideshow_thumbnailhover/views_slideshow_thumbnailhover.views_slideshow.inc 6 Jun 2010 22:47:45 -0000 1.1.2.1.2.24 +++ contrib/views_slideshow_thumbnailhover/views_slideshow_thumbnailhover.views_slideshow.inc 27 Jun 2010 15:17:27 -0000 @@ -32,6 +32,9 @@ function views_slideshow_thumbnailhover_ 'random' => array('default' => 0), 'pause' => array('default' => 1), 'pause_on_click' => array('default' => 0), + 'pause_when_hidden' => array('default' => 0), + 'pasue_when_hidden_type' => array('default' => 'full'), + 'amount_allowed_visible' => array('default' => ''), 'remember_slide' => array('default' => 0), 'remember_slide_days' => array('default' => 1), 'pager_event' => array('default' => 'hover'), @@ -158,6 +161,41 @@ function views_slideshow_thumbnailhover_ '#default_value' => $view->options['views_slideshow_thumbnailhover']['pause_on_click'], '#description' => t('Pause when the slide is clicked.'), ); + $form['views_slideshow_thumbnailhover']['pause_when_hidden'] = array( + '#type' => 'checkbox', + '#title' => t('Pause When the Slideshow is Not Visible'), + '#default_value' => $view->options['views_slideshow_thumbnailhover']['pause_when_hidden'], + '#description' => t('When the slideshow is scrolled out of view this will pause the slideshow.'), + ); + $form['views_slideshow_thumbnailhover']['pause_when_hidden_type'] = array( + '#type' => 'select', + '#title' => t('How to Calculate Amount of Slide that Needs to be Shown'), + '#options' => array( + 'full' => t('Entire slide'), + 'vertical' => t('Set amount of vertical'), + 'horizontal' => t('Set amount of horizontal'), + 'area' => t('Set total area of the slide'), + ), + '#default_value' => $view->options['views_slideshow_thumbnailhover']['pause_when_hidden_type'], + '#description' => t('Choose how to calculate how much of the slide has to be shown. Entire Slide: All the slide has to be shown. Vertical: Set amount of height that has to be shown. Horizontal: Set amount of width that has to be shown. Area: Set total area that has to be shown.'), + '#process' => array('views_process_dependency'), + '#dependency' => array('edit-style-options-views-slideshow-thumbnailhover-pause-when-hidden' => array(1)), + ); + $form['views_slideshow_thumbnailhover']['amount_allowed_visible'] = array( + '#type' => 'textfield', + '#title' => t('Amount of Slide Needed to be Shown'), + '#default_value' => $view->options['views_slideshow_thumbnailhover']['amount_allowed_visible'], + '#description' => t('The amount of the slide that needs to be shown to have it rotate. You can set a percentage such as 50% or the height in px such as 250.'), + '#size' => 4, + '#process' => array('views_process_dependency'), + '#dependency' => array( + 'edit-style-options-views-slideshow-thumbnailhover-pause-when-hidden-type' => array( + 'vertical', + 'horizontal', + 'area', + ), + ), + ); $form['views_slideshow_thumbnailhover']['remember_slide'] = array( '#type' => 'checkbox', '#title' => t('Start On Last Slide Viewed'),