Projet

Général

Profil

Paste
Télécharger (24,4 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views_slideshow / contrib / views_slideshow_cycle / js / views_slideshow_cycle.js @ 99781f3b

1

    
2
/**
3
 *  @file
4
 *  A simple jQuery Cycle Div Slideshow Rotator.
5
 */
6

    
7
/**
8
 * This will set our initial behavior, by starting up each individual slideshow.
9
 */
10
(function ($) {
11
  Drupal.behaviors.viewsSlideshowCycle = {
12
    attach: function (context) {
13
      $('.views_slideshow_cycle_main:not(.viewsSlideshowCycle-processed)', context).addClass('viewsSlideshowCycle-processed').each(function() {
14
        var fullId = '#' + $(this).attr('id');
15
        var settings = Drupal.settings.viewsSlideshowCycle[fullId];
16
        settings.targetId = '#' + $(fullId + " :first").attr('id');
17

    
18
        settings.slideshowId = settings.targetId.replace('#views_slideshow_cycle_teaser_section_', '');
19
        // Pager after function.
20
        var pager_after_fn = function(curr, next, opts) {
21
          // Need to do some special handling on first load.
22
          var slideNum = opts.currSlide;
23
          if (typeof settings.processedAfter == 'undefined' || !settings.processedAfter) {
24
            settings.processedAfter = 1;
25
            slideNum = (typeof settings.opts.startingSlide == 'undefined') ? 0 : settings.opts.startingSlide;
26
          }
27
          Drupal.viewsSlideshow.action({ "action": 'transitionEnd', "slideshowID": settings.slideshowId, "slideNum": slideNum });
28
        }
29
        // Pager before function.
30
        var pager_before_fn = function(curr, next, opts) {
31
          var slideNum = opts.nextSlide;
32

    
33
          // Remember last slide.
34
          if (settings.remember_slide) {
35
            createCookie(settings.vss_id, slideNum, settings.remember_slide_days);
36
          }
37

    
38
          // Make variable height.
39
          if (!settings.fixed_height) {
40
            //get the height of the current slide
41
            var $ht = $(next).height();
42
            //set the container's height to that of the current slide
43
            $(next).parent().animate({height: $ht});
44
          }
45

    
46
          // Need to do some special handling on first load.
47
          if (typeof settings.processedBefore == 'undefined' || !settings.processedBefore) {
48
            settings.processedBefore = 1;
49
            slideNum = (typeof opts.startingSlide == 'undefined') ? 0 : opts.startingSlide;
50
          }
51

    
52
          Drupal.viewsSlideshow.action({ "action": 'transitionBegin', "slideshowID": settings.slideshowId, "slideNum": slideNum });
53
        }
54
        settings.loaded = false;
55

    
56
        settings.opts = {
57
          speed:settings.speed,
58
          timeout:settings.timeout,
59
          delay:settings.delay,
60
          sync:settings.sync,
61
          random:settings.random,
62
          nowrap:settings.nowrap,
63
          after:pager_after_fn,
64
          before:pager_before_fn,
65
          cleartype:(settings.cleartype)? true : false,
66
          cleartypeNoBg:(settings.cleartypenobg)? true : false
67
        }
68

    
69
        // Set the starting slide if we are supposed to remember the slide
70
        if (settings.remember_slide) {
71
          var startSlide = readCookie(settings.vss_id);
72
          if (startSlide == null) {
73
            startSlide = 0;
74
          }
75
          settings.opts.startingSlide = parseInt(startSlide);
76
        }
77

    
78
        if (settings.effect == 'none') {
79
          settings.opts.speed = 1;
80
        }
81
        else {
82
          settings.opts.fx = settings.effect;
83
        }
84

    
85
        // Take starting item from fragment.
86
        var hash = location.hash;
87
        if (hash) {
88
          var hash = hash.replace('#', '');
89
          var aHash = hash.split(';');
90
          var aHashLen = aHash.length;
91

    
92
          // Loop through all the possible starting points.
93
          for (var i = 0; i < aHashLen; i++) {
94
            // Split the hash into two parts. One part is the slideshow id the
95
            // other is the slide number.
96
            var initialInfo = aHash[i].split(':');
97
            // The id in the hash should match our slideshow.
98
            // The slide number chosen shouldn't be larger than the number of
99
            // slides we have.
100
            if (settings.slideshowId == initialInfo[0] && settings.num_divs > initialInfo[1]) {
101
              settings.opts.startingSlide = parseInt(initialInfo[1]);
102
            }
103
          }
104
        }
105

    
106
        // Pause on hover.
107
        if (settings.pause) {
108
          var mouseIn = function() {
109
            Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
110
          }
111

    
112
          var mouseOut = function() {
113
            Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId });
114
          }
115

    
116
          if (jQuery.fn.hoverIntent) {
117
            $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hoverIntent(mouseIn, mouseOut);
118
          }
119
          else {
120
            $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(mouseIn, mouseOut);
121
          }
122
        }
123
        
124
        // Play on hover.
125
        if (settings.play_on_hover) {
126
          var mouseIn = function() {
127
            Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId, "force": true });
128
          }
129

    
130
          var mouseOut = function() {
131
            Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
132
          }
133

    
134
          if (jQuery.fn.hoverIntent) {
135
            $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hoverIntent(mouseIn, mouseOut);
136
          }
137
          else {
138
            $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(mouseIn, mouseOut);
139
          }
140
        }
141

    
142
        // Pause on clicking of the slide.
143
        if (settings.pause_on_click) {
144
          $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).click(function() {
145
            Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true });
146
          });
147
        }
