/* * Name: * advanceImageGallery.js * Description: * Function will send request to server for the image gallery images and will display * images using jquery galleria. * Preconditions/Input: * * Postconditions/Output: * Function will send request to server for the image gallery images and will display * images using jquery galleria. or else it will return alert message to the user for empty image gallery. * Stored Procedures: * None * Log: * Dipak A.Basantani 04/01/2009 [VX-3682] * - Creation * Prajapati Nilesh 02 Mar 2011 VI-1943 + VI-1967 * Chanda Kudale 07/21/2011 [VI-2533] default selected image if imageGalleryXrefId is passed from url */ var imageGalleryXRefId; function displayAdvanceImageGallery(parameterArrayForAdvanceImageGallery) { // // check if initially any # image alreay there then // clear it and refresh the page. // //if(location.href.match(/#(.)*/)) //location.href = location.href.replace(/#(.)*/,""); // // collect all the vairables or set the default values. // collectionId = parameterArrayForAdvanceImageGallery['advanceImageGallery_Id']; delayVar = (parameterArrayForAdvanceImageGallery['advanceImageGallery_Delay']=="")?3:parameterArrayForAdvanceImageGallery['advanceImageGallery_Delay']; recordPerPage = (parameterArrayForAdvanceImageGallery['advanceImageGallery_recordPerPage']==='')?10:parameterArrayForAdvanceImageGallery['advanceImageGallery_recordPerPage']; playLinkText = (parameterArrayForAdvanceImageGallery['advanceImageGallery_playLinkText']==='')?"Play":parameterArrayForAdvanceImageGallery['advanceImageGallery_playLinkText']; pauseLinkText = (parameterArrayForAdvanceImageGallery['advanceImageGallery_pauseLinkText']==='')?"Pause":parameterArrayForAdvanceImageGallery['advanceImageGallery_pauseLinkText']; prevLinkText = (parameterArrayForAdvanceImageGallery['advanceImageGallery_prevLinkText']==='')?"Prev":parameterArrayForAdvanceImageGallery['advanceImageGallery_prevLinkText']; nextLinkText = (parameterArrayForAdvanceImageGallery['advanceImageGallery_nextLinkText']==='')?"Next":parameterArrayForAdvanceImageGallery['advanceImageGallery_nextLinkText']; nextPageLinkText = (parameterArrayForAdvanceImageGallery['advanceImageGallery_nextPageLinkText']==='')?"Next ›":parameterArrayForAdvanceImageGallery['advanceImageGallery_nextPageLinkText']; prevPageLinkText = (parameterArrayForAdvanceImageGallery['advanceImageGallery_prevPageLinkText']==='')?"‹ Prev":parameterArrayForAdvanceImageGallery['advanceImageGallery_prevPageLinkText']; autoPlay = (!parameterArrayForAdvanceImageGallery['autoPlay'])?0:parameterArrayForAdvanceImageGallery['autoPlay']; descriptionLimit = parameterArrayForAdvanceImageGallery['descriptionLimit']; displayLimit = parameterArrayForAdvanceImageGallery['displayLimit']; stnBoxIdGalleriFfic = parameterArrayForAdvanceImageGallery['stnBoxIdGalleriFfic']; thumbTypeGalleriFfic = parameterArrayForAdvanceImageGallery['thumbTypeGalleriFfic']; progressBar = parameterArrayForAdvanceImageGallery['progressBar']; //alert(progressBar); if (progressBar == 0 || progressBar == '0') { progressBar = false; } swipeControls = parameterArrayForAdvanceImageGallery['swipeControls']; if (swipeControls == 0 || swipeControls == '0') { swipeControls = false; } // // step 1 : call ajax function and insert all the mage in the div : navigation using ajax or anything. // $.ajax({ url : "/custom_code/feature_group_image_gal_in_xml_java_form.php?sid="+Math.random()+"&descriptionLimit="+descriptionLimit+"&collectionId="+collectionId+"&displayLimit="+displayLimit+"&collectionType=ImageGallery&galleria=Galleria&resultOutput=javascript", success : function (data) { // // evalute image array. // //2 : image,3: title ,5: description. eval(data); if(imageArray.length == 0) { return; }// end if check if images are availabe for that image gallery or not. var htmlStringForDis = ''; if (newVerisonGalleriFfic && newVerisonGalleriFfic != 'undefined') { if (progressBar && progressBar != 'undefined') { $('#thumbs_'+stnBoxIdGalleriFfic).css('display', 'none'); } if (thumbTypeGalleriFfic && thumbTypeGalleriFfic != 'undefined') { //for left and right thumb if (thumbTypeGalleriFfic == '2' || thumbTypeGalleriFfic == 2 || thumbTypeGalleriFfic == '3' || thumbTypeGalleriFfic == 3) { } else { htmlStringForDis += ''; } } } htmlStringForDis += ''; }catch(e){alert(e)} if (newVerisonGalleriFfic && newVerisonGalleriFfic != 'undefined') { if (thumbTypeGalleriFfic && thumbTypeGalleriFfic != 'undefined') { //for left and right thumb if (thumbTypeGalleriFfic == '2' || thumbTypeGalleriFfic == 2 || thumbTypeGalleriFfic == '3' || thumbTypeGalleriFfic == 3) { } else { htmlStringForDis += ''; } } } if (newVerisonGalleriFfic && newVerisonGalleriFfic != 'undefined') { document.getElementById('thumbs_'+stnBoxIdGalleriFfic).innerHTML = htmlStringForDis; } else { document.getElementById('navigation').innerHTML = htmlStringForDis; } if (newVerisonGalleriFfic && newVerisonGalleriFfic != 'undefined') { if (progressBar && progressBar != 'undefined') { //for new gelleriffic also added progressbar same as old one. firstTime = false; $("#progressbar_"+stnBoxIdGalleriFfic).fadeIn(500).progressbar( function() { interval: 500; text: 0; textClass: "progressBarTextXugular"; width: 250; range: true; increment: 1; }); setTimeout("initialProgressing_"+stnBoxIdGalleriFfic+"();",50); setTimeout("advance10Percent_"+stnBoxIdGalleriFfic+"();",1000); setTimeout("advance10Percent_"+stnBoxIdGalleriFfic+"();",1000); } else { setTimeout("startGalleria();",50); //if we will direct open this then we donot need below code of progressbar. } } else { //for old gelleriffic firstTime = false; $("#progressbar").fadeIn(500).progressbar( function() { interval: 500; text: 0; textClass: "progressBarTextXugular"; width: 250; range: true; increment: 1; }); setTimeout("initialProgressing();",50); setTimeout("advance10Percent();",1000); setTimeout("advance10Percent();",1000); } return; } }); }// end function displayAdvanceImageGallery function startGalleria() { if (newVerisonGalleriFfic && newVerisonGalleriFfic != 'undefined') { // We only want these styles applied when javascript is enabled //$('div.content_mf_ig').css('display', 'block'); //if class $('#content_mf_ig_'+stnBoxIdGalleriFfic).css('display', 'block'); //if id // Initially set opacity on thumbs and add // additional styling for hover effect on thumbs var onMouseOutOpacity = 0.67; if (thumbTypeGalleriFfic && thumbTypeGalleriFfic != 'undefined' && false) { //Added false to remove opacity from thumb //for left and right thumb if (thumbTypeGalleriFfic == '2' || thumbTypeGalleriFfic == 2 || thumbTypeGalleriFfic == '3' || thumbTypeGalleriFfic == 3) { $('#thumbs_'+stnBoxIdGalleriFfic+' ul.thumbs li').opacityrollover({ mouseOutOpacity: onMouseOutOpacity, mouseOverOpacity: 1.0, fadeSpeed: 'fast', exemptionSelector: '.selected' }); } else { $('#thumbs_'+stnBoxIdGalleriFfic+' ul.thumbs li, div.navigation_'+stnBoxIdGalleriFfic+' a.pageLink').opacityrollover({ mouseOutOpacity: onMouseOutOpacity, mouseOverOpacity: 1.0, fadeSpeed: 'fast', exemptionSelector: '.selected' }); } } enableTopPagerVal = false; enableBottomPagerVal = false; maxPagesToShowVal = ''; if (thumbTypeGalleriFfic && thumbTypeGalleriFfic != 'undefined') { if (thumbTypeGalleriFfic == '2' || thumbTypeGalleriFfic == 2 || thumbTypeGalleriFfic == '3' || thumbTypeGalleriFfic == 3) { enableTopPagerVal = true; enableBottomPagerVal = false; maxPagesToShowVal = 3; } } transitionTypeVal = 'fade'; //transitionTypeVal = 'slide'; gallery = $('#thumbs_'+stnBoxIdGalleriFfic).galleriffic( { allowNextPrevButtonToPage: true, //customize added option specially for vortal allowNextPrevButtonToNav: true, //customize added option specially for vortal stnBoxIdVortal: stnBoxIdGalleriFfic, //customize as per vortal stnBoxClass: '_'+stnBoxIdGalleriFfic, //customize as per vortal pagerOutsideThumbnailDiv: true, //customize as per vortal playPauseLinkToSpan: true, //customize as per vortal imageCaptionToDiv: true, //customize as per vortal delay: delayVar, numThumbs: recordPerPage, preloadAhead: 10, //enableTopPager: false, //enableBottomPager: false, enableTopPager: enableTopPagerVal, enableBottomPager: enableBottomPagerVal, maxPagesToShow: maxPagesToShowVal, renderSSControls: true, renderNavControls: true, playLinkText: playLinkText, pauseLinkText: pauseLinkText, prevLinkText: prevLinkText, nextLinkText: nextLinkText, nextPageLinkText: nextPageLinkText, prevPageLinkText: prevPageLinkText, imageContainerSel: '#slideshow_'+stnBoxIdGalleriFfic, controlsContainerSel: '#controls_'+stnBoxIdGalleriFfic, captionContainerSel: '#caption_'+stnBoxIdGalleriFfic, loadingContainerSel: '#loading_'+stnBoxIdGalleriFfic, enableHistory: false, autoStart: autoPlay, syncTransitions: true, defaultTransitionDuration: 900, onSlideChange: function(prevIndex, nextIndex) { // 'this' refers to the gallery, which is an extension of $('#thumbs') /*this.find('ul.thumbs').children() .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end() .eq(nextIndex).fadeTo('fast', 1.0);*/ // Update the photo index display /*this.$captionContainer.find('div.photo-index_'+stnBoxIdGalleriFfic) .html('Photo '+ (nextIndex+1) +' of '+ this.data.length);*/ }, onPageTransitionOut: function(callback) { this.fadeTo('fast', 0.0, callback); }, onPageTransitionIn: function() { var prevPageLink = this.find('a.prev').css('visibility', 'hidden'); var nextPageLink = this.find('a.next').css('visibility', 'hidden'); // Show appropriate next / prev page links /*if (this.displayedPage > 0) prevPageLink.css('visibility', 'visible'); var lastPage = this.getNumPages() - 1; if (this.displayedPage < lastPage) nextPageLink.css('visibility', 'visible');*/ //both the time it will must display prev and thumb image. prevPageLink.css('visibility', 'visible'); nextPageLink.css('visibility', 'visible'); //When there is only one page of thumbnails, no need to dispaly arrow for top and bottom thumbnail navigation var lastPage = this.getNumPages() - 1; if (this.displayedPage <= 0 && lastPage == 0) { prevPageLink.css('visibility', 'hidden'); } if (this.displayedPage >= lastPage && lastPage == 0) { nextPageLink.css('visibility', 'hidden'); } this.fadeTo('fast', 1.0); }, onTransitionOut: function(slide, caption, isSync, callback) { if (transitionTypeVal == 'slide') { /*slide.animate({ width: "70%", opacity: 0.4, marginLeft: "0.6in", fontSize: "3em", borderWidth: "10px" }, 1500 );*/ slide.stop().animate({left:'300px',opacity: 0.4},{queue:false,duration:300}); //slide.stop().animate({top:'260px', left:'325px'},{queue:false,duration:300}); caption.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0); } else { slide.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0, callback); caption.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0); } }, onTransitionIn: function(slide, caption, isSync) { if (transitionTypeVal == 'slide') { slide.fadeTo(this.getDefaultTransitionDuration(isSync), 1.0); caption.fadeTo(this.getDefaultTransitionDuration(isSync), 1.0); } else { slide.fadeTo(this.getDefaultTransitionDuration(isSync), 1.0); caption.fadeTo(this.getDefaultTransitionDuration(isSync), 1.0); } } }); /*$('#slideshow-container_'+stnBoxIdGalleriFfic+' #slideshow_'+stnBoxIdGalleriFfic).mouseover(function() { //$('div.nav-controls').show(); $('div.nav-controls').css('visibility', 'visible'); }).mouseout(function() { //$('div.nav-controls').hide(); $('div.nav-controls').css('visibility', 'hidden'); });*/ /**************** Event handlers for custom next / prev page links **********************/ gallery.find('a.prev').click(function(e) { gallery.previousPage(); e.preventDefault(); }); gallery.find('a.next').click(function(e) { gallery.nextPage(); e.preventDefault(); }); if (progressBar && progressBar != 'undefined') { $('#thumbs_'+stnBoxIdGalleriFfic).css('display', 'block'); } if (swipeControls && swipeControls != 'undefined') { $('#slideshow_'+stnBoxIdGalleriFfic).bind( 'swipeleft', function( e ) {swipeEvent('previous'); }); $('#slideshow_'+stnBoxIdGalleriFfic).bind( 'swiperight', function( e ) {swipeEvent('next'); }); } } else { //Old galleriffic, as usual working.... gallery = $(document).galleriffic.init('#navigation', { delay: delayVar, numThumbs: recordPerPage, downloadLinkSel: '', playLinkText: playLinkText, pauseLinkText: pauseLinkText, prevLinkText: prevLinkText, nextLinkText: nextLinkText, nextPageLinkText: nextPageLinkText, prevPageLinkText: prevPageLinkText, imageContainerSel: '#slideshow', controlsContainerSel: '#controls', titleContainerSel: '#image-title', descContainerSel: '#image-desc', enableBottomPager: false }); gallery.onFadeOut = function() { $('#details').fadeOut('fast'); }; gallery.onFadeIn = function() { $('#details').fadeIn('fast'); }; if(autoPlay) { gallery.$controlsContainer.find('div.ss-controls span').removeClass().addClass('pause').attr('title', pauseLinkText).html(pauseLinkText); gallery.interval = setInterval(function () { gallery.ssAdvance(); }, delayVar); } if (swipeControls && swipeControls != 'undefined') { $('#slideshow').bind( 'swipeleft', function( e ) {swipeEvent('previous'); }); $('#slideshow').bind( 'swiperight', function( e ) {swipeEvent('next'); }); } } }// end function startGalleria /** * for refreshing the banners of one state if they are present on the page. * */ function refreshBanners() { try{ for(var x=0;x