/** * prototype gallery funciton */ jQuery.fn.unitegallery = function(options){ var element = jQuery(this); var galleryID = "#" + element.attr("id"); if(!options) var options = {}; var objGallery = new UniteGalleryMain(); objGallery.run(galleryID, options); var api = new UG_API(objGallery); return(api); } /** * check for errors function */ function ugCheckForErrors(galleryID, type){ if(typeof jQuery.fn.unitegallery == "function") return(true); var errorMessage = "Unite Gallery Error: You have some jquery.js library include that comes after the gallery files js include."; errorMessage += "
This include eliminates the gallery libraries, and make it not work."; if(type == "cms"){ errorMessage += "

To fix it you can:
    1. In the Gallery Settings -> Troubleshooting set option: Put JS Includes To Body option to true."; errorMessage += "
    2. Find the double jquery.js include and remove it."; }else{ errorMessage += "

Please find and remove this jquery.js include and the gallery will work.
* There should be only one jquery.js include before all other js includes in the page."; } errorMessage = "
" + errorMessage + "
" jQuery(galleryID).show().html(errorMessage); return(false); } function UniteGalleryMain(){ var t = this; var g_galleryID; var g_objGallery = jQuery(t), g_objWrapper; var g_objThumbs, g_objSlider, g_functions = new UGFunctions(); var g_arrItems = [], g_numItems, g_selectedItem = null, g_selectedItemIndex = -1; var g_objTheme; this.events = { ITEM_CHANGE: "item_change", SIZE_CHANGE: "size_change", ENTER_FULLSCREEN: "enter_fullscreen", EXIT_FULLSCREEN: "exit_fullscreen", START_PLAY: "start_play", STOP_PLAY: "stop_play", PAUSE_PLAYING: "pause_playing", CONTINUE_PLAYING: "continue_playing", SLIDER_ACTION_START: "slider_action_start", SLIDER_ACTION_END: "slider_action_end", ITEM_IMAGE_UPDATED: "item_image_updated", GALLERY_KEYPRESS: "gallery_keypress" }; //set the default gallery options var g_options = { gallery_width:900, //gallery width gallery_height:500, //gallery height gallery_min_width: 150, //gallery minimal width when resizing gallery_min_height: 100, //gallery minimal height when resizing gallery_theme:"default", //default,compact,grid,slider - select your desired theme from the list of themes. gallery_skin:"default", //default, alexis etc... - the global skin of the gallery. Will change all gallery items by default. gallery_images_preload_type:"minimal", //all , minimal , visible - preload type of the images. //minimal - only image nabours will be loaded each time. //visible - visible thumbs images will be loaded each time. //all - load all the images first time. gallery_autoplay:false, //true / false - begin slideshow autoplay on start gallery_play_interval: 3000, //play interval of the slideshow gallery_pause_on_mouseover: true, //true,false - pause on mouseover when playing slideshow true/false gallery_control_thumbs_mousewheel:false, //true,false - change this option, add more mousewheel choices gallery_control_keyboard: true, //true,false - enable / disble keyboard controls gallery_carousel:true, //true,false - next button on last image goes to first image. gallery_preserve_ratio: true, //true, false - preserver ratio when on window resize gallery_debug_errors:false, //show error message when there is some error on the gallery area. gallery_background_color: "" //set custom background color. If not set it will be taken from css. }; var g_temp = { //temp variables objCustomOptions:{}, isAllItemsPreloaded:false, //flag that tells that all items started preloading isFreestyleMode:false, //no special html additions lastWidth:0, lastHeigh:0, handleResize: null, isInited: false, isPlayMode: false, isPlayModePaused: false, playTimePassed: 0, playTimeLastStep: 0, playHandle: "", playStepInterval: 33, objProgress: null, isFakeFullscreen: false, thumbsType:null, isYoutubePresent:false, //flag if present youtube items isVimeoPresent:false, //flag if present vimeo items isHtml5VideoPresent:false, //flag if present html5 video items isSoundCloudPresent:false, //flag if present soundcloud items isWistiaPresent: false, //flag if some wistia movie present resizeDelay: 100, isRunFirstTime: true, originalOptions: {} }; function __________INIT_GALLERY_______(){}; /** * get theme function from theme name */ function getThemeFunction(themeName){ var themeFunction = themeName; if(themeFunction.indexOf("UGTheme_") == -1) themeFunction = "UGTheme_" + themeFunction; return(themeFunction); } /** * init the theme */ function initTheme(objParams){ //set theme function: if(objParams.hasOwnProperty("gallery_theme")) g_options.gallery_theme = objParams.gallery_theme; else{ var defaultTheme = g_options.gallery_theme; if(g_ugFunctions.isThemeRegistered(defaultTheme) == false) g_options.gallery_theme = g_ugFunctions.getFirstRegisteredTheme(); } var themeFunction = getThemeFunction(g_options.gallery_theme); try{ g_options.gallery_theme = eval(themeFunction); }catch(e){ //check registered themes }; g_options.gallery_theme = eval(themeFunction); //init the theme //destroy last theme if exists if(g_objTheme && typeof g_objTheme.destroy == "function"){ g_objTheme.destroy(); g_objWrapper.html(""); } // trace(g_options.tile_enable_textpanel); g_objTheme = new g_options.gallery_theme(); g_objTheme.init(t, g_temp.objCustomOptions); } /** * reset all the options for the second time run */ function resetOptions(){ g_options = jQuery.extend({}, g_temp.originalOptions); g_selectedItemIndex = -1; g_selectedItem = null; g_objSlider = undefined; g_objThumbs = undefined; g_objSlider = undefined; } /** * the gallery */ function runGallery(galleryID, objCustomOptions){ g_temp.objCustomOptions = objCustomOptions; if(g_temp.isRunFirstTime == true){ g_galleryID = galleryID; g_objWrapper = jQuery(g_galleryID); if(g_objWrapper.length == 0){ trace("div with id: "+g_galleryID+" not found"); return(false); } g_temp.originalOptions = jQuery.extend({}, g_options); //fill arrItems var arrItems = g_objWrapper.children(); fillItemsArray(arrItems); loadAPIs(); //hide images: g_objWrapper.children("img").fadeTo(0,0).hide(); g_objWrapper.show(); clearInitData(); }else{ //reset options resetOptions(); } //extend params with defaults from user g_options = jQuery.extend(g_options, objCustomOptions); //modify and verify the params modifyInitParams(objCustomOptions); validateParams(); //init the theme initTheme(objCustomOptions); //set gallery html elements setGalleryHtml(); //set html properties to all elements setHtmlObjectsProperties(); var galleryWidth = g_objWrapper.width(); if(galleryWidth == 0){ g_functions.waitForWidth(g_objWrapper, runGalleryActually); }else runGalleryActually(); } /** * actually run the gallery */ function runGalleryActually(){ if(g_temp.isFreestyleMode == false){ if(g_options.gallery_preserve_ratio == true) setHeightByOriginalRatio(); } g_objTheme.run(); preloadBigImages(); initEvents(); //select first item if(g_numItems > 0) t.selectItem(0); //set autoplay if(g_options.gallery_autoplay == true) t.startPlayMode(); g_temp.isRunFirstTime = false; } /** * * show error message */ function showErrorMessage(message){ message = "Gallery Error: " + message; var html = "
" + message + "
"; g_objWrapper.children().remove(); g_objWrapper.width(g_options.gallery_width); g_objWrapper.height(g_options.gallery_height); g_objWrapper.css("border","1px solid black"); g_objWrapper.html(html); g_objWrapper.show(); } /** * * @param objParams */ function modifyInitParams(inputParams){ //set default for preloading if(!g_options.gallery_images_preload_type) g_options.gallery_images_preload_type = "minimal"; //normalize gallery min height and width if(inputParams.gallery_min_height == undefined && g_options.gallery_height < g_options.gallery_min_height){ g_options.gallery_min_height = 0; } if(inputParams.gallery_min_width == undefined && g_options.gallery_width < g_options.gallery_min_width){ g_options.gallery_min_width = 0; } } /** * validate the init parameters */ function validateParams(){ //validate theme: if(!g_options.gallery_theme) throw new Error("The gallery can't run without theme"); //if(typeof g_options.theme != "function") //throw new Error("Wrong theme function: " + g_options.theme.toString()); //validate height and width if(g_options.gallery_height < g_options.gallery_min_height) throw new Error("The gallery_height option must be bigger then gallery_min_height option"); if(g_options.gallery_width < g_options.gallery_min_width) throw new Error("The gallery_width option must be bigger then gallery_min_width option"); } /** * set gallery html */ function setGalleryHtml(){ //add classes and divs g_objWrapper.addClass("ug-gallery-wrapper"); t.setSizeClass(); } /** * if the thumbs panel don't exists, delete initial images from dom */ function clearInitData(){ var objItems = g_objWrapper.children().remove(); } /** * store last gallery size */ function storeLastSize(){ var objSize = t.getSize(); g_temp.lastWidth = objSize.width; g_temp.lastHeight = objSize.height; } /** * set gallery height by original ratio */ function setHeightByOriginalRatio(){ var objSize = t.getSize(); var ratio = objSize.width / objSize.height; if(ratio != objSize.orig_ratio){ var newHeight = objSize.width / objSize.orig_ratio; newHeight = Math.round(newHeight); if(newHeight < g_options.gallery_min_height) newHeight = g_options.gallery_min_height; g_objWrapper.height(newHeight); } } /** * set properties of the html objects */ function setHtmlObjectsProperties(){ var optionWidth = g_functions.getCssSizeParam(g_options.gallery_width); //set size var objCss = { //"width":optionWidth, //make it work within tabs "max-width":optionWidth, "min-width":g_functions.getCssSizeParam(g_options.gallery_min_width), }; if(g_temp.isFreestyleMode == false){ objCss["height"] = g_options.gallery_height+"px"; }else{ objCss["overflow"] = "visible"; } //set background color if(g_options.gallery_background_color) objCss["background-color"] = g_options.gallery_background_color; g_objWrapper.css(objCss); } /** * fill items array from images object */ function fillItemsArray(arrChildren){ var numIndex = 0; for(var i=0;i').attr("src", imageUrl); objItem.objPreloadImage.data("itemIndex", objItem.index); //set image load event (not that reliable) objItem.objPreloadImage.on("load", t.onItemBigImageLoaded); //set load error event objItem.objPreloadImage.on( "error", function(){ var objImage = jQuery(this); var itemIndex = objImage.data("itemIndex"); var objItem = g_arrItems[itemIndex]; //update error: objItem.isBigImageLoadError = true; objItem.isBigImageLoaded = false; //print error var imageUrl = jQuery(this).attr("src"); console.log("Can't load image: "+ imageUrl); //try to load the image again g_objGallery.trigger(t.events.ITEM_IMAGE_UPDATED, [itemIndex, objItem.urlImage]); objItem.objThumbImage.attr("src", objItem.urlThumb); }); //check the all items started preloading flag checkAllItemsStartedPreloading(); } /** * on item big image loaded event function. * Update image size and that the image has been preloaded * can be called from another objects like the slider */ this.onItemBigImageLoaded = function(event, objImage){ if(!objImage) var objImage = jQuery(this); var itemIndex = objImage.data("itemIndex"); var objItem = g_arrItems[itemIndex]; objItem.isBigImageLoaded = true; var objSize = g_functions.getImageOriginalSize(objImage); objItem.imageWidth = objSize.width; objItem.imageHeight = objSize.height; } /** * check and fill image size in item object */ this.checkFillImageSize = function(objImage, objItem){ if(!objItem){ var itemIndex = objImage.data("itemIndex"); if(itemIndex === undefined) throw new Error("Wrong image given to gallery.checkFillImageSize"); var objItem = g_arrItems[itemIndex]; } var objSize = g_functions.getImageOriginalSize(objImage); objItem.imageWidth = objSize.width; objItem.imageHeight = objSize.height; } /** * preload next images near current item */ function preloadNearBigImages(objItem){ if(g_temp.isAllItemsPreloaded == true) return(false); if(!objItem) var objItem = g_selectedItem; if(!objItem) return(true); var currentIndex = objItem.index; var lastItemIndex = currentIndex - 1; var nextItemIndex = currentIndex + 1; if(lastItemIndex > 0) preloadItemImage(g_arrItems[lastItemIndex]); if(nextItemIndex < g_numItems) preloadItemImage(g_arrItems[nextItemIndex]); } /** * check that all items started preloading, if do, set * flag g_temp.isAllItemsPreloaded to true */ function checkAllItemsStartedPreloading(){ if(g_temp.isAllItemsPreloaded == true) return(false); //if some of the items not started, exit function: for(var index in g_arrItems){ if(g_arrItems[index].isBigImageLoadStarted == false) return(false); } //if all started, set flag to true g_temp.isAllItemsPreloaded = true; } /** * set freestyle mode */ this.setFreestyleMode = function(){ g_temp.isFreestyleMode = true; } /** * init the thumbs panel object * type - strip / grid */ this.initThumbsPanel = function(type, options){ if(!options) var options = {}; if(!type) var type = "strip"; g_temp.thumbsType = type; switch(type){ case "strip": g_objThumbs = new UGThumbsStrip(); break; case "grid": g_objThumbs = new UGThumbsGrid(); break; default: throw new Error("Wrong thumbs type: " + type); break; } options = jQuery.extend(options, g_temp.objCustomOptions); g_objThumbs.init(t, options); } /** * init the slider */ this.initSlider = function(customOptions, optionsPrefix){ //mix options with user options if(!customOptions) var customOptions = {}; customOptions = jQuery.extend(customOptions, g_temp.objCustomOptions); g_objSlider = new UGSlider(); g_objSlider.init(t, customOptions, optionsPrefix); } function __________END_INIT_GALLERY_______(){}; function __________EVENTS_____________(){}; /** * on gallery mousewheel event handler, advance the thumbs */ function onGalleryMouseWheel(event, delta, deltaX, deltaY){ event.preventDefault(); if(delta > 0) t.prevItem(); else t.nextItem(); } /** * on mouse enter event */ function onSliderMouseEnter(event){ if(g_options.gallery_pause_on_mouseover == true && g_temp.isPlayMode == true && g_objSlider && g_objSlider.isSlideActionActive() == false) t.pausePlaying(); } /** * on mouse move event */ function onSliderMouseLeave(event){ if(g_options.gallery_pause_on_mouseover == true && g_temp.isPlayMode == true && g_objSlider && g_objSlider.isSlideActionActive() == false) t.continuePlaying(); } /** * on keypress - keyboard control */ function onKeyPress(event){ var keyCode = (event.charCode) ? event.charCode :((event.keyCode) ? event.keyCode :((event.which) ? event.which : 0)); switch(keyCode){ case 39: //right key t.nextItem(); event.preventDefault(); break; case 37: //left key t.prevItem(); event.preventDefault(); break; } g_objGallery.trigger(t.events.GALLERY_KEYPRESS, keyCode); } /** * check that the gallery resized, if do, trigger onresize event */ function onGalleryResized(){ t.setSizeClass(); var objSize = t.getSize(); if(objSize.width != g_temp.lastWidth || objSize.height != g_temp.lastHeight){ if(g_options.gallery_preserve_ratio == true && g_temp.isFreestyleMode == false) setHeightByOriginalRatio(); storeLastSize(); g_objGallery.trigger(t.events.SIZE_CHANGE); } } /** * on strip move event * preload visible images if that option selected */ function onThumbsChange(event){ //preload visible images if(g_options.gallery_images_preload_type == "visible" && g_temp.isAllItemsPreloaded == false){ preloadBigImages(); } } /** * on full screen change event */ function onFullScreenChange(){ var isFullscreen = g_functions.isFullScreen(); var event = isFullscreen ? t.events.ENTER_FULLSCREEN:t.events.EXIT_FULLSCREEN; //add classes for the gallery if(isFullscreen){ g_objWrapper.addClass("ug-fullscreen"); }else{ g_objWrapper.removeClass("ug-fullscreen"); } g_objGallery.trigger(event); onGalleryResized(); } /** * on big image updated, if needed - preload this item image */ function onItemImageUpdated(event, index){ var objItem = t.getItem(index); checkPreloadItemImage(objItem); } /** * init all events */ function initEvents(){ //avoid annoyong firefox image dragging g_objWrapper.on("dragstart",function(event){ event.preventDefault(); }); //on big image updated, if needed - preload this item image g_objGallery.on(t.events.ITEM_IMAGE_UPDATED, onItemImageUpdated); //init custom event on strip moving if(g_objThumbs){ switch(g_temp.thumbsType){ case "strip": jQuery(g_objThumbs).on(g_objThumbs.events.STRIP_MOVE, onThumbsChange); break; case "grid": jQuery(g_objThumbs).on(g_objThumbs.events.PANE_CHANGE, onThumbsChange); break; } } //init mouse wheel if(g_options.gallery_control_thumbs_mousewheel == true) g_objWrapper.on("mousewheel",onGalleryMouseWheel); //on resize event storeLastSize(); jQuery(window).resize(function(){ g_objWrapper.css("width","auto"); g_functions.whenContiniousEventOver("gallery_resize", onGalleryResized, g_temp.resizeDelay); }); //fullscreen: g_functions.addFullScreenChangeEvent(onFullScreenChange); //on slider item changed event if(g_objSlider){ jQuery(g_objSlider).on(g_objSlider.events.ITEM_CHANGED, function(){ var sliderIndex = g_objSlider.getCurrentItemIndex(); if(sliderIndex != -1) t.selectItem(sliderIndex); }); //add slider onmousemove event if(g_options.gallery_pause_on_mouseover == true){ var sliderElement = g_objSlider.getElement(); sliderElement.hover(onSliderMouseEnter, onSliderMouseLeave); } //retrigger slider events retriggerEvent(g_objSlider, g_objSlider.events.ACTION_START, t.events.SLIDER_ACTION_START); retriggerEvent(g_objSlider, g_objSlider.events.ACTION_END, t.events.SLIDER_ACTION_END); } //add keyboard events if(g_options.gallery_control_keyboard == true) jQuery(document).keydown(onKeyPress); } function __________GENERAL_______(){}; /** * get items array */ this.getArrItems = function(){ return g_arrItems; } /** * get gallery objects */ this.getObjects = function(){ var objects = { g_galleryID:g_galleryID, g_objWrapper:g_objWrapper, g_objThumbs:g_objThumbs, g_objSlider:g_objSlider, g_options:g_options, g_arrItems:g_arrItems, g_numItems:g_numItems }; return(objects); } /** * get slider object */ this.getObjSlider = function(){ return(g_objSlider); } /** * * get item by index, if the index don't fit, trace error */ this.getItem = function(index){ if(index < 0){ throw new Error("item with index: " + index + " not found"); return(null); } if(index >= g_numItems){ throw new Error("item with index: " + index + " not found"); return(null); } return(g_arrItems[index]); } /** * get gallery width */ this.getWidth = function(){ var objSize = t.getSize(); return(objSize.width); } /** * get gallery height */ this.getHeight = function(){ var objSize = t.getSize(); return(objSize.height); } /** * get gallery size */ this.getSize = function(){ var objSize = g_functions.getElementSize(g_objWrapper); objSize.orig_width = g_options.gallery_width; objSize.orig_height = g_options.gallery_height; objSize.orig_ratio = objSize.orig_width / objSize.orig_height; return(objSize); } /** * get gallery ID */ this.getGalleryID = function(){ var id = g_galleryID.replace("#",""); return(id); } /** * get next item by current index (or current object) */ this.getNextItem = function(index, forceCarousel){ if(typeof index == "object") index = index.index; var nextIndex = index + 1; if(forceCarousel !== true && g_numItems == 1) return(null); if(nextIndex >= g_numItems){ if(g_options.gallery_carousel == true || forceCarousel === true) nextIndex = 0; else return(null); } var objItem = g_arrItems[nextIndex]; return(objItem); } /** * get previous item by index (or item object) */ this.getPrevItem = function(index){ if(typeof index == "object") index = index.index; var prevIndex = index - 1; if(prevIndex < 0){ if(g_options.gallery_carousel == true || forceCarousel === true) prevIndex = g_numItems - 1; else return(null); } var objItem = g_arrItems[prevIndex]; return(objItem); } /** * get selected item */ this.getSelectedItem = function(){ return(g_selectedItem); } /** * get number of items */ this.getNumItems = function(){ return g_numItems; } /** * get true if the current item is last */ this.isLastItem = function(){ if(g_selectedItemIndex == g_numItems - 1) return(true); return(false); } /** * get true if the current item is first */ this.isFirstItem = function(){ if(g_selectedItemIndex == 0) return(true); return(false); } /** * get gallery options */ this.getOptions = function(){ return g_options; } /** * get the gallery wrapper element */ this.getElement = function(){ return(g_objWrapper); } this.___________SET_CONTROLS___________ = function(){} /** * set next button element * set onclick event */ this.setNextButton = function(objButton){ //register button as a unite gallery belong objButton.data("ug-button", true); g_functions.setButtonOnClick(objButton, t.nextItem); } /** * set prev button element * set onclick event */ this.setPrevButton = function(objButton){ //register button as a unite gallery belong objButton.data("ug-button", true); g_functions.setButtonOnClick(objButton, t.prevItem); } /** * set fullscreen button to enter / exit fullscreen. * on fullscreen mode ug-fullscreenmode class wil be added */ this.setFullScreenToggleButton = function(objButton){ //register button as a unite gallery belong objButton.data("ug-button", true); g_functions.setButtonOnClick(objButton, t.toggleFullscreen); g_objGallery.on(t.events.ENTER_FULLSCREEN,function(){ objButton.addClass("ug-fullscreenmode"); }); g_objGallery.on(t.events.EXIT_FULLSCREEN,function(){ objButton.removeClass("ug-fullscreenmode"); }); } /** * destroy full screen button */ this.destroyFullscreenButton = function(objButton){ g_functions.destroyButton(objButton); g_objGallery.off(t.events.ENTER_FULLSCREEN); g_objGallery.off(t.events.EXIT_FULLSCREEN); } /** * set play button event */ this.setPlayButton = function(objButton){ //register button as a unite gallery belong objButton.data("ug-button", true); g_functions.setButtonOnClick(objButton, t.togglePlayMode); g_objGallery.on(t.events.START_PLAY,function(){ objButton.addClass("ug-stop-mode"); }); g_objGallery.on(t.events.STOP_PLAY, function(){ objButton.removeClass("ug-stop-mode"); }); } /** * destroy the play button */ this.destroyPlayButton = function(objButton){ g_functions.destroyButton(objButton); g_objGallery.off(t.events.START_PLAY); g_objGallery.off(t.events.STOP_PLAY); } /** * set playing progress indicator */ this.setProgressIndicator = function(objProgress){ g_temp.objProgress = objProgress; } /** * set title and descreiption containers */ this.setTextContainers = function(objTitle, objDescription){ g_objGallery.on(t.events.ITEM_CHANGE, function(){ var objItem = t.getSelectedItem(); objTitle.html(objItem.title); objDescription.html(objItem.description); }); } this.___________END_SET_CONTROLS___________ = function(){} /** * remove all size classes */ function removeAllSizeClasses(objWrapper){ if(!objWrapper) objWrapper = g_objWrapper; objWrapper.removeClass("ug-under-480"); objWrapper.removeClass("ug-under-780"); objWrapper.removeClass("ug-under-960"); } /** * retrigger event from another objects * the second parameter will be the second object */ function retriggerEvent(object, originalEvent, newEvent){ jQuery(object).on(originalEvent, function(event){ g_objGallery.trigger(newEvent, [this]); }); } /** * advance next play step */ function advanceNextStep(){ var timeNow = jQuery.now(); var timeDiff = timeNow - g_temp.playTimeLastStep; g_temp.playTimePassed += timeDiff; g_temp.playTimeLastStep = timeNow; //set the progress if(g_temp.objProgress){ var percent = g_temp.playTimePassed / g_options.gallery_play_interval; g_temp.objProgress.setProgress(percent); } //if interval passed - proceed to next item if(g_temp.playTimePassed >= g_options.gallery_play_interval){ t.nextItem(); g_temp.playTimePassed = 0; } } this.___________PLAY_MODE___________ = function(){} /** * start play mode */ this.startPlayMode = function(){ g_temp.isPlayMode = true; g_temp.isPlayModePaused = false; g_temp.playTimePassed = 0; g_temp.playTimeLastStep = jQuery.now(); g_temp.playHandle = setInterval(advanceNextStep, g_temp.playStepInterval); //show and reset progress indicator if(g_temp.objProgress){ var objElement = g_temp.objProgress.getElement(); g_temp.objProgress.setProgress(0); objElement.show(); } g_objGallery.trigger(t.events.START_PLAY); } /** * reset playing - set the timer to 0 */ this.resetPlaying = function(){ if(g_temp.isPlayMode == false) return(true); g_temp.playTimePassed = 0; g_temp.playTimeLastStep = jQuery.now(); } /** * pause playing slideshow */ this.pausePlaying = function(){ if(g_temp.isPlayModePaused == true) return(true); g_temp.isPlayModePaused = true; clearInterval(g_temp.playHandle); g_objGallery.trigger(t.events.PAUSE_PLAYING); } /** * continue playing slideshow */ this.continuePlaying = function(){ if(g_temp.isPlayModePaused == false) return(true); g_temp.isPlayModePaused = false; g_temp.playTimeLastStep = jQuery.now(); g_temp.playHandle = setInterval(advanceNextStep, g_temp.playStepInterval); } /** * stop play mode */ this.stopPlayMode = function(){ g_temp.isPlayMode = false; clearInterval(g_temp.playHandle); g_temp.playTimePassed = 0; //hide progress indicator if(g_temp.objProgress){ var objElement = g_temp.objProgress.getElement(); objElement.hide(); } g_objGallery.trigger(t.events.STOP_PLAY); } /** * tells if the play mode are active */ this.isPlayMode = function(){ return(g_temp.isPlayMode); } /** * start / stop play mode */ this.togglePlayMode = function(){ if(t.isPlayMode() == false) t.startPlayMode(); else t.stopPlayMode(); } this.___________END_PLAY_MODE___________ = function(){} /** * unselect all items */ function unselectSeletedItem(){ if(g_selectedItem == null) return(true); if(g_objThumbs) g_objThumbs.setThumbUnselected(g_selectedItem.objThumbWrapper); g_selectedItem = null; g_selectedItemIndex = -1; } /** * set main gallery params, extend current params */ this.setOptions = function(customOptions){ g_options = jQuery.extend(g_options, customOptions); } /** * select some item * the input can be index or object */ this.selectItem = function(objItem){ if(typeof objItem == "number") objItem = t.getItem(objItem); var itemIndex = objItem.index; if(itemIndex == g_selectedItemIndex) return(true); unselectSeletedItem(); //set selected item g_selectedItem = objItem; g_selectedItemIndex = itemIndex; //reset playback, if playing if(g_temp.isPlayMode == true) t.resetPlaying(); g_objGallery.trigger(t.events.ITEM_CHANGE, objItem); } /** * go to next item */ this.nextItem = function(){ var newItemIndex = g_selectedItemIndex + 1; if(g_numItems == 0) return(true); if(g_options.gallery_carousel == false && newItemIndex >= g_numItems) return(true); if(newItemIndex >= g_numItems) newItemIndex = 0; //debugLine(newItemIndex,true); t.selectItem(newItemIndex); } /** * go to previous item */ this.prevItem = function(){ var newItemIndex = g_selectedItemIndex - 1; if(g_selectedItemIndex == -1) newItemIndex = 0; if(g_numItems == 0) return(true); if(g_options.gallery_carousel == false && newItemIndex < 0) return(true); if(newItemIndex < 0) newItemIndex = g_numItems - 1; t.selectItem(newItemIndex); } /** * expand gallery to body size */ function toFakeFullScreen(){ jQuery("body").addClass("ug-body-fullscreen"); g_objWrapper.addClass("ug-fake-fullscreen"); g_temp.isFakeFullscreen = true; g_objGallery.trigger(t.events.ENTER_FULLSCREEN); g_objGallery.trigger(t.events.SIZE_CHANGE); } /** * exit fake fullscreen */ function exitFakeFullscreen(){ jQuery("body").removeClass("ug-body-fullscreen"); g_objWrapper.removeClass("ug-fake-fullscreen"); g_temp.isFakeFullscreen = false; g_objGallery.trigger(t.events.EXIT_FULLSCREEN); g_objGallery.trigger(t.events.SIZE_CHANGE); } /** * return if the fullscreen mode is available */ this.isFullScreen = function(){ if(g_temp.isFakeFullscreen == true) return(true); if(g_functions.isFullScreen() == true) return(true); return(false); } /** * tells if it's fake fullscreen */ this.isFakeFullscreen = function(){ return(g_temp.isFakeFullscreen); } /** * go to fullscreen mode */ this.toFullScreen = function(){ var divGallery = g_objWrapper.get(0); var isSupported = g_functions.toFullscreen(divGallery); //trace(isSupported); if(isSupported == false) toFakeFullScreen(); } /** * exit full screen */ this.exitFullScreen = function(){ if(g_temp.isFakeFullscreen == true) exitFakeFullscreen(); else g_functions.exitFullscreen(); } /** * toggle fullscreen */ this.toggleFullscreen = function(){ if(t.isFullScreen() == false){ t.toFullScreen(); }else{ t.exitFullScreen(); } } /** * resize the gallery * noevent - initally false */ this.resize = function(newWidth, newHeight, noevent){ g_objWrapper.css("width", "auto"); g_objWrapper.css("max-width",newWidth+"px"); if(newHeight) g_objWrapper.height(newHeight); if(!noevent && noevent !== true) onGalleryResized(); } /** * set size class to the wrapper * this can work to any other wrapper too */ this.setSizeClass = function(objWrapper, width){ if(!objWrapper) var objWrapper = g_objWrapper; if(!width){ var objSize = t.getSize(); var width = objSize.width; } var addClass = ""; if(width <= 480){ addClass = "ug-under-480"; }else if(width <= 780){ addClass = "ug-under-780"; }else if(width < 960){ addClass = "ug-under-960"; } removeAllSizeClasses(objWrapper); if(addClass != "") objWrapper.addClass(addClass); } /** * return if the size is suited for mobile */ this.isMobileMode = function(){ if(g_objWrapper.hasClass("ug-under-480")) return(true); return(false); } function __________END_GENERAL_______(){}; /** * run the gallery */ this.run = function(galleryID, objParams){ var debug_errors = g_options.gallery_debug_errors; if(objParams && objParams.hasOwnProperty("gallery_debug_errors")) g_options.gallery_debug_errors = objParams.gallery_debug_errors; if(g_options.gallery_debug_errors == true){ try{ runGallery(galleryID, objParams); }catch(objError){ if(typeof objError == "object"){ var message = objError; var lineNumber = objError.lineNumber; var fileName = objError.fileName; var stack = objError.stack; message += "

in file: "+fileName; message += " line " + lineNumber + ""; trace(objError); }else{ var message = objError; } //remove double "error:" text message = message.replace("Error:",""); showErrorMessage(message); } }else{ runGallery(galleryID, objParams); } } } //unitegallery object end