148

    
149
        if (typeof JSON != 'undefined') {
150
          var advancedOptions = JSON.parse(settings.advanced_options);
151
          for (var option in advancedOptions) {
152
            switch(option) {
153

    
154
              // Standard Options
155
              case "activePagerClass":
156
              case "allowPagerClickBubble":
157
              case "autostop":
158
              case "autostopCount":
159
              case "backwards":
160
              case "bounce":
161
              case "cleartype":
162
              case "cleartypeNoBg":
163
              case "containerResize":
164
              case "continuous":
165
              case "delay":
166
              case "easeIn":
167
              case "easeOut":
168
              case "easing":
169
              case "fastOnEvent":
170
              case "fit":
171
              case "fx":
172
              case "manualTrump":
173
              case "metaAttr":
174
              case "next":
175
              case "nowrap":
176
              case "pager":
177
              case "pagerEvent":
178
              case "pause":
179
              case "pauseOnPagerHover":
180
              case "prev":
181
              case "prevNextEvent":
182
              case "random":
183
              case "randomizeEffects":
184
              case "requeueOnImageNotLoaded":
185
              case "requeueTimeout":
186
              case "rev":
187
              case "slideExpr":
188
              case "slideResize":
189
              case "speed":
190
              case "speedIn":
191
              case "speedOut":
192
              case "startingSlide":
193
              case "sync":
194
              case "timeout":
195
                var optionValue = advancedOptions[option];
196
                optionValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(optionValue);
197
                settings.opts[option] = optionValue;
198
                break;
199

    
200
              // If width is set we need to disable resizing.
201
              case "width":
202
                var optionValue = advancedOptions["width"];
203
                optionValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(optionValue);
204
                settings.opts["width"] = optionValue;
205
                settings.opts["containerResize"] = 0;
206
                break;
207

    
208
              // If height is set we need to set fixed_height to true.
209
              case "height":
210
                var optionValue = advancedOptions["height"];
211
                optionValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(optionValue);
212
                settings.opts["height"] = optionValue;
213
                settings.fixed_height = 1;
214
                break;
215

    
216
              // These process options that look like {top:50, bottom:20}
217
              case "animIn":
218
              case "animInDelay":
219
              case "animOut":
220
              case "animOutDelay":
221
              case "cssBefore":
222
              case "cssAfter":
223
              case "shuffle":
224
                var cssValue = advancedOptions[option];
225
                cssValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(cssValue);
226
                settings.opts[option] = eval('(' + cssValue + ')');
227
                break;
228

    
229
              // These options have their own functions.
230
              case "after":
231
                var afterValue = advancedOptions[option];
232
                afterValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(afterValue);
233
                // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag)
234
                settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
235
                  pager_after_fn(currSlideElement, nextSlideElement, options);
236
                  eval(afterValue);
237
                }
238
                break;
239

    
240
              case "before":
241
                var beforeValue = advancedOptions[option];
242
                beforeValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(beforeValue);
243
                // transition callback (scope set to element to be shown):     function(currSlideElement, nextSlideElement, options, forwardFlag)
244
                settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
245
                  pager_before_fn(currSlideElement, nextSlideElement, options);
246
                  eval(beforeValue);
247
                }
248
                break;
249

    
250
              case "end":
251
                var endValue = advancedOptions[option];
252
                endValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(endValue);
253
                // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
254
                settings.opts[option] = function(options) {
255
                  eval(endValue);
256
                }
257
                break;
258

    
259
              case "fxFn":
260
                var fxFnValue = advancedOptions[option];
261
                fxFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(fxFnValue);
262
                // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
263
                settings.opts[option] = function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) {
264
                  eval(fxFnValue);
265
                }
