1/** 2 * @file 3 * A simple jQuery Cycle Div Slideshow Rotator. 4 */ 5 6/** 7 * This will set our initial behavior, by starting up each individual slideshow. 8 */ 9(function ($) { 10 Drupal.behaviors.viewsSlideshowCycle = { 11 attach: function (context) { 12 $('.views_slideshow_cycle_main:not(.viewsSlideshowCycle-processed)', context).addClass('viewsSlideshowCycle-processed').each(function() { 13 var fullId = '#' + $(this).attr('id'); 14 var settings = Drupal.settings.viewsSlideshowCycle[fullId]; 15 settings.targetId = '#' + $(fullId + " :first").attr('id'); 16 17 settings.slideshowId = settings.targetId.replace('#views_slideshow_cycle_teaser_section_', ''); 18 // Pager after function. 19 var pager_after_fn = function(curr, next, opts) { 20 // Need to do some special handling on first load. 21 var slideNum = opts.currSlide; 22 if (typeof settings.processedAfter == 'undefined' || !settings.processedAfter) { 23 settings.processedAfter = 1; 24 slideNum = (typeof settings.opts.startingSlide == 'undefined') ? 0 : settings.opts.startingSlide; 25 } 26 if (settings.pause_after_slideshow) { 27 opts.counter += 1; 28 if (opts.counter == settings.num_divs + 1) { 29 opts.counter = 1; 30 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true }); 31 } 32 } 33 Drupal.viewsSlideshow.action({ "action": 'transitionEnd', "slideshowID": settings.slideshowId, "slideNum": slideNum }); 34 } 35 // Pager before function. 36 var pager_before_fn = function(curr, next, opts) { 37 $(document).trigger('drupal:views_slideshow_cycle:before', { 38 curr: curr, next: next, opts: opts, settings: settings 39 }); 40 41 var slideNum = opts.nextSlide; 42 43 // Remember last slide. 44 if (settings.remember_slide) { 45 createCookie(settings.vss_id, slideNum, settings.remember_slide_days); 46 } 47 48 // Make variable height. 49 if (!settings.fixed_height) { 50 //get the height of the current slide 51 var $ht = $(next).height(); 52 //set the container's height to that of the current slide 53 $(next).parent().animate({height: $ht}); 54 } 55 56 // Need to do some special handling on first load. 57 if (typeof settings.processedBefore == 'undefined' || !settings.processedBefore) { 58 settings.processedBefore = 1; 59 slideNum = (typeof opts.startingSlide == 'undefined') ? 0 : opts.startingSlide; 60 } 61 62 Drupal.viewsSlideshow.action({ "action": 'transitionBegin', "slideshowID": settings.slideshowId, "slideNum": slideNum }); 63 } 64 settings.loaded = false; 65 66 settings.opts = { 67 speed:settings.speed, 68 timeout:settings.timeout, 69 delay:settings.delay, 70 sync:settings.sync, 71 random:settings.random, 72 nowrap:settings.nowrap, 73 pause_after_slideshow:settings.pause_after_slideshow, 74 counter:0, 75 after:pager_after_fn, 76 before:pager_before_fn, 77 cleartype:(settings.cleartype)? true : false, 78 cleartypeNoBg:(settings.cleartypenobg)? true : false 79 } 80 81 // Set the starting slide if we are supposed to remember the slide 82 if (settings.remember_slide) { 83 var startSlide = readCookie(settings.vss_id); 84 if (startSlide == null) { 85 startSlide = 0; 86 } 87 settings.opts.startingSlide = parseInt(startSlide); 88 } 89 90 if (settings.effect == 'none') { 91 settings.opts.speed = 1; 92 } 93 else { 94 settings.opts.fx = settings.effect; 95 } 96 97 // Take starting item from fragment. 98 var hash = location.hash; 99 if (hash) { 100 var hash = hash.replace('#', ''); 101 var aHash = hash.split(';'); 102 var aHashLen = aHash.length; 103 104 // Loop through all the possible starting points. 105 for (var i = 0; i < aHashLen; i++) { 106 // Split the hash into two parts. One part is the slideshow id the 107 // other is the slide number. 108 var initialInfo = aHash[i].split(':'); 109 // The id in the hash should match our slideshow. 110 // The slide number chosen shouldn't be larger than the number of 111 // slides we have. 112 if (settings.slideshowId == initialInfo[0] && settings.num_divs >
112 initialInfo[1]) { 113 settings.opts.startingSlide = parseInt(initialInfo[1]); 114 } 115 } 116 } 117 118 // Pause on hover. 119 if (settings.pause) { 120 var mouseIn = function() { 121 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId }); 122 } 123 124 var mouseOut = function() { 125 Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId }); 126 } 127 128 if (jQuery.fn.hoverIntent) { 129 $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hoverIntent(mouseIn, mouseOut); 130 } 131 else { 132 $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(mouseIn, mouseOut); 133 } 134 } 135 136 // Play on hover. 137 if (settings.play_on_hover) { 138 var mouseIn = function() { 139 Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId, "force": true }); 140 } 141 142 var mouseOut = function() { 143 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId }); 144 } 145 146 if (jQuery.fn.hoverIntent) { 147 $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hoverIntent(mouseIn, mouseOut); 148 } 149 else { 150 $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(mouseIn, mouseOut); 151 } 152 } 153 154 // Pause on clicking of the slide. 155 if (settings.pause_on_click) { 156 $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).click(function() { 157 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true }); 158 }); 159 } 160 161 if (typeof JSON != 'undefined') { 162 var advancedOptions = JSON.parse(settings.advanced_options); 163 for (var option in advancedOptions) { 164 switch(option) { 165 166 // Standard Options 167 case "activePagerClass": 168 case "allowPagerClickBubble": 169 case "autostop": 170 case "autostopCount": 171 case "backwards": 172 case "bounce": 173 case "cleartype": 174 case "cleartypeNoBg": 175 case "containerResize": 176 case "continuous": 177 case "delay": 178 case "easeIn": 179 case "easeOut": 180 case "easing": 181 case "fastOnEvent": 182 case "fit": 183 case "fx": 184 case "manualTrump": 185 case "metaAttr": 186 case "next": 187 case "nowrap": 188 case "pager": 189 case "pagerEvent": 190 case "pause": 191 case "pauseOnPagerHover": 192 case "prev": 193 case "prevNextEvent": 194 case "random": 195 case "randomizeEffects": 196 case "requeueOnImageNotLoaded": 197 case "requeueTimeout": 198 case "rev": 199 case "slideExpr": 200 case "slideResize": 201 case "speed": 202 case "speedIn": 203 case "speedOut": 204 case "startingSlide": 205 case "sync": 206 case "timeout": 207 var optionValue = advancedOptions[option]; 208 optionValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(optionValue); 209 settings.opts[option] = optionValue; 210 break; 211 212 // If width is set we need to disable resizing. 213 case "width": 214 var optionValue = advancedOptions["width"]; 215 optionValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(optionValue); 216 settings.opts["width"] = optionValue; 217 settings.opts["containerResize"] = 0; 218 break; 219 220 // If height is set we need to set fixed_height to true. 221 case "height": 222 var optionValue = advancedOptions["height"]; 223 optionValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(optionValue); 224 settings.opts["height"] = optionValue; 225 settings.fixed_height = 1; 226 break; 227 228 // These process options that look like {top:50, bottom:20} 229 case "animIn": 230 case "animInDelay": 231 case "animOut": 232 case "animOutDelay": 233 case "cssBefore": 234 case "cssAfter": 235 case "shuffle": 236 var cssValue = advancedOptions[option]; 237 cssValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(cssValue); 238 settings.opts[option] = eval('(' + cssValue + ')'); 239 break; 240 241 // These options have their own functions. 242 case "after": 243 var afterValue = advancedOptions[option]; 244 afterValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(afterValue); 245 // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 246 settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) { 247 pager_after_fn(currSlideElement, nextSlideElement, options); 248 eval(afterValue); 249 } 250 break; 251 252 case "before": 253 var beforeValue = advancedOptions[option]; 254 beforeValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(beforeValue); 255 // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 256 settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) { 257 pager_before_fn(currSlideElement, nextSlideElement, options); 258 eval(beforeValue); 259 } 260 break; 261 262 case "end": 263 var endValue = advancedOptions[option]; 264 endValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(endValue); 265 // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) 266 settings.opts[option] = function(options) { 267 eval(endValue); 268 } 269 break; 270 271 case "fxFn": 272 var fxFnValue = advancedOptions[option]; 273 fxFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(fxFnValue); 274 // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) 275 settings.opts[option] = function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) { 276 eval(fxFnValue); 277 } 278 break; 279 280 case "onPagerEvent": 281 var onPagerEventValue = advancedOptions[option]; 282 onPagerEventValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(onPagerEventValue); 283 settings.opts[option] = function(zeroBasedSlideIndex, slideElement) { 284 eval(onPagerEventValue); 285 } 286 break; 287 288 case "onPrevNextEvent": 289 var onPrevNextEventValue = advancedOptions[option]; 290 onPrevNextEventValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(onPrevNextEventValue); 291 settings.opts[option] = function(isNext, zeroBasedSlideIndex, slideElement) { 292 eval(onPrevNextEventValue); 293 } 294 break; 295 296 case "pagerAnchorBuilder": 297 var pagerAnchorBuilderValue = advancedOptions[option]; 298 pagerAnchorBuilderValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pagerAnchorBuilderValue); 299 // callback fn for building anchor links: function(index, DOMelement) 300 settings.opts[option] = function(index, DOMelement) { 301 var returnVal = ''; 302 eval(pagerAnchorBuilderValue); 303 return returnVal; 304 } 305 break; 306 307 case "pagerClick": 308 var pagerClickValue = advancedOptions[option]; 309 pagerClickValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pagerClickValue); 310 // callback fn for pager clicks: function(zeroBasedSlideIndex, slideElement) 311 settings.opts[option] = function(zeroBasedSlideIndex, slideElement) { 312 eval(pagerClickValue); 313 } 314 break; 315 316 case "paused": 317 var pausedValue = advancedOptions[option]; 318 pausedValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pausedValue); 319 // undocumented callback when slideshow is paused: function(cont, opts, byHover) 320 settings.opts[option] = function(cont, opts, byHover) { 321 eval(pausedValue); 322 } 323 break; 324 325 case "resumed": 326 var resumedValue = advancedOptions[option]; 327 resumedValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(resumedValue); 328 // undocumented callback when slideshow is resumed: function(cont, opts, byHover) 329 settings.opts[option] = function(cont, opts, byHover) { 330 eval(resumedValue); 331 } 332 break; 333 334 case "timeoutFn": 335 var timeoutFnValue = advancedOptions[option]; 336 timeoutFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(timeoutFnValue); 337 settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) { 338 // Set a sane return value unless function overrides it. 339 var returnVal = settings.timeout; 340 eval(timeoutFnValue); 341 return returnVal; 342 } 343 break; 344 345 case "updateActivePagerLink": 346 var updateActivePagerLinkValue = advancedOptions[option]; 347 updateActivePagerLinkValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(updateActivePagerLinkValue); 348 // callback fn invoked to update the active pager link (adds/removes activePagerClass style) 349 settings.opts[option] = function(pager, currSlideIndex) { 350 eval(updateActivePagerLinkValue); 351 } 352 break; 353 } 354 } 355 } 356 357 // If selected wait for the images to be loaded. 358 // otherwise just load the slideshow. 359 if (settings.wait_for_image_load) { 360 // For IE/Chrome/Opera we if there are images then we need to make 361 // sure the images are loaded before starting the slideshow. 362 settings.totalImages = $(settings.targetId + ' img').length; 363 if (settings.totalImages) { 364 settings.loadedImages = 0; 365 366 // Add a load event for each image. 367 $(settings.targetId + ' img').each(function() { 368 var $imageElement = $(this); 369 $imageElement.bind('load', function () { 370 Drupal.viewsSlideshowCycle.imageWait(fullId); 371 }); 372 373 // Removing the source and adding it again will fire the load event. 374 var imgSrc = $imageElement.attr('src'); 375 $imageElement.attr('src', ''); 376 $imageElement.attr('src', imgSrc); 377 }); 378 379 // We need to set a timeout so that the slideshow doesn't wait 380 // indefinitely for all images to load. 381 setTimeout("Drupal.viewsSlideshowCycle.load('" + fullId + "')", settings.wait_for_image_load_timeout); 382 } 383 else { 384 Drupal.viewsSlideshowCycle.load(fullId); 385 } 386 } 387 else { 388 Drupal.viewsSlideshowCycle.load(fullId); 389 } 390 }); 391 } 392 }; 393 394 /** 395 * Views Slideshow swipe support. 396 */ 397 Drupal.behaviors.viewsSlideshowSwipe = { 398 attach: function (context) { 399 var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
400 if (isTouch === true && $('.views-slideshow-cycle-main-frame').length) { 401 var $slider = $('.views-slideshow-cycle-main-frame'), 402 opts = { 403 start: {x: 0, y: 0}, 404 end: {x: 0, y: 0}, 405 hdiff: 0, 406 vdiff: 0, 407 length: 0, 408 angle: null, 409 direction: null, 410 }, 411 optsReset = $.extend(true, {}, opts), 412 H_THRESHOLD = 110, // roughly one inch effective resolution on ipad 413 V_THRESHOLD = 50; 414 $slider.data('bw', opts) 415 .bind('touchstart.cycle', function (e) { 416 var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; 417 if (e.originalEvent.touches.length == 1) { 418 var data = $(this).data('bw'); 419 data.start.x = touch.pageX; 420 data.start.y = touch.pageY; 421 $(this).data('bw', data); 422 } 423 }) 424 .bind('touchend.cycle', function (e) { 425 var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; 426 var data = $(this).data('bw'); 427 data.end.x = touch.pageX; 428 data.end.y = touch.pageY; 429 $(this).data('bw', data); 430 if (data.start.x != 0 && data.start.y != 0) { 431 data.vdiff = data.start.x - data.end.x; 432 data.hdiff = data.end.y - data.start.y; 433 if (Math.abs(data.vdiff) == data.start.x && Math.abs(data.hdiff) == data.start.y) { 434 data.vdiff = 0; 435 data.hdiff = 0; 436 } 437 var length = Math.round(Math.sqrt(Math.pow(data.vdiff,2) + Math.pow(data.hdiff,2))); 438 var rads = Math.atan2(data.hdiff, data.vdiff); 439 var angle = Math.round(rads*180/Math.PI); 440 if (angle < 0) { angle = 360 - Math.abs(angle); } 441 if (length > H_THRESHOLD && V_THRESHOLD > data.hdiff) { 442 e.preventDefault(); 443 if (angle > 135 && angle < 225) { 444 var cyopt = $slider.data('cycle.opts'); 445 if (cyopt.currSlide > 0) { 446 $slider.cycle((cyopt.currSlide - 1), 'scrollRight'); 447 } 448 else { 449 $slider.cycle((cyopt.slideCount - 1), 'scrollRight'); 450 } 451 } 452 else if (angle > 315 || angle < 45) { 453 $slider.cycle('next'); 454 } 455 } 456 } 457 data = $.extend(true, {}, optsReset); 458 }); 459 } 460 } 461 }; 462 463 Drupal.viewsSlideshowCycle = Drupal.viewsSlideshowCycle || {}; 464 465 // Cleanup the values of advanced options. 466 Drupal.viewsSlideshowCycle.advancedOptionCleanup = function(value) { 467 value = $.trim(value); 468 value = value.replace(/\n/g, ''); 469 if (value.match(/^[\d.]+%$/)) { 470 // noop 471 } 472 else if (!isNaN(parseInt(value))) { 473 value = parseInt(value); 474 } 475 else if (value.toLowerCase() == 'true') { 476 value = true; 477 } 478 else if (value.toLowerCase() == 'false') { 479 value = false; 480 } 481 482 return value; 483 } 484 485 // This checks to see if all the images have been loaded. 486 // If they have then it starts the slideshow. 487 Drupal.viewsSlideshowCycle.imageWait = function(fullId) { 488 if (++Drupal.settings.viewsSlideshowCycle[fullId].loadedImages == Drupal.settings.viewsSlideshowCycle[fullId].totalImages) { 489 Drupal.viewsSlideshowCycle.load(fullId); 490 } 491 }; 492 493 // Start the slideshow. 494 Drupal.viewsSlideshowCycle.load = function (fullId) { 495 var settings = Drupal.settings.viewsSlideshowCycle[fullId]; 496 497 // Make sure the slideshow isn't already loaded. 498 if (!settings.loaded) { 499 $(settings.targetId).cycle(settings.opts); 500 $(settings.targetId).parent().parent().addClass('views-slideshow-cycle-processed'); 501 settings.loaded = true; 502 503 // Start Paused 504 if (settings.start_paused) { 505 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true }); 506 } 507 508 // Pause if hidden. 509 if (settings.pause_when_hidden) { 510 var checkPause = function(settings) { 511 // If the slideshow is visible and it is paused then resume. 512 // otherwise if the slideshow is not visible and it is not paused then 513 // pause it.
514 var visible = viewsSlideshowCycleIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible); 515 if (visible) { 516 Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId }); 517 } 518 else { 519 Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId }); 520 } 521 } 522 523 // Check when scrolled. 524 $(window).scroll(function() { 525 checkPause(settings); 526 }); 527 528 // Check when the window is resized. 529 $(window).resize(function() { 530 checkPause(settings); 531 }); 532 } 533 } 534 }; 535 536 Drupal.viewsSlideshowCycle.pause = function (options) { 537 //Eat TypeError, cycle doesn't handle pause well if options isn't defined. 538 try{ 539 if (options.pause_in_middle && $.fn.pause) { 540 $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).pause(); 541 } 542 else { 543 $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('pause'); 544 } 545 } 546 catch(e){ 547 if(!e instanceof TypeError){ 548 throw e; 549 } 550 } 551 }; 552 553 Drupal.viewsSlideshowCycle.play = function (options) { 554 Drupal.settings.viewsSlideshowCycle['#views_slideshow_cycle_main_' + options.slideshowID].paused = false; 555 if (options.pause_in_middle && $.fn.resume) { 556 $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).resume(); 557 } 558 else { 559 $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('resume'); 560 } 561 }; 562 563 Drupal.viewsSlideshowCycle.previousSlide = function (options) { 564 $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('prev'); 565 }; 566 567 Drupal.viewsSlideshowCycle.nextSlide = function (options) { 568 $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('next'); 569 }; 570 571 Drupal.viewsSlideshowCycle.goToSlide = function (options) { 572 $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle(options.slideNum); 573 }; 574 575 // Verify that the value is a number. 576 function IsNumeric(sText) { 577 var ValidChars = "0123456789"; 578 var IsNumber=true; 579 var Char; 580 581 for (var i=0; i < sText.length && IsNumber == true; i++) { 582 Char = sText.charAt(i); 583 if (ValidChars.indexOf(Char) == -1) { 584 IsNumber = false; 585 } 586 } 587 return IsNumber; 588 } 589 590 /** 591 * Cookie Handling Functions 592 */ 593 function createCookie(name,value,days) { 594 if (days) { 595 var date = new Date(); 596 date.setTime(date.getTime()+(days*24*60*60*1000)); 597 var expires = "; expires="+date.toGMTString(); 598 } 599 else { 600 var expires = ""; 601 } 602 document.cookie = name+"="+value+expires+"; path=/"; 603 } 604 605 function readCookie(name) { 606 var nameEQ = name + "="; 607 var ca = document.cookie.split(';'); 608 for(var i=0;i < ca.length;i++) { 609 var c = ca[i]; 610 while (c.charAt(0)==' ') c = c.substring(1,c.length); 611 if (c.indexOf(nameEQ) == 0) { 612 return c.substring(nameEQ.length,c.length); 613 } 614 } 615 return null; 616 } 617 618 function eraseCookie(name) { 619 createCookie(name,"",-1); 620 } 621 622 /** 623 * Checks to see if the slide is visible enough. 624 * elem = element to check. 625 * type = The way to calculate how much is visible. 626 * amountVisible = amount that should be visible. Either in percent or px. If 627 * it's not defined then all of the slide must be visible. 628 * 629 * Returns true or false 630 */ 631 function viewsSlideshowCycleIsVisible(elem, type, amountVisible) { 632 // Get the top and bottom of the window; 633 var docViewTop = $(window).scrollTop(); 634 var docViewBottom = docViewTop + $(window).height(); 635 var docViewLeft = $(window).scrollLeft(); 636 var docViewRight = docViewLeft + $(window).width(); 637 638 // Get the top, bottom, and height of the slide; 639 var elemTop = $(elem).offset().top; 640 var elemHeight = $(elem).height(); 641 var elemBottom = elemTop + elemHeight; 642 var elemLeft = $(elem).offset().left; 643 var elemWidth = $(elem).width(); 644 var elemRight = elemLeft + elemWidth; 645 var elemArea = elemHeight * elemWidth; 646 647 // Calculate what's hiding in the slide. 648 var missingLeft = 0; 649 var missingRight = 0; 650 var missingTop = 0; 651 var missingBottom = 0; 652 653 // Find out how much of the slide is missing from the left. 654 if (elemLeft < docViewLeft) { 655 missingLeft = docViewLeft - elemLeft; 656 } 657 658 // Find out how much of the slide is missing from the right. 659 if (elemRight > docViewRight) { 660 missingRight = elemRight - docViewRight; 661 } 662 663 // Find out how much of the slide is missing from the top. 664 if (elemTop < docViewTop) { 665 missingTop = docViewTop - elemTop; 666 } 667 668 // Find out how much of the slide is missing from the bottom. 669 if (elemBottom > docViewBottom) { 670 missingBottom = elemBottom - docViewBottom; 671 } 672 673 // If there is no amountVisible defined then check to see if the whole slide 674 // is visible. 675 if (type == 'full') { 676 return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) 677 && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) 678 && (elemLeft >= docViewLeft) && (elemRight <= docViewRight) 679 && (elemLeft <= docViewRight) && (elemRight >= docViewLeft)); 680 } 681 else if(type == 'vertical') { 682 var verticalShowing = elemHeight - missingTop - missingBottom; 683 684 // If user specified a percentage then find out if the current shown percent 685 // is larger than the allowed percent. 686 // Otherwise check to see if the amount of px shown is larger than the 687 // allotted amount. 688 if (typeof amountVisible === 'string' && amountVisible.indexOf('%')) { 689 return (((verticalShowing/elemHeight)*100) >= parseInt(amountVisible)); 690 } 691 else { 692 return (verticalShowing >= parseInt(amountVisible)); 693 } 694 } 695 else if(type == 'horizontal') { 696 var horizontalShowing = elemWidth - missingLeft - missingRight; 697 698 // If user specified a percentage then find out if the current shown percent 699 // is larger than the allowed percent. 700 // Otherwise check to see if the amount of px shown is larger than the 701 // allotted amount. 702 if (typeof amountVisible === 'string' && amountVisible.indexOf('%')) { 703 return (((horizontalShowing/elemWidth)*100) >= parseInt(amountVisible)); 704 } 705 else { 706 return (horizontalShowing >= parseInt(amountVisible)); 707 } 708 } 709 else if(type == 'area') { 710 var areaShowing = (elemWidth - missingLeft - missingRight) * (elemHeight - missingTop - missingBottom); 711 712 // If user specified a percentage then find out if the current shown percent 713 // is larger than the allowed percent. 714 // Otherwise check to see if the amount of px shown is larger than the 715 // allotted amount. 716 if (typeof amountVisible === 'string' && amountVisible.indexOf('%')) { 717 return (((areaShowing/elemArea)*100) >= parseInt(amountVisible)); 718 } 719 else { 720 return (areaShowing >= parseInt(amountVisible)); 721 } 722 } 723 } 724})(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.