";
+
+ objThumbWrapper.append(imageOverlayHtml);
+
+ //hide the image overlay if reversed
+ if(g_options.tile_image_effect_reverse == true){
+ objThumbWrapper.children(".ug-tile-image-overlay").fadeTo(0,0);
+ }
+
+ }
+
+
+ //add text panel
+ if(g_options.tile_enable_textpanel == true){
+
+ var objTextPanel = new UGTextPanel();
+ objTextPanel.init(g_gallery, g_options, "tile");
+
+ //set transition class
+ var textpanelAddClass = "";
+ if(g_options.tile_textpanel_always_on == true || g_temp.isTextpanelOutside == true)
+ textpanelAddClass = "ug-trans-enabled";
+
+ objTextPanel.appendHTML(objThumbWrapper, textpanelAddClass);
+
+ var panelTitle = objItem.title;
+ var panelDesc = "";
+
+ switch(g_options.tile_textpanel_source){
+ case "desc":
+ case "description":
+ panelTitle = objItem.description;
+ break;
+ case "desc_title":
+ if(objItem.description != "")
+ panelTitle = objItem.description;
+ break;
+ case "title_and_desc":
+ panelTitle = objItem.title;
+ panelDesc = objItem.description;
+ break;
+ }
+
+ objTextPanel.setTextPlain(panelTitle, panelDesc);
+
+ if(g_options.tile_textpanel_always_on == false)
+ objTextPanel.getElement().fadeTo(0,0);
+
+ objThumbWrapper.data("objTextPanel", objTextPanel);
+
+ //if textpanel always on, it has to be under the overlay
+ if(g_options.tile_textpanel_always_on == true){
+ var textPanelElement = getTextPanelElement(objThumbWrapper);
+ textPanelElement.css("z-index",2);
+ }
+
+ //if text panel is outside, clone textpanel
+ if(g_temp.isTextpanelOutside == true){
+
+ var htmlClone = "";
+ objThumbWrapper.append(htmlClone);
+ var objCloneWrapper = objThumbWrapper.children(".ug-tile-cloneswrapper");
+
+ var objTextPanelClone = new UGTextPanel();
+ objTextPanelClone.init(g_gallery, g_options, "tile");
+ objTextPanelClone.appendHTML(objCloneWrapper);
+ objTextPanelClone.setTextPlain(panelTitle, panelDesc);
+ objThumbWrapper.data("objTextPanelClone", objTextPanelClone);
+ }
+
+ }
+
+ //add additional html
+ if(objItem.addHtml !== null)
+ objThumbWrapper.append(objItem.addHtml);
+
+ }
+
+
+ /**
+ * load tile image, place the image on load
+ */
+ this.loadTileImage = function(objTile){
+
+ var objImage = t.getTileImage(objTile);
+
+ g_functions.checkImagesLoaded(objImage, null, function(objImage,isError){
+ onPlaceImage(null, objTile, jQuery(objImage));
+ });
+
+ }
+
+ function _________________GETTERS________________(){};
+
+
+
+ /**
+ * get image overlay
+ */
+ function getTileOverlayImage(objTile){
+ var objOverlayImage = objTile.children(".ug-tile-image-overlay");
+ return(objOverlayImage);
+ }
+
+ /**
+ * get tile color overlay
+ */
+ function getTileOverlay(objTile){
+ var objOverlay = objTile.children(".ug-thumb-overlay");
+ return(objOverlay);
+ }
+
+
+ /**
+ * get image container
+ */
+ function getTileImageContainer(objTile){
+ if(g_temp.hasImageContainer == false)
+ return(null);
+
+ var objImageContainer = objTile.children(".ug-image-container");
+
+ return(objImageContainer);
+ }
+
+
+ /**
+ * get image effect
+ */
+ function getTileImageEffect(objTile){
+ var objImageEffect = objTile.find(".ug-tile-image-overlay img");
+ return(objImageEffect);
+ }
+
+
+ /**
+ * get text panel
+ */
+ function getTextPanel(objTile){
+ var objTextPanel = objTile.data("objTextPanel");
+
+ return(objTextPanel);
+ }
+
+
+ /**
+ * get cloned text panel
+ */
+ function getTextPanelClone(objTile){
+ var objTextPanelClone = objTile.data("objTextPanelClone");
+
+ return(objTextPanelClone);
+
+ }
+
+
+ /**
+ * get text panel element from the tile
+ */
+ function getTextPanelElement(objTile){
+ var objTextPanel = objTile.children(".ug-textpanel");
+
+ return(objTextPanel);
+ }
+
+
+ /**
+ * get text panel element cloned
+ */
+ function getTextPanelCloneElement(objTile){
+ var objTextPanel = objTile.find(".ug-tile-cloneswrapper .ug-textpanel");
+
+ if(objTextPanel.length == 0)
+ throw new Error("text panel cloned element not found");
+
+ return(objTextPanel);
+
+ }
+
+
+ /**
+ * get text panel height
+ */
+ function getTextPanelHeight(objTile){
+
+ if(g_temp.isTextpanelOutside == true)
+ var objTextPanel = getTextPanelCloneElement(objTile);
+ else
+ var objTextPanel = getTextPanelElement(objTile);
+
+
+ if(!objTextPanel)
+ return(0);
+
+ var objSize = g_functions.getElementSize(objTextPanel);
+ return(objSize.height);
+ }
+
+
+ /**
+ * get button link
+ */
+ function getButtonLink(objTile){
+ var objButton = objTile.find(".ug-icon-link");
+ if(objButton.length == 0)
+ return(null);
+
+ return objButton;
+ }
+
+
+ /**
+ * get tile ratio
+ */
+ function getTileRatio(objTile){
+
+ //global ratio
+ var ratio = g_temp.ratioByHeight;
+
+ switch(g_options.tile_size_by){
+ default: //global ratio
+ ratio = g_temp.ratioByHeight;
+ break;
+ case t.sizeby.IMAGE_RATIO:
+
+ if(!objTile)
+ throw new Error("tile should be given for tile ratio");
+
+ var item = t.getItemByTile(objTile);
+
+ if(typeof item.thumbRatioByHeight != "undefined"){
+
+ if(item.thumbRatioByHeight == 0){
+ trace(item);
+ throw new Error("the item ratio not inited yet");
+ }
+
+ ratio = item.thumbRatioByHeight;
+ }
+
+ break;
+ case t.sizeby.CUSTOM:
+ return null;
+ break;
+ }
+
+ return(ratio);
+ }
+
+
+ /**
+ * get button zoom
+ */
+ function getButtonZoom(objTile){
+ var objButton = objTile.find(".ug-button-play");
+
+ if(objButton.length == 0)
+ return(null);
+
+ return objButton;
+ }
+
+
+ /**
+ * tells if the tile is over style
+ */
+ function isOverStyle(objTile){
+
+ if(objTile.hasClass("ug-thumb-over"))
+ return(true);
+
+ return(false);
+ }
+
+
+ /**
+ * check if the tile is clickable
+ */
+ function isTileClickable(objTile){
+
+ return objTile.hasClass("ug-tile-clickable");
+ }
+
+
+ /**
+ * return if the items icon always on
+ */
+ function isItemIconAlwaysOn(objItem){
+
+ if(g_options.tile_enable_icons == true && g_temp.isVideoplayIconAlwaysOn == true && objItem.type != "image")
+ return(true);
+
+ return(false);
+ }
+
+
+ function _________________SETTERS________________(){};
+
+
+ /**
+ * position tile images elements
+ * width, height - tile width height
+ */
+ function positionElements_images(objTile, width, height, visibleOnly){
+
+ var objImageOverlay = getTileOverlayImage(objTile);
+ var objThumbImage = t.getTileImage(objTile);
+ var objImageEffect = getTileImageEffect(objTile);
+
+ //reduce borders
+ width -= g_temp.tileInnerReduce;
+ height -= g_temp.tileInnerReduce;
+
+ var imagePosy = null;
+
+ //reduce textpanel height
+ if(g_temp.isTextpanelOutside == true){
+
+ var textHeight = getTextPanelHeight(objTile);
+ height -= textHeight;
+
+ if(g_options.tile_textpanel_position == "top"){
+ imagePosy = textHeight;
+ }
+
+ /**
+ * if has image container
+ */
+ if(g_temp.hasImageContainer == true){
+ var objImageContainer = getTileImageContainer(objTile);
+ g_functions.setElementSize(objImageContainer, width, height);
+
+ if(imagePosy !== null)
+ g_functions.placeElement(objImageContainer, 0, imagePosy);
+ }
+
+ }
+
+ //scale image
+ if(g_options.tile_enable_image_effect == false){
+
+ g_functions.scaleImageCoverParent(objThumbImage, width, height);
+
+ if(g_temp.hasImageContainer == false && imagePosy !== null)
+ g_functions.placeElement(objThumbImage, 0, imagePosy);
+
+ }else{ //width the effect
+
+ //set what to resize
+ var dontResize = "nothing";
+ if(visibleOnly === true && g_temp.isTextpanelOutside == false){
+ if(g_options.tile_image_effect_reverse == true){
+ dontResize = "effect";
+ }else{
+ dontResize = "image";
+ }
+ }
+
+ //resize image effect
+ if(dontResize != "effect"){
+ g_functions.setElementSize(objImageOverlay, width, height);
+
+ if(imagePosy !== null)
+ g_functions.placeElement(objImageOverlay, 0, imagePosy);
+
+ g_functions.scaleImageCoverParent(objImageEffect, width, height);
+ }
+
+
+ //resize image
+ if(dontResize != "image"){
+
+ if(g_temp.hasImageContainer == true){
+ g_functions.scaleImageCoverParent(objThumbImage, width, height);
+ }else{
+
+ //if can't clone, resize
+ if(dontResize == "effect"){
+ g_functions.scaleImageCoverParent(objThumbImage, width, height);
+ if(imagePosy !== null)
+ g_functions.placeElement(objThumbImage, 0, imagePosy);
+ }
+ else
+ g_functions.cloneElementSizeAndPos(objImageEffect, objThumbImage, false, null, imagePosy);
+
+ }
+
+ }
+
+
+
+ }
+
+ }
+
+
+ /**
+ * position text panel
+ * panelType - default or clone
+ */
+ function positionElements_textpanel(objTile, panelType, tileWidth, tileHeight){
+
+ var panelWidth = null;
+ if(tileWidth)
+ panelWidth = tileWidth - g_temp.tileInnerReduce;
+
+ if(tileHeight)
+ tileHeight -= g_temp.tileInnerReduce;
+
+ if(panelType == "clone"){
+ var objTextPanelClone = getTextPanelClone(objTile);
+ objTextPanelClone.refresh(true, true, panelWidth);
+ var objItem = t.getItemByTile(objTile);
+ objItem.textPanelCloneSizeSet = true;
+
+ return(false);
+ }
+
+ var objTextPanel = getTextPanel(objTile);
+
+ if(!objTextPanel)
+ return(false);
+
+ var panelHeight = null;
+
+ //set panel height also
+ if(g_temp.isTextpanelOutside == true)
+ panelHeight = getTextPanelHeight(objTile);
+
+ objTextPanel.refresh(false, true, panelWidth, panelHeight);
+
+ var isPosition = (g_options.tile_textpanel_always_on == true || g_options.tile_textpanel_appear_type == "fade");
+
+ if(isPosition){
+
+ if(g_temp.isTextpanelOutside == true && tileHeight && g_options.tile_textpanel_position == "bottom"){
+
+ var posy = tileHeight - panelHeight;
+ objTextPanel.positionPanel(posy);
+ }else
+ objTextPanel.positionPanel();
+ }
+
+ }
+
+
+ /**
+ * position the elements
+ */
+ function positionElements(objTile){
+
+ var objItem = t.getItemByTile(objTile);
+ var objButtonZoom = getButtonZoom(objTile);
+ var objButtonLink = getButtonLink(objTile);
+ var sizeTile = g_functions.getElementSize(objTile);
+
+ positionElements_images(objTile, sizeTile.width, sizeTile.height);
+
+ //position text panel:
+ if(g_options.tile_enable_textpanel == true)
+ positionElements_textpanel(objTile, "regular", sizeTile.width, sizeTile.height);
+
+
+ //position overlay:
+ var overlayWidth = sizeTile.width - g_temp.tileInnerReduce;
+ var overlayHeight = sizeTile.height - g_temp.tileInnerReduce;
+ var overlayY = 0;
+ if(g_temp.isTextpanelOutside == true){
+ var textHeight = getTextPanelHeight(objTile);
+ overlayHeight -= textHeight;
+ if(g_options.tile_textpanel_position == "top")
+ overlayY = textHeight;
+ }
+
+ var objOverlay = getTileOverlay(objTile);
+ g_functions.setElementSizeAndPosition(objOverlay, 0, overlayY, overlayWidth, overlayHeight);
+
+ //set vertical gap for icons
+ if(objButtonZoom || objButtonLink){
+
+ var gapVert = 0;
+ if( g_options.tile_enable_textpanel == true && g_temp.isTextPanelHidden == false && g_temp.isTextpanelOutside == false){
+ var objTextPanelElement = getTextPanelElement(objTile);
+ var texPanelSize = g_functions.getElementSize(objTextPanelElement);
+ if(texPanelSize.height > 0)
+ gapVert = Math.floor((texPanelSize.height / 2) * -1);
+ }
+
+ }
+
+ if(objButtonZoom && objButtonLink){
+ var sizeZoom = g_functions.getElementSize(objButtonZoom);
+ var sizeLink = g_functions.getElementSize(objButtonLink);
+ var spaceBetween = g_options.tile_space_between_icons;
+
+ var buttonsWidth = sizeZoom.width + spaceBetween + sizeLink.width;
+ var buttonsX = Math.floor((sizeTile.width - buttonsWidth) / 2);
+
+ //trace("X: "+buttonsX+" "+"space: " + spaceBetween);
+
+ //if space more then padding, calc even space.
+ if(buttonsX < spaceBetween){
+ spaceBetween = Math.floor((sizeTile.width - sizeZoom.width - sizeLink.width) / 3);
+ buttonsWidth = sizeZoom.width + spaceBetween + sizeLink.width;
+ buttonsX = Math.floor((sizeTile.width - buttonsWidth) / 2);
+ }
+
+ g_functions.placeElement(objButtonZoom, buttonsX, "middle", 0 ,gapVert);
+ g_functions.placeElement(objButtonLink, buttonsX + sizeZoom.width + spaceBetween, "middle", 0, gapVert);
+
+ }else{
+
+ if(objButtonZoom)
+ g_functions.placeElement(objButtonZoom, "center", "middle", 0, gapVert);
+
+ if(objButtonLink)
+ g_functions.placeElement(objButtonLink, "center", "middle", 0, gapVert);
+
+ }
+
+ if(objButtonZoom)
+ objButtonZoom.show();
+
+ if(objButtonLink)
+ objButtonLink.show();
+ }
+
+
+ /**
+ * set tiles htmls
+ */
+ this.setHtml = function(objParent, isAppend){
+ g_objParentWrapper = objParent;
+
+ if(isAppend !== true)
+ modifyOptionsBeforeRender();
+
+ g_thumbs.setHtmlThumbs(objParent, isAppend);
+ }
+
+
+
+ /**
+ * set the overlay effect
+ */
+ function setImageOverlayEffect(objTile, isActive){
+
+ var objItem = t.getItemByTile(objTile);
+ var objOverlayImage = getTileOverlayImage(objTile);
+
+ var animationDuration = g_options.thumb_transition_duration;
+
+ if(g_options.tile_image_effect_reverse == false){
+
+ var objThumbImage = t.getTileImage(objTile);
+
+ if(isActive){
+ objThumbImage.fadeTo(0,1);
+ objOverlayImage.stop(true).fadeTo(animationDuration, 0);
+ }
+ else
+ objOverlayImage.stop(true).fadeTo(animationDuration, 1);
+
+ }else{
+
+ if(isActive){
+ objOverlayImage.stop(true).fadeTo(animationDuration, 1);
+ }
+ else{
+ objOverlayImage.stop(true).fadeTo(animationDuration, 0);
+ }
+ }
+
+ }
+
+
+ /**
+ * set textpanel effect
+ */
+ function setTextpanelEffect(objTile, isActive){
+
+ var animationDuration = g_options.thumb_transition_duration;
+
+ var objTextPanel = getTextPanelElement(objTile);
+ if(!objTextPanel)
+ return(true);
+
+ if(g_options.tile_textpanel_appear_type == "slide"){
+
+ var panelSize = g_functions.getElementSize(objTextPanel);
+ if(panelSize.width == 0)
+ return(false);
+
+ var startPos = -panelSize.height;
+ var endPos = 0;
+ var startClass = {}, endClass = {};
+
+ var posName = "bottom";
+ if(g_options.tile_textpanel_position == "inside_top")
+ posName = "top";
+
+ startClass[posName] = startPos+"px";
+ endClass[posName] = endPos+"px";
+
+ if(isActive == true){
+
+ objTextPanel.fadeTo(0,1);
+
+ if(objTextPanel.is(":animated") == false)
+ objTextPanel.css(startClass);
+
+ endClass["opacity"] = 1;
+
+ objTextPanel.stop(true).animate(endClass, animationDuration);
+
+ }else{
+
+ objTextPanel.stop(true).animate(startClass, animationDuration);
+
+ }
+
+ }else{ //fade effect
+
+ if(isActive == true){
+ objTextPanel.stop(true).fadeTo(animationDuration, 1);
+ }else{
+ objTextPanel.stop(true).fadeTo(animationDuration, 0);
+ }
+
+ }
+
+ }
+
+
+ /**
+ * set thumb border effect
+ */
+ function setIconsEffect(objTile, isActive, noAnimation){
+
+ var animationDuration = g_options.thumb_transition_duration;
+ if(noAnimation && noAnimation === true)
+ animationDuration = 0;
+
+ var g_objIconZoom = getButtonZoom(objTile);
+ var g_objIconLink = getButtonLink(objTile);
+ var opacity = isActive?1:0;
+
+ if(g_objIconZoom)
+ g_objIconZoom.stop(true).fadeTo(animationDuration, opacity);
+
+ if(g_objIconLink)
+ g_objIconLink.stop(true).fadeTo(animationDuration, opacity);
+
+ }
+
+
+
+ /**
+ * set tile over style
+ */
+ function setOverStyle(data, objTile){
+
+ objTile = jQuery(objTile);
+
+ if(g_options.tile_enable_image_effect)
+ setImageOverlayEffect(objTile, true);
+
+ if(g_options.tile_enable_textpanel == true && g_options.tile_textpanel_always_on == false && g_temp.isTextPanelHidden == false)
+ setTextpanelEffect(objTile, true);
+
+ //show/hide icons - if saparate (if not, they are part of the overlay)
+ //if the type is video and icon always on - the icon should stay
+ if(g_temp.isSaparateIcons && g_options.tile_enable_icons == true){
+ var isSet = (g_options.thumb_overlay_reverse == true);
+
+ var objItem = t.getItemByTile(objTile);
+ if(isItemIconAlwaysOn(objItem) == false)
+ setIconsEffect(objTile, isSet, false);
+
+ }
+
+ }
+
+
+ /**
+ * set normal style
+ */
+ function setNormalStyle(data, objTile){
+
+ objTile = jQuery(objTile);
+
+ if(g_options.tile_enable_image_effect)
+ setImageOverlayEffect(objTile, false);
+
+ if(g_options.tile_enable_textpanel == true && g_options.tile_textpanel_always_on == false)
+ setTextpanelEffect(objTile, false);
+
+ //show/hide icons - if saparate (if not, they are part of the overlay)
+ if(g_temp.isSaparateIcons == true && g_options.tile_enable_icons == true){
+
+ var isSet = (g_options.thumb_overlay_reverse == true)?false:true;
+
+ var objItem = t.getItemByTile(objTile);
+ if(isItemIconAlwaysOn(objItem) == false)
+ setIconsEffect(objTile, isSet, false);
+ else{ //make icon always appear
+ setIconsEffect(objTile, true, true);
+ }
+
+ }
+
+ }
+
+
+ /**
+ * set all tiles normal style
+ */
+ function setAllTilesNormalStyle(objTileExcept){
+
+ var objTiles = g_thumbs.getThumbs().not(objTileExcept);
+ objTiles.each(function(index, objTile){
+ g_thumbs.setThumbNormalStyle(jQuery(objTile));
+ });
+
+ }
+
+
+ function _________________EVENTS________________(){};
+
+
+ /**
+ * on tile size change, place elements
+ */
+ function onSizeChange(data, objTile, forcePosition){
+
+ objTile = jQuery(objTile);
+
+ //position elements only if the image loaded (placed)
+ if(g_options.tile_visible_before_image == true && objTile.data("image_placed") !== true && forcePosition !== true)
+ return(true);
+
+ positionElements(objTile);
+
+ g_thumbs.setThumbNormalStyle(objTile);
+ }
+
+
+ /**
+ * on place image event after images loaded
+ */
+ function onPlaceImage(data, objTile, objImage){
+
+ positionElements(objTile);
+ objImage.fadeTo(0,1);
+
+ objTile.data("image_placed", true);
+ }
+
+
+ /**
+ * on tile click on mobile devices on normal state
+ * set the tile over state
+ */
+ function onMobileClick(objTile){
+
+ if(isTileClickable(objTile) == true){
+ g_objThis.trigger(t.events.TILE_CLICK, objTile);
+ return(true);
+ }
+
+ if(isOverStyle(objTile) == false){
+ setAllTilesNormalStyle(objTile);
+ g_thumbs.setThumbOverStyle(objTile);
+ }
+
+ }
+
+
+ /**
+ * on tile click event
+ */
+ function onTileClick(event){
+
+ var objTile = jQuery(this);
+
+ var tagname = objTile.prop("tagName").toLowerCase();
+ var isApproved = true;
+ if(g_temp.funcParentApproveClick && g_temp.funcParentApproveClick() == false)
+ isApproved = false;
+
+ if(tagname == "a"){
+
+ if(isApproved == false)
+ event.preventDefault();
+
+ }else{ //in case of div
+
+ if(isOverStyle(objTile) == false){ //mobile click version
+
+ if(isApproved == true)
+ onMobileClick(objTile);
+
+ }else{
+ if(isTileClickable(objTile) == false)
+ return(true);
+
+ if(isApproved == true)
+ g_objThis.trigger(t.events.TILE_CLICK, objTile);
+ }
+
+
+ }
+
+ }
+
+
+ /**
+ * click on zoom button (as tile click)
+ */
+ function onZoomButtonClick(event){
+
+ event.stopPropagation();
+
+ var objTile = jQuery(this).parents(".ug-tile");
+
+ var isApproved = true;
+
+ if(g_temp.funcParentApproveClick && g_temp.funcParentApproveClick() == false)
+ isApproved = false;
+
+ if(isOverStyle(objTile) == false){
+ onMobileClick(objTile);
+ return(true);
+ }
+
+ if(isApproved == true){
+ g_objThis.trigger(t.events.TILE_CLICK, objTile);
+ return(false);
+ }
+
+ }
+
+
+ /**
+ * on link icon click
+ */
+ function onLinkButtonClick(event){
+ var objTile = jQuery(this).parents(".ug-tile");
+
+ if(g_temp.funcParentApproveClick && g_temp.funcParentApproveClick() == false)
+ event.preventDefault();
+
+ //allow click only from over style
+ if(isOverStyle(objTile) == false && g_options.tile_as_link == false){
+ event.preventDefault();
+ onMobileClick(objTile);
+ }
+
+ }
+
+
+ /**
+ * init events
+ */
+ this.initEvents = function(){
+
+ g_thumbs.initEvents();
+
+ //connect the over and normal style of the regular thumbs
+ jQuery(g_thumbs).on(g_thumbs.events.SETOVERSTYLE, setOverStyle);
+ jQuery(g_thumbs).on(g_thumbs.events.SETNORMALSTYLE, setNormalStyle);
+ jQuery(g_thumbs).on(g_thumbs.events.PLACEIMAGE, onPlaceImage);
+
+ g_objWrapper.on(g_temp.eventSizeChange, onSizeChange);
+
+ g_objParentWrapper.on("click", ".ug-tile", onTileClick);
+
+ g_objParentWrapper.on("click", ".ug-tile .ug-button-play", onZoomButtonClick);
+
+ g_objParentWrapper.on("click", ".ug-tile .ug-icon-link", onLinkButtonClick);
+ }
+
+
+ /**
+ * destroy the element events
+ */
+ this.destroy = function(){
+
+ g_objParentWrapper.off("click", ".ug-tile");
+ g_objParentWrapper.off("click", ".ug-tile .ug-button-play");
+ g_objParentWrapper.off("click", ".ug-tile .ug-icon-link");
+
+ jQuery(g_thumbs).off(g_thumbs.events.SETOVERSTYLE);
+ jQuery(g_thumbs).off(g_thumbs.events.SETNORMALSTYLE);
+ jQuery(g_thumbs).off(g_thumbs.events.PLACEIMAGE);
+ g_objWrapper.off(g_temp.eventSizeChange);
+
+ if(g_options.tile_enable_textpanel == true){
+ var objThumbs = g_thumbs.getThumbs();
+ jQuery.each(objThumbs, function(index, thumb){
+ var textPanel = getTextPanel(jQuery(thumb));
+ if(textPanel)
+ textPanel.destroy();
+ });
+ }
+
+ g_thumbs.destroy();
+
+ }
+
+
+ /**
+ * external init
+ */
+ this.init = function(gallery, g_thumbs, customOptions){
+
+ init(gallery, g_thumbs, customOptions);
+ }
+
+ /**
+ * set fixed mode
+ */
+ this.setFixedMode = function(){
+
+ g_options.tile_size_by = t.sizeby.GLOBAL_RATIO;
+ g_options.tile_visible_before_image = true;
+ }
+
+
+ /**
+ * set parent approve click function
+ */
+ this.setApproveClickFunction = function(funcApprove){
+ g_temp.funcParentApproveClick = funcApprove;
+ }
+
+
+
+ /**
+ * resize tile. If no size given, resize to original size
+ * the resize mode taken from resize modes constants, default is full
+ */
+ this.resizeTile = function(objTile, newWidth, newHeight, resizeMode){
+
+ //if textpanel outside - refresh the textpanel first
+ if(g_temp.isTextpanelOutside == true)
+ positionElements_textpanel(objTile, "clone", newWidth);
+
+ if(!newWidth){
+
+ var newWidth = g_options.tile_width;
+ var newHeight = g_options.tile_height;
+
+ }else{ //only height is missing
+ if(!newHeight){
+
+ var newHeight = t.getTileHeightByWidth(newWidth, objTile);
+ }
+ }
+
+ g_functions.setElementSize(objTile, newWidth, newHeight);
+
+ switch(resizeMode){
+ default:
+ case t.resizemode.FULL:
+ t.triggerSizeChangeEvent(objTile, true);
+ break;
+ case t.resizemode.WRAPPER_ONLY:
+ return(true);
+ break;
+ case t.resizemode.VISIBLE_ELEMENTS:
+
+ if(g_temp.funcCustomTileHtml){
+ t.triggerSizeChangeEvent(objTile, true);
+ return(true);
+ }
+
+ //resize images
+ positionElements_images(objTile, newWidth, newHeight, true);
+
+ //resize text panel, if visible
+ if(g_options.tile_enable_textpanel == true && g_options.tile_textpanel_always_on == true && newWidth){
+ positionElements_textpanel(objTile, "regular", newWidth, newHeight);
+ }
+
+ break;
+ }
+
+ }
+
+
+ /**
+ * resize all tiles
+ */
+ this.resizeAllTiles = function(newWidth, resizeMode, objTiles){
+
+ modifyOptionsBeforeRender();
+
+ var newHeight = null;
+
+ if(g_options.tile_size_by == t.sizeby.GLOBAL_RATIO)
+ newHeight = t.getTileHeightByWidth(newWidth);
+
+ if(!objTiles)
+ var objTiles = g_thumbs.getThumbs();
+
+ objTiles.each(function(index, objTile){
+ t.resizeTile(jQuery(objTile), newWidth, newHeight, resizeMode);
+ });
+
+ }
+
+
+ /**
+ * trigger size change events
+ * the force is only for fixed size mode
+ */
+ this.triggerSizeChangeEvent = function(objTile, isForce){
+
+ if(!objTile)
+ return(false);
+
+ if(!isForce)
+ var isForce = false;
+
+ g_objWrapper.trigger(g_temp.eventSizeChange, [objTile, isForce]);
+
+ }
+
+
+ /**
+ * trigger size change event to all tiles
+ * the force is only for fixed mode
+ */
+ this.triggerSizeChangeEventAllTiles = function(isForce){
+
+ var objThumbs = g_thumbs.getThumbs();
+
+ objThumbs.each(function(){
+ var objTile = jQuery(this);
+
+ t.triggerSizeChangeEvent(objTile, isForce);
+
+ });
+
+ }
+
+
+
+
+
+ /**
+ * disable all events
+ */
+ this.disableEvents = function(){
+ var objThumbs = g_thumbs.getThumbs();
+ objThumbs.css("pointer-events", "none");
+ }
+
+
+ /**
+ * enable all events
+ */
+ this.enableEvents = function(){
+ var objThumbs = g_thumbs.getThumbs();
+ objThumbs.css("pointer-events", "auto");
+ }
+
+
+ /**
+ * set new options
+ */
+ this.setOptions = function(newOptions){
+ g_options = jQuery.extend(g_options, newOptions);
+ g_thumbs.setOptions(newOptions);
+ }
+
+
+ /**
+ * set new tile size, this function will not resize, and keep ratio
+ */
+ this.setTileSizeOptions = function(newTileWidth){
+
+ if(g_options.tile_size_by !== t.sizeby.GLOBAL_RATIO)
+ throw new Error("setNewTileOptions works with global ration only");
+
+ g_options.tile_width = newTileWidth;
+ g_options.tile_height = Math.floor(newTileWidth * g_temp.ratioByHeight);
+
+
+ }
+
+
+ /**
+ * set custom tile html function
+ */
+ this.setCustomFunctions = function(funcCustomHtml, funcPositionElements){
+ g_temp.funcCustomTileHtml = funcCustomHtml;
+ g_temp.funcCustomPositionElements = funcPositionElements;
+ }
+
+
+ /**
+ * run the tile design
+ */
+ this.run = function(newOnly){
+
+ //resize all tiles
+ var getMode = g_thumbs.type.GET_THUMBS_ALL;
+ if(newOnly === true)
+ getMode = g_thumbs.type.GET_THUMBS_NEW;
+
+ var objThumbs = g_thumbs.getThumbs(getMode);
+
+ if(g_options.tile_size_by == t.sizeby.GLOBAL_RATIO){
+ t.resizeAllTiles(g_options.tile_width, t.resizemode.WRAPPER_ONLY, objThumbs);
+ }
+
+ //hide original image if image effect active
+ if(g_options.tile_enable_image_effect == true && g_options.tile_image_effect_reverse == false)
+ objThumbs.children(".ug-thumb-image").fadeTo(0,0);
+
+ g_thumbs.setHtmlProperties(objThumbs);
+
+ if(g_options.tile_visible_before_image == true){
+
+ //if textpanel outside - refresh the textpanel first
+ objThumbs.children(".ug-thumb-image").fadeTo(0,0);
+ g_thumbs.loadThumbsImages();
+ }
+
+ }
+
+
+ this._____________EXTERNAL_GETTERS____________=function(){};
+
+
+ /**
+ * get thumbs general option
+ */
+ this.getObjThumbs = function(){
+ return g_thumbs;
+ }
+
+ /**
+ * get options
+ */
+ this.getOptions = function(){
+ return g_options;
+ }
+
+ /**
+ * get tile image
+ */
+ this.getTileImage = function(objTile){
+ var objImage = objTile.find("img.ug-thumb-image");
+ return(objImage);
+ }
+
+
+ /**
+ * get item from tile
+ */
+ this.getItemByTile = function(objTile){
+ return g_thumbs.getItemByThumb(objTile);
+ }
+
+
+ /**
+ * get tile height by width
+ */
+ this.getTileHeightByWidth = function(newWidth, objTile){
+
+ var ratio = getTileRatio(objTile);
+
+ if(ratio === null)
+ return(null);
+
+ var height = Math.floor( (newWidth - g_temp.tileInnerReduce) * ratio) + g_temp.tileInnerReduce;
+
+ if(objTile && g_temp.isTextpanelOutside == true && g_options.tile_size_by == t.sizeby.IMAGE_RATIO)
+ height += getTextPanelHeight(objTile);
+
+ return(height);
+ }
+
+
+ /**
+ * get tile original size
+ */
+ this.getTileImageSize = function(objTile){
+ var objItem = t.getItemByTile(objTile);
+ if(!objItem.thumbWidth || !objItem.thumbHeight)
+ throw new Error("Can't get image size - image not inited.");
+
+ var objSize = {
+ width: objItem.thumbWidth,
+ height: objItem.thumbHeight
+ };
+
+ return(objSize);
+ }
+
+
+ /**
+ * get tile size
+ */
+ this.getGlobalTileSize = function(){
+
+ if(g_options.tile_size_by != t.sizeby.GLOBAL_RATIO)
+ throw new Error("The size has to be global ratio");
+
+ var objSize = {
+ width: g_options.tile_width,
+ height: g_options.tile_height
+ };
+
+ return(objSize);
+ }
+
+
+}
+
+/**
+ * avia control class
+ * addon to strip gallery
+ */
+function UGAviaControl(){
+
+ var g_parent, g_gallery, g_objects, g_objStrip, g_objStripInner, g_options;
+ var g_isVertical;
+
+ var g_temp = {
+ touchEnabled:false, //variable that tells if touch event was before move event
+ isMouseInsideStrip: false,
+ strip_finalPos:0,
+ handle_timeout:"",
+ isStripMoving:false,
+ isControlEnabled: true
+ };
+
+
+ /**
+ * enable the control
+ */
+ this.enable = function(){
+ g_temp.isControlEnabled = true;
+ }
+
+ /**
+ * disable the control
+ */
+ this.disable = function(){
+ g_temp.isControlEnabled = false;
+ }
+
+ /**
+ * init function for avia controls
+ */
+ this.init = function(objParent){
+ g_parent = objParent;
+
+ g_objects = objParent.getObjects();
+
+ g_gallery = g_objects.g_gallery;
+
+ g_objStrip = g_objects.g_objStrip;
+ g_objStripInner = g_objects.g_objStripInner;
+ g_options = g_objects.g_options;
+ g_isVertical = g_objects.isVertical;
+
+ initEvents();
+ }
+
+ /**
+ * get mouse position from event according the orientation
+ */
+ function getMousePos(event){
+
+ if(g_isVertical == false)
+ return(event.pageX);
+
+ return(event.pageY);
+ }
+
+ /**
+ * handle avia strip control event on body mouse move
+ */
+ function initEvents(event){
+
+ //make sure that the avia control will not work on touch devices
+ jQuery("body").on("touchstart", function(event){
+
+ if(g_temp.isControlEnabled == false)
+ return(true);
+
+ g_temp.touchEnabled = true;
+
+ });
+
+ //on body move
+ jQuery("body").mousemove(function(event){
+
+ if(g_temp.isControlEnabled == false)
+ return(true);
+
+ //protection for touch devices, disable the avia events
+ if(g_temp.touchEnabled == true){
+ jQuery("body").off("mousemove");
+ return(true);
+ }
+
+ g_temp.isMouseInsideStrip = g_objStrip.ismouseover();
+ var strip_touch_active = g_parent.isTouchMotionActive();
+
+ if(g_temp.isMouseInsideStrip == true && strip_touch_active == false){
+
+ var mousePos = getMousePos(event);
+
+ moveStripToMousePosition(mousePos);
+ }else{
+ stopStripMovingLoop();
+ }
+
+ });
+
+ }
+
+
+ /**
+ * destroy the avia control events
+ */
+ this.destroy = function(){
+
+ jQuery("body").off("touchstart");
+ jQuery("body").off("mousemove");
+
+ }
+
+
+ /**
+ * get inner y position according mouse y position on the strip
+ */
+ function getInnerPosY(mouseY){
+
+ var innerOffsetTop = g_options.strip_padding_top;
+ var innerOffsetBottom = g_options.strip_padding_bottom;
+
+ var stripHeight = g_objStrip.height();
+ var innerHeight = g_objStripInner.height();
+
+ //if all thumbs visible, no need to move
+ if(stripHeight > innerHeight)
+ return(null);
+
+ //find y position inside the strip
+ var stripOffset = g_objStrip.offset();
+ var offsetY = stripOffset.top;
+ var posy = mouseY - offsetY - innerOffsetTop;
+ if(posy < 0)
+ return(null);
+
+ //set measure line parameters
+ var mlineStart = g_options.thumb_height;
+ var mlineEnd = stripHeight - g_options.thumb_height;
+ var mLineSize = mlineEnd - mlineStart;
+
+ //fix position borders on the measure line
+ if(posy < mlineStart)
+ posy = mlineStart;
+
+ if(posy > mlineEnd)
+ posy = mlineEnd;
+
+ //count the ratio of the position on the measure line
+ var ratio = (posy - mlineStart) / mLineSize;
+ var innerPosY = (innerHeight - stripHeight) * ratio;
+ innerPosY = Math.round(innerPosY) * -1 + innerOffsetTop;
+
+ return(innerPosY);
+ }
+
+
+ /**
+ * get inner x position according mouse x position on the strip
+ */
+ function getInnerPosX(mouseX){
+
+ var innerOffsetLeft = g_options.strip_padding_left;
+ var innerOffsetRight = g_options.strip_padding_right;
+
+ var stripWidth = g_objStrip.width() - innerOffsetLeft - innerOffsetRight;
+ var innerWidth = g_objStripInner.width();
+
+ //if all thumbs visible, no need to move
+ if(stripWidth > innerWidth)
+ return(null);
+
+ var stripOffset = g_objStrip.offset();
+ var offsetX = stripOffset.left;
+ var posx = mouseX - offsetX - innerOffsetLeft;
+
+ //set measure line parameters
+ var mlineStart = g_options.thumb_width;
+ var mlineEnd = stripWidth - g_options.thumb_width;
+ var mLineSize = mlineEnd - mlineStart;
+
+ //fix position borders on the measure line
+ if(posx < mlineStart)
+ posx = mlineStart;
+
+ if(posx > mlineEnd)
+ posx = mlineEnd;
+
+ //count the ratio of the position on the measure line
+ var ratio = (posx - mlineStart) / mLineSize;
+ var innerPosX = (innerWidth - stripWidth) * ratio;
+ innerPosX = Math.round(innerPosX) * -1 + innerOffsetLeft;
+
+
+ return(innerPosX);
+ }
+
+
+ /**
+ * move strip stap to final position
+ */
+ function moveStripStep(){
+
+ if(g_temp.is_strip_moving == false){
+ return(false);
+ }
+
+ var innerPos = g_parent.getInnerStripPos();
+
+ if(Math.floor(innerPos) == Math.floor(g_temp.strip_finalPos)){
+ stopStripMovingLoop();
+ }
+
+ //calc step
+ var diff = Math.abs(g_temp.strip_finalPos - innerPos);
+
+ var dpos;
+ if(diff < 1){
+ dpos = diff;
+ }
+ else{
+
+ dpos = diff / 4;
+ if(dpos > 0 && dpos < 1)
+ dpos = 1;
+ }
+
+ if(g_temp.strip_finalPos < innerPos)
+ dpos = dpos * -1;
+
+ var newPos = innerPos + dpos;
+
+ g_parent.positionInnerStrip(newPos);
+
+ }
+
+
+ /**
+ * start loop of strip moving
+ */
+ function startStripMovingLoop(){
+
+ if(g_temp.isStripMoving == true)
+ return(false);
+
+ g_temp.isStripMoving = true;
+ g_temp.handle_timeout = setInterval(moveStripStep,10);
+ }
+
+ /**
+ * stop loop of strip moving
+ */
+ function stopStripMovingLoop(){
+
+ if(g_temp.isStripMoving == false)
+ return(false);
+
+ g_temp.isStripMoving = false;
+ g_temp.handle_timeout = clearInterval(g_temp.handle_timeout);
+ }
+
+ /**
+ * get inner position according the orientation
+ * taken by the mouse position
+ */
+ function getInnerPos(mousePos){
+
+ if(g_isVertical == false)
+ return getInnerPosX(mousePos);
+ else
+ return getInnerPosY(mousePos);
+
+ }
+
+
+ /**
+ * move the strip to mouse position on it
+ * mousex - mouse position relative to the document
+ */
+ function moveStripToMousePosition(mousePos){
+
+ var innerPos = getInnerPos(mousePos);
+
+ if(innerPos === null)
+ return(false);
+
+ g_temp.is_strip_moving = true;
+ g_temp.strip_finalPos = innerPos;
+
+ startStripMovingLoop();
+ }
+
+}
+
+/**
+ * slider class
+ * addon to strip gallery
+ */
+function UGSlider(){
+
+ var t = this, g_objThis = jQuery(t);
+ var g_gallery = new UniteGalleryMain(), g_objGallery, g_objWrapper, g_objThumbs;
+ //the video arrows is independent arrows that is not sitting on the controls
+ var g_objSlider, g_objInner, g_objSlide1, g_objSlide2, g_objSlide3, g_objArrowLeft, g_objArrowRight;
+ var g_objTouchSlider, g_objZoomSlider, g_objZoomPanel, g_objButtonPlay = null, g_objButtonFullscreen = null, g_objBullets = null;
+ var g_objVideoPlayer = new UGVideoPlayer(), g_optionsPrefix;
+ var g_functions = new UGFunctions(), g_objProgress = null, g_objTextPanel = null;
+
+
+ this.events = {
+ ITEM_CHANGED: "item_changed", //on item changed
+ BEFORE_SWITCH_SLIDES: "before_switch", //before slides switching
+ BEFORE_RETURN: "before_return", //before return from pan or from zoom
+ AFTER_RETURN: "after_return", //after return from pan or from zoom
+ ZOOM_START: "slider_zoom_start", //on zoom start
+ ZOOM_END: "slider_zoom_end", //on zoom move
+ ZOOMING: "slider_zooming", //on zooming
+ ZOOM_CHANGE: "slider_zoom_change", //on slide image image zoom change
+ START_DRAG: "start_drag", //on slider drag start
+ AFTER_DRAG_CHANGE: "after_drag_change", //after finish drag chagne transition
+ ACTION_START: "action_start", //on slide action start
+ ACTION_END: "action_end", //on slide action stop
+ CLICK: "slider_click", //on click event
+ TRANSITION_START:"slider_transition_start", //before transition start event
+ TRANSITION_END:"slider_transition_end", //on transition end event
+ AFTER_PUT_IMAGE: "after_put_image", //after put slide image
+ IMAGE_MOUSEENTER: "slider_image_mouseenter", //on slide image mouseonter
+ IMAGE_MOUSELEAVE: "slider_image_mouseleave", //on slide image mouseleave
+ CURRENTSLIDE_LOAD_START: "slider_current_loadstart", //on current slide load image start
+ CURRENTSLIDE_LOAD_END: "slider_current_loadend" //on finish load current slide image
+ }
+
+ var g_options = {
+ slider_scale_mode: "fill", //fit: scale down and up the image to always fit the slider
+ //down: scale down only, smaller images will be shown, don't enlarge images (scale up)
+ //fill: fill the entire slider space by scaling, cropping and centering the image
+ //fitvert: make the image always fill the vertical slider area
+ slider_scale_mode_media: "fill", //fill, fit, down, fitvert - scale mode on media items
+ slider_scale_mode_fullscreen: "down", //fill, fit, down, fitvert - scale mode on fullscreen.
+
+ slider_item_padding_top: 0, //padding top of the slider item
+ slider_item_padding_bottom: 0, //padding bottom of the slider item
+ slider_item_padding_left: 0, //padding left of the slider item
+ slider_item_padding_right: 0, //padding right of the slider item
+
+ slider_background_color: "", //slider background color, set if you want to change default
+ slider_background_opacity: 1, //slider background opacity
+
+ slider_image_padding_top: 0, //padding top of the image inside the item
+ slider_image_padding_bottom: 0, //padding bottom of the image inside the item
+ slider_image_padding_left: 0, //padding left of the image inside the item
+ slider_image_padding_right: 0, //padding right of the image inside the item
+
+ slider_image_border: false, //enable border around the image
+ slider_image_border_width: 10, //image border width
+ slider_image_border_color: "#ffffff", //image border color
+ slider_image_border_radius: 0, //image border radius
+ slider_image_border_maxratio: 0.35, //max ratio that the border can take from the image
+ slider_image_shadow: false, //enable border shadow the image
+
+ slider_video_constantsize: false, //constant video size mode for video items
+ slider_video_constantsize_scalemode: "fit", //fit,down: constant video size scale mode
+ slider_video_constantsize_width: 854, //constant video size width
+ slider_video_constantsize_height: 480, //constant video size height
+
+ slider_video_padding_top: 0, //padding top of the video player inside the item
+ slider_video_padding_bottom: 0, //padding bottom of the video player inside the item
+ slider_video_padding_left: 0, //padding left of the video player inside the item
+ slider_video_padding_right: 0, //padding right of the video player inside the item
+
+ slider_video_enable_closebutton: true, //enable video close button
+
+ slider_transition: "slide", //fade, slide - the transition of the slide change
+ slider_transition_speed:300, //transition duration of slide change
+ slider_transition_easing: "easeInOutQuad", //transition easing function of slide change
+
+ slider_control_swipe:true, //true,false - enable swiping control
+ slider_control_zoom:true, //true, false - enable zooming control
+ slider_zoom_mousewheel: true, //enable zoom on mousewheel
+ slider_vertical_scroll_ondrag: false, //vertical scroll on slider area drag
+ slider_loader_type: 1, //shape of the loader (1-7)
+ slider_loader_color:"white", //color of the loader: (black , white)
+ slider_enable_links: true, //enable slide as link functionality
+ slider_links_newpage: false, //open the slide link in new page
+
+ slider_enable_bullets: false, //enable the bullets onslider element
+ slider_bullets_skin: "", //skin of the bullets, if empty inherit from gallery skin
+ slider_bullets_space_between: -1, //set the space between bullets. If -1 then will be set default space from the skins
+ slider_bullets_align_hor:"center", //left, center, right - bullets horizontal align
+ slider_bullets_align_vert:"bottom", //top, middle, bottom - bullets vertical algin
+ slider_bullets_offset_hor:0, //bullets horizontal offset
+ slider_bullets_offset_vert:10, //bullets vertical offset
+
+ slider_enable_arrows: true, //enable arrows onslider element
+ slider_arrows_skin: "", //skin of the slider arrows, if empty inherit from gallery skin
+
+ slider_arrow_left_align_hor:"left", //left, center, right - left arrow horizonal align
+ slider_arrow_left_align_vert:"middle", //top, middle, bottom - left arrow vertical align
+ slider_arrow_left_offset_hor:20, //left arrow horizontal offset
+ slider_arrow_left_offset_vert:0, //left arrow vertical offset
+
+ slider_arrow_right_align_hor:"right", //left, center, right - right arrow horizontal algin
+ slider_arrow_right_align_vert:"middle", //top, middle, bottom - right arrow vertical align
+ slider_arrow_right_offset_hor:20, //right arrow horizontal offset
+ slider_arrow_right_offset_vert:0, //right arrow vertical offset
+
+ slider_enable_progress_indicator: true, //enable progress indicator element
+ slider_progress_indicator_type: "pie", //pie, pie2, bar (if pie not supported, it will switch to bar automatically)
+ slider_progress_indicator_align_hor:"right", //left, center, right - progress indicator horizontal align
+ slider_progress_indicator_align_vert:"top", //top, middle, bottom - progress indicator vertical align
+ slider_progress_indicator_offset_hor:10, //progress indicator horizontal offset
+ slider_progress_indicator_offset_vert:10, //progress indicator vertical offset
+
+ slider_enable_play_button: true, //true,false - enable play / pause button onslider element
+ slider_play_button_skin: "", //skin of the slider play button, if empty inherit from gallery skin
+ slider_play_button_align_hor:"left", //left, center, right - play button horizontal align
+ slider_play_button_align_vert:"top", //top, middle, bottom - play button vertical align
+ slider_play_button_offset_hor:40, //play button horizontal offset
+ slider_play_button_offset_vert:8, //play button vertical offset
+ slider_play_button_mobilehide:false, //hide the play button on mobile
+
+ slider_enable_fullscreen_button: true, //true,false - enable fullscreen button onslider element
+ slider_fullscreen_button_skin: "", //skin of the slider fullscreen button, if empty inherit from gallery skin
+ slider_fullscreen_button_align_hor:"left", //left, center, right - fullscreen button horizonatal align
+ slider_fullscreen_button_align_vert:"top", //top, middle, bottom - fullscreen button vertical align
+ slider_fullscreen_button_offset_hor:11, //fullscreen button horizontal offset
+ slider_fullscreen_button_offset_vert:9, //fullscreen button vertical offset
+ slider_fullscreen_button_mobilehide:false, //hide the button on mobile
+
+ slider_enable_zoom_panel: true, //true,false - enable the zoom buttons, works together with zoom control.
+ slider_zoompanel_skin: "", //skin of the slider zoom panel, if empty inherit from gallery skin
+ slider_zoompanel_align_hor:"left", //left, center, right - zoom panel horizontal align
+ slider_zoompanel_align_vert:"top", //top, middle, bottom - zoom panel vertical align
+ slider_zoompanel_offset_hor:12, //zoom panel horizontal offset
+ slider_zoompanel_offset_vert:92, //zoom panel vertical offset
+ slider_zoompanel_mobilehide:false, //hide the zoom panel on mobile
+
+ slider_controls_always_on: false, //true,false - controls are always on, false - show only on mouseover
+ slider_controls_appear_ontap: true, //true,false - appear controls on tap event on touch devices
+ slider_controls_appear_duration: 300, //the duration of appearing controls
+
+ slider_enable_text_panel: true, //true,false - enable the text panel
+ slider_textpanel_always_on: true, //true,false - text panel are always on, false - show only on mouseover
+
+ slider_videoplay_button_type: "square" //square, round - the videoplay button type, square or round
+ };
+
+
+ //default options for bar progress incicator
+ var g_defaultsProgressBar = {
+ slider_progress_indicator_align_hor:"left", //left, center, right
+ slider_progress_indicator_align_vert:"bottom", //top, middle, bottom
+ slider_progress_indicator_offset_hor:0, //horizontal offset
+ slider_progress_indicator_offset_vert:0 //vertical offset
+ };
+
+ var g_temp = {
+ isRunOnce: false,
+ isTextPanelSaparateHover: false, //if the panel need to be appeared without the controls object on mouseover
+ numPrev:1,
+ numCurrent:2,
+ numNext: 3,
+ isControlsVisible: true,
+ currentControlsMode: "image"
+ };
+
+ function __________GENERAL___________(){};
+
+
+ /**
+ * init the slider
+ */
+ function initSlider(objGallery, objOptions, optionsPrefix){
+ g_gallery = objGallery;
+
+ //change options by prefix
+ if(optionsPrefix){
+ g_optionsPrefix = optionsPrefix;
+ objOptions = g_functions.convertCustomPrefixOptions(objOptions, g_optionsPrefix, "slider");
+ }
+
+ g_objGallery = jQuery(objGallery);
+
+ var objects = g_gallery.getObjects();
+ g_objWrapper = objects.g_objWrapper;
+ g_objThumbs = objects.g_objThumbs;
+
+ //set progress indicator bar defaults if type bar
+ if(objOptions.hasOwnProperty("slider_progress_indicator_type"))
+ g_options.slider_progress_indicator_type = objOptions.slider_progress_indicator_type;
+
+ if(g_options.slider_progress_indicator_type == "bar"){
+ g_options = jQuery.extend(g_options, g_defaultsProgressBar);
+ }
+
+ if(objOptions)
+ t.setOptions(objOptions);
+
+ processOptions();
+
+ //init bullets:
+ if(g_options.slider_enable_bullets == true){
+ g_objBullets = new UGBullets();
+ var bulletsOptions = {
+ bullets_skin: g_options.slider_bullets_skin,
+ bullets_space_between: g_options.slider_bullets_space_between
+ }
+ g_objBullets.init(g_gallery, bulletsOptions);
+ }
+
+ //init text panel
+ if(g_options.slider_enable_text_panel){
+ g_objTextPanel = new UGTextPanel();
+ g_objTextPanel.init(g_gallery, g_options, "slider");
+ }
+
+ if(g_options.slider_enable_zoom_panel){
+ g_objZoomPanel = new UGZoomButtonsPanel();
+ g_objZoomPanel.init(t, g_options);
+ }
+
+ var galleryID = g_gallery.getGalleryID();
+
+ //init video player
+ g_objVideoPlayer.init(g_options, false, galleryID);
+ }
+
+
+ /**
+ * run the slider functionality
+ */
+ function runSlider(){
+
+ if(g_temp.isRunOnce == true)
+ return(false);
+
+ g_temp.isRunOnce = true;
+
+ //set background color
+ if(g_options.slider_background_color){
+ var bgColor = g_options.slider_background_color;
+
+ if(g_options.slider_background_opacity != 1)
+ bgColor = g_functions.convertHexToRGB(bgColor, g_options.slider_background_opacity);
+
+ g_objSlider.css("background-color", bgColor);
+
+ }else if(g_options.slider_background_opacity != 1){ //set opacity with default color
+
+ bgColor = g_functions.convertHexToRGB("#000000", g_options.slider_background_opacity);
+ g_objSlider.css("background-color", bgColor);
+
+ }
+
+ //init touch slider control
+ if(g_options.slider_control_swipe == true){
+ g_objTouchSlider = new UGTouchSliderControl();
+ g_objTouchSlider.init(t, g_options);
+ }
+
+ //init zoom slider control
+ if(g_options.slider_control_zoom == true){
+ g_objZoomSlider = new UGZoomSliderControl();
+ g_objZoomSlider.init(t, g_options);
+ }
+
+ //run the text panel
+ if(g_objTextPanel)
+ g_objTextPanel.run();
+
+ initEvents();
+ }
+
+
+ /**
+ * process the options
+ */
+ function processOptions(){
+ var galleryOptions = g_gallery.getOptions();
+
+ //set skins:
+ var globalSkin = galleryOptions.gallery_skin;
+
+ if(g_options.slider_bullets_skin == "")
+ g_options.slider_bullets_skin = globalSkin;
+
+ if(g_options.slider_arrows_skin == "")
+ g_options.slider_arrows_skin = globalSkin;
+
+ if(g_options.slider_zoompanel_skin == "")
+ g_options.slider_zoompanel_skin = globalSkin;
+
+ if(g_options.slider_play_button_skin == "")
+ g_options.slider_play_button_skin = globalSkin;
+
+ if(g_options.slider_fullscreen_button_skin == "")
+ g_options.slider_fullscreen_button_skin = globalSkin;
+
+ g_options.video_enable_closebutton = g_options.slider_video_enable_closebutton;
+
+ //set mousewheel option depends on the gallery option
+ if(galleryOptions.gallery_mousewheel_role != "zoom")
+ g_options.slider_zoom_mousewheel = false;
+
+ }
+
+
+ /**
+ *
+ * get html slide
+ */
+ function getHtmlSlide(loaderClass, numSlide){
+
+ var classVideoplay = "ug-type-square";
+ if(g_options.slider_videoplay_button_type == "round")
+ classVideoplay = "ug-type-round";
+
+ var html = "";
+ html += "
";
+ html += "";
+ html += "";
+ html += "";
+ html += "
";
+
+ return(html);
+ }
+
+
+ /**
+ * set the slider html
+ */
+ function setHtmlSlider(objParent){
+
+ if(objParent)
+ g_objWrapper = objParent;
+
+ //get if the slide has controls
+ var loaderClass = getLoaderClass();
+ var galleryOptions = g_gallery.getOptions();
+
+ var html = "
";
+
+ html += "
";
+ html += getHtmlSlide(loaderClass,1);
+ html += getHtmlSlide(loaderClass,2);
+ html += getHtmlSlide(loaderClass,3);
+
+ html += "
"; //end inner
+
+ //----------------
+
+ //add arrows
+ if(g_options.slider_enable_arrows == true){
+ html += "";
+ html += "";
+ }
+
+ //add play button
+ if(g_options.slider_enable_play_button == true){
+ html += "";
+ }
+
+ //add fullscreen button
+ if(g_options.slider_enable_fullscreen_button == true){
+ html += "";
+ }
+
+
+ html += "
"; //end slider
+
+
+ g_objWrapper.append(html);
+
+ //----------------
+
+ //set objects
+ g_objSlider = g_objWrapper.children(".ug-slider-wrapper");
+ g_objInner = g_objSlider.children(".ug-slider-inner");
+
+
+ g_objSlide1 = g_objInner.children(".ug-slide1");
+ g_objSlide2 = g_objInner.children(".ug-slide2");
+ g_objSlide3 = g_objInner.children(".ug-slide3");
+
+ //set slides data
+ g_objSlide1.data("slidenum",1);
+ g_objSlide2.data("slidenum",2);
+ g_objSlide3.data("slidenum",3);
+
+ //add bullets
+ if(g_objBullets)
+ g_objBullets.appendHTML(g_objSlider);
+
+ //----------------
+
+ //get arrows object
+ if(g_options.slider_enable_arrows == true){
+ g_objArrowLeft = g_objSlider.children(".ug-arrow-left");
+ g_objArrowRight = g_objSlider.children(".ug-arrow-right");
+ }
+
+ //get play button
+ if(g_options.slider_enable_play_button == true){
+ g_objButtonPlay = g_objSlider.children(".ug-button-play");
+ }
+
+ //get fullscreen button
+ if(g_options.slider_enable_fullscreen_button == true){
+ g_objButtonFullscreen = g_objSlider.children(".ug-button-fullscreen");
+ }
+
+
+ //----------------
+
+ //add progress indicator
+ if(g_options.slider_enable_progress_indicator == true){
+
+ g_objProgress = g_functions.initProgressIndicator(g_options.slider_progress_indicator_type, g_options, g_objSlider);
+
+ var finalType = g_objProgress.getType();
+
+ //change options in case of type change
+ if(finalType == "bar" && g_options.slider_progress_indicator_type == "pie"){
+ g_options.slider_progress_indicator_type = "bar";
+ g_options = jQuery.extend(g_options, g_defaultsProgressBar);
+ }
+
+ g_gallery.setProgressIndicator(g_objProgress);
+ }
+
+ //----------------
+
+ //add text panel (hidden)
+ if(g_options.slider_enable_text_panel == true){
+
+ g_objTextPanel.appendHTML(g_objSlider);
+
+ //hide panel saparatelly from the controls object
+ if(g_options.slider_textpanel_always_on == false){
+
+ //hide the panel
+ var panelElement = g_objTextPanel.getElement();
+ panelElement.hide().data("isHidden", true);
+
+ g_temp.isTextPanelSaparateHover = true;
+
+ }
+
+ }
+
+ //----------------
+
+ //add zoom buttons panel:
+ if(g_options.slider_enable_zoom_panel == true){
+ g_objZoomPanel.appendHTML(g_objSlider);
+ }
+
+
+ //add video player
+ g_objVideoPlayer.setHtml(g_objInner);
+ }
+
+
+ /**
+ * position elements that related to slide
+ */
+ function positionSlideElements(objSlide){
+
+ //position preloader
+ var objPreloader = getSlidePreloader(objSlide);
+ g_functions.placeElementInParentCenter(objPreloader);
+
+ //position video play button
+ var objVideoPlayButton = getSlideVideoPlayButton(objSlide);
+ g_functions.placeElementInParentCenter(objVideoPlayButton);
+ }
+
+
+ /**
+ * position elements
+ */
+ function positionElements(){
+
+ //place bullets
+ if(g_objBullets){
+ objBullets = g_objBullets.getElement();
+
+ //strange bug fix (bullets width: 20) by double placing
+ g_functions.placeElement(objBullets, g_options.slider_bullets_align_hor, g_options.slider_bullets_align_vert, g_options.slider_bullets_offset_hor, g_options.slider_bullets_offset_vert);
+ g_functions.placeElement(objBullets, g_options.slider_bullets_align_hor, g_options.slider_bullets_align_vert, g_options.slider_bullets_offset_hor, g_options.slider_bullets_offset_vert);
+
+ }
+
+ //place arrows
+ if(g_options.slider_enable_arrows == true){
+ g_functions.placeElement(g_objArrowLeft, g_options.slider_arrow_left_align_hor, g_options.slider_arrow_left_align_vert, g_options.slider_arrow_left_offset_hor, g_options.slider_arrow_left_offset_vert);
+ g_functions.placeElement(g_objArrowRight, g_options.slider_arrow_right_align_hor, g_options.slider_arrow_left_align_vert, g_options.slider_arrow_right_offset_hor, g_options.slider_arrow_right_offset_vert);
+ }
+
+ //hide controls
+ if(g_options.slider_controls_always_on == false)
+ hideControls(true);
+
+ //place progress indicator
+ if(g_objProgress){
+
+ var objProgressElement = g_objProgress.getElement();
+
+ if(g_options.slider_progress_indicator_type == "bar"){
+ var sliderWidth = g_objSlider.width();
+ g_objProgress.setSize(sliderWidth);
+ g_functions.placeElement(objProgressElement, "left", g_options.slider_progress_indicator_align_vert, 0, g_options.slider_progress_indicator_offset_vert);
+
+ }else{
+ g_functions.placeElement(objProgressElement, g_options.slider_progress_indicator_align_hor, g_options.slider_progress_indicator_align_vert, g_options.slider_progress_indicator_offset_hor, g_options.slider_progress_indicator_offset_vert);
+
+ }
+ }
+
+ //position text panel
+ if(g_objTextPanel)
+ g_objTextPanel.positionPanel();
+
+ //position controls elements
+ placeControlsElements();
+
+ //place slide elements
+ positionSlideElements(g_objSlide1);
+ positionSlideElements(g_objSlide2);
+ positionSlideElements(g_objSlide3);
+
+ checkMobileModify();
+
+ }
+
+
+ /**
+ * place elements that located on "controls" div
+ */
+ function placeControlsElements(){
+
+ if(g_objButtonPlay)
+ g_functions.placeElement(g_objButtonPlay, g_options.slider_play_button_align_hor, g_options.slider_play_button_align_vert, g_options.slider_play_button_offset_hor, g_options.slider_play_button_offset_vert);
+
+ //position fullscreen button
+ if(g_objButtonFullscreen)
+ g_functions.placeElement(g_objButtonFullscreen, g_options.slider_fullscreen_button_align_hor, g_options.slider_fullscreen_button_align_vert, g_options.slider_fullscreen_button_offset_hor, g_options.slider_fullscreen_button_offset_vert);
+
+ //position zoom panel
+ if(g_objZoomPanel){
+ var zoomPanelElement = g_objZoomPanel.getElement();
+ g_functions.placeElement(zoomPanelElement, g_options.slider_zoompanel_align_hor, g_options.slider_zoompanel_align_vert, g_options.slider_zoompanel_offset_hor, g_options.slider_zoompanel_offset_vert);
+ }
+ }
+
+
+
+ /**
+ * position slides by their order
+ */
+ function positionSlides(){
+
+ var slides = t.getSlidesReference();
+ var posX = 0, posY = 0, innerWidth;
+ var posXPrev=0, posXCurrent = 0, posXNext, nextHasItem, prevHasItem;
+
+ nextHasItem = t.isSlideHasItem(slides.objNextSlide);
+ prevHasItem = t.isSlideHasItem(slides.objPrevSlide);
+
+ if(prevHasItem){
+ posXCurrent = slides.objPrevSlide.outerWidth();
+ slides.objPrevSlide.css("z-index",1);
+ }else
+ slides.objPrevSlide.hide();
+
+ posXNext = posXCurrent + slides.objCurrentSlide.outerWidth();
+
+ innerWidth = posXNext;
+ if(nextHasItem){
+ innerWidth = posXNext + slides.objNextSlide.outerWidth();
+ slides.objPrevSlide.css("z-index",2);
+ }else
+ slides.objNextSlide.hide();
+
+ slides.objCurrentSlide.css("z-index",3);
+
+ //set inner size and position
+ g_functions.placeElement(slides.objCurrentSlide, posXCurrent, posY);
+ g_objInner.css({"left":-posXCurrent+"px", width:innerWidth+"px"});
+
+ //position prev
+ if(prevHasItem){
+ g_functions.placeElement(slides.objPrevSlide, posXPrev, posY);
+ g_functions.showElement(slides.objPrevSlide);
+ }
+
+ if(nextHasItem){
+ g_functions.showElement(slides.objNextSlide);
+ g_functions.placeElement(slides.objNextSlide, posXNext, posY);
+ }
+
+ }
+
+
+
+ /**
+ * resize the slide image inside item
+ */
+ function resizeSlideItem(objSlide){
+ var index = objSlide.data("index");
+ if(index === undefined || index == null)
+ return(false);
+
+ var objItem = g_gallery.getItem(index);
+
+ if(!objItem)
+ return(false);
+
+ setItemToSlide(objSlide, objItem);
+ }
+
+
+ /**
+ * show the preloader
+ * show the index, so only the current index load will hide.
+ */
+ function showPreloader(objPreloader){
+
+ objPreloader.stop(true).show(100);
+
+ }
+
+ /**
+ * hide the preloader
+ */
+ function hidePreloader(objPreloader){
+
+ objPreloader.stop(true).hide(100);
+ }
+
+ /**
+ * get proper image border width
+ */
+ function getImageBorderWidth(objImage, imageData){
+
+ var borderWidth = g_options.slider_image_border_width;
+
+ if(borderWidth <= 10)
+ return(borderWidth);
+
+ //set image size
+ var imageSize = g_functions.getElementSize(objImage);
+ var imageWidth = imageSize.width;
+ var imageHeight = imageSize.height;
+
+ if(imageData){
+ if(imageData.hasOwnProperty("imageWidth"))
+ imageWidth = imageData.imageWidth;
+
+ if(imageData.hasOwnProperty("imageHeight"))
+ imageHeight = imageData.imageHeight;
+
+ }
+
+ if(imageWidth <= 0)
+ return(borderWidth);
+
+ //take the less size
+ var totalSize = (imageWidth < imageHeight)?imageWidth:imageHeight;
+ var borderSize = borderWidth * 2;
+
+ var borderRatio = borderSize / totalSize;
+
+ if(borderRatio < g_options.slider_image_border_maxratio)
+ return(borderWidth);
+
+ //change border width
+ var borderWidth = (totalSize * g_options.slider_image_border_maxratio)/2;
+
+ borderWidth = Math.round(borderWidth);
+
+ return(borderWidth);
+
+ }
+
+
+ /**
+ * set slider image css design according the settings
+ */
+ function setImageDesign(objImage, slideType, imageData){
+
+ var css = {};
+ if(g_options.slider_image_border == true){
+ css["border-style"] = "solid";
+
+ var borderWidth = getImageBorderWidth(objImage, imageData);
+
+ css["border-width"] = borderWidth+"px";
+ css["border-color"] = g_options.slider_image_border_color;
+ css["border-radius"] = g_options.slider_image_border_radius;
+ }
+
+ if(slideType != "image" && g_options.slider_video_constantsize == true)
+ css["background-color"] = "#000000";
+
+ if(g_options.slider_image_shadow == true){
+ css["box-shadow"] = "3px 3px 10px 0px #353535";
+ }
+
+ objImage.css(css);
+ }
+
+
+ /**
+ * scale image constant size (for video items)
+ */
+ function scaleImageConstantSize(objImage, objItem){
+
+ var constantWidth = g_options.slider_video_constantsize_width;
+ var constantHeight = g_options.slider_video_constantsize_height;
+ var scaleMode = g_options.slider_video_constantsize_scalemode;
+
+ var objSize = g_functions.scaleImageExactSizeInParent(objImage, objItem.imageWidth, objItem.imageHeight, constantWidth, constantHeight, scaleMode);
+
+
+ return(objSize);
+ }
+
+
+ /**
+ *
+ * set item to slide
+ */
+ function setImageToSlide(objSlide, objItem, isForce){
+
+ var objItemWrapper = objSlide.children(".ug-item-wrapper");
+
+ var objPreloader = getSlidePreloader(objSlide);
+
+ if(typeof objItem.urlImage == "undefined" || objItem.urlImage == "")
+ throw new Error("The slide don't have big image defined ( data-image='imageurl' ). Please check gallery items.", "showbig");
+
+ var urlImage = objItem.urlImage;
+
+ var currentImage = objSlide.data("urlImage");
+
+ objSlide.data("urlImage",urlImage);
+
+ var scaleMode = t.getScaleMode(objSlide);
+
+ var slideType = t.getSlideType(objSlide);
+
+ objPadding = t.getObjImagePadding();
+
+
+ if(currentImage == urlImage && isForce !== true){
+
+ var objImage = objItemWrapper.children("img");
+
+ if(objItem.imageWidth == 0 || objItem.imageHeight == 0){
+ g_gallery.checkFillImageSize(objImage, objItem);
+ }
+
+ var objImageData = {};
+
+ if(slideType != "image" && g_options.slider_video_constantsize == true){
+ objImageData = scaleImageConstantSize(objImage, objItem);
+ }
+ else{
+ objImageData = g_functions.scaleImageFitParent(objImage, objItem.imageWidth, objItem.imageHeight, scaleMode, objPadding);
+ }
+
+ setImageDesign(objImage, slideType, objImageData);
+ g_objThis.trigger(t.events.AFTER_PUT_IMAGE, objSlide);
+
+ }
+ else{ //place the image inside parent first time
+
+ objImage = g_functions.placeImageInsideParent(urlImage, objItemWrapper, objItem.imageWidth, objItem.imageHeight, scaleMode, objPadding);
+
+ //set image loaded on load:
+ if(objItem.isBigImageLoaded == true){
+ objImage.fadeTo(0,1);
+ hidePreloader(objPreloader);
+
+ if(slideType != "image" && g_options.slider_video_constantsize == true)
+ var objImageData = scaleImageConstantSize(objImage, objItem);
+ else
+ var objImageData = g_functions.getImageInsideParentData(objItemWrapper, objItem.imageWidth, objItem.imageHeight, scaleMode, objPadding);
+
+ //set missing css width
+ objImage.css("width",objImageData.imageWidth+"px");
+
+ setImageDesign(objImage, slideType, objImageData);
+
+ g_objThis.trigger(t.events.AFTER_PUT_IMAGE, objSlide);
+ }
+ else{ //if the image not loaded, load the image and show it after.
+ objImage.fadeTo(0,0);
+ showPreloader(objPreloader);
+ objSlide.data("isLoading", true);
+
+ if(t.isSlideCurrent(objSlide))
+ g_objThis.trigger(t.events.CURRENTSLIDE_LOAD_START);
+
+ objImage.data("itemIndex", objItem.index);
+ objImage.on("load",function(){
+
+ //place the image normally with coordinates
+ var objImage = jQuery(this);
+ var itemIndex = objImage.data("itemIndex");
+
+ objImage.fadeTo(0,1);
+
+ //get and hide preloader
+ var objSlide = objImage.parent().parent();
+ var slideType = t.getSlideType(objSlide);
+ var objPreloader = getSlidePreloader(objSlide);
+ var objPadding = t.getObjImagePadding();
+ var scaleMode = t.getScaleMode(objSlide);
+
+ hidePreloader(objPreloader);
+ objSlide.data("isLoading", false);
+
+ if(t.isSlideCurrent(objSlide))
+ g_objThis.trigger(t.events.CURRENTSLIDE_LOAD_END);
+
+ g_gallery.onItemBigImageLoaded(null, objImage);
+
+ var objItem = g_gallery.getItem(itemIndex);
+
+ var objImageData = {};
+
+ if(slideType != "image" && g_options.slider_video_constantsize == true)
+ scaleImageConstantSize(objImage, objItem);
+ else{
+ objImageData = g_functions.scaleImageFitParent(objImage, objItem.imageWidth, objItem.imageHeight, scaleMode, objPadding);
+ }
+
+ objImage.fadeTo(0,1);
+
+ setImageDesign(objImage, slideType, objImageData);
+
+ g_objThis.trigger(t.events.AFTER_PUT_IMAGE, objSlide);
+ });
+ }
+
+ }
+
+
+ }
+
+
+
+ /**
+ * set slider image by url
+ * if item not set, get current slide item
+ */
+ function setItemToSlide(objSlide, objItem){
+
+ try{
+
+ var objItemWrapper = objSlide.children(".ug-item-wrapper");
+
+ //if the item is empty, remove the image from slide
+ if(objItem == null){
+ objItemWrapper.html("");
+ objSlide.removeData("index");
+ objSlide.removeData("type");
+ objSlide.removeData("urlImage");
+ return(false);
+ }
+
+ var currentIndex = objSlide.data("index");
+
+ objSlide.data("index",objItem.index);
+ objSlide.data("type", objItem.type);
+
+ //set link class
+ if(g_options.slider_enable_links == true && objItem.type == "image"){
+
+ if(objItem.link)
+ objSlide.addClass("ug-slide-clickable");
+ else
+ objSlide.removeClass("ug-slide-clickable");
+ }
+
+ setImageToSlide(objSlide, objItem);
+
+ //show type related elements
+ var objVideoPlayButton = getSlideVideoPlayButton(objSlide);
+ switch(objItem.type){
+ case "image":
+ objVideoPlayButton.hide();
+ break;
+ default: //video
+ objVideoPlayButton.show();
+ break;
+ }
+
+ }catch(error){
+
+ if(typeof error.fileName != "undefined" && error.fileName == "showbig")
+ g_gallery.showErrorMessageReplaceGallery(error.message);
+
+ objItemWrapper.html("");
+ throw new Error(error);
+ return(true);
+ }
+
+ }
+
+
+
+ /**
+ * hide the panel
+ */
+ function hideTextPanel(){
+
+ if(!g_objTextPanel)
+ return(false);
+
+ if(isTextPanelHidden() == true)
+ return(false);
+
+ var panelElement = g_objTextPanel.getElement();
+
+ var animationTime = 0;
+ if(g_temp.isTextPanelSaparateHover == true || g_options.slider_textpanel_always_on == true){
+ animationTime = g_options.slider_controls_appear_duration;
+ }
+
+ panelElement.stop().fadeTo(animationTime, 0);
+
+ panelElement.data("isHidden", true);
+ }
+
+
+ /**
+ * show the text panel
+ */
+ function showTextPanel(){
+
+ if(!g_objTextPanel)
+ return(false);
+
+ if(isTextPanelHidden() == false)
+ return(false);
+
+ var panelElement = g_objTextPanel.getElement();
+
+ var animationTime = 0;
+
+ if(g_temp.isTextPanelSaparateHover == true || g_options.slider_textpanel_always_on == true){
+
+ panelElement.show();
+ g_objTextPanel.positionElements();
+
+ animationTime = g_options.slider_controls_appear_duration;
+ }
+
+ panelElement.stop().show().fadeTo(animationTime,1);
+
+ panelElement.data("isHidden", false);
+
+ }
+
+
+ /**
+ * check if the text panel is hidden or not
+ */
+ function isTextPanelHidden(){
+
+ var panelElement = g_objTextPanel.getElement();
+
+ var isHidden = panelElement.data("isHidden");
+ if(isHidden === false)
+ return(false);
+
+ return(true);
+ }
+
+
+ /**
+ * validate that the slide is certain type, if not, throw error
+ */
+ function validateSlideType(type, objSlide){
+ if(objSlide == undefined)
+ var objSlide = t.getCurrentSlide();
+
+ var slideType = t.getSlideType(objSlide);
+
+ if(slideType != type){
+ throw new Error("Wrong slide type: "+ slideType +", should be: "+type);
+ return(false);
+ }
+
+ return(true);
+ }
+
+ function __________VIDEO_PLAYER_______(){};
+
+
+
+ /**
+ * set video player position
+ */
+ function setVideoPlayerPosition(){
+
+ var objCurrentSlide = t.getCurrentSlide();
+ var objImage = t.getSlideImage(objCurrentSlide);
+
+ var slideSize = g_functions.getElementSize(objCurrentSlide);
+ var left = slideSize.left;
+ var top = slideSize.top;
+
+ //set by image position
+ if(g_options.slider_video_constantsize == true){
+
+ var imageSize = g_functions.getElementSize(objImage);
+ left += imageSize.left;
+ top += imageSize.top;
+
+ }else{ //set video padding
+
+ left += g_options.slider_video_padding_left;
+ top += g_options.slider_video_padding_top;
+
+ }
+
+ g_objVideoPlayer.setPosition(left, top);
+ }
+
+
+ /**
+ * set video player constant size
+ */
+ function setVideoPlayerConstantSize(){
+
+ var videoWidth = g_options.slider_video_constantsize_width;
+ var videoHeight = g_options.slider_video_constantsize_height;
+
+ g_objVideoPlayer.setSize(videoWidth, videoHeight);
+
+ //set video design
+ var videoElement = g_objVideoPlayer.getObject();
+
+ setImageDesign(videoElement, "video");
+ }
+
+
+ function __________TRANSITION_______(){};
+
+
+
+ /**
+ * do the transition between the current and the next
+ */
+ function doTransition(direction, objItem, forceTransition){
+
+ g_objThis.trigger(t.events.TRANSITION_START);
+
+ var transition = g_options.slider_transition;
+ if(forceTransition)
+ transition = forceTransition;
+
+ //stop current slide action
+ t.stopSlideAction(null, true);
+
+ switch(transition){
+ default:
+ case "fade":
+ transitionFade(objItem);
+ break;
+ case "slide":
+ transitionSlide(direction, objItem);
+ break;
+ case "lightbox_open": //fade transition without animation
+ transitionFade(objItem, false, true);
+ break;
+ }
+
+ }
+
+
+ /**
+ * switch slide numbers after transition (by direction)
+ *
+ */
+ this.switchSlideNums = function(direction){
+
+ //trigger item changed effect
+ g_objThis.trigger(t.events.BEFORE_SWITCH_SLIDES);
+
+ switch(direction){
+ case "left":
+ var currentNum = g_temp.numCurrent;
+ g_temp.numCurrent = g_temp.numNext;
+ g_temp.numNext = g_temp.numPrev;
+ g_temp.numPrev = currentNum;
+ break;
+ case "right":
+ var currentNum = g_temp.numCurrent;
+ g_temp.numCurrent = g_temp.numPrev;
+ g_temp.numPrev = g_temp.numNext;
+ g_temp.numNext = currentNum;
+ break;
+ default:
+ throw new Error("wrong direction: "+ direction);
+ break;
+ }
+
+ //trace(g_temp.numCurrent);
+
+ //trigger item changed effect
+ g_objThis.trigger(t.events.ITEM_CHANGED);
+ }
+
+
+ /**
+ * do slide transition
+ */
+ function transitionSlide(direction, objItem){
+
+ var animating = t.isAnimating();
+
+ if(animating == true){
+ g_temp.itemWaiting = objItem;
+ return(true);
+ }
+
+ //always clear next item on transition start
+ // next item can be only in the middle of the transition.
+ if(g_temp.itemWaiting != null)
+ g_temp.itemWaiting = null;
+
+ var slides = t.getSlidesReference();
+
+
+ switch(direction){
+ case "right": //change to prev item
+ setItemToSlide(slides.objPrevSlide, objItem);
+ positionSlides();
+
+ var posPrev = g_functions.getElementSize(slides.objPrevSlide);
+ var destX = -posPrev.left;
+
+ t.switchSlideNums("right");
+
+ break;
+ case "left": //change to next item
+ setItemToSlide(slides.objNextSlide, objItem);
+ positionSlides();
+
+ var posNext = g_functions.getElementSize(slides.objNextSlide);
+ var destX = -posNext.left;
+
+ t.switchSlideNums("left");
+
+ break;
+ default:
+ throw new Error("wrong direction: "+direction);
+ break;
+ }
+
+ var transSpeed = g_options.slider_transition_speed;
+ var transEasing = g_options.slider_transition_easing;
+
+
+ var animateParams = {
+ duration: transSpeed,
+ easing: transEasing,
+ queue: false,
+ always:function(){
+
+ t.stopSlideAction();
+ g_objVideoPlayer.hide();
+
+ //transit next item if waiting
+ if(g_temp.itemWaiting != null){
+ var direction = getSlideDirection(g_temp.itemWaiting);
+ transitionSlide(direction, g_temp.itemWaiting);
+ }else{
+ //if no item waiting, please neighbour items in places
+ t.placeNabourItems();
+ g_objThis.trigger(t.events.TRANSITION_END);
+ }
+
+ }
+ };
+
+
+ g_objInner.animate({left:destX+"px"}, animateParams);
+
+ }
+
+
+ /**
+ *
+ * animate opacity in and out
+ */
+ function animateOpacity(objItem, opacity, completeFunction){
+
+ if(completeFunction)
+ objItem.fadeTo(g_options.slider_transition_speed, opacity, completeFunction);
+ else
+ objItem.fadeTo(g_options.slider_transition_speed, opacity);
+ }
+
+
+ /**
+ * do fade transition
+ */
+ function transitionFade(objItem, noAnimation, noHidePlayer){
+
+ if(!noAnimation)
+ var noAnimation = false;
+
+ var slides = t.getSlidesReference();
+
+ setItemToSlide(slides.objNextSlide, objItem);
+
+ var objCurrentPos = g_functions.getElementSize(slides.objCurrentSlide);
+
+ g_functions.placeElement(slides.objNextSlide,objCurrentPos.left,objCurrentPos.top);
+
+ //switch slide nums
+ var currentNum = g_temp.numCurrent;
+ g_temp.numCurrent = g_temp.numNext;
+ g_temp.numNext = currentNum;
+
+ g_objThis.trigger(t.events.ITEM_CHANGED);
+
+ slides.objNextSlide.stop(true);
+ slides.objCurrentSlide.stop(true);
+
+ if(noAnimation == true){
+
+ slides.objCurrentSlide.fadeTo(0, 0);
+ slides.objNextSlide.fadeTo(0, 1);
+ t.placeNabourItems();
+ g_objThis.trigger(t.events.TRANSITION_END);
+
+ if(noHidePlayer !== true)
+ g_objVideoPlayer.hide();
+
+ }else{
+ slides.objNextSlide.fadeTo(0,0);
+
+ animateOpacity(slides.objCurrentSlide,0,function(){
+ t.placeNabourItems();
+ g_objThis.trigger(t.events.TRANSITION_END);
+ if(noHidePlayer !== true)
+ g_objVideoPlayer.hide();
+ });
+
+ if(g_objVideoPlayer.isVisible() == true){
+ var videoElement = g_objVideoPlayer.getObject();
+ animateOpacity(videoElement, 0);
+ }
+
+ //animate to next show next
+ animateOpacity(slides.objNextSlide,1);
+ }
+
+ }
+
+
+
+
+ function __________CONTROLS_OBJECT_______(){};
+
+ /**
+ * modify the slider for mobile
+ */
+ function modifyForMobile(){
+
+ if(g_options.slider_fullscreen_button_mobilehide == true && g_objButtonFullscreen)
+ g_objButtonFullscreen.hide();
+
+ if(g_options.slider_play_button_mobilehide == true && g_objButtonPlay)
+ g_objButtonPlay.hide();
+
+ if(g_options.slider_zoompanel_mobilehide == true && g_objZoomPanel)
+ g_objZoomPanel.getElement().hide();
+
+ }
+
+
+ /**
+ * modify for no mobile
+ */
+ function modifyForDesctop(){
+
+ if(g_options.slider_fullscreen_button_mobilehide == true && g_objButtonFullscreen)
+ g_objButtonFullscreen.show();
+
+ if(g_options.slider_play_button_mobilehide == true && g_objButtonPlay)
+ g_objButtonPlay.show();
+
+ if(g_options.slider_zoompanel_mobilehide == true && g_objZoomPanel)
+ g_objZoomPanel.getElement().show();
+
+ }
+
+
+ /**
+ * check and modify for mobile or desctop
+ */
+ function checkMobileModify(){
+
+ var isMobile = g_gallery.isMobileMode();
+
+ if(isMobile)
+ modifyForMobile();
+ else
+ modifyForDesctop();
+
+ }
+
+
+ /**
+ * get a jquery set of the controls objects
+ */
+ function getControlsObjects(){
+
+ var objControl = g_objSlider.children(".ug-slider-control");
+
+ return(objControl);
+ }
+
+
+ /**
+ * hide the controls
+ */
+ function hideControls(noAnimation){
+
+ if(g_functions.isTimePassed("sliderControlsToggle") == false)
+ return(false);
+
+ if(g_temp.isControlsVisible == false)
+ return(false);
+
+ if(!noAnimation)
+ var noAnimation = false;
+
+ var objControls = getControlsObjects();
+
+ if(noAnimation === true)
+ objControls.stop().fadeTo(0,0).hide();
+ else{
+ objControls.stop().fadeTo(g_options.slider_controls_appear_duration, 0, function(){objControls.hide()});
+ }
+
+ g_temp.isControlsVisible = false;
+ }
+
+
+ /**
+ * show controls only if they meaned to be shown
+ * @param noAnimation
+ */
+ function checkAndShowControls(noAnimation){
+
+ if(g_options.slider_controls_always_on == true)
+ showControls(noAnimation);
+ }
+
+
+ /**
+ * hide the controls
+ */
+ function showControls(noAnimation){
+
+ //validate for short time pass
+ if(g_functions.isTimePassed("sliderControlsToggle") == false)
+ return(false);
+
+ if(g_temp.isControlsVisible == true)
+ return(true);
+
+
+ if(!noAnimation)
+ var noAnimation = false;
+
+ var objControls = getControlsObjects();
+
+ if(noAnimation === true)
+ objControls.stop().show();
+ else{
+
+ objControls.stop().show().fadeTo(0,0);
+ objControls.fadeTo(g_options.slider_controls_appear_duration, 1);
+
+ }
+
+ g_temp.isControlsVisible = true;
+
+ }
+
+
+
+ /**
+ * toggle the controls (show, hide)
+ */
+ function toggleControls(){
+
+ if(g_temp.isControlsVisible == false)
+ showControls();
+ else
+ hideControls();
+ }
+
+
+ /**
+ * set controls mode
+ * modes: image, video
+ */
+ function setControlsMode(mode){
+
+ if(mode == g_temp.currentControlsMode)
+ return(false);
+
+ switch(mode){
+ case "image":
+ if(g_objZoomPanel)
+ g_objZoomPanel.getElement().show();
+ break;
+ case "video":
+ if(g_objZoomPanel)
+ g_objZoomPanel.getElement().hide();
+ break;
+ default:
+ throw new Error("wrong controld mode: " + mode);
+ break;
+ }
+
+ g_temp.currentControlsMode = mode;
+
+ }
+
+
+
+ function __________EVENTS___________(){};
+
+ /**
+ * on item change event
+ */
+ function onItemChange(data, arg_objItem, role){
+
+ //trace("slider on change");
+
+ var objItem = g_gallery.getSelectedItem();
+
+ t.setItem(objItem, false, role);
+
+ var itemIndex = objItem.index;
+
+ //set active bullet
+ if(g_objBullets)
+ g_objBullets.setActive(itemIndex);
+
+ //handle text panel
+ if(g_objTextPanel){
+ if(g_temp.isTextPanelSaparateHover == false)
+ showTextPanel();
+ }
+
+ if(objItem.type == "image"){
+ setControlsMode("image");
+ //placeControlsElements();
+ }
+ else{
+ setControlsMode("video");
+ }
+
+ }
+
+
+ /**
+ * on bullet click - change the item to selected
+ */
+ function onBulletClick(event, bulletIndex){
+ g_gallery.selectItem(bulletIndex);
+ }
+
+
+ /**
+ * on touch end
+ * toggle controls
+ */
+ function onClick(event){
+
+ //double tap action
+ if(g_objTouchSlider && g_objTouchSlider.isTapEventOccured(event) == false)
+ return(true);
+
+ g_objThis.trigger(t.events.CLICK, event);
+
+
+ }
+
+
+ /**
+ * on actual click event
+ */
+ function onActualClick(){
+
+ //check link
+ var currentSlide = t.getCurrentSlide();
+ var isClickable = currentSlide.hasClass("ug-slide-clickable");
+ var objItem = t.getCurrentItem();
+
+ if(isClickable){
+
+ //redirect to link
+ if(g_options.slider_links_newpage == false){
+ location.href = objItem.link;
+ }else{
+ window.open(objItem.link, '_blank');
+ }
+
+ return(true);
+ }
+
+ //check toggle controls
+ if(g_options.slider_controls_always_on == false &&
+ g_options.slider_controls_appear_ontap == true && t.isCurrentSlideType("image") == true){
+
+ toggleControls();
+
+ //show text panel if hidden
+ if(g_objTextPanel && g_options.slider_textpanel_always_on == true && t.isCurrentSlideType("image") && t.isCurrentSlideImageFit())
+ showTextPanel();
+ }
+
+
+ }
+
+
+ /**
+ * on zoom start event
+ */
+ function onZoomChange(event){
+
+ if(g_objTextPanel && t.isCurrentSlideType("image") && t.isCurrentSlideImageFit() == false)
+ hideTextPanel();
+ }
+
+
+ /**
+ * on mouse enter
+ */
+ function onMouseEnter(){
+
+ showControls();
+
+ }
+
+
+ /**
+ * on mouse leave
+ */
+ function onMouseLeave(){
+
+ hideControls();
+
+ }
+
+
+ /**
+ * on slide video play button click
+ */
+ function objVideoPlayClick(objButton){
+ var objSlide = objButton.parent();
+ t.startSlideAction(objSlide);
+ }
+
+ /**
+ * on video player show event
+ */
+ function onVideoPlayerShow(){
+
+ if(g_gallery.isPlayMode()){
+ g_gallery.pausePlaying();
+ }
+
+ g_objThis.trigger(t.events.ACTION_START);
+ }
+
+
+ /**
+ * on video player hide event
+ */
+ function onVideoPlayerHide(){
+
+ if(g_gallery.isPlayMode()){
+ g_gallery.continuePlaying();
+ }
+
+ g_objThis.trigger(t.events.ACTION_END);
+ }
+
+
+ /**
+ * on item image update, update the image inside the slider if relevant
+ */
+ function onItemImageUpdate(event, index, urlImage){
+
+ if(g_objSlide1.data("index") == index){
+ objItem = g_gallery.getItem(index);
+ setImageToSlide(g_objSlide1, objItem, true); //force
+ }
+
+ if(g_objSlide2.data("index") == index){
+ objItem = g_gallery.getItem(index);
+ setImageToSlide(g_objSlide2, objItem, true);
+ }
+
+ if(g_objSlide3.data("index") == index){
+ objItem = g_gallery.getItem(index);
+ setImageToSlide(g_objSlide3, objItem, true);
+ }
+
+ }
+
+
+ /**
+ * after image loaded. position video play button
+ */
+ function onSlideImageLoaded(data, objSlide){
+
+ objSlide = jQuery(objSlide);
+ var objImage = t.getSlideImage(objSlide);
+ var objButtonVideoPlay = getSlideVideoPlayButton(objSlide);
+ var objSize = g_functions.getElementSize(objImage);
+
+ g_functions.placeElement(objButtonVideoPlay, "center", "middle", objSize.left, objSize.top, objImage);
+ }
+
+
+ /**
+ * init event of current slide
+ */
+ function initSlideEvents(objSlide){
+
+ //set video player events
+ var objVideoPlayButton = getSlideVideoPlayButton(objSlide);
+ g_functions.addClassOnHover(objVideoPlayButton);
+
+ g_functions.setButtonOnClick(objVideoPlayButton, objVideoPlayClick);
+
+ }
+
+
+ /**
+ * init events
+ */
+ function initEvents(){
+
+ //on item image update, update the image inside the slider if relevant
+ g_objGallery.on(g_gallery.events.ITEM_IMAGE_UPDATED, onItemImageUpdate);
+
+
+ //on item change, change the item in the slider.
+ g_objGallery.on(g_gallery.events.ITEM_CHANGE, onItemChange);
+
+ if(g_objBullets)
+ jQuery(g_objBullets).on(g_objBullets.events.BULLET_CLICK,onBulletClick);
+
+ //arrows events
+ if(g_options.slider_enable_arrows == true){
+
+ g_functions.addClassOnHover(g_objArrowRight, "ug-arrow-hover");
+ g_functions.addClassOnHover(g_objArrowLeft, "ug-arrow-hover");
+
+ g_gallery.setNextButton(g_objArrowRight);
+ g_gallery.setPrevButton(g_objArrowLeft);
+ }
+
+
+ //show / hide controls
+ if(g_options.slider_controls_always_on == false){
+
+ //assign hover evens only if no touch device
+ g_objSlider.hover(onMouseEnter, onMouseLeave);
+
+ }
+
+ //touch events appear on tap event
+ g_objSlider.on("touchend click", onClick);
+
+ //actual click event
+ g_objThis.on(t.events.CLICK, onActualClick);
+
+ //show / hide text panel, if it's saparate from controls
+ if(g_objTextPanel && g_temp.isTextPanelSaparateHover == true){
+ g_objSlider.hover(showTextPanel, hideTextPanel);
+ }
+
+ //init play / pause button
+ if(g_objButtonPlay){
+ g_functions.addClassOnHover(g_objButtonPlay, "ug-button-hover");
+ g_gallery.setPlayButton(g_objButtonPlay);
+ }
+
+ //init fullscreen button
+ if(g_objButtonFullscreen){
+ g_functions.addClassOnHover(g_objButtonFullscreen, "ug-button-hover");
+ g_gallery.setFullScreenToggleButton(g_objButtonFullscreen);
+ }
+
+ //on zoom start / end events
+ if(g_objZoomSlider){
+ g_objThis.on(t.events.ZOOM_CHANGE, onZoomChange);
+ }
+
+ if(g_objZoomPanel)
+ g_objZoomPanel.initEvents();
+
+ //init video player related events
+ g_objVideoPlayer.initEvents();
+
+ //video API events
+ jQuery(g_objVideoPlayer).on(g_objVideoPlayer.events.SHOW, onVideoPlayerShow);
+ jQuery(g_objVideoPlayer).on(g_objVideoPlayer.events.HIDE, onVideoPlayerHide);
+
+ //add slide events
+ initSlideEvents(g_objSlide1);
+ initSlideEvents(g_objSlide2);
+ initSlideEvents(g_objSlide3);
+
+ //on image loaded
+ g_objThis.on(t.events.AFTER_PUT_IMAGE, onSlideImageLoaded);
+
+ //image mouseenter / mouseleave event
+
+ //set mouseover events on the images
+ g_objSlider.on("mouseenter",".ug-item-wrapper img",function(event){
+ g_objThis.trigger(t.events.IMAGE_MOUSEENTER);
+ });
+
+ g_objSlider.on("mouseleave",".ug-item-wrapper img",function(event){
+ var isMouseOver = t.isMouseInsideSlideImage(event);
+
+ if(isMouseOver == false)
+ g_objThis.trigger(t.events.IMAGE_MOUSELEAVE);
+ });
+
+ }
+
+
+ /**
+ * destroy slider events
+ */
+ this.destroy = function(){
+
+ g_objThis.off(t.events.AFTER_PUT_IMAGE);
+
+ g_objGallery.off(g_gallery.events.ITEM_IMAGE_UPDATED);
+ g_objGallery.off(g_gallery.events.ITEM_CHANGE);
+
+ if(g_objBullets)
+ jQuery(g_objBullets).on(g_objBullets.events.BULLET_CLICK);
+
+ g_objSlider.off("mouseenter");
+ g_objSlider.off("mouseleave");
+
+ g_objSlider.off("touchend");
+ g_objSlider.off("click");
+ g_objThis.off(t.events.CLICK);
+
+ if(g_objZoomSlider)
+ g_objThis.off(t.events.ZOOM_CHANGE);
+
+ g_objThis.off(t.events.BEFORE_SWITCH_SLIDES);
+ jQuery(g_objVideoPlayer).off(g_objVideoPlayer.events.SHOW);
+ jQuery(g_objVideoPlayer).off(g_objVideoPlayer.events.HIDE);
+
+ g_objVideoPlayer.destroy();
+
+ g_objSlider.off("mouseenter",".ug-item-wrapper img");
+ g_objSlider.off("mouseleave",".ug-item-wrapper img");
+ }
+
+
+ function __________GETTERS___________(){};
+
+ /**
+ * get loader class by loader type
+ */
+ function getLoaderClass(){
+ var loaderClass;
+ switch(g_options.slider_loader_type){
+ default:
+ case 1: loaderClass = "ug-loader1";break;
+ case 2: loaderClass = "ug-loader2";break;
+ case 3: loaderClass = "ug-loader3";break;
+ case 4: loaderClass = "ug-loader4";break;
+ case 5: loaderClass = "ug-loader5";break;
+ case 6: loaderClass = "ug-loader6";break;
+ case 7: loaderClass = "ug-loader7";break;
+ case 8: loaderClass = "ug-loader8";break;
+ case 9: loaderClass = "ug-loader9";break;
+ }
+
+ if(g_options.slider_loader_color == "black")
+ loaderClass += " ug-loader-black";
+
+ return(loaderClass);
+ }
+
+
+
+ /**
+ *
+ * get slide by number
+ */
+ function getSlideByNum(num){
+
+ switch(num){
+ case 1:
+ return(g_objSlide1);
+ break;
+ case 2:
+ return(g_objSlide2);
+ break;
+ case 3:
+ return(g_objSlide3);
+ break;
+ default:
+ throw new Error("wrong num: " + num);
+ break;
+ }
+ }
+
+
+ /**
+ *
+ * get slide direction of current item
+ */
+ function getSlideDirection(objItem){
+
+ var slides = t.getSlidesReference();
+
+ //validate if the item is not selected already
+ var currentIndex = slides.objCurrentSlide.data("index");
+ var nextIndex = objItem.index;
+
+ var direction = "left";
+ if(currentIndex > nextIndex)
+ direction = "right";
+
+ return(direction);
+ }
+
+
+ /**
+ * get slide preloader
+ */
+ function getSlidePreloader(objSlide){
+
+ if(!objSlide)
+ var objSlide = t.getCurrentSlide();
+
+ var objPreloader = objSlide.children(".ug-slider-preloader");
+ return(objPreloader);
+ }
+
+ /**
+ * get slide videoplay button
+ */
+ function getSlideVideoPlayButton(objSlide){
+ var objButton = objSlide.children(".ug-button-videoplay");
+ return(objButton);
+ }
+
+
+
+ /**
+ * get slide item
+ */
+ function getSlideItem(objSlide){
+ if(!objSlide)
+ var objSlide = t.getCurrentSlide();
+
+ var index = objSlide.data("index");
+ if(index == undefined)
+ return(null);
+
+ var objItem = g_gallery.getItem(index);
+ return(objItem);
+ }
+
+
+ /**
+ * get slide number
+ */
+ function getNumSlide(objSlide){
+ var numSlide = objSlide.data("slidenum");
+ return(numSlide);
+ }
+
+
+
+ this.________EXTERNAL_GENERAL___________ = function(){};
+
+
+ /**
+ * init function for avia controls
+ * options: width / height
+ */
+ this.init = function(objGallery, objOptions, optionsPrefix){
+
+ initSlider(objGallery, objOptions, optionsPrefix);
+ }
+
+ /**
+ * get slide image
+ */
+ this.getSlideImage = function(objSlide){
+
+ if(!objSlide)
+ var objSlide = t.getCurrentSlide();
+
+ var objImage = objSlide.find(".ug-item-wrapper img");
+ return(objImage);
+ }
+
+
+ /**
+ * set slider html
+ */
+ this.setHtml = function(objParent){
+
+ setHtmlSlider(objParent);
+ }
+
+
+ /**
+ * run the slider
+ */
+ this.run = function(){
+
+ runSlider();
+ }
+
+
+ /**
+ * check if the inner object in place, for panning znd zooming posibility check
+ */
+ this.isInnerInPlace = function(){
+
+ var slides = t.getSlidesReference();
+
+ var posCurrent = g_functions.getElementSize(slides.objCurrentSlide);
+ var inPlaceX = -posCurrent.left;
+ var objInnerSize = g_functions.getElementSize(g_objInner);
+
+ if(inPlaceX == objInnerSize.left)
+ return(true);
+ else
+ return(false);
+ }
+
+ /**
+ * is animating
+ */
+ this.isAnimating = function(){
+
+ var isAnimated = g_objInner.is(":animated");
+
+ return(isAnimated);
+ }
+
+ /**
+ * check if the slide is current
+ */
+ this.isSlideCurrent = function(objSlide){
+ var numSlide = objSlide.data("slidenum");
+ if(g_temp.numCurrent == numSlide)
+ return(true);
+
+ return(false);
+ }
+
+
+ /**
+ *
+ * tells if the slide has item
+ */
+ this.isSlideHasItem = function(objSlide){
+ var index = objSlide.data("index");
+ if(index === undefined || index === null)
+ return(false);
+
+ return(true);
+ }
+
+
+ /**
+ * get image padding object for scaling the image
+ */
+ this.getObjImagePadding = function(){
+
+ var objPadding = {
+ padding_top: g_options.slider_image_padding_top,
+ padding_bottom: g_options.slider_image_padding_bottom,
+ padding_left: g_options.slider_image_padding_left,
+ padding_right: g_options.slider_image_padding_right
+ };
+
+ return(objPadding);
+ }
+
+
+ /**
+ * get items reference by their order
+ */
+ this.getSlidesReference = function(){
+
+ var obj = {
+ objPrevSlide: getSlideByNum(g_temp.numPrev),
+ objNextSlide: getSlideByNum(g_temp.numNext),
+ objCurrentSlide: getSlideByNum(g_temp.numCurrent)
+ };
+
+ return(obj);
+ }
+
+
+ /**
+ * get current slide
+ */
+ this.getCurrentSlide = function(){
+
+ var slides = t.getSlidesReference();
+
+ return(slides.objCurrentSlide);
+ }
+
+
+ /**
+ * get index of current item
+ */
+ this.getCurrentItemIndex = function(){
+
+ var slides = t.getSlidesReference();
+
+ var currentIndex = slides.objCurrentSlide.data("index");
+ if(currentIndex === null || currentIndex === undefined)
+ currentIndex = -1;
+
+ return(currentIndex);
+ }
+
+
+ /**
+ * get current slide item
+ */
+ this.getCurrentItem = function(){
+ var currentIndex = t.getCurrentItemIndex();
+ if(currentIndex == -1)
+ return(null);
+
+ var objItem = g_gallery.getItem(currentIndex);
+
+ return(objItem);
+ }
+
+
+ /**
+ * get type of some slide
+ */
+ this.getSlideType = function(objSlide){
+
+ if(objSlide == undefined)
+ objSlide = t.getCurrentSlide();
+
+ var type = objSlide.data("type");
+ return(type);
+ }
+
+
+ /**
+ * is mouse inside slide image
+ * get mouse position from event
+ */
+ this.isMouseInsideSlideImage = function(event){
+
+ var objImage = t.getSlideImage();
+
+ var point = g_functions.getMousePosition(event);
+ if(point.pageX === undefined)
+ point = g_objTouchSlider.getLastMousePos();
+
+ var pointImg = g_functions.getMouseElementPoint(point, objImage);
+ var objSize = g_functions.getElementSize(objImage);
+ isMouseInside = g_functions.isPointInsideElement(pointImg, objSize);
+
+ return(isMouseInside);
+ }
+
+
+ /**
+ * check if current slide type is certain type
+ */
+ this.isCurrentSlideType = function(type){
+ var currentSlideType = t.getSlideType();
+ if(currentSlideType == type)
+ return(true);
+
+ return(false);
+ }
+
+
+ /**
+ * check if current slide is loading image
+ */
+ this.isCurrentSlideLoadingImage = function(){
+ var currentSlide = t.getCurrentSlide();
+ var isLoading = currentSlide.data("isLoading");
+ if(isLoading === true)
+ return(true);
+
+ return(false);
+ }
+
+
+ /**
+ * change the slider to some item content
+ */
+ this.setItem = function(objItem, forseTransition, role){
+
+ var slides = t.getSlidesReference();
+
+ //validate if the item is not selected already
+ var currentIndex = slides.objCurrentSlide.data("index");
+ var nextIndex = objItem.index;
+
+ if(nextIndex == currentIndex){
+ return(true);
+ }
+
+ var isFirstSlide = (currentIndex == undefined);
+
+ if(isFirstSlide){
+ setItemToSlide(slides.objCurrentSlide, objItem);
+ t.placeNabourItems();
+
+ }else{
+
+ var direction = "left"; //move foreward
+
+ var numItems = g_gallery.getNumItems();
+
+ if(role == "next")
+ direction = "left";
+ else if(role == "prev" || currentIndex > nextIndex)
+ direction = "right";
+ else if(currentIndex > nextIndex)
+ direction = "right";
+
+ doTransition(direction, objItem, forseTransition);
+ }
+
+ }
+
+
+ /**
+ * when the transition complete, put the next / prev items at their place
+ */
+ this.placeNabourItems = function(){
+
+ var slides = t.getSlidesReference();
+ var currentIndex = slides.objCurrentSlide.data("index");
+
+ var itemPrev = g_gallery.getPrevItem(currentIndex);
+ var itemNext = g_gallery.getNextItem(currentIndex);
+
+ //trace(itemPrev);
+ //trace(itemNext);
+
+ //trace("place " + currentIndex, "next: "+);
+
+ setItemToSlide(slides.objNextSlide, itemNext);
+ setItemToSlide(slides.objPrevSlide, itemPrev);
+
+ positionSlides();
+ }
+
+
+
+ this.________EXTERNAL_API___________ = function(){};
+
+
+ /**
+ * stop some slide action if active
+ */
+ this.stopSlideAction = function(objSlide, isPause){
+
+ if(!objSlide)
+ objSlide = t.getCurrentSlide();
+
+ if(isPause === true)
+ g_objVideoPlayer.pause();
+ else
+ g_objVideoPlayer.hide();
+
+ // trace("stop action");
+
+ }
+
+
+
+ /**
+ * start some slide action if exists
+ */
+ this.startSlideAction = function(objSlide){
+
+ // trace("start action");
+
+ if(!objSlide)
+ objSlide = t.getCurrentSlide();
+
+ var objItem = getSlideItem(objSlide);
+
+ if(objItem.type == "image")
+ return(true)
+
+ if(g_options.slider_video_constantsize == true)
+ setVideoPlayerConstantSize();
+
+ setVideoPlayerPosition();
+
+ g_objVideoPlayer.show();
+
+ switch(objItem.type){
+ case "youtube":
+ g_objVideoPlayer.playYoutube(objItem.videoid);
+ break;
+ case "vimeo":
+ g_objVideoPlayer.playVimeo(objItem.videoid);
+ break;
+ case "html5video":
+ g_objVideoPlayer.playHtml5Video(objItem.videoogv, objItem.videowebm, objItem.videomp4, objItem.urlImage);
+ break;
+ case "soundcloud":
+ g_objVideoPlayer.playSoundCloud(objItem.trackid);
+ break;
+ case "wistia":
+ g_objVideoPlayer.playWistia(objItem.videoid);
+ break;
+ }
+
+ }
+
+
+ /**
+ * get the scale mode according the state (normal, fullscreen).
+ */
+ this.getScaleMode = function(objSlide){
+
+ if(!objSlide)
+ var objSlide = t.getCurrentSlide();
+
+ var slideType = t.getSlideType(objSlide);
+
+ //return media scale mode
+ if(slideType != "image")
+ return(g_options.slider_scale_mode_media);
+
+ if(g_options.slider_scale_mode == g_options.slider_scale_mode_fullscreen)
+ return(g_options.slider_scale_mode);
+
+ if(g_gallery.isFullScreen() == true)
+ return(g_options.slider_scale_mode_fullscreen);
+ else
+ return(g_options.slider_scale_mode);
+
+ }
+
+
+ /**
+ * get slider objects
+ */
+ this.getObjects = function(){
+
+ var obj = {
+ g_objSlider: g_objSlider,
+ g_objInner: g_objInner,
+ g_options: g_options,
+ g_objZoomSlider: g_objZoomSlider
+ };
+
+ return(obj);
+ }
+
+
+ /**
+ * get zoom object
+ */
+ this.getObjZoom = function(){
+
+ return(g_objZoomSlider);
+ }
+
+
+
+ /**
+ * get slider options
+ */
+ this.getOptions = function(){
+
+ return(g_options);
+ }
+
+
+ /**
+ * get slider element
+ */
+ this.getElement = function(){
+
+ return(g_objSlider);
+ }
+
+ /**
+ * get video object
+ */
+ this.getVideoObject = function(){
+ return(g_objVideoPlayer);
+ }
+
+
+ /**
+ * return true if current slider image fit the slider
+ * @returns
+ */
+ this.isCurrentSlideImageFit = function(){
+ var objSlide = t.getCurrentSlide();
+
+ var slideType = t.getSlideType(objSlide);
+
+ validateSlideType("image", objSlide);
+
+ var objImage = t.getSlideImage(objSlide);
+
+ //if image don't yet added to dom, return false
+ if(objImage.length == 0)
+ return(false);
+
+ var isFit = g_functions.isImageFitParent(objImage);
+
+ return(isFit);
+ }
+
+
+ /**
+ * check if current image in place
+ */
+ this.isCurrentImageInPlace = function(){
+
+ var objImage = t.getSlideImage();
+ if(objImage.length == 0)
+ return(false);
+
+ var scaleMode = t.getScaleMode();
+ var objPadding = t.getObjImagePadding();
+ var objItem = getSlideItem();
+
+ var objParent = objImage.parent();
+
+ var objFitSize = g_functions.getImageInsideParentData(objParent, objItem.imageWidth, objItem.imageHeight, scaleMode, objPadding);
+ var objSize = g_functions.getElementSize(objImage);
+
+ var output = false;
+
+ if(objFitSize.imageWidth == objSize.width)
+ output = true;
+
+ return(output);
+ }
+
+
+ /**
+ * if slide is bussy in some action
+ */
+ this.isSlideActionActive = function(){
+
+ return g_objVideoPlayer.isVisible();
+ }
+
+ /**
+ * return if swipe action active
+ */
+ this.isSwiping = function(){
+ if(!g_objTouchSlider)
+ return(false);
+
+ var isActive = g_objTouchSlider.isTouchActive();
+
+ return(isActive);
+ }
+
+
+ /**
+ * if slider preloading image (if preloader visible)
+ */
+ this.isPreloading = function(){
+
+ var objPreloader = getSlidePreloader();
+ if(objPreloader.is(":visible"))
+ return(true);
+
+ return(false);
+ }
+
+ /**
+ * set the options
+ */
+ this.setOptions = function(objOptions){
+
+ //change options by prefix
+ if(g_optionsPrefix)
+ objOptions = g_functions.convertCustomPrefixOptions(objOptions, g_optionsPrefix, "slider");
+
+ g_options = jQuery.extend(g_options, objOptions);
+
+ }
+
+
+ /**
+ * set the slider size
+ * works well on resize too.
+ */
+ this.setSize = function(width, height){
+
+ if(width < 0 || height < 0)
+ return(true);
+
+ var objCssSlider = {};
+ objCssSlider["width"] = width + "px";
+ objCssSlider["height"] = height + "px";
+ g_objSlider.css(objCssSlider);
+
+ //set inner:
+ var objCssInner = {};
+ objCssInner["height"] = height + "px";
+ objCssInner["top"] = "0px";
+ objCssInner["left"] = "0px";
+ g_objInner.css(objCssInner);
+
+ //set slide wrapper
+ var objCssSlide = {};
+ objCssSlide["height"] = height + "px";
+ objCssSlide["width"] = width + "px";
+
+ g_objSlide1.css(objCssSlide);
+ g_objSlide2.css(objCssSlide);
+ g_objSlide3.css(objCssSlide);
+
+ var itemWidth = width - g_options.slider_item_padding_left - g_options.slider_item_padding_right;
+ var itemHeight = height - g_options.slider_item_padding_top - g_options.slider_item_padding_bottom;
+
+ //set item wrapper
+ var objCssItemWrapper = {};
+ objCssItemWrapper["width"] = itemWidth + "px";
+ objCssItemWrapper["height"] = itemHeight + "px";
+ objCssItemWrapper["top"] = g_options.slider_item_padding_top + "px";
+ objCssItemWrapper["left"] = g_options.slider_item_padding_left + "px";
+
+ g_objSlider.find(".ug-item-wrapper").css(objCssItemWrapper);
+
+
+ //set text panel size
+ if(g_objTextPanel){
+ g_objTextPanel.setSizeByParent();
+ }
+
+ positionElements();
+
+ //set image to slides
+ resizeSlideItem(g_objSlide1);
+ resizeSlideItem(g_objSlide2);
+ resizeSlideItem(g_objSlide3);
+
+ positionSlides();
+
+ //set video player size
+ var currentSlideType = t.getSlideType();
+
+ if(currentSlideType != "image" && g_options.slider_video_constantsize == true){
+
+ setVideoPlayerConstantSize();
+ }else{
+ var videoWidth = width - g_options.slider_video_padding_left - g_options.slider_video_padding_right;
+ var videoHeight = height - g_options.slider_video_padding_top - g_options.slider_video_padding_bottom;
+
+ //set video player size
+ g_objVideoPlayer.setSize(videoWidth, videoHeight);
+ }
+
+ setVideoPlayerPosition();
+
+ }
+
+
+ /**
+ * refresh slide items after options change
+ */
+ this.refreshSlideItems = function(){
+
+ if(t.isAnimating() == true)
+ return(true);
+
+ resizeSlideItem(g_objSlide1);
+ resizeSlideItem(g_objSlide2);
+ resizeSlideItem(g_objSlide3);
+ positionSlides();
+
+ }
+
+
+ /**
+ * is mouse over the slider
+ */
+ this.isMouseOver = function(){
+
+ return g_objSlider.ismouseover();
+ }
+
+ /**
+ * set slider position
+ */
+ this.setPosition = function(left, top){
+
+ g_functions.placeElement(g_objSlider, left, top);
+
+ }
+
+
+ /**
+ * zoom in
+ */
+ this.zoomIn = function(){
+ if(!g_objZoomSlider)
+ return(true);
+
+ g_objZoomSlider.zoomIn();
+ }
+
+ /**
+ * zoom out
+ */
+ this.zoomOut = function(){
+
+ if(!g_objZoomSlider)
+ return(true);
+
+ g_objZoomSlider.zoomOut();
+
+ }
+
+ /**
+ * zoom back to original
+ */
+ this.zoomBack = function(){
+
+ if(!g_objZoomSlider)
+ return(true);
+
+ g_objZoomSlider.zoomBack();
+ }
+
+
+}
+
+/** -------------- TextPanel class ---------------------*/
+
+function UGTextPanel(){
+
+ var t = this;
+ var g_objPanel, g_objParent, g_objTitle, g_objDesc;
+ var g_objBG, g_objTextWrapper, g_gallery;
+ var g_functions = new UGFunctions(), g_optionsPrefix = "";
+
+ var g_options = {
+ textpanel_align:"bottom", //(top , bottom), textpanel align according the parent
+ textpanel_margin:0, //margin from the textpanel position according the textpanel_align
+ textpanel_text_valign:"middle", //middle, top, bottom - text vertical align
+ textpanel_padding_top:10, //textpanel padding top
+ textpanel_padding_bottom:10, //textpanel padding bottom
+ textpanel_height: null, //textpanel height. if null it will be set dynamically
+ textpanel_padding_title_description: 5, //the space between the title and the description
+ textpanel_padding_right: 11, //cut some space for text from right
+ textpanel_padding_left: 11, //cut some space for text from left
+ textpanel_fade_duration: 200, //the fade duration of textpanel appear
+ textpanel_enable_title: true, //enable the title text
+ textpanel_enable_description: true, //enable the description text
+ textpanel_enable_bg: true, //enable the textpanel background
+ textpanel_bg_color:"#000000", //textpanel background color
+ textpanel_bg_opacity: 0.4, //textpanel background opacity
+
+ textpanel_title_color:null, //textpanel title color. if null - take from css
+ textpanel_title_font_family:null, //textpanel title font family. if null - take from css
+ textpanel_title_text_align:null, //textpanel title text align. if null - take from css
+ textpanel_title_font_size:null, //textpanel title font size. if null - take from css
+ textpanel_title_bold:null, //textpanel title bold. if null - take from css
+ textpanel_css_title:{}, //textpanel additional css of the title
+
+ textpanel_desc_color:null, //textpanel description font family. if null - take from css
+ textpanel_desc_font_family:null, //textpanel description font family. if null - take from css
+ textpanel_desc_text_align:null, //textpanel description text align. if null - take from css
+ textpanel_desc_font_size:null, //textpanel description font size. if null - take from css
+ textpanel_desc_bold:null, //textpanel description bold. if null - take from css
+ textpanel_css_description:{}, //textpanel additional css of the description
+
+ textpanel_desc_style_as_title: false, //set that the description style will be as title
+
+ textpanel_bg_css:{} //textpanel background css
+ };
+
+ var g_temp = {
+ isFirstTime: true,
+ setInternalHeight: true, //flag if set internal height or not
+ lastTitleBottom: 0,
+ lastDescHeight: 0
+ };
+
+
+ /**
+ * position elements from top
+ */
+ function positionElementsTop(animateHeight, startY){
+
+ if(!startY)
+ var startY = g_options.textpanel_padding_top;
+
+ //place title
+ var maxy = startY;
+
+ //place title
+ if(g_objTitle){
+ var titleY = maxy;
+ g_functions.placeElement(g_objTitle, 0, titleY);
+
+ var isTitleVisible = g_objTitle.is(":visible");
+ if(isTitleVisible == true){
+ var objTitleSize = g_functions.getElementSize(g_objTitle);
+
+ var maxy = objTitleSize.bottom;
+ if(maxy > 0)
+ g_temp.lastTitleBottom = maxy;
+ }else{
+ var maxy = 20; //get last or assumed maxy
+
+ if(g_temp.lastTitleBottom > 0)
+ maxy = g_temp.lastTitleBottom;
+ }
+
+ }
+
+
+ //place description
+ var textDesc = "";
+ if(g_objDesc)
+ textDesc = jQuery.trim(g_objDesc.text());
+
+ if(textDesc != ""){
+
+ var descY = maxy;
+
+ if(g_objTitle)
+ descY += g_options.textpanel_padding_title_description;
+
+ g_functions.placeElement(g_objDesc, 0, descY);
+
+ var isVisible = jQuery(g_objDesc).is(":visible");
+
+ if(isVisible == true){
+ var objDescSize = g_functions.getElementSize(g_objDesc);
+ maxy = objDescSize.bottom;
+
+ if(objDescSize.height > 0)
+ g_temp.lastDescHeight = objDescSize.height;
+
+ }else{
+ var descHeight = 16; //take from last saved
+ if(g_temp.lastDescHeight > 0)
+ descHeight = g_temp.lastDescHeight;
+
+ maxy = descY + descHeight;
+ }
+
+ }
+
+
+ //change panel height
+ if(!g_options.textpanel_height && g_temp.setInternalHeight == true){
+
+ var panelHeight = maxy + g_options.textpanel_padding_bottom;
+
+ setHeight(panelHeight, animateHeight);
+ }
+
+ }
+
+ /**
+ * get total text and description height
+ */
+ function getTotalTextHeight(){
+ var totalHeight = 0;
+
+ if(g_objTitle)
+ totalHeight += g_objTitle.outerHeight();
+
+ if(g_objDesc){
+ var textDesc = "";
+ if(g_objDesc)
+ textDesc = jQuery.trim(g_objDesc.text());
+
+ if(textDesc != ""){
+ if(g_objTitle)
+ totalHeight += g_options.textpanel_padding_title_description;
+
+ totalHeight += g_objDesc.outerHeight();
+ }
+
+ }
+
+
+ return(totalHeight);
+ }
+
+
+ /**
+ * position elements to center
+ */
+ function positionElementsMiddle(){
+
+ var totalTextHeight = getTotalTextHeight();
+ var startY = (g_objTextWrapper.height() - totalTextHeight) / 2;
+
+ positionElementsTop(false, startY);
+ }
+
+
+ /**
+ * position elements to bottom
+ */
+ function positionElementBottom(){
+
+ var totalTextHeight = getTotalTextHeight();
+ var startY = g_objTextWrapper.height() - totalTextHeight - g_options.textpanel_padding_bottom;
+
+ positionElementsTop(false, startY);
+ }
+
+
+ /**
+ * position elements inside the panel
+ */
+ this.positionElements = function(animateHeight){
+
+ //if(g_objPanel.is(":visible") == false)
+ //trace("the text panel is hidden. can't position elements")
+
+ //if height not set, position only top
+ if(!g_options.textpanel_height || g_options.textpanel_text_valign == "top"){
+ positionElementsTop(animateHeight);
+ return(false);
+ }
+
+ switch(g_options.textpanel_text_valign){
+ default:
+ case "top":
+ positionElementsTop(false); //no animation in this case
+ break;
+ case "bottom":
+ positionElementBottom();
+ break;
+ case "center":
+ case "middle":
+ positionElementsMiddle();
+ break;
+ }
+
+ }
+
+
+ /**
+ * set new panel height
+ */
+ function setHeight(height, animateHeight){
+
+ if(!animateHeight)
+ var animateHeight = false;
+
+ if(animateHeight == true){
+
+ if(g_objBG){
+
+ //avoid background jumps
+ var currentHeight = g_objBG.height();
+ if(height > currentHeight)
+ g_objBG.height(height);
+ }
+
+ var objCss = {height: height+"px"};
+ g_objPanel.add(g_objTextWrapper).animate(objCss, g_options.textpanel_fade_duration);
+
+ }else{
+
+ if(g_objBG)
+ g_objBG.height(height);
+
+ g_objPanel.add(g_objTextWrapper).height(height);
+ }
+
+ }
+
+
+
+
+ /**
+ * init the panel
+ */
+ this.init = function(objGallery, customOptions, optionsPrefix){
+
+ g_gallery = objGallery;
+
+ //change options by prefix
+ if(optionsPrefix){
+ g_optionsPrefix = optionsPrefix;
+ customOptions = g_functions.convertCustomPrefixOptions(customOptions,g_optionsPrefix,"textpanel");
+
+ }
+
+ if(customOptions)
+ g_options = jQuery.extend(g_options, customOptions);
+
+ //validation:
+ if(g_options.textpanel_enable_title == false && g_options.textpanel_enable_description == false)
+ throw new Error("Textpanel Error: The title or description must be enabled");
+
+ if(g_options.textpanel_height && g_options.textpanel_height < 0)
+ g_options.textpanel_height = null;
+
+ //copy desc style from title
+ if(g_options.textpanel_desc_style_as_title == true){
+ if(!g_options.textpanel_desc_color)
+ g_options.textpanel_desc_color = g_options.textpanel_title_color;
+
+ if(!g_options.textpanel_desc_bold)
+ g_options.textpanel_desc_bold = g_options.textpanel_title_bold;
+
+ if(!g_options.textpanel_desc_font_family)
+ g_options.textpanel_desc_font_family = g_options.textpanel_title_font_family;
+
+ if(!g_options.textpanel_desc_font_size)
+ g_options.textpanel_desc_font_size = g_options.textpanel_title_font_size;
+
+ if(!g_options.textpanel_desc_text_align)
+ g_options.textpanel_desc_text_align = g_options.textpanel_title_text_align;
+ }
+
+ }
+
+
+ /**
+ * append the bullets html to some parent
+ */
+ this.appendHTML = function(objParent, addClass){
+ g_objParent = objParent;
+
+ if(addClass){
+ addClass = " "+addClass;
+ }else
+ addClass = "";
+
+ var html = "
";
+
+ if(g_options.textpanel_enable_bg == true)
+ html += "";
+
+ html += "
";
+
+ if(g_options.textpanel_enable_title == true)
+ html += "";
+
+ if(g_options.textpanel_enable_description == true)
+ html += "";
+
+ html += "
";
+ html += "";
+ html += "";
+ html += "";
+ html += "";
+
+ if(g_temp.standAloneMode == false && g_options.video_enable_closebutton == true)
+ html += "";
+
+ html += "
";
+
+ objParent.append(html);
+
+ g_objPlayer = objParent.children(".ug-videoplayer");
+ g_objYoutube = g_objPlayer.children(".ug-videoplayer-youtube");
+ g_objVimeo = g_objPlayer.children(".ug-videoplayer-vimeo");
+ g_objHtml5 = g_objPlayer.children(".ug-videoplayer-html5");
+ g_objSoundCloud = g_objPlayer.children(".ug-videoplayer-soundcloud");
+ g_objWistia = g_objPlayer.children(".ug-videoplayer-wistia");
+
+ if(g_temp.standAloneMode == false && g_options.video_enable_closebutton == true)
+ g_objButtonClose = g_objPlayer.children(".ug-videoplayer-button-close")
+ }
+
+
+ function __________EVENTS___________(){};
+
+ /**
+ * on close button click event
+ */
+ function onCloseButtonClick(){
+ t.hide();
+ }
+
+ /**
+ * on some video play start
+ */
+ function onPlayStart(){
+
+ g_objThis.trigger(t.events.PLAY_START);
+
+ if(g_objButtonClose)
+ g_objButtonClose.hide();
+ }
+
+
+ /**
+ * on some video play stop
+ */
+ function onPlayStop(){
+
+ g_objThis.trigger(t.events.PLAY_STOP);
+
+ if(g_objButtonClose)
+ g_objButtonClose.show();
+ }
+
+ /**
+ * on video ended
+ */
+ function onVideoEnded(){
+
+ g_objThis.trigger(t.events.VIDEO_ENDED);
+
+ }
+
+
+ /**
+ * init events
+ */
+ function initEvents(){
+
+ //close button events
+ if(g_objButtonClose){
+ g_functions.setButtonMobileReady(g_objButtonClose);
+ g_functions.setButtonOnClick(g_objButtonClose, onCloseButtonClick);
+ }
+
+ //youtube events
+ jQuery(g_youtubeAPI).on(g_youtubeAPI.events.START_PLAYING, onPlayStart);
+ jQuery(g_youtubeAPI).on(g_youtubeAPI.events.STOP_PLAYING, onPlayStop);
+ jQuery(g_youtubeAPI).on(g_youtubeAPI.events.VIDEO_ENDED, onVideoEnded);
+
+ //vimeo events
+ jQuery(g_vimeoAPI).on(g_vimeoAPI.events.START_PLAYING, onPlayStart);
+ jQuery(g_vimeoAPI).on(g_vimeoAPI.events.STOP_PLAYING, onPlayStop);
+ jQuery(g_vimeoAPI).on(g_vimeoAPI.events.VIDEO_ENDED, onVideoEnded);
+
+ //html5 video events
+ jQuery(g_html5API).on(g_html5API.events.START_PLAYING, onPlayStart);
+ jQuery(g_html5API).on(g_html5API.events.STOP_PLAYING, onPlayStop);
+ jQuery(g_html5API).on(g_html5API.events.VIDEO_ENDED, onVideoEnded);
+
+ jQuery(g_soundCloudAPI).on(g_soundCloudAPI.events.START_PLAYING, onPlayStart);
+ jQuery(g_soundCloudAPI).on(g_soundCloudAPI.events.STOP_PLAYING, onPlayStop);
+ jQuery(g_soundCloudAPI).on(g_soundCloudAPI.events.VIDEO_ENDED, onVideoEnded);
+
+ jQuery(g_wistiaAPI).on(g_wistiaAPI.events.START_PLAYING, onPlayStart);
+ jQuery(g_wistiaAPI).on(g_wistiaAPI.events.STOP_PLAYING, onPlayStop);
+ jQuery(g_wistiaAPI).on(g_wistiaAPI.events.VIDEO_ENDED, onVideoEnded);
+
+ }
+
+
+ /**
+ * destroy the video player events
+ */
+ this.destroy = function(){
+
+ if(g_objButtonClose){
+ g_objButtonClose.off("click");
+ g_objButtonClose.off("touchend");
+ }
+
+ //youtube events
+ jQuery(g_youtubeAPI).off(g_youtubeAPI.events.START_PLAYING);
+ jQuery(g_youtubeAPI).off(g_youtubeAPI.events.STOP_PLAYING);
+
+ //vimeo events
+ jQuery(g_vimeoAPI).off(g_vimeoAPI.events.START_PLAYING);
+ jQuery(g_vimeoAPI).off(g_vimeoAPI.events.STOP_PLAYING);
+
+ //html5 video events
+ jQuery(g_html5API).off(g_html5API.events.START_PLAYING);
+ jQuery(g_html5API).off(g_html5API.events.STOP_PLAYING);
+
+ jQuery(g_soundCloudAPI).off(g_soundCloudAPI.events.START_PLAYING, onPlayStart);
+ jQuery(g_soundCloudAPI).off(g_soundCloudAPI.events.STOP_PLAYING, onPlayStop);
+
+ jQuery(g_wistiaAPI).off(g_wistiaAPI.events.START_PLAYING, onPlayStart);
+ jQuery(g_wistiaAPI).off(g_wistiaAPI.events.STOP_PLAYING, onPlayStop);
+
+ g_activePlayerType = null;
+ }
+
+
+ /**
+ * init events
+ */
+ this.initEvents = function(){
+
+ initEvents();
+ }
+
+
+ /**
+ * set element size and position the button
+ */
+ this.setSize = function(width, height){
+
+ g_functions.setElementSize(g_objPlayer, width, height);
+
+ if(g_objButtonClose)
+ g_functions.placeElement(g_objButtonClose, "right", "top");
+
+ }
+
+
+ /**
+ * set video player position
+ */
+ this.setPosition = function(left, top){
+ g_functions.placeElement(g_objPlayer, left, top);
+ }
+
+ /**
+ * get video player object for placing
+ */
+ this.getObject = function(){
+ return(g_objPlayer);
+ }
+
+
+ /**
+ * show the player
+ */
+ this.show = function(){
+
+ if(t.isVisible() == true)
+ return(true);
+
+ g_objPlayer.show();
+
+ g_objPlayer.fadeTo(0,1);
+
+ if(g_objButtonClose)
+ g_objButtonClose.show();
+
+ g_objThis.trigger(t.events.SHOW);
+ }
+
+
+ /**
+ * hide the player
+ */
+ this.hide = function(){
+
+ if(t.isVisible() == false)
+ return(true);
+
+ //pause all players
+ stopAndHidePlayers();
+
+ g_activePlayerType = null;
+
+ g_objPlayer.hide();
+
+ g_objThis.trigger(t.events.HIDE);
+ }
+
+
+ /**
+ * get active player
+ */
+ this.getActiveAPI = function(){
+
+ switch(g_activePlayerType){
+ case "youtube":
+ return g_youtubeAPI;
+ break;
+ case "vimeo":
+ return g_vimeoAPI;
+ break;
+ case "wistia":
+ return g_wistiaAPI;
+ break;
+ case "soundcloud":
+ return g_soundCloudAPI;
+ break;
+ case "html5":
+ return g_html5API;
+ break;
+ default:
+ return null;
+ break;
+ }
+ }
+
+
+ /**
+ * pause active player if playing
+ */
+ this.pause = function(){
+
+ var activeAPI = t.getActiveAPI();
+ if(activeAPI == null)
+ return(false);
+
+ if(typeof activeAPI.pause == "function")
+ activeAPI.pause();
+
+ }
+
+
+ /**
+ * return if the player is visible
+ */
+ this.isVisible = function(){
+
+ return g_objPlayer.is(":visible");
+ }
+
+
+ /**
+ * stop and hide other elements except some
+ */
+ function stopAndHidePlayers(except){
+
+ var arrPlayers = ["youtube", "vimeo", "html5", "soundcloud", "wistia"];
+ for(var index in arrPlayers){
+ var player = arrPlayers[index];
+ if(player == except)
+ continue;
+ switch(player){
+ case "youtube":
+ g_youtubeAPI.pause();
+ g_youtubeAPI.destroy();
+ g_objYoutube.hide();
+ break;
+ case "vimeo":
+ g_vimeoAPI.pause();
+ g_vimeoAPI.destroy();
+ g_objVimeo.hide();
+ break;
+ case "html5":
+ g_html5API.pause();
+ g_objHtml5.hide();
+ break;
+ case "soundcloud":
+ g_soundCloudAPI.pause();
+ g_soundCloudAPI.destroy();
+ g_objSoundCloud.hide();
+ break;
+ case "wistia":
+ g_wistiaAPI.pause();
+ g_objWistia.hide();
+ break;
+ }
+ }
+
+ }
+
+
+ /**
+ * play youtube inside the video, isAutoplay - true by default
+ */
+ this.playYoutube = function(videoID, isAutoplay){
+
+ if(typeof isAutoplay == "undefined")
+ var isAutoplay = true;
+
+ stopAndHidePlayers("youtube");
+
+ g_objYoutube.show();
+
+ var objYoutubeInner = g_objYoutube.children("#"+g_temp.youtubeInnerID);
+ if(objYoutubeInner.length == 0)
+ g_objYoutube.append("");
+
+
+ if(g_youtubeAPI.isPlayerReady() == true && g_temp.standAloneMode == true)
+ g_youtubeAPI.changeVideo(videoID, isAutoplay);
+ else{
+ g_youtubeAPI.putVideo(g_temp.youtubeInnerID, videoID, "100%", "100%", isAutoplay);
+ }
+
+ g_activePlayerType = "youtube";
+ }
+
+
+ /**
+ * play vimeo
+ */
+ this.playVimeo = function(videoID, isAutoplay){
+
+ if(typeof isAutoplay == "undefined")
+ var isAutoplay = true;
+
+ stopAndHidePlayers("vimeo");
+
+ g_objVimeo.show();
+
+ g_vimeoAPI.putVideo(g_temp.vimeoPlayerID, videoID, "100%", "100%", isAutoplay);
+
+ /*
+ if(g_vimeoAPI.isPlayerReady() && g_temp.standAloneMode == true){
+ g_vimeoAPI.changeVideo(videoID, isAutoplay);
+ }
+ else
+ g_vimeoAPI.putVideo(g_temp.vimeoPlayerID, videoID, "100%", "100%", isAutoplay);
+ */
+
+ g_activePlayerType = "vimeo";
+
+ }
+
+
+ /**
+ * play html5 video
+ */
+ this.playHtml5Video = function(ogv, webm, mp4, posterImage, isAutoplay){
+
+ if(typeof isAutoplay == "undefined")
+ var isAutoplay = true;
+
+ stopAndHidePlayers("html5");
+
+ g_objHtml5.show();
+
+ //trace(posterImage);
+
+ var data = {
+ ogv: ogv,
+ webm: webm,
+ mp4: mp4,
+ posterImage: posterImage
+ };
+
+ g_html5API.putVideo(g_temp.html5PlayerID, data, "100%", "100%", isAutoplay);
+
+ g_activePlayerType = "html5";
+
+ }
+
+ /**
+ * play sound cloud
+ */
+ this.playSoundCloud = function(trackID, isAutoplay){
+
+ if(typeof isAutoplay == "undefined")
+ var isAutoplay = true;
+
+ stopAndHidePlayers("soundcloud");
+
+ g_objSoundCloud.show();
+
+ g_soundCloudAPI.putSound(g_temp.soundCloudPlayerID, trackID, "100%", "100%", isAutoplay);
+
+ g_activePlayerType = "soundcloud";
+
+ }
+
+
+ /**
+ * play sound cloud
+ */
+ this.playWistia = function(videoID, isAutoplay){
+
+ if(typeof isAutoplay == "undefined")
+ var isAutoplay = true;
+
+ stopAndHidePlayers("wistia");
+
+ g_objWistia.show();
+
+ g_wistiaAPI.putVideo(g_temp.wistiaPlayerID, videoID, "100%", "100%", isAutoplay);
+
+ g_activePlayerType = "wistia";
+
+ }
+
+}
+
+
+var g_ugYoutubeAPI = new UGYoutubeAPI();
+var g_ugVimeoAPI = new UGVimeoAPI();
+var g_ugHtml5MediaAPI = new UGHtml5MediaAPI();
+var g_ugSoundCloudAPI = new UGSoundCloudAPI();
+var g_ugWistiaAPI = new UGWistiaAPI();
+
+
+ /**
+ * 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 min jquery version
+ */
+ function ugCheckForMinJQueryVersion(){
+
+ var isMinJQuery = g_ugFunctions.checkMinJqueryVersion("1.8.0");
+
+ if(isMinJQuery == false)
+ throw new Error("The gallery can run from jquery 1.8 You have jQuery "+jQuery.fn.jquery+" Please update your jQuery library.");
+ }
+
+
+ /**
+ * check for errors function
+ */
+ function ugCheckForErrors(galleryID, type){
+
+ /**
+ * check for jquery presents
+ */
+ function checkForJqueryPresents(){
+ if(typeof jQuery == "undefined")
+ throw new Error("jQuery library not included");
+ }
+
+ /**
+ * check for double jquery error
+ */
+ function checkForDoubleJQuery(){
+
+ if(typeof jQuery.fn.unitegallery == "function")
+ return(true);
+
+ var errorMessage = "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.";
+ }
+
+
+ throw new Error(errorMessage);
+ }
+
+ try{
+ if(type == "jquery"){
+ checkForJqueryPresents();
+ ugCheckForMinJQueryVersion();
+ }else{
+ ugCheckForMinJQueryVersion();
+ // checkForDoubleJQuery();
+ }
+
+ }catch(objError){
+
+ var message = objError.message;
+ message = "Unite Gallery Error: "+ message;
+ message = "
" + message + "
"
+
+ if(type == "jquery"){
+ var objGallery = document.getElementById(galleryID);
+ objGallery.innerHTML = message;
+ objGallery.style.display = "block";
+ }
+ else
+ jQuery(galleryID).show().html(message);
+
+ return(false);
+ }
+
+ return(true);
+ }
+
+
+function UniteGalleryMain(){
+
+ var t = this;
+ var g_galleryID;
+ var g_objGallery = jQuery(t), g_objWrapper, g_objParent;
+ var g_objThumbs, g_objSlider, g_functions = new UGFunctions(), g_objTabs, g_objLoadMore;
+ var g_arrItems = [], g_numItems, g_selectedItem = null, g_selectedItemIndex = -1;
+ var g_objTheme, g_objCache = {};
+
+ 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",
+ GALLERY_BEFORE_REQUEST_ITEMS: "gallery_before_request_items", //before ajax load items
+ OPEN_LIGHTBOX:"open_lightbox",
+ CLOSE_LIGHTBOX:"close_lightbox"
+ };
+
+
+ //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_mousewheel_role:"zoom", //none, zoom, advance
+ 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_background_color: "", //set custom background color. If not set it will be taken from css.
+ gallery_debug_errors:false, //show error message when there is some error on the gallery area.
+ gallery_shuffle:false, //randomise position of items at start.
+ gallery_urlajax:null, //ajax url for requesting new items etc.
+ gallery_enable_tabs: false, //enable/disable category tabs
+ gallery_enable_loadmore: false, //enable / disable loadmore button
+ gallery_enable_cache: true, //enable caching items
+ gallery_initial_catid: "" //initial category id (for caching)
+ };
+
+ //gallery_control_thumbs_mousewheel
+
+ 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: {},
+ funcCustomHeight: null //custom height function, set by the theme if needed
+ };
+
+
+
+ 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(objCustomOptions){
+
+ //set theme function:
+ if(objCustomOptions.hasOwnProperty("gallery_theme"))
+ g_options.gallery_theme = objCustomOptions.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
+ g_objTheme = new g_options.gallery_theme();
+ g_objTheme.init(t, 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;
+ }
+
+
+ /**
+ * check for some errors and fire error if needed
+ */
+ function checkForStartupErrors(){
+
+ //protection agains old jquery version
+ try{
+ ugCheckForMinJQueryVersion();
+ }catch(e){
+ throwErrorShowMessage(e.message);
+ }
+
+ //protection against some jquery ui function change
+ if(typeof g_objWrapper.outerWidth() == "object")
+ throwErrorShowMessage("You have some buggy script. most chances jquery-ui.js that destroy jquery outerWidth, outerHeight functions. The gallery can't run. Please update jquery-ui.js to latest version.");
+
+ //check for late jquery include
+ setTimeout(function(){ugCheckForErrors(g_galleryID, "cms")} , 5000);
+
+ }
+
+
+
+ /**
+ * the gallery
+ */
+ function runGallery(galleryID, objCustomOptions, htmlItems, cacheID){
+
+ var isCustomOptions = (typeof objCustomOptions == "object");
+
+ if(isCustomOptions)
+ 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_objParent = g_objWrapper.parent();
+
+ checkForStartupErrors();
+
+ g_temp.originalOptions = jQuery.extend({}, g_options);
+
+ //merge options
+ if(isCustomOptions)
+ g_options = jQuery.extend(g_options, objCustomOptions);
+
+ //cache items
+ if(g_options.gallery_enable_cache == true && g_options.gallery_initial_catid)
+ cacheItems(g_options.gallery_initial_catid);
+
+ //set size class
+ t.setSizeClass();
+
+ //fill arrItems
+ var objItems = g_objWrapper.children();
+
+ fillItemsArray(objItems);
+ loadAPIs();
+
+ //hide images:
+ g_objWrapper.find("img").fadeTo(0,0).hide();
+ g_objWrapper.show();
+
+ clearInitData();
+
+ }else{ //reset options - not first time run
+
+ t.destroy();
+
+ resetOptions();
+
+ g_options = jQuery.extend(g_options, g_temp.objCustomOptions);
+
+ if(htmlItems){
+
+ //cache items
+ if(cacheID && g_options.gallery_enable_cache == true)
+ cacheItems(cacheID, htmlItems);
+
+ if(htmlItems == "noitems"){
+ showErrorMessage("No items in this category","");
+ return(false);
+ }
+
+ g_objWrapper.html(htmlItems);
+
+ var objItems = g_objWrapper.children();
+ fillItemsArray(objItems);
+
+ loadAPIs();
+
+ g_objWrapper.children().fadeTo(0,0).hide();
+
+ g_objWrapper.show();
+ clearInitData();
+ }
+
+ }
+
+ //init tabs
+ if(g_temp.isRunFirstTime == true && g_options.gallery_enable_tabs == true){
+ g_objTabs = new UGTabs();
+ g_objTabs.init(t, g_options);
+ }
+
+ //init loadmore button
+ if(g_temp.isRunFirstTime == true && g_options.gallery_enable_loadmore == true){
+ g_objLoadMore = new UGLoadMore();
+ g_objLoadMore.init(t, g_options);
+ }
+
+ //modify and verify the params
+ if(isCustomOptions)
+ modifyInitParams(g_temp.objCustomOptions);
+
+ validateParams();
+
+ //shuffle items
+ if(g_options.gallery_shuffle == true)
+ t.shuffleItems();
+
+ //init the theme
+ initTheme(g_temp.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(){
+
+ t.setSizeClass();
+
+ if(g_temp.isFreestyleMode == false){
+
+ if(g_options.gallery_preserve_ratio == true)
+ setHeightByOriginalRatio();
+ }
+
+ g_objTheme.run();
+
+ if(g_objTabs && g_temp.isRunFirstTime)
+ g_objTabs.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, prefix){
+
+ if(typeof prefix == "undefined")
+ var prefix = "Unite Gallery Error: ";
+ else
+ prefix = ""+prefix+": ";
+
+ message = prefix + message;
+
+ var html = "
" + message + "
";
+
+ g_objWrapper.children().remove();
+
+ g_objWrapper.html(html);
+ g_objWrapper.show();
+ }
+
+ /**
+ * show error message and throw error
+ */
+ function throwErrorShowMessage(message){
+ showErrorMessage(message);
+ throw new Error(message);
+ }
+
+
+ /**
+ *
+ * @param objParams
+ */
+ function modifyInitParams(){
+
+ //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(g_options.gallery_min_height == undefined || g_options.gallery_height < g_options.gallery_min_height){
+ g_options.gallery_min_height = 0;
+ }
+
+ if(g_options.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(jQuery.isNumeric(g_options.gallery_height) && 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");
+
+ g_objWrapper.append("");
+
+ 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){
+
+ var galleryHeight = g_functions.getCssSizeParam(g_options.gallery_height);
+ objCss["height"] = galleryHeight;
+
+ }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 item by html child
+ */
+ function fillItemByChild(objChild){
+
+ var isMobile = t.isMobileMode();
+
+ var tagname = objChild.prop("tagName").toLowerCase();
+
+ //handle link wrapper
+ var itemLink = "";
+ if(tagname == "a"){
+ itemLink = objChild.attr("href");
+ objChild = objChild.children();
+ var tagname = objChild.prop("tagName").toLowerCase();
+ }
+
+ var itemType = objChild.data("type");
+ if(itemType == undefined)
+ itemType = "image";
+
+ var objItem = {};
+ objItem.type = itemType;
+
+ if(tagname == "img"){
+
+ //protection agains lasy load
+ var lasyLoadSrc = objChild.data("lazyload-src");
+ if(lasyLoadSrc && lasyLoadSrc != ""){
+ objChild.attr("src", lasyLoadSrc);
+ jQuery.removeData(objChild, "lazyload-src");
+ }
+
+ //src is thumb
+ var urlImage = objChild.data("image");
+ var urlThumb = objChild.data("thumb");
+
+ if(typeof(urlImage) == "undefined")
+ urlImage = null;
+
+ if(typeof(urlThumb) == "undefined")
+ urlThumb = null;
+
+ var imageSrc = objChild.attr("src");
+
+ if(!urlImage)
+ urlImage = imageSrc;
+
+ if(!urlThumb)
+ urlThumb = imageSrc;
+
+ if(!urlThumb)
+ urlThumb = urlImage;
+
+ if(!urlImage)
+ urlImage = urlThumb;
+
+ objItem.urlThumb = urlThumb;
+ objItem.urlImage = urlImage;
+
+ objItem.title = objChild.attr("alt");
+
+ //always set thumb image to object
+ objItem.objThumbImage = objChild;
+
+ objItem.objThumbImage.attr("src", objItem.urlThumb);
+
+ }else{
+
+ if(itemType == "image"){
+ trace("Problematic gallery item found:");
+ trace(objChild);
+ trace("Please look for some third party js script that could add this item to the gallery");
+ throw new Error("The item should not be image type");
+ }
+
+ objItem.urlThumb = objChild.data("thumb");
+ objItem.title = objChild.data("title");
+ objItem.objThumbImage = null;
+ objItem.urlImage = objChild.data("image");
+ }
+
+ //trace(isMobile);
+
+ //check mobile version images
+ if(isMobile == true){
+
+ var urlThumbMobile = objChild.data("thumb-mobile");
+ if(typeof urlThumbMobile != "undefined" && urlThumbMobile != ""){
+ objItem.urlThumb = urlThumbMobile;
+
+ if(tagname == "img")
+ objChild.attr("src",objItem.urlThumb);
+ }
+
+ var urlImageMobile = objChild.data("image-mobile");
+ if(typeof urlImageMobile != "undefined" && urlImageMobile != "")
+ objItem.urlImage = urlImageMobile;
+ }
+
+ objItem.link = itemLink;
+
+ //get description:
+ objItem.description = objChild.attr("title");
+ if(!objItem.description)
+ objItem.description = objChild.data("description");
+
+ if(!objItem.description)
+ objItem.description = "";
+
+ objItem.isNewAdded = false; //fill outside
+ objItem.isLoaded = false;
+ objItem.isThumbImageLoaded = false; //if the image loaded or error load
+ objItem.objPreloadImage = null;
+ objItem.isBigImageLoadStarted = false;
+ objItem.isBigImageLoaded = false;
+ objItem.isBigImageLoadError = false;
+ objItem.imageWidth = 0;
+ objItem.imageHeight = 0;
+
+ //set thumb size
+ objItem.thumbWidth = 0;
+ objItem.thumbHeight = 0;
+ objItem.thumbRatioByWidth = 0;
+ objItem.thumbRatioByHeight = 0;
+
+ var dataWidth = objChild.data("width");
+ var dataHeight = objChild.data("height");
+ if(dataWidth && typeof dataWidth == "number" && dataHeight && typeof dataHeight == "number"){
+ objItem.thumbWidth = dataWidth;
+ objItem.thumbHeight = dataHeight;
+ objItem.thumbRatioByWidth = dataWidth / dataHeight;
+ objItem.thumbRatioByHeight = dataHeight / dataWidth;
+ }
+
+ objItem.addHtml = null;
+
+ var isImageMissing = (objItem.urlImage == undefined || objItem.urlImage == "");
+ var isThumbMissing = (objItem.urlThumb == undefined || objItem.urlThumb == "");
+
+ switch(objItem.type){
+ case "youtube":
+ objItem.videoid = objChild.data("videoid");
+
+ if(isImageMissing || isThumbMissing){
+
+ var objImages = g_ugYoutubeAPI.getVideoImages(objItem.videoid);
+
+ //set preview image
+ if(isImageMissing)
+ objItem.urlImage = objImages.preview;
+
+ //set thumb image
+ if(isThumbMissing){
+ objItem.urlThumb = objImages.thumb;
+
+ if(tagname == "img")
+ objChild.attr("src",objItem.urlThumb);
+ }
+
+ }
+
+ g_temp.isYoutubePresent = true;
+ break;
+ case "vimeo":
+
+ objItem.videoid = objChild.data("videoid");
+
+ g_temp.isVimeoPresent = true;
+ break;
+ case "html5video":
+ objItem.videoogv = objChild.data("videoogv");
+ objItem.videowebm = objChild.data("videowebm");
+ objItem.videomp4 = objChild.data("videomp4");
+
+ g_temp.isHtml5VideoPresent = true;
+ break;
+ case "soundcloud":
+ objItem.trackid = objChild.data("trackid");
+ g_temp.isSoundCloudPresent = true;
+ break;
+ case "wistia":
+ objItem.videoid = objChild.data("videoid");
+ g_temp.isWistiaPresent = true;
+ break;
+ case "custom":
+ var objChildImage = objChild.children("img");
+
+ if(objChildImage.length){
+ objChildImage = jQuery(objChildImage[0]);
+
+ objItem.urlThumb = objChildImage.attr("src");
+ objItem.title = objChildImage.attr("alt");
+ objItem.objThumbImage = objChildImage;
+ }
+
+ //add additional html
+ var objChildren = objChild.children().not("img:first-child");
+
+ if(objChildren.length)
+ objItem.addHtml = objChildren.clone();
+
+ break;
+ }
+
+ //clear not needed attributes
+ if(objItem.objThumbImage){
+ objItem.objThumbImage.removeAttr("data-description", "");
+ objItem.objThumbImage.removeAttr("data-image", "");
+ objItem.objThumbImage.removeAttr("data-thumb", "");
+ objItem.objThumbImage.removeAttr("title", "");
+ }
+
+
+ return(objItem);
+ }
+
+
+ /**
+ * fill items array from images object
+ */
+ function fillItemsArray(arrChildren, isAppend){
+
+ if(isAppend !== true){
+ g_arrItems = [];
+ }else{ //append
+
+ //clear last new added items
+ 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;
+
+ //get size with fallback function
+ 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;
+
+ }
+
+
+ /**
+ * attach thumbs panel to the gallery
+ */
+ this.attachThumbsPanel = function(type, objThumbs){
+ g_temp.thumbsType = type;
+ g_objThumbs = objThumbs;
+ }
+
+
+ /**
+ * init the slider
+ */
+ this.initSlider = function(customOptions, optionsPrefix){
+
+ //mix options with user options
+ if(!customOptions)
+ var customOptions = {};
+
+ customOptions = jQuery.extend(g_temp.objCustomOptions, customOptions);
+
+ g_objSlider = new UGSlider();
+ g_objSlider.init(t, customOptions, optionsPrefix);
+ }
+
+
+ function __________END_INIT_GALLERY_______(){};
+
+ function __________EVENTS_____________(){};
+
+
+ /**
+ * on gallery mousewheel event handler, advance the thumbs
+ */
+ this.onGalleryMouseWheel = function(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 && t.isFullScreen() == false && 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){
+
+ var isStillLoading = g_objSlider.isCurrentSlideLoadingImage();
+
+ if(isStillLoading == false)
+ t.continuePlaying();
+ }
+
+ }
+
+
+ /**
+ * on keypress - keyboard control
+ */
+ function onKeyPress(event){
+
+ var obj = jQuery(event.target);
+ if(obj.is("textarea") || obj.is("select") || obj.is("input"))
+ return(true);
+
+ var keyCode = (event.charCode) ? event.charCode :((event.keyCode) ? event.keyCode :((event.which) ? event.which : 0));
+
+ var wasAction = true;
+
+ switch(keyCode){
+ case 39: //right key
+ t.nextItem();
+ break;
+ case 37: //left key
+ t.prevItem();
+ break;
+ default:
+ wasAction = false;
+ break;
+ }
+
+ //only first page gallery affected
+
+ if(wasAction == true){
+ event.preventDefault();
+ event.stopPropagation();
+ event.stopImmediatePropagation();
+ }
+
+ g_objGallery.trigger(t.events.GALLERY_KEYPRESS, [keyCode,event]);
+ }
+
+
+ /**
+ * check that the gallery resized, if do, trigger onresize event
+ */
+ function onGalleryResized(){
+
+ var objSize = t.getSize();
+
+ if(objSize.width == 0) //fix hidden gallery change
+ return(true);
+
+ t.setSizeClass();
+
+ var objSize = t.getSize();
+
+ if(objSize.width != g_temp.lastWidth || (g_temp.isFreestyleMode == false && objSize.height != g_temp.lastHeight)){
+
+ var heightWasSet = false;
+
+ //set height with custom function (if exists)
+ if(g_temp.funcCustomHeight){
+ var newHeight = g_temp.funcCustomHeight(objSize);
+ if(newHeight){
+ g_objWrapper.height(newHeight);
+ heightWasSet = true;
+ }
+ }
+
+ if(heightWasSet == false && 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;
+
+ var fullscreenID = g_functions.getGlobalData("fullscreenID");
+
+ //check if this gallery was affected
+ if(g_galleryID !== fullscreenID)
+ return(true);
+
+ //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);
+ }
+
+ /**
+ * on current slide image load end. If playing mode, begin playing again
+ */
+ function onCurrentSlideImageLoadEnd(){
+
+ if(t.isPlayMode() == true)
+ t.continuePlaying();
+ }
+
+
+ /**
+ * 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_mousewheel_role == "advance" && g_temp.isFreestyleMode == false)
+ g_objWrapper.on("mousewheel", t.onGalleryMouseWheel);
+
+ //on resize event
+ storeLastSize();
+
+ jQuery(window).resize(function(){
+ g_objWrapper.css("width","auto");
+ g_functions.whenContiniousEventOver("gallery_resize", onGalleryResized, g_temp.resizeDelay);
+ });
+
+ //check resize once in a time, start from 10 seconds
+ setTimeout(function(){
+ setInterval(onGalleryResized, 2000);
+ }, 10000);
+
+ //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);
+
+ //on full screen, run on mouse leave
+ g_objGallery.on(t.events.ENTER_FULLSCREEN, function(){
+ 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);
+
+ jQuery(g_objSlider).on(g_objSlider.events.CURRENTSLIDE_LOAD_END, onCurrentSlideImageLoadEnd);
+
+ }
+
+ //add keyboard events
+ if(g_options.gallery_control_keyboard == true)
+ jQuery(document).keydown(onKeyPress);
+
+ }
+
+
+ /**
+ * destroy all gallery events
+ */
+ this.destroy = function(){
+
+ g_objWrapper.off("dragstart");
+ g_objGallery.off(t.events.ITEM_IMAGE_UPDATED);
+
+ //init custom event on strip moving
+ if(g_objThumbs){
+ switch(g_temp.thumbsType){
+ case "strip":
+ jQuery(g_objThumbs).off(g_objThumbs.events.STRIP_MOVE);
+ break;
+ case "grid":
+ jQuery(g_objThumbs).off(g_objThumbs.events.PANE_CHANGE);
+ break;
+ }
+ }
+
+ g_objWrapper.off("mousewheel");
+
+ jQuery(window).off("resize");
+
+ //fullscreen:
+ g_functions.destroyFullScreenChangeEvent();
+
+ //on slider item changed event
+ if(g_objSlider){
+
+ jQuery(g_objSlider).off(g_objSlider.events.ITEM_CHANGED);
+
+ //add slider onmousemove event
+ var sliderElement = g_objSlider.getElement();
+ sliderElement.off("mouseenter");
+ sliderElement.off("mouseleave");
+
+ g_objGallery.off(t.events.ENTER_FULLSCREEN);
+ jQuery(g_objSlider).off(g_objSlider.events.ACTION_START);
+ jQuery(g_objSlider).off(g_objSlider.events.ACTION_END);
+ jQuery(g_objSlider).off(g_objSlider.events.CURRENTSLIDE_LOAD_END);
+ }
+
+ //add keyboard events
+ if(g_options.gallery_control_keyboard == true)
+ jQuery(document).off("keydown");
+
+ //destroy theme
+ if(g_objTheme && typeof g_objTheme.destroy == "function"){
+ g_objTheme.destroy();
+ }
+
+ g_objWrapper.html("");
+
+ }
+
+
+ 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 selected item index
+ */
+ this.getSelectedItemIndex = function(){
+
+ return(g_selectedItemIndex);
+ }
+
+
+ /**
+ * 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.setButtonOnTap(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);
+
+ });
+
+ }
+
+ /**
+ * show overlay disabled
+ */
+ this.showDisabledOverlay = function(){
+ g_objWrapper.children(".ug-overlay-disabled").show();
+ }
+
+ /**
+ * show overlay disabled
+ */
+ this.hideDisabledOverlay = function(){
+ g_objWrapper.children(".ug-overlay-disabled").hide();
+ }
+
+ this.___________END_SET_CONTROLS___________ = function(){}
+
+
+ /**
+ * cache items, put to cache array by id
+ * the items must be unprocessed yet
+ */
+ function cacheItems(cacheID, htmlItemsArg){
+
+ if(htmlItemsArg){
+ var htmlItems = htmlItemsArg;
+ if(htmlItems != "noitems")
+ htmlItems = jQuery(htmlItemsArg).clone();
+ }else{
+ var htmlItems = g_objWrapper.children().clone();
+ }
+
+ g_objCache[cacheID] = htmlItems;
+ }
+
+
+ /**
+ * 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.playTimeLastStep = timeNow;
+
+ var isVisible = t.isGalleryVisible();
+ if(isVisible == false){
+ return(false);
+ }
+
+ g_temp.playTimePassed += timeDiff;
+
+ //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);
+
+ //check if there is a need to pause
+ if(g_objSlider && g_objSlider.isCurrentSlideLoadingImage() == true){
+ t.pausePlaying();
+ }
+
+ }
+
+
+ /**
+ * 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();
+ }
+
+
+ /**
+ * 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;
+ }
+
+
+ this.___________GENERAL_EXTERNAL___________ = function(){}
+
+ /**
+ * shuffle items - usually before theme start
+ */
+ this.shuffleItems = function(){
+
+ g_arrItems = g_functions.arrayShuffle(g_arrItems);
+
+ for(var index in g_arrItems) //fix index
+ g_arrItems[index].index = parseInt(index);
+
+ }
+
+ /**
+ * 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
+ * role - the role of the object who selected the item
+ */
+ this.selectItem = function(objItem, role){
+
+ 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;
+
+ g_objGallery.trigger(t.events.ITEM_CHANGE, [objItem,role]);
+
+ //reset playback, if playing
+ if(g_temp.isPlayMode == true){
+ t.resetPlaying();
+
+ var stillLoading = g_objSlider.isCurrentSlideLoadingImage();
+ if(stillLoading == true)
+ t.pausePlaying();
+ }
+
+ }
+
+
+ /**
+ * 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, "next");
+ }
+
+
+ /**
+ * 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, "prev");
+
+ }
+
+
+ /**
+ * 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(){
+
+ g_functions.setGlobalData("fullscreenID", g_galleryID);
+
+ var divGallery = g_objWrapper.get(0);
+
+ var isSupported = g_functions.toFullscreen(divGallery);
+
+ 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;
+ }
+
+ if(width == 0)
+ var width = jQuery(window).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";
+ }
+
+ if(objWrapper.hasClass(addClass) == true)
+ return(true);
+
+ 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);
+ }
+
+
+ /**
+ * get if small screen
+ */
+ this.isSmallWindow = function(){
+
+ var windowWidth = jQuery(window).width();
+
+
+ if(!windowWidth)
+ return(true);
+
+ if(windowWidth <= 480)
+ return(true);
+
+ return(false);
+ }
+
+
+ /**
+ * check if the gallery is visible
+ */
+ this.isGalleryVisible = function(){
+
+ var isVisible = g_objWrapper.is(":visible");
+
+ return(isVisible);
+ }
+
+
+ /**
+ * change gallery items
+ */
+ this.changeItems = function(itemsContent, cacheID){
+
+ if(!itemsContent)
+ var itemsContent = "noitems";
+
+ runGallery(g_galleryID, "nochange", itemsContent, cacheID);
+ }
+
+
+
+ /**
+ * add items
+ */
+ this.addItems = function(itemsContent){
+
+ if(!itemsContent || itemsContent.length == 0)
+ return(false);
+
+ //add new items wrapper
+ var objNewItemsWrapper = g_objWrapper.children(".ug-newitems-wrapper");
+ if(objNewItemsWrapper.length == 0)
+ g_objWrapper.append("");
+
+ objNewItemsWrapper = g_objWrapper.children(".ug-newitems-wrapper");
+
+ //add the items
+ objNewItemsWrapper.append(itemsContent);
+
+ var objChildren = jQuery(objNewItemsWrapper.children());
+
+ fillItemsArray(objChildren, true);
+
+ loadAPIs();
+
+ if(!g_objTheme || typeof g_objTheme.addItems != "function")
+ throw new Error("addItems function not found in the theme");
+
+ objNewItemsWrapper.remove();
+
+ g_objTheme.addItems();
+ }
+
+
+ /**
+ * get new added items indexes array
+ */
+ this.getNewAddedItemsIndexes = function(){
+
+ var arrIndexes = [];
+
+ jQuery.each(g_arrItems, function(index, objItem){
+
+ if(objItem.isNewAdded == true)
+ arrIndexes.push(index);
+ });
+
+ return(arrIndexes);
+ }
+
+
+ /**
+ * show error message, replace whole gallery div
+ */
+ this.showErrorMessageReplaceGallery = function(message){
+ showErrorMessage(message);
+ }
+
+ /**
+ * set custom height function by width
+ */
+ this.setFuncCustomHeight = function(func){
+ g_temp.funcCustomHeight = func;
+ }
+
+
+ this.__________EXTERNAL_EVENTS_______ = function(){};
+
+
+ /**
+ * trigger event
+ */
+ this.triggerEvent = function(event, arrParams){
+
+ if(!arrParams)
+ g_objGallery.trigger(event);
+ else{
+ if(jQuery.type(arrParams) != "array")
+ arrParams = [arrParams];
+
+ g_objGallery.trigger(event, arrParams);
+ }
+
+ }
+
+ /**
+ * on event
+ */
+ this.onEvent = function(event, func){
+
+ g_objGallery.on(event, func);
+ }
+
+
+ /**
+ * destroy event
+ */
+ this.destroyEvent = function(event){
+
+ g_objGallery.off(event);
+ }
+
+
+ this.__________AJAX_REQUEST_______ = function(){};
+
+
+ /**
+ * ajax request
+ */
+ this.ajaxRequest = function(action, data, successFunction, errorFunction){
+
+ if(!successFunction || typeof successFunction != "function")
+ throw new Error("ajaxRequest error: success function should be passed");
+
+ var urlAjax = g_options.gallery_urlajax;
+ if(!urlAjax || urlAjax == "")
+ throw new Error("ajaxRequest error: Ajax url don't passed");
+
+ if(typeof data == "undefined")
+ var data = {};
+
+ //add galleryID to data
+ var objData = {
+ action:"unitegallery_ajax_action",
+ client_action:action,
+ galleryID: g_galleryID,
+ data:data
+ };
+
+ jQuery.ajax({
+ type:"post",
+ url:g_options.gallery_urlajax,
+ dataType: 'json',
+ data:objData,
+ success:function(response){
+
+ if(!response){
+ throw new Error("Empty ajax response!");
+ }
+
+ if(response == -1 || response === 0)
+ throw new Error("ajax error!!!");
+
+
+ if(typeof response.success == "undefined")
+ throw new Error("ajax error!!!");
+
+ if(response.success == false){
+ showErrorMessage(response.message, "ajax error");
+ return(false);
+ }
+
+ successFunction(response);
+ },
+ error:function(jqXHR, textStatus, errorThrown){
+ console.log("Ajax Error!!! " + textStatus);
+ responseText = jqXHR.responseText;
+ if(errorFunction && typeof errorFunction == "function"){
+ errorFunction(responseText);
+ }else
+ trace(responseText);
+ }
+ });
+
+ }
+
+
+ /**
+ * request new items
+ * isForce - don't take from cache
+ */
+ this.requestNewItems = function(catID, isForce, cacheID){
+
+ var checkCache = g_options.gallery_enable_cache;
+
+ if(!cacheID)
+ cacheID = catID;
+
+ if(isForce == true)
+ checkCache = false;
+
+ //get items from cache
+ if(checkCache == true && g_objCache.hasOwnProperty(cacheID)){
+
+ var htmlItems = g_objCache[cacheID];
+
+ t.changeItems(htmlItems, cacheID);
+
+ }else{
+
+ g_objGallery.trigger(t.events.GALLERY_BEFORE_REQUEST_ITEMS);
+
+ t.ajaxRequest("front_get_cat_items",{catid:catID}, function(response){
+
+ var htmlItems = response.html;
+
+ t.changeItems(htmlItems, cacheID);
+
+ });
+
+ }
+
+ }
+
+
+ /**
+ * 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.message;
+ 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
+
+
+/**
+ * tiles class
+ */
+function UGLightbox(){
+
+ var t = this, g_objThis = jQuery(this);
+ var g_gallery = new UniteGalleryMain(), g_objGallery, g_objWrapper;
+ var g_objSlider = new UGSlider(), g_objOverlay, g_objArrowLeft, g_objArrowRight, g_objButtonClose;
+ var g_functions = new UGFunctions(), g_objTextPanel = new UGTextPanel(), g_objNumbers;
+ var g_objTopPanel;
+
+ var g_options = {
+ lightbox_type: "wide", //compact / wide - lightbox type
+
+ lightbox_show_textpanel: true, //show the text panel
+ lightbox_textpanel_width: 550, //the width of the text panel.
+
+ lightbox_hide_arrows_onvideoplay: true, //hide the arrows when video start playing and show when stop
+ lightbox_arrows_position: "sides", //sides, inside: position of the arrows, used on compact type
+ lightbox_arrows_offset: 10, //The horizontal offset of the arrows
+ lightbox_arrows_inside_offset: 10, //The offset from the image border if the arrows placed inside
+ lightbox_arrows_inside_alwayson: false, //Show the arrows on mouseover, or always on.
+
+ lightbox_overlay_color:null, //the color of the overlay. if null - will take from css
+ lightbox_overlay_opacity:1, //the opacity of the overlay. if null - will take from css
+ lightbox_top_panel_opacity: null, //the opacity of the top panel
+
+ lightbox_show_numbers: true, //show numbers on the right side
+ lightbox_numbers_size: null, //the size of the numbers string
+ lightbox_numbers_color: null, //the color of the numbers
+ lightbox_numbers_padding_top:null, //the top padding of the numbers (used in compact mode)
+ lightbox_numbers_padding_right:null, //the right padding of the numbers (used in compact mode)
+
+ lightbox_compact_closebutton_offsetx: 1, //the offsetx of the close button. Valid only for compact mode
+ lightbox_compact_closebutton_offsety: 1, //the offsetx of the close button. Valid only for compact mode
+
+ lightbox_close_on_emptyspace:true //close the lightbox on empty space
+ };
+
+ this.events = {
+ LIGHTBOX_INIT: "lightbox_init"
+ };
+
+ var g_temp = {
+ topPanelHeight: 44,
+ initTextPanelHeight: 26, //init height for compact mode
+ isOpened: false,
+ isRightNowOpened:false,
+ putSlider: true,
+ isCompact: false,
+ fadeDuration: 300,
+ positionFrom: null,
+ textPanelTop: null,
+ textPanelLeft: null,
+ isArrowsInside: false,
+ isArrowsOnHoverMode: false,
+ lastMouseX: null,
+ lastMouseY: null,
+ originalOptions: null,
+ isSliderChangedOnce:false,
+ isTopPanelEnabled:true
+ };
+
+ var g_defaults = {
+ lightbox_slider_controls_always_on: true,
+ lightbox_slider_enable_bullets: false,
+ lightbox_slider_enable_arrows: false,
+ lightbox_slider_enable_progress_indicator: false,
+ lightbox_slider_enable_play_button: false,
+ lightbox_slider_enable_fullscreen_button: false,
+ lightbox_slider_enable_zoom_panel: false,
+ lightbox_slider_enable_text_panel: false,
+ lightbox_slider_scale_mode_media: "down",
+ lightbox_slider_scale_mode: "down",
+ lightbox_slider_loader_type: 3,
+ lightbox_slider_loader_color: "black",
+ lightbox_slider_transition: "fade",
+
+ lightbox_slider_image_padding_top: g_temp.topPanelHeight,
+ lightbox_slider_image_padding_bottom: 0,
+
+ lightbox_slider_video_padding_top: 0,
+ lightbox_slider_video_padding_bottom: 0,
+
+ lightbox_textpanel_align: "middle",
+ lightbox_textpanel_padding_top: 5,
+ lightbox_textpanel_padding_bottom: 5,
+
+ slider_video_constantsize: false,
+ lightbox_slider_image_border: false,
+
+ lightbox_textpanel_enable_title: true,
+ lightbox_textpanel_enable_description: false,
+ lightbox_textpanel_desc_style_as_title: true,
+
+ lightbox_textpanel_enable_bg:false,
+
+ video_enable_closebutton: false,
+ lightbox_slider_video_enable_closebutton: false,
+ video_youtube_showinfo: false,
+ lightbox_slider_enable_links:false
+ };
+
+ var g_defaultsCompact = {
+ lightbox_overlay_opacity:0.6,
+
+ lightbox_slider_image_border: true,
+ lightbox_slider_image_shadow:true,
+ lightbox_slider_image_padding_top: 30,
+ lightbox_slider_image_padding_bottom: 30,
+
+ slider_video_constantsize: true,
+
+ lightbox_textpanel_align: "bottom",
+ lightbox_textpanel_title_text_align: "left",
+ lightbox_textpanel_desc_text_align: "left",
+ lightbox_textpanel_padding_left: 10, //the padding left of the textpanel
+ lightbox_textpanel_padding_right: 10
+ };
+
+
+ function __________GENERAL_________(){};
+
+
+ /**
+ * init the gallery
+ */
+ function initLightbox(gallery, customOptions){
+
+ g_gallery = gallery;
+ g_objGallery = jQuery(gallery);
+
+ g_options = jQuery.extend(g_options, g_defaults);
+ g_options = jQuery.extend(g_options, customOptions);
+
+ g_temp.originalOptions = jQuery.extend({}, g_options);
+
+ if(g_options.lightbox_type == "compact"){
+ g_temp.isCompact = true;
+ g_options = jQuery.extend(g_options, g_defaultsCompact);
+ g_options = jQuery.extend(g_options, customOptions);
+ }
+
+ //modify some options
+ modifyOptions();
+
+ if(g_temp.putSlider == true){
+
+ g_gallery.initSlider(g_options, "lightbox");
+ g_objects = gallery.getObjects();
+ g_objSlider = g_objects.g_objSlider;
+
+ }else{
+ g_objSlider = null;
+ }
+
+ if(g_options.lightbox_show_textpanel == true){
+ g_objTextPanel.init(g_gallery, g_options, "lightbox");
+ }
+ else
+ g_objTextPanel = null;
+
+
+ }
+
+
+ /**
+ * modify some options according user options
+ */
+ function modifyOptions(){
+
+ if(g_temp.isCompact == true && g_options.lightbox_show_textpanel == true){
+ g_options.lightbox_slider_image_padding_bottom = g_temp.initTextPanelHeight;
+ }
+
+ if(g_temp.isCompact == true && g_options.lightbox_arrows_position == "inside"){
+ g_temp.isArrowsInside = true;
+ }
+
+ if(g_temp.isArrowsInside == true && g_options.lightbox_arrows_inside_alwayson == false)
+ g_temp.isArrowsOnHoverMode = true;
+
+ //disable top panel if no text panel enabled
+ if(g_options.lightbox_show_textpanel == false){
+ g_temp.isTopPanelEnabled = false;
+ g_temp.topPanelHeight = 0;
+ g_options.lightbox_slider_image_padding_top = 0;
+ }
+
+ //modify slider image border width
+
+
+ }
+
+
+ /**
+ * put the lightbox html
+ */
+ function putLightboxHtml(){
+
+ var html = "";
+ var classAddition = "";
+ if(g_temp.isCompact == true){
+ classAddition = " ug-lightbox-compact";
+ }
+
+ html += "
";
+ html += "";
+
+ //set top panel only on wide mode
+ if(g_temp.isCompact == false && g_temp.isTopPanelEnabled){
+ html += "
";
+ html += "";
+
+ if(g_options.lightbox_show_numbers)
+ html += "";
+
+ html += "
"; //top panel
+ }else{
+
+ //put numbers without top panel
+ if(g_options.lightbox_show_numbers)
+ html += "";
+
+ }
+
+
+ html += "";
+
+ html += "";
+ html += "";
+
+ html += "
";
+
+ g_objWrapper = jQuery(html);
+
+ jQuery("body").append(g_objWrapper);
+
+ if(g_objSlider)
+ g_objSlider.setHtml(g_objWrapper);
+
+ g_objOverlay = g_objWrapper.children(".ug-lightbox-overlay");
+
+ if(g_temp.isCompact == false && g_temp.isTopPanelEnabled == true){
+ g_objTopPanel = g_objWrapper.children(".ug-lightbox-top-panel");
+ if(g_objTopPanel.length == 0)
+ g_objTopPanel = null;
+ }
+
+ g_objButtonClose = g_objWrapper.find(".ug-lightbox-button-close");
+
+ if(g_options.lightbox_show_numbers)
+ g_objNumbers = g_objWrapper.find(".ug-lightbox-numbers");
+
+ g_objArrowLeft = g_objWrapper.children(".ug-lightbox-arrow-left");
+ g_objArrowRight = g_objWrapper.children(".ug-lightbox-arrow-right");
+
+ if(g_objTextPanel){
+ if(g_objTopPanel)
+ g_objTextPanel.appendHTML(g_objTopPanel);
+ else
+ g_objTextPanel.appendHTML(g_objWrapper);
+ }
+
+ }
+
+
+ /**
+ * set lightbox properties
+ */
+ function setProperties(){
+
+ if(g_options.lightbox_overlay_color !== null)
+ g_objOverlay.css("background-color", g_options.lightbox_overlay_color);
+
+ if(g_options.lightbox_overlay_opacity !== null)
+ g_objOverlay.fadeTo(0, g_options.lightbox_overlay_opacity);
+
+ if(g_objTopPanel && g_options.lightbox_top_panel_opacity !== null){
+ g_objTopPanel.children(".ug-lightbox-top-panel-overlay").fadeTo(0, g_options.lightbox_top_panel_opacity);
+ }
+
+ //set numbers properties
+ if(g_objNumbers){
+ var cssNumbers = {};
+
+ if(g_options.lightbox_numbers_size !== null)
+ cssNumbers["font-size"] = g_options.lightbox_numbers_size+"px";
+
+ if(g_options.lightbox_numbers_color)
+ cssNumbers["color"] = g_options.lightbox_numbers_color;
+
+ if(g_options.lightbox_numbers_padding_right !== null)
+ cssNumbers["padding-right"] = g_options.lightbox_numbers_padding_right + "px";
+
+ if(g_options.lightbox_numbers_padding_top !== null)
+ cssNumbers["padding-top"] = g_options.lightbox_numbers_padding_top + "px";
+
+
+ g_objNumbers.css(cssNumbers);
+ }
+
+ }
+
+
+ /**
+ * refresh slider item with new height
+ */
+ function refreshSliderItem(newHeight){
+
+ if(!g_objSlider)
+ return(true);
+
+ //set slider new image position
+ var objOptions = {
+ slider_image_padding_top: newHeight
+ };
+
+ g_objSlider.setOptions(objOptions);
+ g_objSlider.refreshSlideItems();
+
+ }
+
+ function __________WIDE_ONLY_________(){};
+
+
+ /**
+ * handle panel height according text height
+ */
+ function handlePanelHeight(fromWhere){
+
+ if(!g_objTopPanel)
+ return(false);
+
+ if(!g_objTextPanel)
+ return(false);
+
+ //check text panel size, get the panel bigger then
+ var panelHeight = g_objTopPanel.height();
+ if(panelHeight == 0)
+ return(false);
+
+ if(g_objTopPanel.is(":visible") == false)
+ return(false);
+
+ var newPanelHeight = panelHeight;
+
+ var objTextPanelSize = g_objTextPanel.getSize();
+
+ var textPanelHeight = objTextPanelSize.height;
+
+ if(panelHeight != g_temp.topPanelHeight)
+ newPanelHeight = g_temp.topPanelHeight;
+
+ if(textPanelHeight > newPanelHeight)
+ newPanelHeight = textPanelHeight;
+
+ if(panelHeight != newPanelHeight){
+ g_objTopPanel.height(newPanelHeight);
+
+ if(g_objSlider && g_objSlider.isAnimating() == false)
+ refreshSliderItem(newPanelHeight);
+ }
+
+ }
+
+
+ /**
+ * position text panel for wide
+ * size - wrapper size
+ */
+ function positionTextPanelWide(size){
+
+ var objOptions = {};
+
+ var textWidth = g_options.lightbox_textpanel_width;
+ var minPaddingLeft = 47;
+ var minPaddingRight = 40;
+ var maxTextPanelWidth = size.width - minPaddingLeft - minPaddingRight;
+
+ if(textWidth > maxTextPanelWidth){ //mobile mode
+
+ objOptions.textpanel_padding_left = minPaddingLeft;
+ objOptions.textpanel_padding_right = minPaddingRight;
+
+ objOptions.textpanel_title_text_align = "center";
+ objOptions.textpanel_desc_text_align = "center";
+ }else{
+ objOptions.textpanel_padding_left = Math.floor((size.width - textWidth) / 2);
+ objOptions.textpanel_padding_right = objOptions.textpanel_padding_left;
+ objOptions.textpanel_title_text_align = "left";
+ objOptions.textpanel_desc_text_align = "left";
+
+ if(g_options.lightbox_textpanel_title_text_align)
+ objOptions.textpanel_title_text_align = g_options.lightbox_textpanel_desc_text_align;
+
+ if(g_options.lightbox_textpanel_desc_text_align)
+ objOptions.textpanel_desc_text_align = g_options.lightbox_textpanel_desc_text_align;
+
+ }
+
+ g_objTextPanel.setOptions(objOptions);
+
+ g_objTextPanel.refresh(true, true);
+
+ handlePanelHeight("positionTextPanelWide");
+ g_objTextPanel.positionPanel();
+ }
+
+ /**
+ * hide top panel
+ */
+ function hideTopPanel(){
+
+ if(!g_objTopPanel)
+ return(false);
+
+ g_objTopPanel.hide();
+ }
+
+
+ /**
+ * show top panel
+ */
+ function showTopPanel(){
+
+ if(!g_objTopPanel)
+ return(false);
+
+ g_objTopPanel.show();
+ }
+
+
+ function __________COMPACT_ONLY_________(){};
+
+ /**
+ * handle slider image height according the textpanel height
+ * refresh the slider if the height is not in place
+ */
+ function handleCompactHeight(objImageSize){
+
+ if(g_temp.isOpened == false)
+ return(false);
+
+ if(!g_objTextPanel)
+ return(false);
+
+ if(!g_objSlider)
+ return(false);
+
+ var wrapperSize = g_functions.getElementSize(g_objWrapper);
+ var textPanelSize = g_objTextPanel.getSize();
+
+ if(textPanelSize.width == 0 || textPanelSize.height > 120)
+ return(false);
+
+ if(!objImageSize){
+ var objImage = g_objSlider.getSlideImage();
+ var objImageSize = g_functions.getElementSize(objImage);
+ }
+
+ if(objImageSize.height == 0 || objImageSize.width == 0)
+ return(false);
+
+ //check elements end size
+ var totalBottom = objImageSize.bottom + textPanelSize.height;
+
+ if(totalBottom < wrapperSize.height)
+ return(false);
+
+ var sliderOptions = g_objSlider.getOptions();
+
+ var imagePaddingBottom = textPanelSize.height;
+
+ if(imagePaddingBottom != sliderOptions.slider_image_padding_bottom){
+
+ var objOptions = {
+ slider_image_padding_bottom: imagePaddingBottom
+ };
+
+ if(g_objSlider.isAnimating() == false){
+ g_objSlider.setOptions(objOptions);
+ g_objSlider.refreshSlideItems();
+ return(true);
+ }
+
+ }
+
+ return(false);
+ }
+
+ /**
+ * set text panel top of compact mode
+ */
+ function setCompactTextpanelTop(objImageSize, positionPanel){
+
+ if(!objImageSize){
+ var objImage = g_objSlider.getSlideImage();
+ var objImageSize = g_functions.getElementSize(objImage);
+ }
+
+ g_temp.textPanelTop = objImageSize.bottom;
+
+ if(positionPanel === true)
+ g_objTextPanel.positionPanel(g_temp.textPanelTop, g_temp.textPanelLeft);
+ }
+
+
+ /**
+ * handle text panel width on compact mode,
+ * run when the image is ready.
+ * Set top position of the panel as well
+ * position numbers as well
+ */
+ function handleCompactTextpanelSizes(showTextpanel){
+
+ var wrapperSize = g_functions.getElementSize(g_objWrapper);
+ var objImage = g_objSlider.getSlideImage();
+ var objImageSize = g_functions.getElementSize(objImage);
+
+ if(objImageSize.width == 0)
+ return(false);
+
+
+ g_temp.textPanelLeft = objImageSize.left;
+ g_temp.textPanelTop = objImageSize.bottom;
+
+ var textPanelWidth = objImageSize.width;
+
+ if(g_objNumbers){
+
+ var objNumbersSize = g_functions.getElementSize(g_objNumbers);
+ textPanelWidth -= objNumbersSize.width;
+
+ //place numbers object
+ var numbersLeft = objImageSize.right - objNumbersSize.width;
+ g_functions.placeElement(g_objNumbers, numbersLeft, g_temp.textPanelTop);
+ }
+
+
+ if(g_objTextPanel){
+ g_objTextPanel.show();
+ g_objTextPanel.refresh(true, true, textPanelWidth);
+ setCompactTextpanelTop(objImageSize);
+ }
+
+ var isChanged = handleCompactHeight(objImageSize);
+
+ if(isChanged == false){
+
+ g_temp.positionFrom = "handleCompactTextpanelSizes";
+
+ if(g_objTextPanel){
+ g_objTextPanel.positionPanel(g_temp.textPanelTop, g_temp.textPanelLeft);
+ if(showTextpanel === true){
+ showTextpanel();
+ showNumbers();
+ }
+ }
+
+ }
+
+ }
+
+
+
+ /**
+ * return that current slider image is in place
+ */
+ function isSliderImageInPlace(){
+
+ if(g_objSlider.isCurrentSlideType("image") == false)
+ return(true);
+
+ var isImageInPlace = (g_objSlider.isCurrentImageInPlace() == true);
+
+ return(isImageInPlace);
+ }
+
+
+ /**
+ * position the arrows inside mode
+ */
+ function positionArrowsInside(toShow, isAnimation){
+
+ if(g_temp.isArrowsInside == false)
+ return(false);
+
+ if(!g_objArrowLeft)
+ return(false);
+
+ var isImageInPlace = isSliderImageInPlace();
+
+ g_objArrowLeft.show();
+ g_objArrowRight.show();
+
+ g_temp.positionFrom = "positionArrowsInside";
+
+ if(g_temp.isArrowsOnHoverMode == true && isImageInPlace == true && isMouseInsideImage() == false)
+ hideArrows(true);
+
+ if(isImageInPlace == false){
+ var leftArrowLeft = g_functions.getElementRelativePos(g_objArrowLeft, "left", g_options.lightbox_arrows_offset);
+ var leftArrowTop = g_functions.getElementRelativePos(g_objArrowLeft, "middle");
+
+ var rightArrowLeft = g_functions.getElementRelativePos(g_objArrowRight, "right", g_options.lightbox_arrows_offset);
+ var rightArrowTop = leftArrowTop;
+
+ }else{
+
+ var objImage = g_objSlider.getSlideImage();
+ var objImageSize = g_functions.getElementSize(objImage);
+ var objSliderSize = g_functions.getElementSize(g_objSlider.getElement());
+
+ var leftArrowLeft = g_functions.getElementRelativePos(g_objArrowLeft, "left", 0, objImage) + objImageSize.left + g_options.lightbox_arrows_inside_offset;
+ var leftArrowTop = g_functions.getElementRelativePos(g_objArrowLeft, "middle", 0, objImage) + objImageSize.top;
+ var rightArrowLeft = g_functions.getElementRelativePos(g_objArrowLeft, "right", 0, objImage) + objImageSize.left - g_options.lightbox_arrows_inside_offset;
+ var rightArrowTop = leftArrowTop;
+
+ }
+
+
+ //place the image with animation or not
+ if(isAnimation === true){
+
+ var objCssLeft = {
+ left: leftArrowLeft,
+ top: leftArrowTop
+ };
+
+ var objCssRight = {
+ left: rightArrowLeft,
+ top: rightArrowTop
+ };
+
+ g_objArrowLeft.stop().animate(objCssLeft,{
+ duration: g_temp.fadeDuration
+ });
+
+ g_objArrowRight.stop().animate(objCssRight,{
+ duration: g_temp.fadeDuration
+ });
+
+
+ }else{
+ g_objArrowLeft.stop();
+ g_objArrowRight.stop();
+
+ g_functions.placeElement(g_objArrowLeft, leftArrowLeft, leftArrowTop);
+ g_functions.placeElement(g_objArrowRight, rightArrowLeft, rightArrowTop);
+ }
+
+
+ if(toShow == true)
+ showArrows(isAnimation);
+
+ }
+
+
+
+ /**
+ * position close button for compact type
+ */
+ function positionCloseButton(toShow, isAnimation){
+
+ g_temp.positionFrom = null;
+
+ var isImageInPlace = isSliderImageInPlace();
+
+ var minButtonTop = 2;
+ var maxButtonLeft = g_functions.getElementRelativePos(g_objButtonClose, "right", 2, g_objWrapper);
+
+ if(isImageInPlace == false){ //put image to corner
+
+ var closeButtonTop = minButtonTop;
+ var closeButtonLeft = maxButtonLeft;
+
+ }else{
+ var objImage = g_objSlider.getSlideImage();
+ var objImageSize = g_functions.getElementSize(objImage);
+ var objSliderSize = g_functions.getElementSize(g_objSlider.getElement());
+ var objButtonSize = g_functions.getElementSize(g_objButtonClose);
+
+ //some strange bug
+ if(objSliderSize.top == objSliderSize.height)
+ objSliderSize.top = 0;
+
+ var closeButtonLeft = objSliderSize.left + objImageSize.right - objButtonSize.width / 2 + g_options.lightbox_compact_closebutton_offsetx;
+ var closeButtonTop = objSliderSize.top + objImageSize.top - objButtonSize.height / 2 - g_options.lightbox_compact_closebutton_offsety;
+
+ if(closeButtonTop < minButtonTop)
+ closeButtonTop = minButtonTop;
+
+ if(closeButtonLeft > maxButtonLeft)
+ closeButtonLeft = maxButtonLeft;
+
+ }
+
+ //place the image with animation or not
+ if(isAnimation === true){
+ var objCss = {
+ left: closeButtonLeft,
+ top: closeButtonTop
+ };
+
+ g_objButtonClose.stop().animate(objCss,{
+ duration: g_temp.fadeDuration
+ });
+
+ }else{
+ g_objButtonClose.stop();
+ g_functions.placeElement(g_objButtonClose, closeButtonLeft, closeButtonTop);
+ }
+
+ if(toShow === true)
+ showCloseButton(isAnimation);
+
+ }
+
+
+ /**
+ * hide close button
+ */
+ function hideCompactElements(){
+
+ if(g_objButtonClose)
+ g_objButtonClose.stop().fadeTo(g_temp.fadeDuration, 0);
+
+ hideTextPanel();
+
+ hideNumbers();
+
+ g_temp.positionFrom = "hideCompactElements";
+ if(g_temp.isArrowsInside == true)
+ hideArrows();
+ }
+
+
+ /**
+ * actual hide all compact type elements
+ */
+ function actualHideCompactElements(){
+
+ if(g_objButtonClose)
+ g_objButtonClose.hide();
+
+ if(g_objArrowLeft && g_temp.isArrowsInside == true){
+ g_objArrowLeft.hide();
+ g_objArrowRight.hide();
+ }
+
+ if(g_objNumbers)
+ g_objNumbers.hide();
+
+ if(g_objTextPanel)
+ g_objTextPanel.hide();
+
+ }
+
+
+ function __________COMMON_________(){};
+
+
+ /**
+ * position the elements
+ */
+ function positionElements(){
+
+ var size = g_functions.getElementSize(g_objWrapper);
+
+ //position top panel:
+ if(g_objTopPanel)
+ g_functions.setElementSizeAndPosition(g_objTopPanel, 0, 0, size.width, g_temp.topPanelHeight);
+
+ //position arrows
+ if(g_objArrowLeft && g_temp.isArrowsInside == false){
+
+ if(g_options.lightbox_hide_arrows_onvideoplay == true){
+ g_objArrowLeft.show();
+ g_objArrowRight.show();
+ }
+
+ g_functions.placeElement(g_objArrowLeft, "left", "middle", g_options.lightbox_arrows_offset);
+ g_functions.placeElement(g_objArrowRight, "right", "middle", g_options.lightbox_arrows_offset);
+ }
+
+ if(g_temp.isCompact == false)
+ g_functions.placeElement(g_objButtonClose, "right", "top", 2, 2);
+
+ //place text panel
+ if(g_objTextPanel){
+
+ g_temp.positionFrom = "positionElements";
+
+ if(g_temp.isCompact == false)
+ positionTextPanelWide(size);
+ else{
+ showTextPanel();
+ showNumbers();
+ }
+
+ }
+
+ var sliderWidth = size.width;
+ var sliderHeight = size.height;
+ var sliderTop = 0;
+ var sliderLeft = 0;
+
+ if(g_objSlider){
+
+ if(g_objTopPanel){
+ var topPanelHeight = g_objTopPanel.height();
+ var objOptions = {
+ slider_image_padding_top: topPanelHeight
+ };
+ g_objSlider.setOptions(objOptions);
+ }
+
+ g_objSlider.setSize(sliderWidth, sliderHeight);
+ g_objSlider.setPosition(sliderLeft, sliderTop);
+ }
+
+ }
+
+
+ /**
+ * hide the text panel
+ */
+ function hideTextPanel(){
+
+ if(g_objTextPanel)
+ g_objTextPanel.getElement().stop().fadeTo(g_temp.fadeDuration, 0);
+
+ }
+
+
+ /**
+ * hide the numbers text
+ */
+ function hideNumbers(){
+
+ if(g_objNumbers)
+ g_objNumbers.stop().fadeTo(g_temp.fadeDuration, 0);
+ }
+
+
+ /**
+ * is mouse inside image
+ */
+ function isMouseInsideImage(){
+ if(!g_temp.lastMouseX)
+ return(true);
+ var obj = {
+ pageX: g_temp.lastMouseX,
+ pageY: g_temp.lastMouseY
+ };
+
+ var isMouseInside = g_objSlider.isMouseInsideSlideImage(obj);
+
+ return(isMouseInside);
+ }
+
+
+ /**
+ * hide the arrows
+ */
+ function hideArrows(noAnimation, isForce){
+
+ if(!g_objArrowLeft)
+ return(false);
+
+ //don't hide the arrows if mouse inside image
+ if(g_temp.isArrowsOnHoverMode == true && isForce === false){
+ if(isMouseInsideImage() == true);
+ return(true);
+ }
+
+ if(noAnimation === true){
+ g_objArrowLeft.stop().fadeTo(0, 0);
+ g_objArrowRight.stop().fadeTo(0, 0);
+ }else{
+ g_objArrowLeft.stop().fadeTo(g_temp.fadeDuration, 0);
+ g_objArrowRight.stop().fadeTo(g_temp.fadeDuration, 0);
+ }
+
+ }
+
+ /**
+ * get if the arrows are hidden
+ */
+ function isArrowsHidden(){
+
+ if(!g_objArrowLeft)
+ return(true);
+ if(g_objArrowLeft.is(":visible") == false)
+ return(true);
+
+ var opacity = g_objArrowLeft.css("opacity");
+ if(opacity != 1)
+ return(true);
+
+ return(false);
+ }
+
+ /**
+ * show the arrows
+ */
+ function showArrows(noStop, fromHover){
+
+ if(!g_objArrowLeft)
+ return(false);
+
+ //don't show every time on arrowsonhover mode
+ if(g_temp.isArrowsOnHoverMode == true && fromHover !== true && isSliderImageInPlace() == true)
+ return(true);
+
+ //don't show if swiping
+ if(g_objSlider.isSwiping() == true)
+ return(true);
+
+ if(noStop !== true){
+ g_objArrowLeft.stop();
+ g_objArrowRight.stop();
+ }
+
+ g_objArrowLeft.fadeTo(g_temp.fadeDuration, 1);
+ g_objArrowRight.fadeTo(g_temp.fadeDuration, 1);
+
+ }
+
+
+
+
+
+ /**
+ * show close button
+ */
+ function showCloseButton(noStop){
+
+ if(noStop !== true)
+ g_objButtonClose.stop();
+
+ g_objButtonClose.fadeTo(g_temp.fadeDuration, 1);
+ }
+
+
+ /**
+ * update text panel text of the curren item
+ */
+ function updateTextPanelText(currentItem){
+
+ if(!g_objTextPanel)
+ return(false);
+
+ if(!currentItem)
+ var currentItem = g_objSlider.getCurrentItem();
+
+ g_objTextPanel.setTextPlain(currentItem.title, currentItem.description);
+ }
+
+
+ /**
+ * update numbers text
+ */
+ function updateNumbersText(currentItem){
+
+ if(!g_objNumbers)
+ return(false);
+
+ if(!currentItem)
+ var currentItem = g_objSlider.getCurrentItem();
+
+ var numItems = g_gallery.getNumItems();
+ var numCurrentItem = currentItem.index + 1;
+ g_objNumbers.html(numCurrentItem + " / " + numItems);
+ }
+
+
+ /**
+ * show the text panel
+ */
+ function showTextPanel(){
+
+ if(!g_objTextPanel)
+ return(false);
+
+ g_objTextPanel.getElement().show().stop().fadeTo(g_temp.fadeDuration, 1);
+
+ }
+
+
+ /**
+ * Show the numbers object
+ */
+ function showNumbers(){
+
+ if(g_objNumbers)
+ g_objNumbers.stop().fadeTo(g_temp.fadeDuration, 1);
+ }
+
+
+ function __________EVENTS_________(){};
+
+
+ /**
+ * on start dragging slider item event. hide the elements
+ */
+ function onSliderDragStart(){
+ if(g_temp.isCompact == false)
+ return(true);
+
+ hideCompactElements();
+ }
+
+
+ /**
+ * on zoom change
+ * move the assets of compact to their places
+ */
+ function onZoomChange(){
+ if(g_temp.isCompact == false)
+ return(true);
+
+ g_temp.positionFrom = "onZoomChange";
+
+ positionCloseButton(false, true);
+ positionArrowsInside(false, true);
+
+ //handle compact text panel mode
+ if(g_temp.isCompact == true){
+ var isImageInPlace = (g_objSlider.isCurrentSlideType("image") && g_objSlider.isCurrentImageInPlace() == true);
+ if(isImageInPlace == false){
+ hideTextPanel();
+ hideNumbers();
+ }
+ else{
+ g_temp.positionFrom = "onZoomChange";
+ showTextPanel();
+ showNumbers();
+ }
+ }
+
+ }
+
+
+ /**
+ * after return slider to it's place
+ * show close button
+ */
+ function onSliderAfterReturn(){
+
+ if(g_temp.isCompact == false)
+ return(true);
+
+ g_temp.positionFrom = "onSliderAfterReturn";
+
+ positionCloseButton(true);
+ positionArrowsInside(true);
+
+ var isChanged = handleCompactHeight();
+ if(isChanged == false)
+ handleCompactTextpanelSizes();
+
+ showTextPanel();
+ showNumbers();
+ }
+
+
+ /**
+ * after put image to the slide
+ * position compact elements
+ */
+ function onSliderAfterPutImage(data, objSlide){
+
+ objSlide = jQuery(objSlide);
+
+ if(g_temp.isCompact == false)
+ return(true);
+
+ if(g_objSlider.isSlideCurrent(objSlide) == false)
+ return(true);
+
+ g_temp.positionFrom = "onSliderAfterPutImage";
+
+ positionCloseButton(true);
+
+ positionArrowsInside(true);
+
+ handleCompactTextpanelSizes();
+ }
+
+
+ /**
+ * on slider transition end, handle panel height
+ */
+ function onSliderTransitionEnd(){
+
+ var sliderOptions = g_objSlider.getOptions();
+ var imagePaddingTop = sliderOptions.slider_image_padding_top;
+
+ //handle wide
+ if(g_objTopPanel){
+ var panelHeight = g_objTopPanel.height();
+
+ if(panelHeight != imagePaddingTop)
+ refreshSliderItem(panelHeight);
+ }
+
+ //handle compact
+ if(g_temp.isCompact == true){
+
+ updateTextPanelText();
+ updateNumbersText();
+
+ g_temp.positionFrom = "onSliderTransitionEnd";
+
+ positionCloseButton(true);
+ positionArrowsInside(true);
+
+ if(g_objSlider.isSlideActionActive() == false){
+ var isChanged = handleCompactHeight();
+ if(isChanged == false)
+ handleCompactTextpanelSizes();
+ }
+
+ showTextPanel();
+ showNumbers();
+
+ }
+
+ }
+
+
+ /**
+ * on item change
+ * update numbers text and text panel text/position
+ */
+ function onItemChange(data, currentItem){
+
+ if(g_temp.isCompact == false){ //wide mode
+
+ if(g_objNumbers)
+ updateNumbersText(currentItem);
+
+ if(g_objTextPanel){
+ updateTextPanelText(currentItem);
+
+ //update panel height only if the lightbox is already opened, and the items changed within it.
+ if(g_temp.isRightNowOpened == false){
+ g_objTextPanel.positionElements(false);
+ handlePanelHeight("onchange");
+ g_objTextPanel.positionPanel();
+ }
+
+ }
+
+ }else{
+
+ if(g_objSlider.isAnimating() == false){
+
+ if(g_objTextPanel)
+ updateTextPanelText(currentItem);
+
+ if(g_objNumbers)
+ updateNumbersText(currentItem);
+ }
+
+ }
+
+
+ //trigger lightbox init event
+ if(g_temp.isSliderChangedOnce == false){
+ g_temp.isSliderChangedOnce = true;
+ g_objThis.trigger(t.events.LIGHTBOX_INIT);
+ }
+
+ }
+
+
+ /**
+ * on slider click
+ */
+ function onSliderClick(data, event){
+
+ var slideType = g_objSlider.getSlideType();
+ if(slideType != "image" && g_temp.isCompact == false && g_objSlider.isSlideActionActive() )
+ return(true);
+
+ var isPreloading = g_objSlider.isPreloading();
+ if(isPreloading == true){
+ t.close("slider");
+ return(true);
+ }
+
+ //close the lightbox on empty space click
+ if(g_options.lightbox_close_on_emptyspace == true){
+
+ var isInside = g_objSlider.isMouseInsideSlideImage(event);
+
+ if(isInside == false)
+ t.close("slider_inside");
+ }
+
+ }
+
+
+ /**
+ * on lightbox resize
+ */
+ function onResize(){
+
+ positionElements();
+ }
+
+
+
+ /**
+ * on start play - hide the side buttons
+ */
+ function onPlayVideo(){
+
+ if(g_objTopPanel){
+ hideTopPanel();
+ }else{
+ if(g_objNumbers)
+ g_objNumbers.hide();
+ }
+
+ if(g_objArrowLeft && g_options.lightbox_hide_arrows_onvideoplay == true){
+ g_objArrowLeft.hide();
+ g_objArrowRight.hide();
+ }
+
+ }
+
+
+ /**
+ * on stop video - show the side buttons
+ */
+ function onStopVideo(){
+
+ if(g_objTopPanel){
+ showTopPanel();
+ handlePanelHeight("onStopVideo");
+ }else{
+
+ if(g_objNumbers)
+ g_objNumbers.show();
+ }
+
+ if(g_objArrowLeft && g_options.lightbox_hide_arrows_onvideoplay == true){
+ g_objArrowLeft.show();
+ g_objArrowRight.show();
+ }
+
+ }
+
+ /**
+ * on gallery keypres, do operations
+ */
+ function onKeyPress(data, key, event){
+
+ var isScrollKey = false;
+
+ switch(key){
+ case 27: //escape - close lightbox
+ if(g_temp.isOpened == true)
+ t.close("keypress");
+ break;
+ case 38: //up and down arrows
+ case 40:
+ case 33: //page up and down
+ case 34:
+ isScrollKey = true;
+ break;
+ }
+
+ if(g_temp.isOpened == true && isScrollKey == true)
+ event.preventDefault();
+
+
+ }
+
+ /**
+ * on image mouse enter event
+ */
+ function onImageMouseEnter(){
+
+ if(g_temp.isArrowsOnHoverMode == true)
+ showArrows(false, true);
+
+ }
+
+ /**
+ * on image mouse leave
+ */
+ function onImageMouseLeave(event){
+
+ g_temp.positionFrom = "hideCompactElements";
+
+ if(g_temp.isArrowsOnHoverMode == true && isSliderImageInPlace() == true)
+ hideArrows(false, true);
+
+ }
+
+
+ /**
+ * on mouse move event
+ * show arrows if inside image
+ */
+ function onMouseMove(event){
+ g_temp.lastMouseX = event.pageX;
+ g_temp.lastMouseY = event.pageY;
+
+ var isHidden = isArrowsHidden()
+
+
+ if(isHidden == true && isMouseInsideImage() && g_objSlider.isAnimating() == false){
+ g_temp.positionFrom = "onMouseMove";
+ if(g_objArrowLeft && g_objArrowLeft.is(":animated") == false)
+ showArrows(false, true);
+ }
+
+ }
+
+
+ /**
+ * on mouse wheel
+ */
+ function onMouseWheel(event, delta, deltaX, deltaY){
+
+ if(g_temp.isOpened == false)
+ return(true);
+
+ switch(g_options.gallery_mousewheel_role){
+ default:
+ case "zoom":
+ var slideType = g_objSlider.getSlideType();
+ if(slideType != "image")
+ event.preventDefault();
+ break;
+ case "none":
+ event.preventDefault();
+ break;
+ case "advance":
+ g_gallery.onGalleryMouseWheel(event, delta, deltaX, deltaY);
+ break;
+ }
+
+ }
+
+
+ /**
+ * init events
+ */
+ function initEvents(){
+
+ g_objOverlay.on("touchstart", function(event){
+ event.preventDefault();
+ });
+
+ g_objOverlay.on("touchend", function(event){
+ t.close("overlay");
+ });
+
+
+ g_functions.addClassOnHover(g_objArrowRight, "ug-arrow-hover");
+ g_functions.addClassOnHover(g_objArrowLeft, "ug-arrow-hover");
+
+ g_functions.addClassOnHover(g_objButtonClose);
+
+ g_gallery.setNextButton(g_objArrowRight);
+ g_gallery.setPrevButton(g_objArrowLeft);
+
+ g_objButtonClose.click(function(){
+ t.close("button");
+ });
+
+ g_objGallery.on(g_gallery.events.ITEM_CHANGE, onItemChange);
+
+ if(g_objSlider){
+ jQuery(g_objSlider).on(g_objSlider.events.TRANSITION_END, onSliderTransitionEnd);
+
+ //on slider click event
+ jQuery(g_objSlider).on(g_objSlider.events.CLICK, onSliderClick);
+
+ //on slider video
+ var objVideo = g_objSlider.getVideoObject();
+
+ jQuery(objVideo).on(objVideo.events.PLAY_START, onPlayVideo);
+ jQuery(objVideo).on(objVideo.events.PLAY_STOP, onStopVideo);
+
+ //handle close button hide / appear
+ jQuery(g_objSlider).on(g_objSlider.events.START_DRAG, onSliderDragStart);
+ jQuery(g_objSlider).on(g_objSlider.events.TRANSITION_START, onSliderDragStart);
+
+ jQuery(g_objSlider).on(g_objSlider.events.AFTER_DRAG_CHANGE, onSliderAfterReturn);
+ jQuery(g_objSlider).on(g_objSlider.events.AFTER_RETURN, onSliderAfterReturn);
+ jQuery(g_objSlider).on(g_objSlider.events.AFTER_PUT_IMAGE, onSliderAfterPutImage);
+
+ jQuery(g_objSlider).on(g_objSlider.events.ZOOM_CHANGE, onZoomChange);
+
+ jQuery(g_objSlider).on(g_objSlider.events.IMAGE_MOUSEENTER, onImageMouseEnter);
+ jQuery(g_objSlider).on(g_objSlider.events.IMAGE_MOUSELEAVE, onImageMouseLeave);
+
+ }
+
+ //on resize
+ jQuery(window).resize(function(){
+
+ if(g_temp.isOpened == false)
+ return(true);
+
+ g_functions.whenContiniousEventOver("lightbox_resize", onResize, 100);
+ });
+
+ g_objGallery.on(g_gallery.events.GALLERY_KEYPRESS, onKeyPress);
+
+ //store last mouse x and y
+ if(g_temp.isArrowsOnHoverMode == true){
+
+ jQuery(document).bind('mousemove', onMouseMove);
+
+ }
+
+ //on mouse wheel - disable functionality if video
+ g_objWrapper.on("mousewheel", onMouseWheel);
+
+ }
+
+
+ /**
+ * destroy the lightbox events and the html it created
+ */
+ this.destroy = function(){
+
+ jQuery(document).unbind("mousemove");
+
+ g_objOverlay.off("touchstart");
+ g_objOverlay.off("touchend");
+ g_objButtonClose.off("click");
+ g_objGallery.off(g_gallery.events.ITEM_CHANGE);
+
+ if(g_objSlider){
+ jQuery(g_objSlider).off(g_objSlider.events.TRANSITION_END);
+ jQuery(g_objSlider).off(g_objSlider.events.CLICK);
+ jQuery(g_objSlider).off(g_objSlider.events.START_DRAG);
+ jQuery(g_objSlider).off(g_objSlider.events.TRANSITION_START);
+ jQuery(g_objSlider).off(g_objSlider.events.AFTER_DRAG_CHANGE);
+ jQuery(g_objSlider).off(g_objSlider.events.AFTER_RETURN);
+
+ var objVideo = g_objSlider.getVideoObject();
+ jQuery(objVideo).off(objVideo.events.PLAY_START);
+ jQuery(objVideo).off(objVideo.events.PLAY_STOP);
+
+ jQuery(g_objSlider).on(g_objSlider.events.IMAGE_MOUSEENTER, onImageMouseEnter);
+ jQuery(g_objSlider).on(g_objSlider.events.IMAGE_MOUSELEAVE, onImageMouseLeave);
+
+ g_objSlider.destroy();
+ }
+
+ jQuery(window).unbind("resize");
+ g_objGallery.off(g_gallery.events.GALLERY_KEYPRESS, onKeyPress);
+
+ g_objWrapper.off("mousewheel");
+
+ //remove the html
+ g_objWrapper.remove();
+ }
+
+
+ /**
+ * open the lightbox with some item index
+ */
+ this.open = function(index){
+
+ var objItem = g_gallery.getItem(index);
+
+ g_temp.isOpened = true;
+
+ //set if the panel right now opened
+ g_temp.isRightNowOpened = true;
+ setTimeout(function(){g_temp.isRightNowOpened = false},100);
+
+ if(g_objSlider){
+ g_objSlider.setItem(objItem, "lightbox_open");
+ }
+
+ if(g_objTextPanel){
+ g_objTextPanel.setTextPlain(objItem.title, objItem.description);
+ }
+
+ g_objOverlay.stop().fadeTo(0,0);
+ g_objWrapper.show();
+ g_objWrapper.fadeTo(0,1);
+
+ //show the overlay
+ g_objOverlay.stop().fadeTo(g_temp.fadeDuration, g_options.lightbox_overlay_opacity);
+
+ positionElements();
+
+ if(g_temp.isCompact == true){
+
+ var isPreloading = g_objSlider.isPreloading();
+ if(isPreloading == true){
+
+ actualHideCompactElements();
+
+ }else{
+
+ //hide only arrows if they are inside
+ if(g_temp.isArrowsInside == true){
+ g_objArrowLeft.hide();
+ g_objArrowRight.hide();
+ }
+
+ }
+
+ }
+
+ if(g_objSlider)
+ g_objSlider.startSlideAction();
+
+ //trigger gallery event
+ g_objGallery.trigger(g_gallery.events.OPEN_LIGHTBOX, objItem);
+
+ }
+
+
+ /**
+ * close the lightbox
+ */
+ this.close = function(fromWhere){
+
+ g_temp.isOpened = false;
+
+ if(g_temp.isCompact == true)
+ hideCompactElements();
+
+ if(g_objSlider)
+ g_objSlider.stopSlideAction();
+
+ var slideType = g_objSlider.getSlideType();
+
+ if(slideType != "image")
+ g_objWrapper.hide();
+ else{
+ g_objWrapper.fadeTo(g_temp.fadeDuration,0,function(){
+ g_objWrapper.hide();
+ });
+ }
+
+ g_objGallery.trigger(g_gallery.events.CLOSE_LIGHTBOX);
+
+ }
+
+
+ /**
+ * external init function
+ */
+ this.init = function(gallery, customOptions){
+
+ initLightbox(gallery, customOptions);
+ }
+
+
+ /**
+ * switch to wide mode from compact mode
+ */
+ function switchToWide(){
+ g_temp.isCompact = false;
+ modifyOptions();
+
+ g_temp.isArrowsInside = false;
+ g_temp.isArrowsOnHoverMode = false;
+
+ g_options = jQuery.extend({}, g_temp.originalOptions);
+
+ g_options.lightbox_arrows_position = "sides";
+
+ g_objSlider.setOptions(g_options);
+ }
+
+
+ /**
+ * external put html function
+ */
+ this.putHtml = function(){
+
+ //check if switch to wide mode
+ var isSmallWindow = g_gallery.isSmallWindow();
+
+ if(isSmallWindow && g_temp.isCompact == true)
+ switchToWide();
+
+ putLightboxHtml();
+ }
+
+
+ /**
+ * run lightbox elements
+ */
+ this.run = function(){
+
+ setProperties();
+
+ if(g_objSlider)
+ g_objSlider.run();
+
+ initEvents();
+ }
+
+
+
+}
+
+
+
+/**
+ * carousel class
+ */
+function UGCarousel(){
+
+ var t = this, g_objThis = jQuery(this);
+ var g_gallery = new UniteGalleryMain(), g_objGallery, g_objWrapper;
+ var g_functions = new UGFunctions(), g_arrItems, g_objTileDesign = new UGTileDesign();
+ var g_thumbs = new UGThumbsGeneral(), g_objCarouselWrapper, g_objInner, arrOrigTiles = [];
+
+ var g_options = {
+ carousel_padding: 8, //padding at the sides of the carousel
+ carousel_space_between_tiles: 20, //space between tiles
+ carousel_navigation_numtiles:3, //number of tiles to scroll when user clicks on next/prev button
+ carousel_scroll_duration:500, //duration of scrolling to tile
+ carousel_scroll_easing:"easeOutCubic", //easing of scrolling to tile animation
+
+ carousel_autoplay: true, //true,false - autoplay of the carousel on start
+ carousel_autoplay_timeout: 3000, //autoplay timeout
+ carousel_autoplay_direction: "right", //left,right - autoplay direction
+ carousel_autoplay_pause_onhover: true, //pause the autoplay on mouse over
+ carousel_vertical_scroll_ondrag: false //vertical screen scroll on carousel drag
+ };
+
+ this.events = {
+ START_PLAY: "carousel_start_play",
+ PAUSE_PLAY: "carousel_pause_play",
+ STOP_PLAY: "carousel_stop_play"
+ };
+
+ var g_temp = {
+ eventSizeChange: "thumb_size_change",
+ isFirstTimeRun:true, //if run once
+ carouselMaxWidth: null,
+ tileWidth:0,
+ initTileWidth:0,
+ initTileHeight:0,
+ sideSpace:1500, //the space that must be filled with items
+ spaceActionSize:500,
+ numCurrent:0,
+ touchActive: false,
+ startInnerPos: 0,
+ lastTime:0,
+ startTime:0,
+ startMousePos:0,
+ lastMousePos:0,
+ scrollShortDuration: 200,
+ scrollShortEasing: "easeOutQuad",
+ handle:null,
+ isPlayMode: false,
+ isPaused: false,
+ storedEventID: "carousel"
+ };
+
+
+ function __________GENERAL_________(){};
+
+ /**
+ * init the gallery
+ */
+ function init(gallery, customOptions){
+
+ g_objects = gallery.getObjects();
+ g_gallery = gallery;
+ g_objGallery = jQuery(gallery);
+ g_objWrapper = g_objects.g_objWrapper;
+ g_arrItems = g_objects.g_arrItems;
+
+ g_options = jQuery.extend(g_options, customOptions);
+
+ g_objTileDesign.setFixedMode();
+ g_objTileDesign.setApproveClickFunction(isApproveTileClick);
+ g_objTileDesign.init(gallery, g_options);
+
+ g_thumbs = g_objTileDesign.getObjThumbs();
+ g_options = g_objTileDesign.getOptions();
+
+ g_temp.initTileWidth = g_options.tile_width;
+ g_temp.initTileHeight = g_options.tile_height;
+
+ g_temp.tileWidth = g_options.tile_width;
+ }
+
+
+ /**
+ * set the grid panel html
+ */
+ function setHtml(objParent){
+
+ if(!objParent)
+ var objParent = g_objWrapper;
+
+ var html = "
",e.append(t),s=e.children(".ug-videoplayer"),l=s.children(".ug-videoplayer-youtube"),u=s.children(".ug-videoplayer-vimeo"),d=s.children(".ug-videoplayer-html5"),g=s.children(".ug-videoplayer-soundcloud"),c=s.children(".ug-videoplayer-wistia"),0==T.standAloneMode&&1==E.video_enable_closebutton&&(_=s.children(".ug-videoplayer-button-close"))},this.destroy=function(){_&&(_.off("click"),_.off("touchend")),jQuery(m).off(m.events.START_PLAYING),jQuery(m).off(m.events.STOP_PLAYING),jQuery(v).off(v.events.START_PLAYING),jQuery(v).off(v.events.STOP_PLAYING),jQuery(b).off(b.events.START_PLAYING),jQuery(b).off(b.events.STOP_PLAYING),jQuery(y).off(y.events.START_PLAYING,t),jQuery(y).off(y.events.STOP_PLAYING,i),jQuery(I).off(I.events.START_PLAYING,t),jQuery(I).off(I.events.STOP_PLAYING,i),w=null},this.initEvents=function(){r()},this.setSize=function(e,t){f.setElementSize(s,e,t),_&&f.placeElement(_,"right","top")},this.setPosition=function(e,t){f.placeElement(s,e,t)},this.getObject=function(){return s},this.show=function(){return 1==h.isVisible()?!0:(s.show(),s.fadeTo(0,1),_&&_.show(),void p.trigger(h.events.SHOW))},this.hide=function(){return 0==h.isVisible()?!0:(o(),w=null,s.hide(),void p.trigger(h.events.HIDE))},this.getActiveAPI=function(){switch(w){case"youtube":return m;case"vimeo":return v;case"wistia":return I;case"soundcloud":return y;case"html5":return b;default:return null}},this.pause=function(){var e=h.getActiveAPI();return null==e?!1:void("function"==typeof e.pause&&e.pause())},this.isVisible=function(){return s.is(":visible")},this.playYoutube=function(e,t){if("undefined"==typeof t)var t=!0;o("youtube"),l.show();var i=l.children("#"+T.youtubeInnerID);0==i.length&&l.append(""),1==m.isPlayerReady()&&1==T.standAloneMode?m.changeVideo(e,t):m.putVideo(T.youtubeInnerID,e,"100%","100%",t),w="youtube"},this.playVimeo=function(e,t){if("undefined"==typeof t)var t=!0;o("vimeo"),u.show(),v.putVideo(T.vimeoPlayerID,e,"100%","100%",t),w="vimeo"},this.playHtml5Video=function(e,t,i,n,r){if("undefined"==typeof r)var r=!0;o("html5"),d.show();var a={ogv:e,webm:t,mp4:i,posterImage:n};b.putVideo(T.html5PlayerID,a,"100%","100%",r),w="html5"},this.playSoundCloud=function(e,t){if("undefined"==typeof t)var t=!0;o("soundcloud"),g.show(),y.putSound(T.soundCloudPlayerID,e,"100%","100%",t),w="soundcloud"},this.playWistia=function(e,t){if("undefined"==typeof t)var t=!0;o("wistia"),c.show(),I.putVideo(T.wistiaPlayerID,e,"100%","100%",t),w="wistia"}}function ugCheckForMinJQueryVersion(){var e=g_ugFunctions.checkMinJqueryVersion("1.8.0");if(0==e)throw new Error("The gallery can run from jquery 1.8 You have jQuery "+jQuery.fn.jquery+" Please update your jQuery library.")}function ugCheckForErrors(e,t){function i(){if("undefined"==typeof jQuery)throw new Error("jQuery library not included")}function n(){if("function"==typeof jQuery.fn.unitegallery)return!0;var e="You have some jquery.js library include that comes after the gallery files js include.";throw e+=" This include eliminates the gallery libraries, and make it not work.","cms"==t?(e+="
To fix it you can: 1. In the Gallery Settings -> Troubleshooting set option: Put JS Includes To Body option to true.",e+=" 2. Find the double jquery.js include and remove it."):e+="
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.",new Error(e)}try{"jquery"==t?(i(),ugCheckForMinJQueryVersion()):(ugCheckForMinJQueryVersion(),n())}catch(r){var o=r.message;if(o="Unite Gallery Error: "+o,o="
"+o+"
","jquery"==t){var a=document.getElementById(e);a.innerHTML=o,a.style.display="block"}else jQuery(e).show().html(o);return!1}return!0}function UniteGalleryMain(){function __________INIT_GALLERY_______(){}function getThemeFunction(e){var t=e;return-1==t.indexOf("UGTheme_")&&(t="UGTheme_"+t),t}function initTheme(objCustomOptions){if(objCustomOptions.hasOwnProperty("gallery_theme"))g_options.gallery_theme=objCustomOptions.gallery_theme;else{var defaultTheme=g_options.gallery_theme;0==g_ugFunctions.isThemeRegistered(defaultTheme)&&(g_options.gallery_theme=g_ugFunctions.getFirstRegisteredTheme())}var themeFunction=getThemeFunction(g_options.gallery_theme);try{g_options.gallery_theme=eval(themeFunction)}catch(e){}g_options.gallery_theme=eval(themeFunction),g_objTheme=new g_options.gallery_theme,g_objTheme.init(t,objCustomOptions)}function resetOptions(){g_options=jQuery.extend({},g_temp.originalOptions),g_selectedItemIndex=-1,g_selectedItem=null,g_objSlider=void 0,g_objThumbs=void 0,g_objSlider=void 0}function checkForStartupErrors(){try{ugCheckForMinJQueryVersion()}catch(e){throwErrorShowMessage(e.message)}"object"==typeof g_objWrapper.outerWidth()&&throwErrorShowMessage("You have some buggy script. most chances jquery-ui.js that destroy jquery outerWidth, outerHeight functions. The gallery can't run. Please update jquery-ui.js to latest version."),setTimeout(function(){ugCheckForErrors(g_galleryID,"cms")},5e3)}function runGallery(e,i,n,r){var o="object"==typeof i;if(o&&(g_temp.objCustomOptions=i),1==g_temp.isRunFirstTime){if(g_galleryID=e,g_objWrapper=jQuery(g_galleryID),0==g_objWrapper.length)return trace("div with id: "+g_galleryID+" not found"),!1;g_objParent=g_objWrapper.parent(),checkForStartupErrors(),g_temp.originalOptions=jQuery.extend({},g_options),o&&(g_options=jQuery.extend(g_options,i)),1==g_options.gallery_enable_cache&&g_options.gallery_initial_catid&&cacheItems(g_options.gallery_initial_catid),t.setSizeClass();var a=g_objWrapper.children();fillItemsArray(a),loadAPIs(),g_objWrapper.find("img").fadeTo(0,0).hide(),g_objWrapper.show(),clearInitData()}else if(t.destroy(),resetOptions(),g_options=jQuery.extend(g_options,g_temp.objCustomOptions),n){if(r&&1==g_options.gallery_enable_cache&&cacheItems(r,n),"noitems"==n)return showErrorMessage("No items in this category",""),!1;g_objWrapper.html(n);var a=g_objWrapper.children();fillItemsArray(a),loadAPIs(),g_objWrapper.children().fadeTo(0,0).hide(),g_objWrapper.show(),clearInitData()}1==g_temp.isRunFirstTime&&1==g_options.gallery_enable_tabs&&(g_objTabs=new UGTabs,g_objTabs.init(t,g_options)),1==g_temp.isRunFirstTime&&1==g_options.gallery_enable_loadmore&&(g_objLoadMore=new UGLoadMore,g_objLoadMore.init(t,g_options)),o&&modifyInitParams(g_temp.objCustomOptions),validateParams(),1==g_options.gallery_shuffle&&t.shuffleItems(),initTheme(g_temp.objCustomOptions),setGalleryHtml(),setHtmlObjectsProperties();var s=g_objWrapper.width();0==s?g_functions.waitForWidth(g_objWrapper,runGalleryActually):runGalleryActually()}function runGalleryActually(){t.setSizeClass(),0==g_temp.isFreestyleMode&&1==g_options.gallery_preserve_ratio&&setHeightByOriginalRatio(),g_objTheme.run(),g_objTabs&&g_temp.isRunFirstTime&&g_objTabs.run(),preloadBigImages(),initEvents(),g_numItems>0&&t.selectItem(0),1==g_options.gallery_autoplay&&t.startPlayMode(),g_temp.isRunFirstTime=!1}function showErrorMessage(e,t){if("undefined"==typeof t)var t="Unite Gallery Error: ";else t=""+t+": ";e=t+e;var i="
"+e+"
";g_objWrapper.children().remove(),g_objWrapper.html(i),g_objWrapper.show()}function throwErrorShowMessage(e){throw showErrorMessage(e),new Error(e)}function modifyInitParams(){g_options.gallery_images_preload_type||(g_options.gallery_images_preload_type="minimal"),(void 0==g_options.gallery_min_height||g_options.gallery_heightgallery_height option must be bigger then gallery_min_height option");if(g_options.gallery_widthgallery_width option must be bigger then gallery_min_width option")}function setGalleryHtml(){g_objWrapper.addClass("ug-gallery-wrapper"),g_objWrapper.append(""),t.setSizeClass()}function clearInitData(){g_objWrapper.children().remove()}function storeLastSize(){var e=t.getSize();g_temp.lastWidth=e.width,g_temp.lastHeight=e.height}function setHeightByOriginalRatio(){var e=t.getSize(),i=e.width/e.height;if(i!=e.orig_ratio){var n=e.width/e.orig_ratio;n=Math.round(n),ni;i++)g_arrItems[i].isNewAdded=!1;for(var i=0;i").attr("src",i),e.objPreloadImage.data("itemIndex",e.index),e.objPreloadImage.on("load",t.onItemBigImageLoaded),e.objPreloadImage.on("error",function(){var e=jQuery(this),i=e.data("itemIndex"),n=g_arrItems[i];n.isBigImageLoadError=!0,n.isBigImageLoaded=!1;var r=jQuery(this).attr("src");console.log("Can't load image: "+r),g_objGallery.trigger(t.events.ITEM_IMAGE_UPDATED,[i,n.urlImage]),n.objThumbImage.attr("src",n.urlThumb)}),void checkAllItemsStartedPreloading())}function preloadNearBigImages(e){if(1==g_temp.isAllItemsPreloaded)return!1;if(!e)var e=g_selectedItem;if(!e)return!0;var t=e.index,i=t-1,n=t+1;i>0&&preloadItemImage(g_arrItems[i]),g_numItems>n&&preloadItemImage(g_arrItems[n])}function checkAllItemsStartedPreloading(){if(1==g_temp.isAllItemsPreloaded)return!1;for(var e in g_arrItems)if(0==g_arrItems[e].isBigImageLoadStarted)return!1;g_temp.isAllItemsPreloaded=!0}function __________END_INIT_GALLERY_______(){}function __________EVENTS_____________(){}function onSliderMouseEnter(e){1==g_options.gallery_pause_on_mouseover&&0==t.isFullScreen()&&1==g_temp.isPlayMode&&g_objSlider&&0==g_objSlider.isSlideActionActive()&&t.pausePlaying()}function onSliderMouseLeave(e){if(1==g_options.gallery_pause_on_mouseover&&1==g_temp.isPlayMode&&g_objSlider&&0==g_objSlider.isSlideActionActive()){var i=g_objSlider.isCurrentSlideLoadingImage();0==i&&t.continuePlaying()}}function onKeyPress(e){var i=jQuery(e.target);if(i.is("textarea")||i.is("select")||i.is("input"))return!0;var n=e.charCode?e.charCode:e.keyCode?e.keyCode:e.which?e.which:0,r=!0;switch(n){case 39:t.nextItem();break;case 37:t.prevItem();break;default:r=!1}1==r&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()),g_objGallery.trigger(t.events.GALLERY_KEYPRESS,[n,e])}function onGalleryResized(){var e=t.getSize();if(0==e.width)return!0;t.setSizeClass();var e=t.getSize();if(e.width!=g_temp.lastWidth||0==g_temp.isFreestyleMode&&e.height!=g_temp.lastHeight){var i=!1;if(g_temp.funcCustomHeight){var n=g_temp.funcCustomHeight(e);n&&(g_objWrapper.height(n),i=!0)}0==i&&1==g_options.gallery_preserve_ratio&&0==g_temp.isFreestyleMode&&setHeightByOriginalRatio(),storeLastSize(),g_objGallery.trigger(t.events.SIZE_CHANGE)}}function onThumbsChange(e){"visible"==g_options.gallery_images_preload_type&&0==g_temp.isAllItemsPreloaded&&preloadBigImages()}function onFullScreenChange(){var e=g_functions.isFullScreen(),i=e?t.events.ENTER_FULLSCREEN:t.events.EXIT_FULLSCREEN,n=g_functions.getGlobalData("fullscreenID");return g_galleryID!==n?!0:(e?g_objWrapper.addClass("ug-fullscreen"):g_objWrapper.removeClass("ug-fullscreen"),g_objGallery.trigger(i),void onGalleryResized())}function onItemImageUpdated(e,i){var n=t.getItem(i);checkPreloadItemImage(n)}function onCurrentSlideImageLoadEnd(){1==t.isPlayMode()&&t.continuePlaying()}function initEvents(){if(g_objWrapper.on("dragstart",function(e){e.preventDefault()}),g_objGallery.on(t.events.ITEM_IMAGE_UPDATED,onItemImageUpdated),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)}if("advance"==g_options.gallery_mousewheel_role&&0==g_temp.isFreestyleMode&&g_objWrapper.on("mousewheel",t.onGalleryMouseWheel),storeLastSize(),jQuery(window).resize(function(){g_objWrapper.css("width","auto"),g_functions.whenContiniousEventOver("gallery_resize",onGalleryResized,g_temp.resizeDelay)}),setTimeout(function(){setInterval(onGalleryResized,2e3)},1e4),g_functions.addFullScreenChangeEvent(onFullScreenChange),g_objSlider){if(jQuery(g_objSlider).on(g_objSlider.events.ITEM_CHANGED,function(){var e=g_objSlider.getCurrentItemIndex();-1!=e&&t.selectItem(e)}),1==g_options.gallery_pause_on_mouseover){var e=g_objSlider.getElement();e.hover(onSliderMouseEnter,onSliderMouseLeave),g_objGallery.on(t.events.ENTER_FULLSCREEN,function(){onSliderMouseLeave()})}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),jQuery(g_objSlider).on(g_objSlider.events.CURRENTSLIDE_LOAD_END,onCurrentSlideImageLoadEnd)}1==g_options.gallery_control_keyboard&&jQuery(document).keydown(onKeyPress)}function __________GENERAL_______(){}function cacheItems(e,t){if(t){var i=t;"noitems"!=i&&(i=jQuery(t).clone())}else var i=g_objWrapper.children().clone();g_objCache[e]=i}function removeAllSizeClasses(e){e||(e=g_objWrapper),e.removeClass("ug-under-480"),e.removeClass("ug-under-780"),e.removeClass("ug-under-960")}function retriggerEvent(e,t,i){jQuery(e).on(t,function(e){g_objGallery.trigger(i,[this])})}function advanceNextStep(){var e=jQuery.now(),i=e-g_temp.playTimeLastStep;g_temp.playTimeLastStep=e;var n=t.isGalleryVisible();if(0==n)return!1;if(g_temp.playTimePassed+=i,g_temp.objProgress){var r=g_temp.playTimePassed/g_options.gallery_play_interval;g_temp.objProgress.setProgress(r)}g_temp.playTimePassed>=g_options.gallery_play_interval&&(t.nextItem(),g_temp.playTimePassed=0)}function unselectSeletedItem(){return null==g_selectedItem?!0:(g_objThumbs&&g_objThumbs.setThumbUnselected(g_selectedItem.objThumbWrapper),g_selectedItem=null,void(g_selectedItemIndex=-1))}function toFakeFullScreen(){jQuery("body").addClass("ug-body-fullscreen"),g_objWrapper.addClass("ug-fake-fullscreen"),g_temp.isFakeFullscreen=!0,g_objGallery.trigger(t.events.ENTER_FULLSCREEN),g_objGallery.trigger(t.events.SIZE_CHANGE)}function exitFakeFullscreen(){jQuery("body").removeClass("ug-body-fullscreen"),g_objWrapper.removeClass("ug-fake-fullscreen"),g_temp.isFakeFullscreen=!1,g_objGallery.trigger(t.events.EXIT_FULLSCREEN),g_objGallery.trigger(t.events.SIZE_CHANGE)}var t=this,g_galleryID,g_objGallery=jQuery(t),g_objWrapper,g_objParent,g_objThumbs,g_objSlider,g_functions=new UGFunctions,g_objTabs,g_objLoadMore,g_arrItems=[],g_numItems,g_selectedItem=null,g_selectedItemIndex=-1,g_objTheme,g_objCache={};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",GALLERY_BEFORE_REQUEST_ITEMS:"gallery_before_request_items",OPEN_LIGHTBOX:"open_lightbox",CLOSE_LIGHTBOX:"close_lightbox"};var g_options={gallery_width:900,gallery_height:500,gallery_min_width:150,gallery_min_height:100,gallery_theme:"default",gallery_skin:"default",gallery_images_preload_type:"minimal",gallery_autoplay:!1,gallery_play_interval:3e3,gallery_pause_on_mouseover:!0,gallery_mousewheel_role:"zoom",gallery_control_keyboard:!0,gallery_carousel:!0,gallery_preserve_ratio:!0,gallery_background_color:"",gallery_debug_errors:!1,gallery_shuffle:!1,gallery_urlajax:null,gallery_enable_tabs:!1,gallery_enable_loadmore:!1,gallery_enable_cache:!0,gallery_initial_catid:""},g_temp={objCustomOptions:{},isAllItemsPreloaded:!1,isFreestyleMode:!1,lastWidth:0,lastHeigh:0,handleResize:null,isInited:!1,isPlayMode:!1,isPlayModePaused:!1,playTimePassed:0,playTimeLastStep:0,playHandle:"",playStepInterval:33,objProgress:null,isFakeFullscreen:!1,thumbsType:null,isYoutubePresent:!1,isVimeoPresent:!1,isHtml5VideoPresent:!1,isSoundCloudPresent:!1,isWistiaPresent:!1,resizeDelay:100,isRunFirstTime:!0,originalOptions:{},funcCustomHeight:null};this.onItemBigImageLoaded=function(e,t){if(!t)var t=jQuery(this);var i=t.data("itemIndex"),n=g_arrItems[i];n.isBigImageLoaded=!0;var r=g_functions.getImageOriginalSize(t);n.imageWidth=r.width,n.imageHeight=r.height},this.checkFillImageSize=function(e,t){if(!t){var i=e.data("itemIndex");if(void 0===i)throw new Error("Wrong image given to gallery.checkFillImageSize");var t=g_arrItems[i]}var n=g_functions.getImageOriginalSize(e);t.imageWidth=n.width,t.imageHeight=n.height},this.setFreestyleMode=function(){g_temp.isFreestyleMode=!0},this.attachThumbsPanel=function(e,t){g_temp.thumbsType=e,g_objThumbs=t},this.initSlider=function(e,i){if(!e)var e={};e=jQuery.extend(g_temp.objCustomOptions,e),g_objSlider=new UGSlider,g_objSlider.init(t,e,i)},this.onGalleryMouseWheel=function(e,i,n,r){e.preventDefault(),i>0?t.prevItem():t.nextItem()},this.destroy=function(){if(g_objWrapper.off("dragstart"),g_objGallery.off(t.events.ITEM_IMAGE_UPDATED),g_objThumbs)switch(g_temp.thumbsType){case"strip":jQuery(g_objThumbs).off(g_objThumbs.events.STRIP_MOVE);break;case"grid":jQuery(g_objThumbs).off(g_objThumbs.events.PANE_CHANGE)}if(g_objWrapper.off("mousewheel"),jQuery(window).off("resize"),g_functions.destroyFullScreenChangeEvent(),g_objSlider){jQuery(g_objSlider).off(g_objSlider.events.ITEM_CHANGED);var e=g_objSlider.getElement();e.off("mouseenter"),e.off("mouseleave"),g_objGallery.off(t.events.ENTER_FULLSCREEN),jQuery(g_objSlider).off(g_objSlider.events.ACTION_START),jQuery(g_objSlider).off(g_objSlider.events.ACTION_END),jQuery(g_objSlider).off(g_objSlider.events.CURRENTSLIDE_LOAD_END)}1==g_options.gallery_control_keyboard&&jQuery(document).off("keydown"),g_objTheme&&"function"==typeof g_objTheme.destroy&&g_objTheme.destroy(),g_objWrapper.html("")},this.getArrItems=function(){return g_arrItems},this.getObjects=function(){var e={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 e},this.getObjSlider=function(){return g_objSlider},this.getItem=function(e){if(0>e)throw new Error("item with index: "+e+" not found");if(e>=g_numItems)throw new Error("item with index: "+e+" not found");return g_arrItems[e]},this.getWidth=function(){var e=t.getSize();return e.width},this.getHeight=function(){var e=t.getSize();return e.height},this.getSize=function(){var e=g_functions.getElementSize(g_objWrapper);return e.orig_width=g_options.gallery_width,e.orig_height=g_options.gallery_height,e.orig_ratio=e.orig_width/e.orig_height,e},this.getGalleryID=function(){var e=g_galleryID.replace("#","");return e},this.getNextItem=function(e,t){"object"==typeof e&&(e=e.index);var i=e+1;if(t!==!0&&1==g_numItems)return null;if(i>=g_numItems){if(1!=g_options.gallery_carousel&&t!==!0)return null;i=0}var n=g_arrItems[i];return n},this.getPrevItem=function(e){"object"==typeof e&&(e=e.index);var t=e-1;if(0>t){if(1!=g_options.gallery_carousel&&forceCarousel!==!0)return null;t=g_numItems-1}var i=g_arrItems[t];return i},this.getSelectedItem=function(){return g_selectedItem},this.getSelectedItemIndex=function(){return g_selectedItemIndex},this.getNumItems=function(){return g_numItems},this.isLastItem=function(){return g_selectedItemIndex==g_numItems-1?!0:!1},this.isFirstItem=function(){return 0==g_selectedItemIndex?!0:!1},this.getOptions=function(){return g_options},this.getElement=function(){return g_objWrapper},this.___________SET_CONTROLS___________=function(){},this.setNextButton=function(e){e.data("ug-button",!0),g_functions.setButtonOnClick(e,t.nextItem)},this.setPrevButton=function(e){e.data("ug-button",!0),g_functions.setButtonOnClick(e,t.prevItem)},this.setFullScreenToggleButton=function(e){e.data("ug-button",!0),g_functions.setButtonOnTap(e,t.toggleFullscreen),g_objGallery.on(t.events.ENTER_FULLSCREEN,function(){e.addClass("ug-fullscreenmode")}),g_objGallery.on(t.events.EXIT_FULLSCREEN,function(){e.removeClass("ug-fullscreenmode")})},this.destroyFullscreenButton=function(e){g_functions.destroyButton(e),g_objGallery.off(t.events.ENTER_FULLSCREEN),g_objGallery.off(t.events.EXIT_FULLSCREEN)},this.setPlayButton=function(e){e.data("ug-button",!0),g_functions.setButtonOnClick(e,t.togglePlayMode),g_objGallery.on(t.events.START_PLAY,function(){e.addClass("ug-stop-mode")}),g_objGallery.on(t.events.STOP_PLAY,function(){e.removeClass("ug-stop-mode")})},this.destroyPlayButton=function(e){g_functions.destroyButton(e),g_objGallery.off(t.events.START_PLAY),g_objGallery.off(t.events.STOP_PLAY)},this.setProgressIndicator=function(e){g_temp.objProgress=e},this.setTextContainers=function(e,i){g_objGallery.on(t.events.ITEM_CHANGE,function(){var n=t.getSelectedItem();e.html(n.title),i.html(n.description)})},this.showDisabledOverlay=function(){g_objWrapper.children(".ug-overlay-disabled").show()},this.hideDisabledOverlay=function(){g_objWrapper.children(".ug-overlay-disabled").hide()},this.___________END_SET_CONTROLS___________=function(){},this.___________PLAY_MODE___________=function(){},this.startPlayMode=function(){if(g_temp.isPlayMode=!0,g_temp.isPlayModePaused=!1,g_temp.playTimePassed=0,g_temp.playTimeLastStep=jQuery.now(),g_temp.playHandle=setInterval(advanceNextStep,g_temp.playStepInterval),g_temp.objProgress){var e=g_temp.objProgress.getElement();g_temp.objProgress.setProgress(0),e.show()}g_objGallery.trigger(t.events.START_PLAY),g_objSlider&&1==g_objSlider.isCurrentSlideLoadingImage()&&t.pausePlaying()},this.resetPlaying=function(){return 0==g_temp.isPlayMode?!0:(g_temp.playTimePassed=0,void(g_temp.playTimeLastStep=jQuery.now()))},this.pausePlaying=function(){return 1==g_temp.isPlayModePaused?!0:(g_temp.isPlayModePaused=!0,clearInterval(g_temp.playHandle),void g_objGallery.trigger(t.events.PAUSE_PLAYING))},this.continuePlaying=function(){return 0==g_temp.isPlayModePaused?!0:(g_temp.isPlayModePaused=!1,g_temp.playTimeLastStep=jQuery.now(),void(g_temp.playHandle=setInterval(advanceNextStep,g_temp.playStepInterval)))},this.stopPlayMode=function(){if(g_temp.isPlayMode=!1,clearInterval(g_temp.playHandle),g_temp.playTimePassed=0,g_temp.objProgress){var e=g_temp.objProgress.getElement();e.hide()}g_objGallery.trigger(t.events.STOP_PLAY)},this.isPlayMode=function(){return g_temp.isPlayMode},this.togglePlayMode=function(){0==t.isPlayMode()?t.startPlayMode():t.stopPlayMode()},this.___________GENERAL_EXTERNAL___________=function(){},this.shuffleItems=function(){g_arrItems=g_functions.arrayShuffle(g_arrItems);for(var e in g_arrItems)g_arrItems[e].index=parseInt(e)},this.setOptions=function(e){g_options=jQuery.extend(g_options,e)},this.selectItem=function(e,i){"number"==typeof e&&(e=t.getItem(e));var n=e.index;if(n==g_selectedItemIndex)return!0;if(unselectSeletedItem(),g_selectedItem=e,g_selectedItemIndex=n,g_objGallery.trigger(t.events.ITEM_CHANGE,[e,i]),1==g_temp.isPlayMode){t.resetPlaying();var r=g_objSlider.isCurrentSlideLoadingImage();1==r&&t.pausePlaying()}},this.nextItem=function(){var e=g_selectedItemIndex+1;return 0==g_numItems?!0:0==g_options.gallery_carousel&&e>=g_numItems?!0:(e>=g_numItems&&(e=0),void t.selectItem(e,"next"))},this.prevItem=function(){var e=g_selectedItemIndex-1;return-1==g_selectedItemIndex&&(e=0),0==g_numItems?!0:0==g_options.gallery_carousel&&0>e?!0:(0>e&&(e=g_numItems-1),void t.selectItem(e,"prev"))},this.isFullScreen=function(){return 1==g_temp.isFakeFullscreen?!0:1==g_functions.isFullScreen()?!0:!1},this.isFakeFullscreen=function(){return g_temp.isFakeFullscreen},this.toFullScreen=function(){g_functions.setGlobalData("fullscreenID",g_galleryID);var e=g_objWrapper.get(0),t=g_functions.toFullscreen(e);0==t&&toFakeFullScreen()},this.exitFullScreen=function(){1==g_temp.isFakeFullscreen?exitFakeFullscreen():g_functions.exitFullscreen()},this.toggleFullscreen=function(){0==t.isFullScreen()?t.toFullScreen():t.exitFullScreen()},this.resize=function(e,t,i){g_objWrapper.css("width","auto"),g_objWrapper.css("max-width",e+"px"),t&&g_objWrapper.height(t),i||i===!0||onGalleryResized()},this.setSizeClass=function(e,i){if(!e)var e=g_objWrapper;if(!i)var n=t.getSize(),i=n.width;if(0==i)var i=jQuery(window).width();var r="";return 480>=i?r="ug-under-480":780>=i?r="ug-under-780":960>i&&(r="ug-under-960"),1==e.hasClass(r)?!0:(removeAllSizeClasses(e),void(""!=r&&e.addClass(r)))},this.isMobileMode=function(){return g_objWrapper.hasClass("ug-under-480")?!0:!1},this.isSmallWindow=function(){var e=jQuery(window).width();return e?480>=e?!0:!1:!0},this.isGalleryVisible=function(){var e=g_objWrapper.is(":visible");return e},this.changeItems=function(e,t){if(!e)var e="noitems";runGallery(g_galleryID,"nochange",e,t)},this.addItems=function(e){if(!e||0==e.length)return!1;var t=g_objWrapper.children(".ug-newitems-wrapper");0==t.length&&g_objWrapper.append(""),t=g_objWrapper.children(".ug-newitems-wrapper"),t.append(e);var i=jQuery(t.children());if(fillItemsArray(i,!0),loadAPIs(),!g_objTheme||"function"!=typeof g_objTheme.addItems)throw new Error("addItems function not found in the theme");t.remove(),g_objTheme.addItems()},this.getNewAddedItemsIndexes=function(){var e=[];return jQuery.each(g_arrItems,function(t,i){1==i.isNewAdded&&e.push(t)}),e},this.showErrorMessageReplaceGallery=function(e){showErrorMessage(e)},this.setFuncCustomHeight=function(e){g_temp.funcCustomHeight=e},this.__________EXTERNAL_EVENTS_______=function(){},this.triggerEvent=function(e,t){t?("array"!=jQuery.type(t)&&(t=[t]),g_objGallery.trigger(e,t)):g_objGallery.trigger(e)},this.onEvent=function(e,t){g_objGallery.on(e,t)},this.destroyEvent=function(e){g_objGallery.off(e)},this.__________AJAX_REQUEST_______=function(){},this.ajaxRequest=function(e,t,i,n){if(!i||"function"!=typeof i)throw new Error("ajaxRequest error: success function should be passed");var r=g_options.gallery_urlajax;if(!r||""==r)throw new Error("ajaxRequest error: Ajax url don't passed");if("undefined"==typeof t)var t={};var o={action:"unitegallery_ajax_action",client_action:e,galleryID:g_galleryID,data:t};jQuery.ajax({type:"post",url:g_options.gallery_urlajax,dataType:"json",data:o,success:function(e){if(!e)throw new Error("Empty ajax response!");if(-1==e||0===e)throw new Error("ajax error!!!");if("undefined"==typeof e.success)throw new Error("ajax error!!!");return 0==e.success?(showErrorMessage(e.message,"ajax error"),!1):void i(e)},error:function(e,t,i){console.log("Ajax Error!!! "+t),responseText=e.responseText,n&&"function"==typeof n?n(responseText):trace(responseText)}})},this.requestNewItems=function(e,i,n){var r=g_options.gallery_enable_cache;if(n||(n=e),1==i&&(r=!1),1==r&&g_objCache.hasOwnProperty(n)){var o=g_objCache[n];t.changeItems(o,n)}else g_objGallery.trigger(t.events.GALLERY_BEFORE_REQUEST_ITEMS),t.ajaxRequest("front_get_cat_items",{catid:e},function(e){var i=e.html;t.changeItems(i,n)})},this.run=function(e,t){g_options.gallery_debug_errors;if(t&&t.hasOwnProperty("gallery_debug_errors")&&(g_options.gallery_debug_errors=t.gallery_debug_errors),1==g_options.gallery_debug_errors)try{runGallery(e,t)}catch(i){if("object"==typeof i){var n=i.message,r=i.lineNumber,o=i.fileName;i.stack;n+="
in file: "+o,n+=" line "+r+"",trace(i)}else var n=i;n=n.replace("Error:",""),showErrorMessage(n)}else runGallery(e,t)}}function UGLightbox(){function e(e,i){ie=e,U=jQuery(e),ae=jQuery.extend(ae,le),ae=jQuery.extend(ae,i),se.originalOptions=jQuery.extend({},ae),"compact"==ae.lightbox_type&&(se.isCompact=!0,ae=jQuery.extend(ae,ue),ae=jQuery.extend(ae,i)),t(),1==se.putSlider?(ie.initSlider(ae,"lightbox"),g_objects=e.getObjects(),ne=g_objects.g_objSlider):ne=null,1==ae.lightbox_show_textpanel?oe.init(ie,ae,"lightbox"):oe=null}function t(){1==se.isCompact&&1==ae.lightbox_show_textpanel&&(ae.lightbox_slider_image_padding_bottom=se.initTextPanelHeight),1==se.isCompact&&"inside"==ae.lightbox_arrows_position&&(se.isArrowsInside=!0),1==se.isArrowsInside&&0==ae.lightbox_arrows_inside_alwayson&&(se.isArrowsOnHoverMode=!0),0==ae.lightbox_show_textpanel&&(se.isTopPanelEnabled=!1,se.topPanelHeight=0,ae.lightbox_slider_image_padding_top=0)}function i(){var e="",t="";1==se.isCompact&&(t=" ug-lightbox-compact"),e+="
Committee Attendance for the 6th Parliament
they ratify work that has been processed, deliberated, negotiated and teased out for months, or sometimes even
years, in committees. Therefore attendance of committee meetings is a critical component of an effective
Parliament and for MP accountability.
-
Since the beginning of the Sixth Parliament, PMG has recorded attendance (View Addendum) in Committee meetings.
+
Since the beginning of the Sixth Parliament, PMG has recorded attendance (View Addendum) in Committee meetings.
Our records show an overall attendance rate of 70% in the Sixth Parliament., which is less than the 74% achieved
in the Fifth Parliament.
The COVID lockdown and subsequent regulations limiting social interaction, combined with the fire, which limited
diff --git a/pmg/templates/pr6/statistics/committee-activities.html b/pmg/templates/pr6/statistics/committee-activities.html
index 9ac3f195e..49521cece 100644
--- a/pmg/templates/pr6/statistics/committee-activities.html
+++ b/pmg/templates/pr6/statistics/committee-activities.html
@@ -6,6 +6,369 @@
+
+
+
+
+
Total number of meetings
+
Legislation
+
Oversight Visits
+
International Study Tours
+
Statutory Appointments
+
International Agreements
+
Petitions
+
Tabled Committee Reports
+
+
+
Agriculture, Land Reform & Rural Development
+
163
+
8
+
5
+
1
+
1
+
2
+
0
+
36
+
+
+
Basic Education
+
130
+
1
+
32
+
1
+
0
+
0
+
3
+
48
+
+
+
Communications
+
197
+
3
+
2
+
0
+
8
+
0
+
1
+
92
+
+
+
COGTA
+
179
+
6
+
7
+
0
+
0
+
0
+
13
+
41
+
+
+
Defence and Military Veterans
+
127
+
2
+
6
+
1
+
0
+
0
+
0
+
40
+
+
+
Employment and Labour
+
130
+
2
+
12
+
1
+
0
+
0
+
1
+
35
+
+
+
Finance
+
235
+
33
+
3
+
0
+
1
+
6
+
0
+
71
+
+
+
Forestry. Fisheries & Environment
+
158
+
2
+
2
+
1
+
0
+
0
+
0
+
20
+
+
+
Health
+
160
+
3
+
1
+
0
+
0
+
1
+
0
+
18
+
+
+
Higher Education, Science & Tech
+
250
+
1
+
35
+
1
+
0
+
2
+
0
+
66
+
+
+
Home Affairs
+
155
+
12
+
12
+
0
+
2
+
0
+
4
+
31
+
+
+
Human Settlements*
+
149
+
6
+
5
+
1
+
0
+
0
+
10
+
48
+
+
+
International Relations
+
117
+
1
+
4
+
0
+
0
+
2
+
0
+
37
+
+
+
Justice & Correctional Services
+
324
+
24
+
6
+
0
+
3
+
4
+
0
+
123
+
+
+
Mineral Resources
+
183
+
5
+
6
+
1
+
0
+
0
+
3
+
35
+
+
+
Planning, Monitoring & Evaluation**
+
16
+
1
+
0
+
0
+
0
+
0
+
0
+
5
+
+
+
Police
+
158
+
3
+
13
+
0
+
2
+
0
+
9
+
80
+
+
+
SCOPA
+
208
+
0
+
10
+
1
+
+
+
+
22
+
+
+
Public Enterprises
+
101
+
1
+
7
+
0
+
0
+
0
+
2
+
20
+
+
+
Public Service & Administration
+
132
+
6
+
2
+
0
+
2
+
0
+
1
+
83
+
+
+
Public Works & Infrastructure
+
137
+
1
+
9
+
1
+
0
+
0
+
4
+
31
+
+
+
Small Business Development
+
122
+
1
+
2
+
1
+
0
+
0
+
1
+
20
+
+
+
Social Development
+
149
+
5
+
1
+
1
+
1
+
0
+
2
+
35
+
+
+
Sport, Arts & Culture
+
168
+
1
+
0
+
0
+
1
+
0
+
2
+
21
+
+
+
Appropriations
+
240
+
31
+
3
+
1
+
0
+
1
+
0
+
43
+
+
+
Auditor-General
+
42
+
0
+
0
+
1
+
2
+
0
+
0
+
11
+
+
+
Tourism
+
113
+
0
+
5
+
1
+
0
+
0
+
0
+
23
+
+
+
Trade, Industry & Competition
+
229
+
6
+
5
+
1
+
2
+
2
+
0
+
47
+
+
+
Transport
+
170
+
12
+
5
+
0
+
0
+
3
+
1
+
56
+
+
+
Water and Sanitation***
+
61
+
1
+
7
+
1
+
0
+
0
+
4
+
15
+
+
+
Women, Youth & Persons with Disabilities
+
131
+
2
+
6
+
1
+
3
+
2
+
1
+
39
+
+
+
+
This list only includes Committees overseeing a government portfolio. It excludes the Powers and Privileges Committee, the Section 194 Committee, and committees dealing with internal business, such as the Rules Committee. See the addendum here for the activity of these excluded committees, select, joint and ad hoc committees. This data is from May 2019 until March 2024.
+
* Used to be joined with Water and Sanitation
+ ** Committee only established in 2023
+ **** Used to be joined with Human Settlements
+
+
+
Committees operate as the central cogs of the parliamentary machinery and are the site where most of the legislature’s business is located. While it is often the main chambers that garner attention, they ratify work that has been processed, deliberated, negotiated and teased out for months, or sometimes even years, in committees.
The above table serves as a useful glance at the overall output and activities of portfolio committees during the Sixth Parliament. We combed through the legacy reports of each committee, and where this information was not available, we relied on PMG website data. The number of tabled committee reports was taken from the PMG website.
Over the duration of the Sixth Parliament, there were 6434 meetings – very similar to the Fifth Parliament
@@ -13,9 +376,9 @@
35 Portfolio Committees
-
12 Select Committees
-
7 Joint Committees
-
8 Ad Hoc Committee
+
12 Select Committees
+
7 Joint Committees
+
8 Ad Hoc Committee
Over the Fifth Parliament, Portfolio Committees held 4979 meetings. This is followed by the Select Committees which collectively held 997 meetings, 92 Ad Hoc Committee meetings and 266 meetings of the Joint Committees
@@ -29,19 +392,22 @@
Statistics and numbers of meetings held, legislation amended, oversight visits embarked on and reports churned out only tell one side of the picture of the performance of committees. While not quantifiable and neatly packed in a table, the real performance of committees is truly measured in the largely intangible impact they made, scrutiny meted out and improved performance of the departments and entities they oversee. If it is to be argued that committees are the primary forum for oversight and accountability, we know oversight is not a once off meeting – it is a continuous cycle of scrutiny.
-
Inquiries Sixth Parliament:
+
+
INQUIRIES OF THE 6TH PARLIAMENT:
Portfolio Committee on Higher Education, Science and Technology: The Committee resolved to conduct an inquiry into the appointment process of Professor P Mbati as the Vice-Chancellor of the Sefako Makgatho University and related matters. The Inquiry process was conducted in 2021 and 2022. The report was completed and tabled
Portfolio Committee on Justice and Correctional Services: in April 2023, the Committee held two sessions to inquire into the escape of convicted murderer and rapist Thabo Bester from Mangaung Correctional Services
+
+
ALMOST THERE:
SCOPA: allegations of the maladministration of public funds at Eskom by the former Eskom CEO, Mr Andre de Ruyter, the Standing Committee on Public Account (SCOPA) has resolved to form an oversight inquiry to test their veracity. The Committee held a series of meetings on the matter in 2023
Portfolio Committee on Police: July 2021 unrest – Committee resolved not to duplicate work of other bodies
Joint Standing Committee on Defence: The Committee did consider a request for investigation against the former Minister of Defence, Nosiviwe Mapisa-Nqakula, and the former Secretary of Defence, Dr Sam Gulube. But there was lack of cooperation from the whistleblower when it was decided to not pursue the matter further
After the devastating fire of January 2022, Parliament moved its business to the Good Hope Building and for the first time, big events like the State of the Nation Address and Budget took place in Cape Town’s City Hall. It also renewed the debate about the relocation of Parliament to Pretoria. A proposed bill was tabled by the EFF leader in this regard but it was later withdrawn.
Throughout the Sixth Parliament, the two Houses held a total of 325 debates in physical, hybrid or virtual full and mini-plenary sessions.
+
+
In our analysis of legislative activity in the Sixth Parliament, we observed that pre-election years were the busiest for the introduction and passing of bills. It is interesting to see this observation mirrored in the above graphs with 2023 (pre-election year) being the busiest for plenary sittings in both Houses.