266
                break;
267

    
268
              case "onPagerEvent":
269
                var onPagerEventValue = advancedOptions[option];
270
                onPagerEventValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(onPagerEventValue);
271
                settings.opts[option] = function(zeroBasedSlideIndex, slideElement) {
272
                  eval(onPagerEventValue);
273
                }
274
                break;
275

    
276
              case "onPrevNextEvent":
277
                var onPrevNextEventValue = advancedOptions[option];
278
                onPrevNextEventValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(onPrevNextEventValue);
279
                settings.opts[option] = function(isNext, zeroBasedSlideIndex, slideElement) {
280
                  eval(onPrevNextEventValue);
281
                }
282
                break;
283

    
284
              case "pagerAnchorBuilder":
285
                var pagerAnchorBuilderValue = advancedOptions[option];
286
                pagerAnchorBuilderValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pagerAnchorBuilderValue);
287
                // callback fn for building anchor links:  function(index, DOMelement)
288
                settings.opts[option] = function(index, DOMelement) {
289
                  var returnVal = '';
290
                  eval(pagerAnchorBuilderValue);
291
                  return returnVal;
292
                }
293
                break;
294

    
295
              case "pagerClick":
296
                var pagerClickValue = advancedOptions[option];
297
                pagerClickValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pagerClickValue);
298
                // callback fn for pager clicks:    function(zeroBasedSlideIndex, slideElement)
299
                settings.opts[option] = function(zeroBasedSlideIndex, slideElement) {
300
                  eval(pagerClickValue);
301
                }
302
                break;
303

    
304
              case "paused":
305
                var pausedValue = advancedOptions[option];
306
                pausedValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(pausedValue);
307
                // undocumented callback when slideshow is paused:    function(cont, opts, byHover)
308
                settings.opts[option] = function(cont, opts, byHover) {
309
                  eval(pausedValue);
310
                }
311
                break;
312

    
313
              case "resumed":
314
                var resumedValue = advancedOptions[option];
315
                resumedValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(resumedValue);
316
                // undocumented callback when slideshow is resumed:    function(cont, opts, byHover)
317
                settings.opts[option] = function(cont, opts, byHover) {
318
                  eval(resumedValue);
319
                }
320
                break;
321

    
322
              case "timeoutFn":
323
                var timeoutFnValue = advancedOptions[option];
324
                timeoutFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(timeoutFnValue);
325
                settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
326
                  // Set a sane return value unless function overrides it.
327
                  var returnVal = settings.timeout;
328
                  eval(timeoutFnValue);
329
                  return returnVal;
330
                }
331
                break;
332

    
333
              case "updateActivePagerLink":
334
                var updateActivePagerLinkValue = advancedOptions[option];
335
                updateActivePagerLinkValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(updateActivePagerLinkValue);
336
                // callback fn invoked to update the active pager link (adds/removes activePagerClass style)
337
                settings.opts[option] = function(pager, currSlideIndex) {
338
                  eval(updateActivePagerLinkValue);
339
                }
340
                break;
341
            }
342
          }
343
        }
344

    
345
        // If selected wait for the images to be loaded.
346
        // otherwise just load the slideshow.
347
        if (settings.wait_for_image_load) {
348
          // For IE/Chrome/Opera we if there are images then we need to make
349
          // sure the images are loaded before starting the slideshow.
350
          settings.totalImages = $(settings.targetId + ' img').length;
351
          if (settings.totalImages) {
352
            settings.loadedImages = 0;
353

    
354
            // Add a load event for each image.
355
            $(settings.targetId + ' img').each(function() {
356
              var $imageElement = $(this);
357
              $imageElement.bind('load', function () {
358
                Drupal.viewsSlideshowCycle.imageWait(fullId);
359
              });
360

    
361
              // Removing the source and adding it again will fire the load event.
362
              var imgSrc = $imageElement.attr('src');
363
              $imageElement.attr('src', '');
364
              $imageElement.attr('src', imgSrc);
365
            });
366

    
367
            // We need to set a timeout so that the slideshow doesn't wait
368
            // indefinitely for all images to load.
369
            setTimeout("Drupal.viewsSlideshowCycle.load('" + fullId + "')", settings.wait_for_image_load_timeout);
370
          }
371
          else {
372
            Drupal.viewsSlideshowCycle.load(fullId);
373
          }
374
        }
375
        else {
376
          Drupal.viewsSlideshowCycle.load(fullId);
377
        }
378
      });
379
    }
380
  };
381

    
382
  Drupal.viewsSlideshowCycle = Drupal.viewsSlideshowCycle || {};
383

    
384
  // Cleanup the values of advanced options.
