Advertisement
Guest User

Untitled

a guest
Mar 6th, 2013
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($) {
  2.  
  3.     /**
  4.  
  5.      * $ is an alias to jQuery object
  6.  
  7.      *
  8.  
  9.      */
  10.  
  11.     $.fn.lightBox = function(settings) {
  12.  
  13.         // Settings to configure the jQuery lightBox plugin how you like
  14.  
  15.         settings = jQuery.extend({
  16.  
  17.             // Configuration related to overlay
  18.  
  19.             overlayBgColor:         '#000',     // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
  20.  
  21.             overlayOpacity:         1,      // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
  22.  
  23.             // Configuration related to navigation
  24.  
  25.             fixedNavigation:        false,      // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
  26.  
  27.             // Configuration related to images
  28.  
  29.             imageLoading:           lightbox_path+'images/lightbox-ico-loading.gif',        // (string) Path and the name of the loading icon
  30.  
  31.             imageBtnPrev:           lightbox_path+'images/lightbox-btn-prev.gif',           // (string) Path and the name of the prev button image
  32.  
  33.             imageBtnNext:           lightbox_path+'images/lightbox-btn-next.gif',           // (string) Path and the name of the next button image
  34.  
  35.             imageBtnClose:          lightbox_path+'images/lightbox-btn-close.gif',      // (string) Path and the name of the close btn
  36.  
  37.             imageBlank:             lightbox_path+'images/lightbox-blank.gif',          // (string) Path and the name of a blank image (one pixel)
  38.  
  39.             // Configuration related to container image box
  40.  
  41.             containerBorderSize:    10,         // (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
  42.  
  43.             containerResizeSpeed:   400,        // (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
  44.  
  45.             // Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
  46.  
  47.             txtImage:               'Copyright PhotoSolutions.pl - All Rights Reserved',    // (string) Specify text "Image"
  48.  
  49.             // Configuration related to keyboard navigation
  50.  
  51.             keyToClose:             'c',        // (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
  52.  
  53.             keyToPrev:              'p',        // (string) (p = previous) Letter to show the previous image
  54.  
  55.             keyToNext:              'n',        // (string) (n = next) Letter to show the next image.
  56.  
  57.             // Don´t alter these variables in any way
  58.  
  59.             imageArray:             [],
  60.  
  61.             activeImage:            0,
  62.  
  63.             captionPosition:        ''
  64.  
  65.         },settings);
  66.  
  67.         // Caching the jQuery object with all elements matched
  68.  
  69.         var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
  70.  
  71.         /**
  72.  
  73.          * Initializing the plugin calling the start function
  74.  
  75.          *
  76.  
  77.          * @return boolean false
  78.  
  79.          */
  80.  
  81.         function _initialize() {
  82.  
  83.             _start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
  84.  
  85.             return false; // Avoid the browser following the link
  86.  
  87.         }
  88.  
  89.         /**
  90.  
  91.          * Start the jQuery lightBox plugin
  92.  
  93.          *
  94.  
  95.          * @param object objClicked The object (link) whick the user have clicked
  96.  
  97.          * @param object jQueryMatchedObj The jQuery object with all elements matched
  98.  
  99.          */
  100.  
  101.         function _start(objClicked,jQueryMatchedObj) {
  102.  
  103.             // Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
  104.  
  105.             $('embed, object, select').css({ 'visibility' : 'hidden' });
  106.  
  107.             // Call the function to create the markup structure; style some elements; assign events in some elements.
  108.  
  109.             _set_interface();
  110.  
  111.             // Unset total images in imageArray
  112.  
  113.             settings.imageArray.length = 0;
  114.  
  115.             // Unset image active information
  116.  
  117.             settings.activeImage = 0;
  118.  
  119.             // We have an image set? Or just an image? Let´s see it.
  120.  
  121.             if ( jQueryMatchedObj.length == 1 ) {
  122.  
  123.                 if( settings.captionPosition == 'gallery' ) var position = jQuery(objClicked).parent().next().html();
  124.  
  125.                 else var position = objClicked.getAttribute('title');
  126.  
  127.                 settings.imageArray.push(new Array(objClicked.getAttribute('href'),position));
  128.  
  129.             } else {
  130.  
  131.                 // Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references
  132.  
  133.                 for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
  134.  
  135.                     if( settings.captionPosition != 'gallery' ) {
  136.  
  137.                         var position = jQueryMatchedObj[i].getAttribute('title');
  138.  
  139.                         settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),position));
  140.  
  141.                     } else {
  142.  
  143.                         if( i > 1 ) {
  144.  
  145.                             if( !(jQueryMatchedObj[i-1].getAttribute('href') != jQueryMatchedObj[i].getAttribute('href') && jQuery(jQueryMatchedObj[i-1]).parent().parent().children().children().attr('href') == jQuery(jQueryMatchedObj[i]).parent().parent().children().children().attr('href'))) {
  146.  
  147.                                 var position = jQuery(jQueryMatchedObj[i]).parent().next().html();
  148.  
  149.                                 settings.imageArray.push(new Array(jQuery(jQueryMatchedObj[i]).parent().parent().children().children().attr('href'),position));
  150.  
  151.                             }
  152.  
  153.                         } else {
  154.  
  155.                                 var position = jQuery(jQueryMatchedObj[i]).parent().next().html();
  156.  
  157.                                 settings.imageArray.push(new Array(jQuery(jQueryMatchedObj[i]).parent().parent().children().children().attr('href'),position));
  158.  
  159.                         }
  160.  
  161.                     }
  162.  
  163.                 }
  164.  
  165.             }
  166.  
  167.             while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
  168.  
  169.                 settings.activeImage++;
  170.  
  171.             }
  172.  
  173.             // Call the function that prepares image exibition
  174.  
  175.             _set_image_to_view();
  176.  
  177.            
  178.  
  179.             // Enable keyboard navigation
  180.  
  181.             _enable_keyboard_navigation();
  182.  
  183.         }
  184.  
  185.         /**
  186.  
  187.          * Create the jQuery lightBox plugin interface
  188.  
  189.          *
  190.  
  191.          * The HTML markup will be like that:
  192.  
  193.             <div id="jquery-overlay"></div>
  194.  
  195.             <div id="jquery-lightbox">
  196.  
  197.                 <div id="lightbox-container-image-box">
  198.  
  199.                     <div id="lightbox-container-image">
  200.  
  201.                         <img src="../fotos/XX.jpg" id="lightbox-image">
  202.  
  203.                         <div id="lightbox-nav">
  204.  
  205.                             <a href="#" id="lightbox-nav-btnPrev"></a>
  206.  
  207.                             <a href="#" id="lightbox-nav-btnNext"></a>
  208.  
  209.                         </div>
  210.  
  211.                         <div id="lightbox-loading">
  212.  
  213.                             <a href="#" id="lightbox-loading-link">
  214.  
  215.                                 <img src="../images/lightbox-ico-loading.gif">
  216.  
  217.                             </a>
  218.  
  219.                         </div>
  220.  
  221.                     </div>
  222.  
  223.                 </div>
  224.  
  225.                 <div id="lightbox-container-image-data-box">
  226.  
  227.                     <div id="lightbox-container-image-data">
  228.  
  229.                         <div id="lightbox-image-details">
  230.  
  231.                             <span id="lightbox-image-details-caption"></span>
  232.  
  233.                             <span id="lightbox-image-details-currentNumber"></span>
  234.  
  235.                         </div>
  236.  
  237.                         <div id="lightbox-secNav">
  238.  
  239.                             <a href="#" id="lightbox-secNav-btnClose">
  240.  
  241.                                 <img src="../images/lightbox-btn-close.gif">
  242.  
  243.                             </a>
  244.  
  245.                         </div>
  246.  
  247.                     </div>
  248.  
  249.                 </div>
  250.  
  251.             </div>
  252.  
  253.          *
  254.  
  255.          */
  256.  
  257.         function _set_interface() {
  258.  
  259.             // Apply the HTML markup into body tag
  260.  
  261.             $('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');  
  262.  
  263.             // Get page sizes
  264.  
  265.             var arrPageSizes = ___getPageSize();
  266.  
  267.             // Style overlay and show it
  268.  
  269.             $('#jquery-overlay').css({
  270.  
  271.                 backgroundColor:    settings.overlayBgColor,
  272.  
  273.                 opacity:            settings.overlayOpacity,
  274.  
  275.                 width:              arrPageSizes[0],
  276.  
  277.                 height:             arrPageSizes[1]
  278.  
  279.             }).fadeIn();
  280.  
  281.             // Get page scroll
  282.  
  283.             var arrPageScroll = ___getPageScroll();
  284.  
  285.             // Calculate top and left offset for the jquery-lightbox div object and show it
  286.  
  287.             $('#jquery-lightbox').css({
  288.  
  289.                 top:    arrPageScroll[1] + (arrPageSizes[3] / 30),
  290.  
  291.                 left:   arrPageScroll[0]
  292.  
  293.             }).show();
  294.  
  295.             // Assigning click events in elements to close overlay
  296.  
  297.             $('#jquery-overlay,#jquery-lightbox').click(function() {
  298.  
  299.                 _finish();                                 
  300.  
  301.             });
  302.  
  303.             // Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
  304.  
  305.             $('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
  306.  
  307.                 _finish();
  308.  
  309.                 return false;
  310.  
  311.             });
  312.  
  313.             // If window was resized, calculate the new overlay dimensions
  314.  
  315.             $(window).resize(function() {
  316.  
  317.                 // Get page sizes
  318.  
  319.                 var arrPageSizes = ___getPageSize();
  320.  
  321.                 // Style overlay and show it
  322.  
  323.                 $('#jquery-overlay').css({
  324.  
  325.                     width:      arrPageSizes[0],
  326.  
  327.                     height:     arrPageSizes[1]
  328.  
  329.                 });
  330.  
  331.                 // Get page scroll
  332.  
  333.                 var arrPageScroll = ___getPageScroll();
  334.  
  335.                 // Calculate top and left offset for the jquery-lightbox div object and show it
  336.  
  337.                 $('#jquery-lightbox').css({
  338.  
  339.                     top:    arrPageScroll[1] + (arrPageSizes[3] / 30),
  340.  
  341.                     left:   arrPageScroll[0]
  342.  
  343.                 });
  344.  
  345.             });
  346.  
  347.         }
  348.  
  349.         /**
  350.  
  351.          * Prepares image exibition; doing a image´s preloader to calculate it´s size
  352.  
  353.          *
  354.  
  355.          */
  356.  
  357.         function _set_image_to_view() { // show the loading
  358.  
  359.             // Show the loading
  360.  
  361.             $('#lightbox-loading').show();
  362.  
  363.             if ( settings.fixedNavigation ) {
  364.  
  365.                 $('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
  366.  
  367.             } else {
  368.  
  369.                 // Hide some elements
  370.  
  371.                 $('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
  372.  
  373.             }
  374.  
  375.             // Image preload process
  376.  
  377.             var objImagePreloader = new Image();
  378.  
  379.             objImagePreloader.onload = function() {
  380.  
  381.                 $('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
  382.  
  383.                 // Perfomance an effect in the image container resizing it
  384.  
  385.                 _resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
  386.  
  387.                 //  clear onLoad, IE behaves irratically with animated gifs otherwise
  388.  
  389.                 objImagePreloader.onload=function(){};
  390.  
  391.             };
  392.  
  393.             objImagePreloader.src = settings.imageArray[settings.activeImage][0];
  394.  
  395.         };
  396.  
  397.         /**
  398.  
  399.          * Perfomance an effect in the image container resizing it
  400.  
  401.          *
  402.  
  403.          * @param integer intImageWidth The image´s width that will be showed
  404.  
  405.          * @param integer intImageHeight The image´s height that will be showed
  406.  
  407.          */
  408.  
  409.         function _resize_container_image_box(intImageWidth,intImageHeight) {
  410.  
  411.             // Get current width and height
  412.  
  413.             var intCurrentWidth = $('#lightbox-container-image-box').width();
  414.  
  415.             var intCurrentHeight = $('#lightbox-container-image-box').height();
  416.  
  417.             // Get the width and height of the selected image plus the padding
  418.  
  419.             var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image´s width and the left and right padding value
  420.  
  421.             var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image´s height and the left and right padding value
  422.  
  423.             // Diferences
  424.  
  425.             var intDiffW = intCurrentWidth - intWidth;
  426.  
  427.             var intDiffH = intCurrentHeight - intHeight;
  428.  
  429.             // Perfomance the effect
  430.  
  431.             $('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
  432.  
  433.             if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
  434.  
  435.                 if ( $.browser.msie ) {
  436.  
  437.                     ___pause(250);
  438.  
  439.                 } else {
  440.  
  441.                     ___pause(100); 
  442.  
  443.                 }
  444.  
  445.             }
  446.  
  447.             $('#lightbox-container-image-data-box').css({ width: intImageWidth });
  448.  
  449.             $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
  450.  
  451.         };
  452.  
  453.         /**
  454.  
  455.          * Show the prepared image
  456.  
  457.          *
  458.  
  459.          */
  460.  
  461.         function _show_image() {
  462.  
  463.             $('#lightbox-loading').hide();
  464.  
  465.             $('#lightbox-image').fadeIn(function() {
  466.  
  467.                 _show_image_data();
  468.  
  469.                 _set_navigation();
  470.  
  471.             });
  472.  
  473.             _preload_neighbor_images();
  474.  
  475.         };
  476.  
  477.         /**
  478.  
  479.          * Show the image information
  480.  
  481.          *
  482.  
  483.          */
  484.  
  485.         function _show_image_data() {
  486.  
  487.             $('#lightbox-container-image-data-box').slideDown('fast');
  488.  
  489.             $('#lightbox-image-details-caption').hide();
  490.  
  491.             if ( settings.imageArray[settings.activeImage][1] ) {
  492.  
  493.                 $('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
  494.  
  495.             }
  496.  
  497.             // If we have a image set, display 'Image X of X'
  498.  
  499.             if ( settings.imageArray.length > 1 ) {
  500.  
  501.                 $('#lightbox-image-details-currentNumber').html(settings.txtImage).show();
  502.  
  503.             }      
  504.  
  505.         }
  506.  
  507.         /**
  508.  
  509.          * Display the button navigations
  510.  
  511.          *
  512.  
  513.          */
  514.  
  515.         function _set_navigation() {
  516.  
  517.             $('#lightbox-nav').show();
  518.  
  519.  
  520.  
  521.             // Instead to define this configuration in CSS file, we define here. And it´s need to IE. Just.
  522.  
  523.             $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
  524.  
  525.            
  526.  
  527.             // Show the prev button, if not the first image in set
  528.  
  529.             if ( settings.activeImage != 0 ) {
  530.  
  531.                 if ( settings.fixedNavigation ) {
  532.  
  533.                     $('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })
  534.  
  535.                         .unbind()
  536.  
  537.                         .bind('click',function() {
  538.  
  539.                             settings.activeImage = settings.activeImage - 1;
  540.  
  541.                             _set_image_to_view();
  542.  
  543.                             return false;
  544.  
  545.                         });
  546.  
  547.                 } else {
  548.  
  549.                     // Show the images button for Next buttons
  550.  
  551.                     $('#lightbox-nav-btnPrev').unbind().hover(function() {
  552.  
  553.                         $(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
  554.  
  555.                     },function() {
  556.  
  557.                         $(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
  558.  
  559.                     }).show().bind('click',function() {
  560.  
  561.                         settings.activeImage = settings.activeImage - 1;
  562.  
  563.                         _set_image_to_view();
  564.  
  565.                         return false;
  566.  
  567.                     });
  568.  
  569.                 }
  570.  
  571.             }
  572.  
  573.            
  574.  
  575.             // Show the next button, if not the last image in set
  576.  
  577.             if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
  578.  
  579.                 if ( settings.fixedNavigation ) {
  580.  
  581.                     $('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })
  582.  
  583.                         .unbind()
  584.  
  585.                         .bind('click',function() {
  586.  
  587.                             settings.activeImage = settings.activeImage + 1;
  588.  
  589.                             _set_image_to_view();
  590.  
  591.                             return false;
  592.  
  593.                         });
  594.  
  595.                 } else {
  596.  
  597.                     // Show the images button for Next buttons
  598.  
  599.                     $('#lightbox-nav-btnNext').unbind().hover(function() {
  600.  
  601.                         $(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
  602.  
  603.                     },function() {
  604.  
  605.                         $(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
  606.  
  607.                     }).show().bind('click',function() {
  608.  
  609.                         settings.activeImage = settings.activeImage + 1;
  610.  
  611.                         _set_image_to_view();
  612.  
  613.                         return false;
  614.  
  615.                     });
  616.  
  617.                 }
  618.  
  619.             }
  620.  
  621.             // Enable keyboard navigation
  622.  
  623.             //_enable_keyboard_navigation();
  624.  
  625.         }
  626.  
  627.         /**
  628.  
  629.          * Enable a support to keyboard navigation
  630.  
  631.          *
  632.  
  633.          */
  634.  
  635.         function _enable_keyboard_navigation() {
  636.  
  637.             $(document).keydown(function(objEvent) {
  638.  
  639.                 _keyboard_action(objEvent);
  640.  
  641.             });
  642.  
  643.         }
  644.  
  645.         /**
  646.  
  647.          * Disable the support to keyboard navigation
  648.  
  649.          *
  650.  
  651.          */
  652.  
  653.         function _disable_keyboard_navigation() {
  654.  
  655.             $(document).unbind('keydown');
  656.  
  657.         }
  658.  
  659.         /**
  660.  
  661.          * Perform the keyboard actions
  662.  
  663.          *
  664.  
  665.          */
  666.  
  667.         function _keyboard_action(objEvent) {
  668.  
  669.             // To ie
  670.  
  671.             if ( objEvent == null ) {
  672.  
  673.                 keycode = event.keyCode;
  674.  
  675.                 escapeKey = 27;
  676.  
  677.             // To Mozilla
  678.  
  679.             } else {
  680.  
  681.                 keycode = objEvent.keyCode;
  682.  
  683.                 escapeKey = objEvent.DOM_VK_ESCAPE;
  684.  
  685.             }
  686.  
  687.             // Get the key in lower case form
  688.  
  689.             key = String.fromCharCode(keycode).toLowerCase();
  690.  
  691.             // Verify the keys to close the ligthBox
  692.  
  693.             if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
  694.  
  695.                 _finish();
  696.  
  697.             }
  698.  
  699.             // Verify the key to show the previous image
  700.  
  701.             if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
  702.  
  703.                 // If we´re not showing the first image, call the previous
  704.  
  705.                 if ( settings.activeImage != 0 ) {
  706.  
  707.                     settings.activeImage = settings.activeImage - 1;
  708.  
  709.                     _set_image_to_view();
  710.  
  711.                     //_disable_keyboard_navigation();
  712.  
  713.                 }
  714.  
  715.             }
  716.  
  717.             // Verify the key to show the next image
  718.  
  719.             if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
  720.  
  721.                 // If we´re not showing the last image, call the next
  722.  
  723.                 if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
  724.  
  725.                     settings.activeImage = settings.activeImage + 1;
  726.  
  727.                     _set_image_to_view();
  728.  
  729.                     //_disable_keyboard_navigation();
  730.  
  731.                 }
  732.  
  733.             }
  734.  
  735.         }
  736.  
  737.         /**
  738.  
  739.          * Preload prev and next images being showed
  740.  
  741.          *
  742.  
  743.          */
  744.  
  745.         function _preload_neighbor_images() {
  746.  
  747.             if ( (settings.imageArray.length -1) > settings.activeImage ) {
  748.  
  749.                 objNext = new Image();
  750.  
  751.                 objNext.src = settings.imageArray[settings.activeImage + 1][0];
  752.  
  753.             }
  754.  
  755.             if ( settings.activeImage > 0 ) {
  756.  
  757.                 objPrev = new Image();
  758.  
  759.                 objPrev.src = settings.imageArray[settings.activeImage -1][0];
  760.  
  761.             }
  762.  
  763.         }
  764.  
  765.         /**
  766.  
  767.          * Remove jQuery lightBox plugin HTML markup
  768.  
  769.          *
  770.  
  771.          */
  772.  
  773.         function _finish() {
  774.  
  775.             $('#jquery-lightbox').remove();
  776.  
  777.             $('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
  778.  
  779.             // Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
  780.  
  781.             $('embed, object, select').css({ 'visibility' : 'visible' });
  782.  
  783.             _disable_keyboard_navigation();
  784.  
  785.         }
  786.  
  787.         /**
  788.  
  789.          / THIRD FUNCTION
  790.  
  791.          * getPageSize() by quirksmode.com
  792.  
  793.          *
  794.  
  795.          * @return Array Return an array with page width, height and window width, height
  796.  
  797.          */
  798.  
  799.         function ___getPageSize() {
  800.  
  801.             var xScroll, yScroll;
  802.  
  803.             if (window.innerHeight && window.scrollMaxY) { 
  804.  
  805.                 xScroll = window.innerWidth + window.scrollMaxX;
  806.  
  807.                 yScroll = window.innerHeight + window.scrollMaxY;
  808.  
  809.             } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
  810.  
  811.                 xScroll = document.body.scrollWidth;
  812.  
  813.                 yScroll = document.body.scrollHeight;
  814.  
  815.             } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
  816.  
  817.                 xScroll = document.body.offsetWidth;
  818.  
  819.                 yScroll = document.body.offsetHeight;
  820.  
  821.             }
  822.  
  823.             var windowWidth, windowHeight;
  824.  
  825.             if (self.innerHeight) { // all except Explorer
  826.  
  827.                 if(document.documentElement.clientWidth){
  828.  
  829.                     windowWidth = document.documentElement.clientWidth;
  830.  
  831.                 } else {
  832.  
  833.                     windowWidth = self.innerWidth;
  834.  
  835.                 }
  836.  
  837.                 windowHeight = self.innerHeight;
  838.  
  839.             } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
  840.  
  841.                 windowWidth = document.documentElement.clientWidth;
  842.  
  843.                 windowHeight = document.documentElement.clientHeight;
  844.  
  845.             } else if (document.body) { // other Explorers
  846.  
  847.                 windowWidth = document.body.clientWidth;
  848.  
  849.                 windowHeight = document.body.clientHeight;
  850.  
  851.             }  
  852.  
  853.             // for small pages with total height less then height of the viewport
  854.  
  855.             if(yScroll < windowHeight){
  856.  
  857.                 pageHeight = windowHeight;
  858.  
  859.             } else {
  860.  
  861.                 pageHeight = yScroll;
  862.  
  863.             }
  864.  
  865.             // for small pages with total width less then width of the viewport
  866.  
  867.             if(xScroll < windowWidth){ 
  868.  
  869.                 pageWidth = xScroll;       
  870.  
  871.             } else {
  872.  
  873.                 pageWidth = windowWidth;
  874.  
  875.             }
  876.  
  877.             arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
  878.  
  879.             return arrayPageSize;
  880.  
  881.         };
  882.  
  883.         /**
  884.  
  885.          / THIRD FUNCTION
  886.  
  887.          * getPageScroll() by quirksmode.com
  888.  
  889.          *
  890.  
  891.          * @return Array Return an array with x,y page scroll values.
  892.  
  893.          */
  894.  
  895.         function ___getPageScroll() {
  896.  
  897.             var xScroll, yScroll;
  898.  
  899.             if (self.pageYOffset) {
  900.  
  901.                 yScroll = self.pageYOffset;
  902.  
  903.                 xScroll = self.pageXOffset;
  904.  
  905.             } else if (document.documentElement && document.documentElement.scrollTop) {     // Explorer 6 Strict
  906.  
  907.                 yScroll = document.documentElement.scrollTop;
  908.  
  909.                 xScroll = document.documentElement.scrollLeft;
  910.  
  911.             } else if (document.body) {// all other Explorers
  912.  
  913.                 yScroll = document.body.scrollTop;
  914.  
  915.                 xScroll = document.body.scrollLeft;
  916.  
  917.             }
  918.  
  919.             arrayPageScroll = new Array(xScroll,yScroll);
  920.  
  921.             return arrayPageScroll;
  922.  
  923.         };
  924.  
  925.          /**
  926.  
  927.           * Stop the code execution from a escified time in milisecond
  928.  
  929.           *
  930.  
  931.           */
  932.  
  933.          function ___pause(ms) {
  934.  
  935.             var date = new Date();
  936.  
  937.             curDate = null;
  938.  
  939.             do { var curDate = new Date(); }
  940.  
  941.             while ( curDate - date < ms);
  942.  
  943.          };
  944.  
  945.         // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
  946.  
  947.         return this.unbind('click').click(_initialize);
  948.  
  949.     };
  950.  
  951. })(jQuery); // Call and execute the function immediately passing the jQuery object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement