META-INF.resources.primefaces.galleria.galleria.js Maven / Gradle / Ivy
/**
* PrimeFaces Galleria Widget
*/
PrimeFaces.widget.Galleria = PrimeFaces.widget.DeferredWidget.extend({
init: function(cfg) {
this._super(cfg);
this.cfg.panelWidth = this.cfg.panelWidth||600;
this.cfg.panelHeight = this.cfg.panelHeight||400;
this.cfg.frameWidth = this.cfg.frameWidth||60;
this.cfg.frameHeight = this.cfg.frameHeight||40;
this.cfg.activeIndex = 0;
this.cfg.showFilmstrip = (this.cfg.showFilmstrip === false) ? false : true;
this.cfg.autoPlay = (this.cfg.autoPlay === false) ? false : true;
this.cfg.transitionInterval = this.cfg.transitionInterval||4000;
this.cfg.effect = this.cfg.effect||'fade';
this.cfg.effectSpeed = this.cfg.effectSpeed||250;
this.cfg.effectOptions = {};
this.panelWrapper = this.jq.children('ul.ui-galleria-panel-wrapper');
this.panels = this.panelWrapper.children('li.ui-galleria-panel');
this.renderDeferred();
},
_render: function() {
this.panelWrapper.width(this.cfg.panelWidth).height(this.cfg.panelHeight);
this.panels.width(this.cfg.panelWidth).height(this.cfg.panelHeight);
this.jq.width(this.cfg.panelWidth);
if(this.cfg.showFilmstrip) {
this.renderStrip();
this.bindEvents();
}
if(this.cfg.custom) {
this.panels.children('img').remove();
}
var activePanel = this.panels.eq(this.cfg.activeIndex);
activePanel.removeClass('ui-helper-hidden');
if(this.cfg.showCaption) {
this.caption = $('').css({
'bottom': this.cfg.showFilmstrip ? this.stripWrapper.outerHeight(true) : 0,
'width': this.panelWrapper.width()
}).appendTo(this.jq);
this.showCaption(activePanel);
}
this.jq.css('visibility', 'visible');
if(this.cfg.autoPlay) {
this.startSlideshow();
}
},
renderStrip: function() {
//strip
var frameStyle = 'style="width:' + this.cfg.frameWidth + "px;height:" + this.cfg.frameHeight + 'px;"';
this.stripWrapper = $('')
.width(this.panelWrapper.width() - 50)
.height(this.cfg.frameHeight)
.appendTo(this.jq);
this.strip = $('