385
  Drupal.viewsSlideshowCycle.advancedOptionCleanup = function(value) {
386
    value = $.trim(value);
387
    value = value.replace(/\n/g, '');
388
    if (value.match(/^[\d.]+%$/)) {
389
      // noop
390
    }
391
    else if (!isNaN(parseInt(value))) {
392
      value = parseInt(value);
393
    }
394
    else if (value.toLowerCase() == 'true') {
395
      value = true;
396
    }
397
    else if (value.toLowerCase() == 'false') {
398
      value = false;
399
    }
400

    
401
    return value;
402
  }
403

    
404
  // This checks to see if all the images have been loaded.
405
  // If they have then it starts the slideshow.
406
  Drupal.viewsSlideshowCycle.imageWait = function(fullId) {
407
    if (++Drupal.settings.viewsSlideshowCycle[fullId].loadedImages == Drupal.settings.viewsSlideshowCycle[fullId].totalImages) {
408
      Drupal.viewsSlideshowCycle.load(fullId);
409
    }
410
  };
411

    
412
  // Start the slideshow.
413
  Drupal.viewsSlideshowCycle.load = function (fullId) {
414
    var settings = Drupal.settings.viewsSlideshowCycle[fullId];
415

    
416
    // Make sure the slideshow isn't already loaded.
417
    if (!settings.loaded) {
418
      $(settings.targetId).cycle(settings.opts);
419
      settings.loaded = true;
420

    
421
      // Start Paused
422
      if (settings.start_paused) {
423
        Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId, "force": true });
424
      }
425

    
426
      // Pause if hidden.
427
      if (settings.pause_when_hidden) {
428
        var checkPause = function(settings) {
429
          // If the slideshow is visible and it is paused then resume.
430
          // otherwise if the slideshow is not visible and it is not paused then
431
          // pause it.
432
          var visible = viewsSlideshowCycleIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible);
433
          if (visible) {
434
            Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId });
435
          }
436
          else {
437
            Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
438
          }
439
        }
440

    
441
        // Check when scrolled.
442
        $(window).scroll(function() {
443
         checkPause(settings);
444
        });
445

    
446
        // Check when the window is resized.
447
        $(window).resize(function() {
448
          checkPause(settings);
449
        });
450
      }
451
    }
452
  };
453

    
454
  Drupal.viewsSlideshowCycle.pause = function (options) {
455
    //Eat TypeError, cycle doesn't handle pause well if options isn't defined.
456
    try{
457
      if (options.pause_in_middle && $.fn.pause) {
458
        $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).pause();
459
      }
460
      else {
461
        $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('pause');
462
      }
463
    }
464
    catch(e){
465
      if(!e instanceof TypeError){
466
        throw e;
467
      }
468
    }
469
  };
470

    
471
  Drupal.viewsSlideshowCycle.play = function (options) {
472
    Drupal.settings.viewsSlideshowCycle['#views_slideshow_cycle_main_' + options.slideshowID].paused = false;
473
    if (options.pause_in_middle && $.fn.resume) {
474
      $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).resume();
475
    }
476
    else {
477
      $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('resume');
478
    }
479
  };
480

    
481
  Drupal.viewsSlideshowCycle.previousSlide = function (options) {
482
    $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('prev');
483
  };
484

    
485
  Drupal.viewsSlideshowCycle.nextSlide = function (options) {
486
    $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('next');
487
  };
488

    
489
  Drupal.viewsSlideshowCycle.goToSlide = function (options) {
490
    $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle(options.slideNum);
491
  };
492

    
493
  // Verify that the value is a number.
494
  function IsNumeric(sText) {
495
    var ValidChars = "0123456789";
496
    var IsNumber=true;
497
    var Char;
498

    
499
    for (var i=0; i < sText.length && IsNumber == true; i++) {
500
      Char = sText.charAt(i);
501
      if (ValidChars.indexOf(Char) == -1) {
502
        IsNumber = false;
503
      }
504
    }
505
    return IsNumber;
506
  }
507

    
508
  /**
509
   * Cookie Handling Functions
510
   */
511
  function createCookie(name,value,days) {
512
    if (days) {
513
      var date = new Date();
514
      date.setTime(date.getTime()+(days*24*60*60*1000));
515
      var expires = "; expires="+date.toGMTString();
516
    }
517
    else {
518
      var expires = "";
519
    }
520
    document.cookie = name+"="+value+expires+"; path=/";
521
  }
522

    
523
  function readCookie(name) {
524
    var nameEQ = name + "=";
525
    var ca = document.cookie.split(';');
526
    for(var i=0;i < ca.length;i++) {
527
      var c = ca[i];
528
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
529
      if (c.indexOf(nameEQ) == 0) {
530
        return c.substring(nameEQ.length,c.length);
531
      }
532
    }
533
    return null;
534
  }
