1/** 2 * @file 3 * Views Slideshow Xtra Javascript. 4 */ 5(function ($) { 6 Drupal.behaviors.viewsSlideshowXtraOverlay = { 7 attach: function (context) { 8 9 // Return if there are no vsx elements on the page 10 if ($('.views-slideshow-xtra-overlay').length == 0) { 11 return; 12 } 13 14 // Hide all overlays for all slides. 15 $('.views-slideshow-xtra-overlay-row').hide(); 16 17 var pageX = 0, pageY = 0, timeout; 18 19 // Modify the slideshow(s) that have a vsx overlay. 20 $('.views_slideshow_main').each(function() { 21 var slideshowMain = $(this); 22 23 // Get the view for this slideshow 24 var view = slideshowMain.closest('.view'); 25 26 // Process the view if it has at least one overlay. 27 if ($('.views-slideshow-xtra-overlay', view).length > 0) { 28 29 // Get the View ID and Display ID so we can get the settings. 30 var viewClasses = classList(view); 31 32 $.each( viewClasses, function(index, item) { 33 // We need this code because the id of the element selected will be something like: 34 // "views_slideshow_cycle_main_views_slideshow_xtra_example-page" 35 // We don't want to reference the string "cycle" in our code, and there is not a way to 36 // get the "View ID - Display ID" substring from the id string, unless the string "cycle" 37 // is referenced in a string manipulation function. 38 39 // Get the View ID 40 if((/^view-id-/).test(item)) { 41 viewId = item.substring('view-id-'.length); 42 } 43 44 // Get the Display ID 45 if((/^view-display-id-/).test(item)) { 46 viewDisplayId = item.substring('view-display-id-'.length); 47 } 48 49 }); 50 51 if(typeof viewId != "undefined") { 52 53 // Get the settings. 54 var settings = Drupal.settings.viewsSlideshowXtraOverlay[viewId + '-' + viewDisplayId]; 55 56 // Set Pause after mouse movement setting. 57 if (settings.hasOwnProperty('pauseAfterMouseMove')) { 58 var pauseAfterMouseMove = settings.pauseAfterMouseMove; 59 if (pauseAfterMouseMove > 0) { 60 $(this).mousemove(function(e) { 61 if (pageX - e.pageX > 5 || pageY - e.pageY > 5) { 62 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": viewId + '-' + viewDisplayId }); 63 clearTimeout(timeout); 64 timeout = setTimeout(function() { 65 Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": viewId + '-' + viewDisplayId }); 66 }, 2000); 67 } 68 pageX = e.pageX; 69 pageY = e.pageY; 70 }); 71 } 72 } 73 74 } 75 76 // Process the overlay(s). 77 $('.views-slideshow-xtra-overlay:not(.views-slideshow-xtra-overlay-processed)', view).addClass('views-slideshow-xtra-overlay-processed').each(function() { 78 // Remove the overlay html from the dom 79 var overlayHTML = $(this).detach(); 80 // Attach the overlay to the slideshow main div. 81 $(overlayHTML).appendTo(slideshowMain); 82 }); 83 84 } 85 86 }); 87 } 88 }; 89 90 Drupal.viewsSlideshowXtraOverlay = Drupal.viewsSlideshowXtraOverlay || {}; 91 92 Drupal.viewsSlideshowXtraOverlay.transitionBegin = function (options) { 93 94 // Hide all overlays for all slides. 95 $('#views_slideshow_cycle_main_' + options.slideshowID + ' .views-slideshow-xtra-overlay-row').hide(); 96 97 // Show the overlays for the current slide. 98 $('#views_slideshow_cycle_main_' + options.slideshowID + ' [id^="views-slideshow-xtra-overlay-"]' + ' .views-slideshow-xtra-overlay-row-' + options.slideNum).each(function() { 99 100 // Get the overlay settings. 101 var overlay = $(this); 102 var overlayContainerId = overlay.parent().attr('id'); 103 var settings = Drupal.settings.viewsSlideshowXtraOverlay[overlayContainerId]; 104 105 // Fade in or show overlay with optional delay. 106 setTimeout(function() { 107 if(settings.overlayFadeIn) { 108 overlay.fadeIn(settings.overlayFadeIn); 109 } else { 110 overlay.show(); 111 } 112 }, 113 settings.overlayDelay 114 ); 115 116 // Fade out overlay with optional delay. 117 if(settings.overlayFadeOut) { 118 setTimeout(function() { 119 overlay.fadeOut(settings.overlayFadeOut); 120 }, 121 settings.overlayFadeOutDelay 122 ); 123 } 124 125 }); 126 }; 127 128 function classList(elem){ 129 var classList = elem.attr('class').split(/\s+/); 130 var classes = new Array(classList.length); 131 $.each( classList, function(index, item){ 132 classes[index] = item; 133 }); 134 135 return classes; 136 } 137 138})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.