1 2/** 3 * @file 4 * A simple jQuery SingleFrame Div Slideshow Rotator. 5 */ 6 7(function ($) { 8 /** 9 * This will set our initial behavior, by starting up each individual slideshow. 10 */ 11 Drupal.behaviors.viewsSlideshowSingleFrame = function (context) { 12 $('.views_slideshow_singleframe_main:not(.viewsSlideshowSingleFrame-processed)', context).addClass('viewsSlideshowSingleFrame-processed').each(function() { 13 var fullId = '#' + $(this).attr('id'); 14 if (!Drupal.settings.viewsSlideshowSingleFrame || !Drupal.settings.viewsSlideshowSingleFrame[fullId]) { 15 return; 16 } 17 var settings = Drupal.settings.viewsSlideshowSingleFrame[fullId]; 18 settings.targetId = '#' + $(fullId + " :first").attr('id'); 19 settings.paused = false; 20 21 settings.opts = { 22 speed:settings.speed, 23 timeout:parseInt(settings.timeout), 24 delay:parseInt(settings.delay), 25 sync:settings.sync==1, 26 random:settings.random==1, 27 pause:false, 28 allowPagerClickBubble:(settings.pager_hover==1 || settings.pager_click_to_page), 29 prev:(settings.controls > 0)?'#views_slideshow_singleframe_prev_' + settings.vss_id:null, 30 next:(settings.controls > 0)?'#views_slideshow_singleframe_next_' + settings.vss_id:null, 31 pager:(settings.pager > 0)?'#views_slideshow_singleframe_pager_' + settings.vss_id:null, 32 nowrap:parseInt(settings.nowrap), 33 pagerAnchorBuilder: function(idx, slide) { 34 var classes = 'pager-item pager-num-' + (idx+1); 35 if (idx == 0) { 36 classes += ' first'; 37 } 38 if ($(slide).siblings().length == idx) { 39 classes += ' last'; 40 } 41 42 if (idx % 2) { 43 classes += ' odd'; 44 } 45 else { 46 classes += ' even'; 47 } 48 49 var theme = 'viewsSlideshowPager' + settings.pager_type; 50 return Drupal.theme.prototype[theme] ? Drupal.theme(theme, classes, idx, slide, settings) : ''; 51 }, 52 after:function(curr, next, opts) { 53 // Used for Image Counter. 54 if (settings.image_count) { 55 $('#views_slideshow_singleframe_image_count_' + settings.vss_id + ' span.num').html(opts.currSlide + 1); 56 $('#views_slideshow_singleframe_image_count_' + settings.vss_id + ' span.total').html(opts.slideCount); 57 } 58 }, 59 before:function(curr, next, opts) { 60 // Remember last slide. 61 if (settings.remember_slide) { 62 createCookie(settings.vss_id, opts.currSlide + 1, settings.remember_slide_days); 63 } 64 65 // Make variable height. 66 if (settings.fixed_height == 0) { 67 //get the height of the current slide 68 var $ht = $(this).height(); 69 //set the container's height to that of the current slide 70 $(this).parent().animate({height: $ht}); 71 } 72 }, 73 cleartype:(settings.ie.cleartype == 'true')? true : false, 74 cleartypeNoBg:(settings.ie.cleartypenobg == 'true')? true : false 75 } 76 77 // Set the starting slide if we are supposed to remember the slide 78 if (settings.remember_slide) { 79 var startSlide = readCookie(settings.vss_id); 80 if (startSlide == null) { 81 startSlide = 0; 82 } 83 settings.opts.startingSlide = startSlide; 84 } 85 86 if (settings.pager_hover == 1) { 87 settings.opts.pagerEvent = 'mouseover'; 88 settings.opts.pauseOnPagerHover = true; 89 } 90 91 if (settings.effect == 'none') { 92 settings.opts.speed = 1; 93 } 94 else { 95 settings.opts.fx = settings.effect; 96 } 97 98 // Pause on hover. 99 if (settings.pause == 1) { 100 $('#views_slideshow_singleframe_teaser_section_' + settings.vss_id).hover(function() { 101 $(settings.targetId).cycle('pause'); 102 }, function() { 103 if (settings.paused == false) { 104 $(settings.targetId).cycle('resume'); 105 } 106 }); 107 } 108 109 // Pause on clicking of the slide. 110 if (settings.pause_on_click == 1) { 111 $('#views_slideshow_singleframe_teaser_section_' + settings.vss_id).click(function() { 112 viewsSlideshowSingleFramePause(settings); 113 }); 114 } 115 116 // Add additional settings. 117 if (settings.advanced != "\n") { 118 settings.advanced.toString(); 119 var advanced = settings.advanced.split("\n"); 120 for (i=0; i<advanced.length; i++) { 121 var prop = ''; 122 var value = ''; 123 var property = advanced[i].split(":"); 124 for (j=0; j<property.length; j++) { 125 if (j == 0) { 126 prop = property[j]; 127 } 128 else if (j == 1) { 129 value = property[j]; 130 } 131 else { 132 value += ":" + property[j]; 133 } 134 } 135 136 // Need to evaluate so true, false and numerics aren't a string. 137 if (value == 'true' || value == 'false' || IsNumeric(value)) { 138 value = eval(value); 139 } 140 else { 141 // Parse strings into functions. 142 var func = value.match(/function\s*\((.*?)\)\s*\{(.*)\}/i); 143 if (func) { 144 value = new Function(func[1].match(/(\w+)/g), func[2]); 145 } 146 } 147 148 // Call both functions if prop was set previously. 149 if (typeof(value) == "function" && prop in settings.opts) {
150 var callboth = function(before_func, new_func) { 151 return function() { 152 before_func.apply(null, arguments); 153 new_func.apply(null, arguments); 154 }; 155 }; 156 settings.opts[prop] = callboth(settings.opts[prop], value); 157 } 158 else { 159 settings.opts[prop] = value; 160 } 161 } 162 } 163 164 $(settings.targetId).cycle(settings.opts); 165 166 // Start Paused 167 if (settings.start_paused) { 168 viewsSlideshowSingleFramePause(settings); 169 } 170 171 // Pause if hidden. 172 if (settings.pause_when_hidden) { 173 var checkPause = function(settings) { 174 // If the slideshow is visible and it is paused then resume. 175 // otherwise if the slideshow is not visible and it is not paused then 176 // pause it. 177 var visible = viewsSlideshowSingleFrameIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible); 178 if (visible && settings.paused) { 179 viewsSlideshowSingleFrameResume(settings); 180 } 181 else if (!visible && !settings.paused) { 182 viewsSlideshowSingleFramePause(settings); 183 } 184 } 185 186 // Check when scrolled. 187 $(window).scroll(function() { 188 checkPause(settings); 189 }); 190 191 // Check when the window is resized. 192 $(window).resize(function() { 193 checkPause(settings); 194 }); 195 } 196 197 // Show image count for people who have js enabled. 198 $('#views_slideshow_singleframe_image_count_' + settings.vss_id).show(); 199 200 if (settings.controls > 0) { 201 // Show controls for people who have js enabled browsers. 202 $('#views_slideshow_singleframe_controls_' + settings.vss_id).show(); 203 204 $('#views_slideshow_singleframe_playpause_' + settings.vss_id).click(function(e) { 205 if (settings.paused) { 206 viewsSlideshowSingleFrameResume(settings); 207 } 208 else { 209 viewsSlideshowSingleFramePause(settings); 210 } 211 e.preventDefault(); 212 }); 213 } 214 }); 215 } 216 217 // Pause the slideshow 218 viewsSlideshowSingleFramePause = function (settings) { 219 //make Resume translatable 220 var resume = Drupal.t('Resume'); 221 222 $(settings.targetId).cycle('pause'); 223 if (settings.controls > 0) { 224 $('#views_slideshow_singleframe_playpause_' + settings.vss_id) 225 .addClass('views_slideshow_singleframe_play') 226 .addClass('views_slideshow_play') 227 .removeClass('views_slideshow_singleframe_pause') 228 .removeClass('views_slideshow_pause') 229 .text(resume); 230 } 231 settings.paused = true; 232 } 233 234 // Resume the slideshow 235 viewsSlideshowSingleFrameResume = function (settings) { 236 // Make Pause translatable 237 var pause = Drupal.t('Pause'); 238 $(settings.targetId).cycle('resume'); 239 if (settings.controls > 0) { 240 $('#views_slideshow_singleframe_playpause_' + settings.vss_id) 241 .addClass('views_slideshow_singleframe_pause') 242 .addClass('views_slideshow_pause') 243 .removeClass('views_slideshow_singleframe_play') 244 .removeClass('views_slideshow_play') 245 .text(pause); 246 } 247 settings.paused = false; 248 } 249 250 Drupal.theme.prototype.viewsSlideshowPagerThumbnails = function (classes, idx, slide, settings) { 251 var href = '#'; 252 if (settings.pager_click_to_page) { 253 href = $(slide).find('a').attr('href'); 254 } 255 var img = $(slide).find('img'); 256 return '<div class="' + classes + '"><a href="' + href + '"><img src="' + $(img).attr('src') + '" alt="' + $(img).attr('alt') + '" title="' + $(img).attr('title') + '"/></a></div>'; 257 } 258 259 Drupal.theme.prototype.viewsSlideshowPagerNumbered = function (classes, idx, slide, settings) { 260 var href = '#'; 261 if (settings.pager_click_to_page) { 262 href = $(slide).find('a').attr('href'); 263 } 264 return '<div class="' + classes + '"><a href="' + href + '">' + (idx+1) + '</a></div>'; 265 } 266 267 // Verify that the value is a number. 268 function IsNumeric(sText) {
269 var ValidChars = "0123456789"; 270 var IsNumber=true; 271 var Char; 272 273 for (var i=0; i < sText.length && IsNumber == true; i++) { 274 Char = sText.charAt(i); 275 if (ValidChars.indexOf(Char) == -1) { 276 IsNumber = false; 277 } 278 } 279 return IsNumber; 280 } 281 282 /** 283 * Cookie Handling Functions 284 */ 285 function createCookie(name,value,days) { 286 if (days) { 287 var date = new Date(); 288 date.setTime(date.getTime()+(days*24*60*60*1000)); 289 var expires = "; expires="+date.toGMTString(); 290 } 291 else { 292 var expires = ""; 293 } 294 document.cookie = name+"="+value+expires+"; path=/"; 295 } 296 297 function readCookie(name) { 298 var nameEQ = name + "="; 299 var ca = document.cookie.split(';'); 300 for(var i=0;i < ca.length;i++) { 301 var c = ca[i]; 302 while (c.charAt(0)==' ') c = c.substring(1,c.length); 303 if (c.indexOf(nameEQ) == 0) { 304 return c.substring(nameEQ.length,c.length); 305 } 306 } 307 return null; 308 } 309 310 function eraseCookie(name) { 311 createCookie(name,"",-1); 312 } 313 314 /** 315 * Checks to see if the slide is visible enough. 316 * elem = element to check. 317 * type = The way to calculate how much is visible. 318 * amountVisible = amount that should be visible. Either in percent or px. If 319 * it's not defined then all of the slide must be visible. 320 * 321 * Returns true or false 322 */ 323 function viewsSlideshowSingleFrameIsVisible(elem, type, amountVisible) { 324 // Get the top and bottom of the window; 325 var docViewTop = $(window).scrollTop(); 326 var docViewBottom = docViewTop + $(window).height(); 327 var docViewLeft = $(window).scrollLeft(); 328 var docViewRight = docViewLeft + $(window).width(); 329 330 // Get the top, bottom, and height of the slide; 331 var elemTop = $(elem).offset().top; 332 var elemHeight = $(elem).height(); 333 var elemBottom = elemTop + elemHeight; 334 var elemLeft = $(elem).offset().left; 335 var elemWidth = $(elem).width(); 336 var elemRight = elemLeft + elemWidth; 337 var elemArea = elemHeight * elemWidth; 338 339 // Calculate what's hiding in the slide. 340 var missingLeft = 0; 341 var missingRight = 0; 342 var missingTop = 0; 343 var missingBottom = 0; 344 345 // Find out how much of the slide is missing from the left. 346 if (elemLeft < docViewLeft) { 347 missingLeft = docViewLeft - elemLeft; 348 } 349 350 // Find out how much of the slide is missing from the right. 351 if (elemRight > docViewRight) { 352 missingRight = elemRight - docViewRight; 353 } 354 355 // Find out how much of the slide is missing from the top. 356 if (elemTop < docViewTop) { 357 missingTop = docViewTop - elemTop; 358 } 359 360 // Find out how much of the slide is missing from the bottom. 361 if (elemBottom > docViewBottom) { 362 missingBottom = elemBottom - docViewBottom; 363 } 364 365 // If there is no amountVisible defined then check to see if the whole slide 366 // is visible. 367 if (type == 'full') { 368 return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) 369 && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) 370 && (elemLeft >= docViewLeft) && (elemRight <= docViewRight) 371 && (elemLeft <= docViewRight) && (elemRight >= docViewLeft)); 372 } 373 else if(type == 'vertical') { 374 var verticalShowing = elemHeight - missingTop - missingBottom; 375 376 // If user specified a percentage then find out if the current shown percent 377 // is larger than the allowed percent. 378 // Otherwise check to see if the amount of px shown is larger than the 379 // allotted amount. 380 if (amountVisible.indexOf('%')) { 381 return (((verticalShowing/elemHeight)*100) >= parseInt(amountVisible)); 382 } 383 else { 384 return (verticalShowing >= parseInt(amountVisible)); 385 } 386 } 387 else if(type == 'horizontal') { 388 var horizontalShowing = elemWidth - missingLeft - missingRight; 389 390 // If user specified a percentage then find out if the current shown percent 391 // is larger than the allowed percent. 392 // Otherwise check to see if the amount of px shown is larger than the 393 // allotted amount. 394 if (amountVisible.indexOf('%')) { 395 return (((horizontalShowing/elemWidth)*100) >= parseInt(amountVisible)); 396 } 397 else { 398 return (horizontalShowing >= parseInt(amountVisible)); 399 } 400 } 401 else if(type == 'area') { 402 var areaShowing = (elemWidth - missingLeft - missingRight) * (elemHeight - missingTop - missingBottom); 403 404 // If user specified a percentage then find out if the current shown percent 405 // is larger than the allowed percent. 406 // Otherwise check to see if the amount of px shown is larger than the 407 // allotted amount. 408 if (amountVisible.indexOf('%')) { 409 return (((areaShowing/elemArea)*100) >= parseInt(amountVisible)); 410 } 411 else { 412 return (areaShowing >= parseInt(amountVisible)); 413 } 414 } 415 } 416})(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.