535

    
536
  function eraseCookie(name) {
537
    createCookie(name,"",-1);
538
  }
539

    
540
  /**
541
   * Checks to see if the slide is visible enough.
542
   * elem = element to check.
543
   * type = The way to calculate how much is visible.
544
   * amountVisible = amount that should be visible. Either in percent or px. If
545
   *                it's not defined then all of the slide must be visible.
546
   *
547
   * Returns true or false
548
   */
549
  function viewsSlideshowCycleIsVisible(elem, type, amountVisible) {
550
    // Get the top and bottom of the window;
551
    var docViewTop = $(window).scrollTop();
552
    var docViewBottom = docViewTop + $(window).height();
553
    var docViewLeft = $(window).scrollLeft();
554
    var docViewRight = docViewLeft + $(window).width();
555

    
556
    // Get the top, bottom, and height of the slide;
557
    var elemTop = $(elem).offset().top;
558
    var elemHeight = $(elem).height();
559
    var elemBottom = elemTop + elemHeight;
560
    var elemLeft = $(elem).offset().left;
561
    var elemWidth = $(elem).width();
562
    var elemRight = elemLeft + elemWidth;
563
    var elemArea = elemHeight * elemWidth;
564

    
565
    // Calculate what's hiding in the slide.
566
    var missingLeft = 0;
567
    var missingRight = 0;
568
    var missingTop = 0;
569
    var missingBottom = 0;
570

    
571
    // Find out how much of the slide is missing from the left.
572
    if (elemLeft < docViewLeft) {
573
      missingLeft = docViewLeft - elemLeft;
574
    }
575

    
576
    // Find out how much of the slide is missing from the right.
577
    if (elemRight > docViewRight) {
578
      missingRight = elemRight - docViewRight;
579
    }
580

    
581
    // Find out how much of the slide is missing from the top.
582
    if (elemTop < docViewTop) {
583
      missingTop = docViewTop - elemTop;
584
    }
585

    
586
    // Find out how much of the slide is missing from the bottom.
587
    if (elemBottom > docViewBottom) {
588
      missingBottom = elemBottom - docViewBottom;
589
    }
590

    
591
    // If there is no amountVisible defined then check to see if the whole slide
592
    // is visible.
593
    if (type == 'full') {
594
      return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
595
      && (elemBottom <= docViewBottom) &&  (elemTop >= docViewTop)
596
      && (elemLeft >= docViewLeft) && (elemRight <= docViewRight)
597
      && (elemLeft <= docViewRight) && (elemRight >= docViewLeft));
598
    }
599
    else if(type == 'vertical') {
600
      var verticalShowing = elemHeight - missingTop - missingBottom;
601

    
602
      // If user specified a percentage then find out if the current shown percent
603
      // is larger than the allowed percent.
604
      // Otherwise check to see if the amount of px shown is larger than the
605
      // allotted amount.
606
      if (typeof amountVisible === 'string' && amountVisible.indexOf('%')) {
607
        return (((verticalShowing/elemHeight)*100) >= parseInt(amountVisible));
608
      }
609
      else {
610
        return (verticalShowing >= parseInt(amountVisible));
611
      }
612
    }
613
    else if(type == 'horizontal') {
614
      var horizontalShowing = elemWidth - missingLeft - missingRight;
615

    
616
      // If user specified a percentage then find out if the current shown percent
617
      // is larger than the allowed percent.
618
      // Otherwise check to see if the amount of px shown is larger than the
619
      // allotted amount.
620
      if (typeof amountVisible === 'string' && amountVisible.indexOf('%')) {
621
        return (((horizontalShowing/elemWidth)*100) >= parseInt(amountVisible));
622
      }
623
      else {
624
        return (horizontalShowing >= parseInt(amountVisible));
625
      }
626
    }
627
    else if(type == 'area') {
628
      var areaShowing = (elemWidth - missingLeft - missingRight) * (elemHeight - missingTop - missingBottom);
629

    
630
      // If user specified a percentage then find out if the current shown percent
631
      // is larger than the allowed percent.
632
      // Otherwise check to see if the amount of px shown is larger than the
633
      // allotted amount.
634
      if (typeof amountVisible === 'string' && amountVisible.indexOf('%')) {
635
        return (((areaShowing/elemArea)*100) >= parseInt(amountVisible));
636
      }
637
      else {
638
        return (areaShowing >= parseInt(amountVisible));
639
      }
640
    }
641
  }
642
})(jQuery);