if(typeof g_ugfunctions != "undefined")
g_ugfunctions.registertheme("default");
else
jquery(document).ready(function(){g_ugfunctions.registertheme("default")});
/**
* default gallery theme
*/
function ugtheme_default(){
var t = this;
var g_gallery = new unitegallerymain(), g_objgallery, g_objects, g_objwrapper;
var g_objbuttonfullscreen, g_objbuttonplay, g_objbuttonhidepanel;
var g_objslider, g_objpanel, g_objstrippanel, g_objtextpanel;
var g_functions = new ugfunctions();
//theme options
var g_options = {
theme_load_slider:true, //this option for debugging only
theme_load_panel:true, //this option for debugging only
theme_enable_fullscreen_button: true, //show, hide the theme fullscreen button. the position in the theme is constant
theme_enable_play_button: false, //show, hide the theme play button. the position in the theme is constant
theme_enable_hidepanel_button: false, //show, hide the hidepanel button
theme_enable_text_panel: false, //enable the panel text panel.
theme_text_padding_left: 20, //left padding of the text in the textpanel
theme_text_padding_right: 5, //right paddin of the text in the textpanel
theme_text_align: "left", //left, center, right - the align of the text in the textpanel
theme_text_type: "description", //title, description, both - text that will be shown on the text panel, title or description or both
theme_hide_panel_under_width: 300 //hide panel under certain browser width, if null, don't hide
};
//default item options:
var g_defaults = {
//slider options:
slider_controls_always_on: true,
slider_zoompanel_align_vert: "top",
slider_zoompanel_offset_vert: 12,
//textpanel options:
slider_textpanel_padding_top: 0,
slider_textpanel_enable_title: false,
slider_textpanel_enable_description: false,
slider_vertical_scroll_ondrag: true,
//strippanel options
strippanel_background_color:"#232323",
strippanel_padding_top:10
};
//options that could not be changed by user
var g_mustoptions = {
slider_enable_text_panel: false,
slider_enable_play_button:false,
slider_enable_fullscreen_button: false,
//text panel options
slider_enable_text_panel: false,
slider_textpanel_height: 50,
slider_textpanel_align:"top",
};
var g_temp = {
ispanelhidden: false
};
/**
* init the theme
*/
function inittheme(gallery, customoptions){
g_gallery = gallery;
g_options = jquery.extend(g_options, g_defaults);
g_options = jquery.extend(g_options, customoptions);
g_options = jquery.extend(g_options, g_mustoptions);
modifyoptions();
//set gallery options
g_gallery.setoptions(g_options);
//include gallery elements
if(g_options.theme_load_panel == true){
g_objstrippanel = new ugstrippanel();
g_objstrippanel.init(gallery, g_options);
}
if(g_options.theme_load_slider == true)
g_gallery.initslider(g_options);
g_objects = gallery.getobjects();
//get some objects for local use
g_objgallery = jquery(gallery);
g_objwrapper = g_objects.g_objwrapper;
if(g_options.theme_load_slider == true)
g_objslider = g_objects.g_objslider;
//init text panel
if(g_options.theme_enable_text_panel == true){
g_objtextpanel = new ugtextpanel();
g_objtextpanel.init(g_gallery, g_options, "slider");
}
}
/**
* run the theme
*/
function runtheme(){
sethtml();
initandplaceelements();
initevents();
}
/**
* modify some options before implimenting
*/
function modifyoptions(){
var moreoptions = {
slider_textpanel_css_title:{}, //additional css of the title
slider_textpanel_css_description:{} //additional css of the description
};
g_options = jquery.extend(moreoptions, g_options);
g_options.slider_textpanel_css_title["text-align"] = g_options.theme_text_align;
g_options.slider_textpanel_css_description["text-align"] = g_options.theme_text_align;
switch(g_options.theme_text_type){
case "title":
g_options.slider_textpanel_enable_title = true;
g_options.slider_textpanel_enable_description = false;
break;
case "both":
g_options.slider_textpanel_enable_title = true;
g_options.slider_textpanel_enable_description = true;
break;
default:
case "description": //the description is the default
}
}
/**
* set gallery html elements
*/
function sethtml(){
//add html elements
g_objwrapper.addclass("ug-theme-default");
var htmladd = "";
//add panel
htmladd += "
";
var classbuttonfullscreen = 'ug-default-button-fullscreen';
var classbuttonplay = 'ug-default-button-play';
var classcapturebuttonfullscreen = '.ug-default-button-fullscreen';
var classcapturebuttonplay = '.ug-default-button-play';
if(!g_objtextpanel){ //take the buttons from default theme
classbuttonfullscreen = 'ug-default-button-fullscreen-single';
classbuttonplay = 'ug-default-button-play-single';
classcapturebuttonfullscreen = '.ug-default-button-fullscreen-single';
classcapturebuttonplay = '.ug-default-button-play-single';
}
//add fullscreen button to the panel
if(g_options.theme_enable_fullscreen_button == true)
htmladd += "
";
//add play button to the panel
if(g_options.theme_enable_play_button == true)
htmladd += "
";
//add hide panel button
if(g_options.theme_enable_hidepanel_button)
htmladd += "
";
htmladd += "
";
g_objwrapper.append(htmladd);
//set elements
g_objpanel = g_objwrapper.children(".ug-theme-panel");
if(g_options.theme_enable_fullscreen_button == true)
g_objbuttonfullscreen = g_objpanel.children(classcapturebuttonfullscreen);
if(g_options.theme_enable_play_button == true)
g_objbuttonplay = g_objpanel.children(classcapturebuttonplay);
if(g_options.theme_enable_hidepanel_button == true)
g_objbuttonhidepanel = g_objpanel.children(".ug-default-button-hidepanel");
//set html strip panel to the panel
g_objstrippanel.sethtml(g_objpanel);
//set text panel html to the panel
if(g_objtextpanel)
g_objtextpanel.appendhtml(g_objpanel);
//set slider html
if(g_objslider)
g_objslider.sethtml();
}
/**
* init all the theme's elements and set them to their places
* according gallery's dimentions.
* this function should work on resize too.
*/
function initandplaceelements(){
//create and place thumbs panel:
if(g_options.theme_load_panel){
initpanel();
placepanel();
}
//place the slider
if(g_objslider){
placeslider();
g_objslider.run();
}
}
/**
* init size of the thumbs panel
*/
function initpanel(){
var objgallerysize = g_gallery.getsize();
var gallerywidth = objgallerysize.width;
//init srip panel width
g_objstrippanel.setorientation("bottom");
g_objstrippanel.setwidth(gallerywidth);
g_objstrippanel.run();
//set panel size
var objstrippanelsize = g_objstrippanel.getsize();
var panelheight = objstrippanelsize.height;
if(g_objtextpanel){
panelheight += g_mustoptions.slider_textpanel_height;
if(g_objbuttonhidepanel){
var hidebuttonheight = g_objbuttonhidepanel.outerheight();
panelheight += hidebuttonheight;
}
}
else{
var maxbuttonsheight = 0;
if(g_objbuttonhidepanel)
maxbuttonsheight = math.max(g_objbuttonhidepanel.outerheight(), maxbuttonsheight);
if(g_objbuttonfullscreen)
maxbuttonsheight = math.max(g_objbuttonfullscreen.outerheight(), maxbuttonsheight);
if(g_objbuttonplay)
maxbuttonsheight = math.max(g_objbuttonplay.outerheight(), maxbuttonsheight);
panelheight += maxbuttonsheight;
}
g_functions.setelementsize(g_objpanel, gallerywidth, panelheight);
//position strip panel
var strippanelelement = g_objstrippanel.getelement();
g_functions.placeelement(strippanelelement, "left", "bottom");
//init hide panel button
if(g_objbuttonhidepanel){
var buttontip = g_objbuttonhidepanel.children(".ug-default-button-hidepanel-tip");
g_functions.placeelement(buttontip, "center", "middle");
//set opacity and bg color from the text panel
if(g_objtextpanel){
var objhidebuttonbg = g_objbuttonhidepanel.children(".ug-default-button-hidepanel-bg");
var hidepanelopacity = g_objtextpanel.getoption("textpanel_bg_opacity");
objhidebuttonbg.fadeto(0, hidepanelopacity);
var bgcolor = g_objtextpanel.getoption("textpanel_bg_color");
objhidebuttonbg.css({"background-color":bgcolor});
}
}
//position buttons on the text panel:
var paddingplaybutton = 0;
var panelbuttonsoffsety = 0;
if(g_objbuttonhidepanel){
panelbuttonsoffsety = hidebuttonheight;
}
if(g_objbuttonfullscreen){
g_functions.placeelement(g_objbuttonfullscreen, "right", "top",0 , panelbuttonsoffsety);
paddingplaybutton = g_objbuttonfullscreen.outerwidth();
}
if(g_objbuttonplay){
var buttonplayoffsety = panelbuttonsoffsety;
if(!g_objtextpanel)
buttonplayoffsety++;
g_functions.placeelement(g_objbuttonplay, "right", "top", paddingplaybutton, buttonplayoffsety);
paddingplaybutton += g_objbuttonplay.outerwidth();
}
//run the text panel
if(g_objtextpanel){
var textpaneloptions = {};
textpaneloptions.slider_textpanel_padding_right = g_options.theme_text_padding_right + paddingplaybutton;
textpaneloptions.slider_textpanel_padding_left = g_options.theme_text_padding_left;
if(g_objbuttonhidepanel){
textpaneloptions.slider_textpanel_margin = hidebuttonheight;
}
g_objtextpanel.setoptions(textpaneloptions);
g_objtextpanel.positionpanel();
g_objtextpanel.run();
}
//place hide panel button
if(g_objbuttonhidepanel){
if(g_objtextpanel) //place at the beginning of hte panel
g_functions.placeelement(g_objbuttonhidepanel,"left", "top");
else{ //place above the strip panel
var strippanelheight = strippanelelement.outerheight();
g_functions.placeelement(g_objbuttonhidepanel,"left", "bottom", 0, strippanelheight);
}
}
}
/**
* place thumbs panel according the settings
*/
function placepanel(){
if(g_temp.ispanelhidden || ispanelneedtohide() == true){
//place panel hidden
var newpanelposy = gethiddenpanelposition();
g_functions.placeelement(g_objpanel, 0, newpanelposy);
g_temp.ispanelhidden = true;
}else //place panel normal
g_functions.placeelement(g_objpanel, 0, "bottom");
}
/**
* place the slider according the thumbs panel size and position
*/
function placeslider(){
var slidertop = 0;
var sliderleft = 0;
var galleryheight = g_gallery.getheight();
var sliderheight = galleryheight;
if(g_objstrippanel && ispanelhidden() == false){
var panelsize = g_objstrippanel.getsize();
sliderheight = galleryheight - panelsize.height;
}
var sliderwidth = g_gallery.getwidth();
//set parent container the panel
g_objslider.setsize(sliderwidth, sliderheight);
g_objslider.setposition(sliderleft, slidertop);
}
/**
* check if need to hide the panel according the options.
*/
function ispanelneedtohide(){
if(!g_options.theme_hide_panel_under_width)
return(false);
var windowwidth = jquery(window).width();
var hidepanelvalue = g_options.theme_hide_panel_under_width;
if(windowwidth <= hidepanelvalue)
return(true);
return(false);
}
/**
* check if need to hide or show panel according the theme_hide_panel_under_width option
*/
function checkhidepanel(){
//check hide panel:
if(!g_options.theme_hide_panel_under_width)
return(false);
var needtohide = ispanelneedtohide();
if(needtohide == true)
hidepanel(true);
else
showpanel(true);
}
/**
* on gallery size change - resize the theme.
*/
function onsizechange(){
initandplaceelements();
checkhidepanel();
}
/**
* get if the panel is hidden
*/
function ispanelhidden(){
return(g_temp.ispanelhidden);
}
/**
* place panel with some animation
*/
function placepanelanimation(panely, functiononcomplete){
var objcss = {top: panely + "px"};
g_objpanel.stop(true).animate(objcss ,{
duration: 300,
easing: "easeinoutquad",
queue: false,
complete: function(){
if(functiononcomplete)
functiononcomplete();
}
});
}
/**
* get position of the hidden panel
*/
function gethiddenpanelposition(){
var galleryheight = g_objwrapper.height();
var newpanelposy = galleryheight;
if(g_objbuttonhidepanel){
var objbuttonsize = g_functions.getelementsize(g_objbuttonhidepanel);
newpanelposy -= objbuttonsize.bottom;
}
return(newpanelposy);
}
/**
* hide the panel
*/
function hidepanel(noanimation){
if(!noanimation)
var noanimation = false;
if(ispanelhidden() == true)
return(false);
var newpanelposy = gethiddenpanelposition();
if(noanimation == true)
g_functions.placeelement(g_objpanel, 0, newpanelposy);
else
placepanelanimation(newpanelposy, placeslider);
if(g_objbuttonhidepanel)
g_objbuttonhidepanel.addclass("ug-button-hidden-mode");
g_temp.ispanelhidden = true;
}
/**
* show the panel
*/
function showpanel(noanimation){
if(!noanimation)
var noanimation = false;
if(ispanelhidden() == false)
return(false);
var galleryheight = g_objwrapper.height();
var panelheight = g_objpanel.outerheight();
var newpanelposy = galleryheight - panelheight;
if(noanimation == true)
g_functions.placeelement(g_objpanel, 0, newpanelposy);
else
placepanelanimation(newpanelposy, placeslider);
if(g_objbuttonhidepanel)
g_objbuttonhidepanel.removeclass("ug-button-hidden-mode");
g_temp.ispanelhidden = false;
}
/**
* on hide panel click
*/
function onhidepanelclick(event){
event.stoppropagation();
event.stopimmediatepropagation();
if(g_functions.validateclicktouchstartevent(event.type) == false)
return(true);
if(ispanelhidden() == true)
showpanel();
else
hidepanel();
}
/**
* before items request: hide items, show preloader
*/
function onbeforereqestitems(){
g_gallery.showdisabledoverlay();
}
/**
* init buttons functionality and events
*/
function initevents(){
g_objgallery.on(g_gallery.events.size_change,onsizechange);
g_objgallery.on(g_gallery.events.gallery_before_request_items, onbeforereqestitems);
//set the panel buttons
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);
}
//init hide panel button
if(g_objbuttonhidepanel){
g_functions.setbuttonmobileready(g_objbuttonhidepanel);
g_functions.addclassonhover(g_objbuttonhidepanel, "ug-button-hover");
g_objbuttonhidepanel.on("click touchstart", onhidepanelclick);
}
//on gallery media player events, bring the element to front
g_objgallery.on(g_gallery.events.slider_action_start, function(){
//set slider to front
g_objpanel.css("z-index","1");
g_objslider.getelement().css("z-index","11");
});
g_objgallery.on(g_gallery.events.slider_action_end, function(){
//set the panel to front
g_objpanel.css("z-index","11");
g_objslider.getelement().css("z-index","1");
});
}
/**
* destroy the gallery events and objects
*/
this.destroy = function(){
g_objgallery.off(g_gallery.events.size_change);
g_objgallery.off(g_gallery.events.gallery_before_request_items);
//set the panel buttons
if(g_objbuttonplay)
g_gallery.destroyplaybutton(g_objbuttonplay);
//init fullscreen button
if(g_objbuttonfullscreen)
g_gallery.destroyfullscreenbutton(g_objbuttonfullscreen);
//init hide panel button
if(g_objbuttonhidepanel)
g_functions.destroybutton(g_objbuttonhidepanel);
g_objgallery.off(g_gallery.events.slider_action_start);
g_objgallery.off(g_gallery.events.slider_action_end);
if(g_objslider)
g_objslider.destroy();
if(g_objstrippanel)
g_objstrippanel.destroy();
if(g_objtextpanel)
g_objtextpanel.destroy();
}
/**
* run the theme setting
*/
this.run = function(){
runtheme();
}
/**
* init
*/
this.init = function(gallery, customoptions){
inittheme(gallery, customoptions);
}
}