YUI.add('fl-event-move', function(Y){
var _eventBase={
_isEndEvent: false,
on: function(node, subscriber, ce){
if(this.type.indexOf('end') > -1){
this._isEndEvent=true;
}
subscriber._direction=this.type.replace('gesturemove', '').replace('end', '');
if(window.navigator.msPointerEnabled){
subscriber._startHandle=node.on('MSPointerDown', this._onStart, this, node, subscriber, ce);
subscriber._moveHandle=node.on('MSPointerMove', this._onMove, this, node, subscriber, ce);
subscriber._endHandle=node.on('MSPointerUp', this._onEnd, this, node, subscriber, ce);
}else{
subscriber._startHandle=node.on('gesturemovestart', this._onStart, null, this, node, subscriber, ce);
subscriber._moveHandle=node.on('gesturemove', this._onMove, null, this, node, subscriber, ce);
subscriber._endHandle=node.on('gesturemoveend', this._onEnd, { standAlone: true }, this, node, subscriber, ce);
}},
detach: function(node, subscriber, ce){
subscriber._startHandle.detach();
subscriber._startHandle=null;
subscriber._moveHandle.detach();
subscriber._moveHandle=null;
subscriber._endHandle.detach();
subscriber._endHandle=null;
},
_onStart: function(e, node, subscriber, ce){
subscriber._doMove=null;
subscriber._startX=e.pageX;
subscriber._startY=e.pageY;
},
_onMove: function(e, node, subscriber, ce){
if(this._checkDirection(e, subscriber)){
subscriber._doMove=true;
}else{
subscriber._doMove=false;
}
if(subscriber._doMove&&!this._isEndEvent){
ce.fire(e);
}},
_onEnd: function(e, node, subscriber, ce){
if(subscriber._doMove&&this._isEndEvent){
e.startPageX=subscriber._startX;
e.startPageY=subscriber._startY;
ce.fire(e);
}
subscriber._doMove=null;
},
_checkDirection: function(e, subscriber){
var xDelta=Math.abs(subscriber._startX - e.pageX),
yDelta=Math.abs(subscriber._startY - e.pageY);
if(yDelta > xDelta&&subscriber._startY > e.pageY&&subscriber._direction=='vertical'){
return true;
}
else if(yDelta > xDelta&&subscriber._startY < e.pageY&&subscriber._direction=='vertical'){
return true;
}
else if(yDelta < xDelta&&subscriber._startX > e.pageX&&subscriber._direction=='horizontal'){
return true;
}
else if(yDelta < xDelta&&subscriber._startX < e.pageX&&subscriber._direction=='horizontal'){
return true;
}
return false;
}};
Y.Event.define('gesturemovevertical', _eventBase);
Y.Event.define('gesturemoveverticalend', _eventBase);
Y.Event.define('gesturemovehorizontal', _eventBase);
Y.Event.define('gesturemovehorizontalend', _eventBase);
}, '2.0.0' ,{requires:['event-move']});
YUI.add('fl-slideshow', function(Y){
Y.namespace('FL').SlideshowCaption=Y.Base.create('fl-slideshow-caption', Y.Widget, [Y.WidgetChild], {
_textToggled: false,
_textToggleLink: null,
renderUI: function(){
var root=this.get('root'),
bb=this.get('boundingBox'),
fallback=this.get('root').get('fallback');
if(fallback){
this._textToggleLink=Y.Node.create('<a role="button" tabindex="0"></a>');
}else{
this._textToggleLink=Y.Node.create('<button type="button"></button>');
}
this._textToggleLink.addClass('fl-slideshow-caption-toggle' + (!fallback ? ' fl-content-ui-button':''));
this._textToggleLink.set('innerHTML', root.get('captionMoreLinkText'));
bb.appendChild(this._textToggleLink);
},
bindUI: function(){
this.get('root').on('imageLoadComplete', Y.bind(this._setText, this));
this._textToggleLink.on('click', Y.bind(this._toggleText, this));
},
_setText: function(){
var root=this.get('root'),
text=root.imageInfo.caption,
textLength=root.get('captionTextLength'),
cb=this.get('contentBox');
if(!root.imageInfo.caption||root.imageInfo.caption===''){
cb.set('innerHTML', '');
this._textToggleLink.setStyle('display', 'none');
return;
}
else if(textLength > -1){
if(!this._textToggled&&textLength < text.length){
text=this._shortenText(text);
this._textToggleLink.setStyle('display', 'inline-block');
}
else if(this._textToggled&&textLength < text.length){
text=this._stripTags(text);
this._textToggleLink.setStyle('display', 'inline-block');
}else{
text=this._stripTags(text);
this._textToggleLink.setStyle('display', 'none');
}}else{
text=this._stripTags(text);
}
cb.set('innerHTML', text);
},
_toggleText: function(){
var root=this.get('root'),
text=root.imageInfo.caption,
cb=this.get('contentBox');
if(this._textToggled){
text=this._shortenText(text);
this._textToggleLink.set('innerHTML', root.get('captionMoreLinkText'));
this._textToggled=false;
}else{
text=this._stripTags(text);
this._textToggleLink.set('innerHTML', root.get('captionLessLinkText'));
this._textToggled=true;
}
cb.set('innerHTML', text);
},
_stripTags: function(text, ignoreSettings){
var root=this.get('root'), textDiv;
if(ignoreSettings||root.get('captionStripTags')){
textDiv=document.createElement('div');
textDiv.innerHTML=text;
text=textDiv.textContent||textDiv.innerText;
}
return text;
},
_shortenText: function(text){
var root=this.get('root');
text=this._stripTags(text, true).substring(0, root.get('captionTextLength'));
return Y.Lang.trim(text.substring(0, text.lastIndexOf(' '))) + ' ...';
}}, {
CSS_PREFIX: 'fl-slideshow-caption',
ATTRS: {
}});
Y.namespace('FL').SlideshowFrame=Y.Base.create('fl-slideshow-frame', Y.Widget, [Y.WidgetParent, Y.WidgetChild], {
_imageInfo: null,
_activeImage: null,
_nextImage: null,
_loadQueue: null,
_transition: null,
_transitioning: false,
_resizeAfterTransition: false,
_gestures: null,
initializer: function(){
var imageConfig=this.get('imageConfig');
this._activeImage=new Y.FL.SlideshowImage(imageConfig);
this._nextImage=new Y.FL.SlideshowImage(imageConfig);
},
renderUI: function(){
this.add(this._activeImage);
this.add(this._nextImage);
},
bindUI: function(){
var activeBB=this._activeImage.get('boundingBox'),
nextBB=this._nextImage.get('boundingBox'),
transition=this.get('transition');
if(('ontouchstart' in window||window.navigator.msPointerEnabled)&&this.get('touchSupport')){
this._gestures=new Y.FL.SlideshowGestures({
direction: transition=='slideVertical' ? 'vertical':'horizontal',
activeItem: activeBB,
nextItem: nextBB
});
this._gestures.on('moveStart', this._gesturesMoveStart, this);
this._gestures.on('endComplete', this._gesturesEndComplete, this);
}},
syncUI: function(){
var activeBB=this._activeImage.get('boundingBox'),
nextBB=this._nextImage.get('boundingBox'),
cb=this.get('contentBox');
activeBB.setStyle('position', 'absolute');
activeBB.setStyle('top', '0px');
activeBB.setStyle('left', '-9999px');
nextBB.setStyle('position', 'absolute');
nextBB.setStyle('top', '0px');
nextBB.setStyle('left', '-9999px');
cb.setStyle('position', 'relative');
cb.setStyle('overflow', 'hidden');
},
load: function(imageInfo){
var activeInfo=this._activeImage._imageInfo;
if(this._transitioning){
this._loadQueue=imageInfo;
return;
}
else if(activeInfo&&activeInfo.largeURL==imageInfo.largeURL){
return;
}
this._imageInfo=imageInfo;
this._transitionInit(imageInfo);
},
preload: function(imageInfo, width, height){
this._imageInfo=imageInfo;
this._nextImage.preload(imageInfo, width, height);
},
unload: function(){
this._imageInfo=null;
this._loadQueue=null;
this._transitioning=false;
this._transition=null;
this._activeImage.detachAll();
this._activeImage.unload();
this._activeImage.get('boundingBox').setStyle('left', '-9999px');
this._nextImage.detachAll();
this._nextImage.unload();
this._nextImage.get('boundingBox').setStyle('left', '-9999px');
},
resize: function(width, height){
if(!width||!height){
return;
}
var bb=this.get('boundingBox'),
padding=[
parseInt(bb.getComputedStyle('paddingTop'), 10),
parseInt(bb.getComputedStyle('paddingRight'), 10),
parseInt(bb.getComputedStyle('paddingBottom'), 10),
parseInt(bb.getComputedStyle('paddingLeft'), 10)
];
width=width - padding[1] - padding[3];
height=height - padding[0] - padding[2];
this.set('width', width);
this.set('height', height);
if(this._transitioning){
this._resizeAfterTransition=true;
}else{
this._activeImage.resize(width, height);
this._nextImage.resize(width, height);
}},
_getTransition: function(){
var root=this.get('root'),
lastIndex=root.albumInfo.images.length - 1,
direction='next',
transition=root.get('transition');
if(root.lastImageIndex===null){
direction='';
}
else if(root.imageIndex==lastIndex&&root.lastImageIndex===0){
direction='prev';
}
else if(root.imageIndex===0&&root.lastImageIndex==lastIndex){
direction='next';
}
else if(root.lastImageIndex > root.imageIndex){
direction='prev';
}
else if(root.lastImageIndex < root.imageIndex){
direction='next';
}
if(direction=='next'){
transition=transition.replace('slideHorizontal', 'slideLeft');
transition=transition.replace('slideVertical', 'slideUp');
}
else if(direction=='prev'){
transition=transition.replace('slideHorizontal', 'slideRight');
transition=transition.replace('slideVertical', 'slideDown');
}
return transition;
},
_transitionInit: function(imageInfo){
this._transitioning=true;
if(this._gestures){
this._gestures.disable();
}
this.fire('transitionInit');
if(imageInfo){
this._nextImage.once('loadComplete', this._transitionStart, this);
this._nextImage.load(imageInfo);
}else{
this._transitionStart();
}},
_transitionStart: function(){
var root=this.get('root');
this.fire('transitionStart');
this._transition=new Y.FL.SlideshowTransition({
itemIn: this._nextImage._imageInfo ? this._nextImage.get('boundingBox'):null,
itemOut: this._activeImage._imageInfo ? this._activeImage.get('boundingBox'):null,
type: this._getTransition(),
duration: root.get('transitionDuration'),
easing: root.get('transitionEasing'),
kenBurnsDuration: root.get('speed')/1000,
kenBurnsZoom: root.get('kenBurnsZoom')
});
if(this._nextImage._imageInfo){
this._nextImage.get('boundingBox').setStyle('left', '0px');
}
this._transition.once('complete', this._transitionComplete, this);
this._transition.run();
},
_transitionComplete: function(){
var root=this.get('root');
this._swapImageRefs();
this.fire('transitionComplete');
this._transition=null;
this._transitioning=false;
if(this._gestures){
if(root&&root.albumInfo.images.length <=1){
this._gestures.disable();
}else{
this._gestures.enable();
}}
if(this._loadQueue){
this.load(this._loadQueue);
this._loadQueue=null;
}
else if(this._resizeAfterTransition){
this._resizeAfterTransition=false;
this._activeImage.resize(this.get('width'), this.get('height'));
this._nextImage.resize(this.get('width'), this.get('height'));
}},
_gesturesMoveStart: function(e){
var index=0,
root=this.get('root');
index=e.direction=='next' ? root.imageIndex + 1:root.imageIndex - 1;
index=index < 0 ? root.albumInfo.images.length - 1:index;
index=index >=root.albumInfo.images.length ? 0:index;
root.pause();
root._hideLoadingImage();
root._showLoadingImageWithDelay();
Y.FL.SlideshowImageLoader.removeGroup(this._nextImage.get('loadGroup'));
this._nextImage.once('loadComplete', root._hideLoadingImage, root);
this._nextImage.load(root.albumInfo.images[index]);
},
_gesturesEndComplete: function(){
var root=this.get('root'),
index=0;
if(this._nextImage._imageInfo){
index=this._nextImage._imageInfo.index;
this._swapImageRefs();
this._imageInfo=root.albumInfo.images[index];
root.loadImage(index);
}},
_swapImageRefs: function(){
var active=this._activeImage;
this._activeImage=this._nextImage;
this._nextImage=active;
if(this._nextImage._imageInfo){
this._nextImage.unload();
this._nextImage.get('boundingBox').setStyle('left', '-9999px');
}
if(this._gestures){
this._gestures.set('activeItem', this._activeImage.get('boundingBox'));
this._gestures.set('nextItem', this._nextImage.get('boundingBox'));
}}
}, {
CSS_PREFIX: 'fl-slideshow-frame',
ATTRS: {
imageConfig: {
value: null
},
touchSupport: {
value: false
}}
});
Y.namespace('FL').SlideshowFullscreen=Y.Base.create('fl-slideshow-fullscreen', Y.Plugin.Base, [], {
active: false,
_closeMessage: null,
_closeMessageTimer: null,
_initialStyles: {
position: 'static',
top: '0px',
left: '0px'
},
initializer: function(){
var host=this.get('host'),
bb=host.get('boundingBox'),
self=this;
bb.addClass('fl-fullscreen-enabled');
if(Y.FL.SlideshowFullscreen.OS_SUPPORT){
document.addEventListener('fullscreenchange', function(){ self._osChange(); }, false);
document.addEventListener('mozfullscreenchange', function(){ self._osChange(); }, false);
document.addEventListener('webkitfullscreenchange', function(){ self._osChange(); }, false);
}else{
this._renderCloseMessage();
}},
toggle: function(){
if(this.active){
this.exit();
}else{
this.enter();
}},
enter: function(){
if(Y.FL.SlideshowFullscreen.OS_SUPPORT){
this._osEnter();
}else{
this._browserEnter();
}},
exit: function(){
if(Y.FL.SlideshowFullscreen.OS_SUPPORT){
this._osExit();
}else{
this._browserExit();
}},
_osEnter: function(){
var bbNode=this.get('host').get('boundingBox')._node;
if(bbNode.webkitRequestFullScreen){
bbNode.webkitRequestFullScreen();
}
else if(bbNode.mozRequestFullScreen){
bbNode.mozRequestFullScreen();
}
else if(bbNode.requestFullScreen){
bbNode.requestFullScreen();
}},
_osExit: function(){
if(document.exitFullscreen){
document.exitFullscreen();
}
else if(document.mozCancelFullScreen){
document.mozCancelFullScreen();
}
else if(document.webkitCancelFullScreen){
document.webkitCancelFullScreen();
}},
_osChange: function(){
var host=this.get('host');
if(host.frame&&host.frame._transitioning){
host.frame._transitionComplete();
}
if(this.active){
this._exit();
}else{
this._enter();
}},
_browserEnter: function(){
var bb=this.get('host').get('boundingBox');
this._initialStyles={
position: bb.getStyle('position'),
top: bb.getStyle('top'),
left: bb.getStyle('left'),
zIndex: bb.getStyle('zIndex')
};
bb.setStyles({
position: 'fixed',
top: '0px',
left: '0px',
zIndex: 10000
});
Y.Node.one('body').on('fl-fullscreen|keydown', Y.bind(this._onKey, this));
this._showCloseMessage();
this._enter();
},
_browserExit: function(){
var bb=this.get('host').get('boundingBox');
bb.setStyles({
position: this._initialStyles.position,
top: this._initialStyles.top,
left: this._initialStyles.left,
zIndex: this._initialStyles.zIndex
});
Y.Node.one('body').detach('fl-fullscreen|keydown');
this._hideCloseMessage();
this._exit();
},
_enter: function(){
var host=this.get('host'),
bb=host.get('boundingBox');
bb.addClass('fl-fullscreen-active');
this.active=true;
host.resize();
},
_exit: function(){
var host=this.get('host'),
bb=host.get('boundingBox');
bb.removeClass('fl-fullscreen-active');
this.active=false;
host.resize();
},
_onKey: function(e){
if(e.keyCode==27){
this.exit();
return false;
}},
_renderCloseMessage: function(){
this._closeMessage=Y.Node.create('<div class="fl-fullscreen-close-message"></div>');
this._closeMessage.set('innerHTML', '<span>Press the "esc" button to exit fullscreen mode.</span>');
this._closeMessage.setStyle('display', 'none');
this.get('host').get('boundingBox').insert(this._closeMessage);
},
_showCloseMessage: function(){
if(this._closeMessageTimer){
this._closeMessageTimer.cancel();
this._closeMessageTimer=null;
}
this._closeMessage.show(true);
this._closeMessageTimer=Y.later(4000, this, this._hideCloseMessage);
},
_hideCloseMessage: function(){
if(this._closeMessageTimer){
this._closeMessageTimer.cancel();
this._closeMessageTimer=null;
}
this._closeMessage.hide(true);
}},	{
NS: 'fullscreen',
OS_SUPPORT: (function(){
var doc=document.documentElement;
return doc.webkitRequestFullScreen||doc.mozRequestFullScreen||doc.requestFullScreen;
})()
});
Y.namespace('FL').SlideshowGestures=Y.Base.create('fl-slideshow-gestures', Y.Base, [], {
_startX: null,
_startY: null,
_touchMoving: false,
_moving: false,
_movingDirection: null,
_transitioning: false,
initializer: function(){
this.enable();
},
enable: function(){
var id=this.get('id'),
direction=this.get('direction'),
active=this.get('activeItem'),
next=this.get('nextItem');
active.on(id + '|gesturemovestart', Y.bind(this._onStart, this));
next.on(id + '|gesturemovestart', Y.bind(this._onStart, this));
next.on(id + '|transitionend', Y.bind(this._onEndComplete, this));
next.on(id + '|oTransitionEnd', Y.bind(this._onEndComplete, this));
next.on(id + '|webkitTransitionEnd', Y.bind(this._onEndComplete, this));
if(direction=='horizontal'){
active.on(id + '|gesturemovehorizontal', Y.bind(this._onMoveHorizontal, this));
active.on(id + '|gesturemovehorizontalend', Y.bind(this._onEndHorizontal, this));
next.on(id + '|gesturemovehorizontal', Y.bind(this._onMoveHorizontal, this));
next.on(id + '|gesturemovehorizontalend', Y.bind(this._onEndHorizontal, this));
}else{
active.on(id + '|gesturemovevertical', Y.bind(this._onMoveVertical, this));
active.on(id + '|gesturemoveverticalend', Y.bind(this._onEndVertical, this));
next.on(id + '|gesturemovevertical', Y.bind(this._onMoveVertical, this));
next.on(id + '|gesturemoveverticalend', Y.bind(this._onEndVertical, this));
}},
disable: function(){
var id=this.get('id'),
active=this.get('activeItem'),
next=this.get('nextItem');
active.detach(id + '|*');
next.detach(id + '|*');
},
_onStart: function(e){
var direction=this.get('direction');
if(this._transitioning){
this._onEndComplete();
}
if(direction=='horizontal'){
this._startX=e.pageX;
}else{
this._startY=e.pageY;
}
this.fire('start');
},
_onMoveHorizontal: function(e){
var x=this._startX - e.pageX,
active=this.get('activeItem'),
next=this.get('nextItem'),
width=parseInt(active.getComputedStyle('width'), 10),
translate=x < 0 ? Math.abs(x):-x,
direction=x < 0 ? 'prev':'next';
e.preventDefault();
if(!this._moving||this._movingDirection!=direction){
active.setStyle('left', 0);
next.setStyles({
'opacity': 1,
'left': x < 0 ? -width:width
});
this._moving=true;
this._movingDirection=direction;
this.fire('moveStart', { direction: direction });
}
active.setStyle('-webkit-transform', 'translate('+ translate +'px, 0px) translateZ(0px)');
active.setStyle('-ms-transform', 'translate('+ translate +'px, 0px) translateZ(0px)');
next.setStyle('-webkit-transform', 'translate('+ translate +'px, 0px) translateZ(0px)');
next.setStyle('-ms-transform', 'translate('+ translate +'px, 0px) translateZ(0px)');
this.fire('move');
},
_onMoveVertical: function(e){
var y=this._startY - e.pageY,
active=this.get('activeItem'),
next=this.get('nextItem'),
height=parseInt(active.getComputedStyle('height'), 10),
translate=y < 0 ? Math.abs(y):-y,
direction=y < 0 ? 'prev':'next';
e.preventDefault();
if(!this._moving||this._movingDirection!=direction){
active.setStyle('top', 0);
next.setStyles({
'opacity': 1,
'left':'auto',
'top': y < 0 ? -height:height
});
this._moving=true;
this._movingDirection=direction;
this.fire('moveStart', { direction: direction });
}
active.setStyle('-webkit-transform', 'translate(0px, '+ translate +'px) translateZ(0px)');
active.setStyle('-ms-transform', 'translate(0px, '+ translate +'px) translateZ(0px)');
next.setStyle('-webkit-transform', 'translate(0px, '+ translate +'px) translateZ(0px)');
next.setStyle('-ms-transform', 'translate(0px, '+ translate +'px) translateZ(0px)');
this.fire('move');
},
_onEndHorizontal: function(e){
if(!this._moving){
return;
}
var x=this._startX - e.pageX,
active=this.get('activeItem'),
next=this.get('nextItem'),
width=parseInt(next.getComputedStyle('width'), 10),
translate=x < 0 ? width:-width;
active.transition({
'transform': 'translate('+ translate +'px, 0px)'
});
next.transition({
'transform': 'translate('+ translate +'px, 0px)'
});
this._transitioning=true;
this.fire('end');
},
_onEndVertical: function(e){
if(!this._moving){
return;
}
var y=this._startY - e.pageY,
active=this.get('activeItem'),
next=this.get('nextItem'),
height=parseInt(next.getComputedStyle('height'), 10),
translate=y < 0 ? height:-height;
active.transition({
'transform': 'translate(0px, '+ translate +'px)'
});
next.transition({
'transform': 'translate(0px, '+ translate +'px)'
});
this._transitioning=true;
this.fire('end');
},
_onEndComplete: function(){
var direction=this.get('direction'),
active=this.get('activeItem'),
next=this.get('nextItem');
active.setStyles({
'opacity': 0,
'-webkit-transform': '',
'-webkit-transition': '',
'-ms-transform': '',
'-ms-transition': ''
});
next.setStyles({
'-webkit-transform': '',
'-webkit-transition': '',
'-ms-transform': '',
'-ms-transition': ''
});
if(direction=='horizontal'){
active.setStyle('left', '-9999px');
next.setStyle('left', '0px');
}else{
active.setStyle('top', '-9999px');
next.setStyle('top', '0px');
}
this.set('activeItem', next);
this.set('nextItem', active);
this._moving=false;
this._movingDirection=null;
this._transitioning=false;
this.fire('endComplete');
}}, {
ATTRS: {
direction: {
value: 'horizontal'
},
activeItem: {
value: null
},
nextItem: {
value: null
}}
});
Y.namespace('FL').SlideshowImageLoader={
_loading: false,
_currentImage: null,
_currentImageData: null,
_queue: [],
add: function(group, src, callback, bump){
var imgData={
group:group,
src:src,
callback:callback
};
if(bump){
this._queue.unshift(imgData);
}else{
this._queue.push(imgData);
}
if(!this._loading){
this._load();
}},
removeGroup: function(group){
var i=this._queue.length - 1;
for(; i > -1 ; i--){
if(this._queue[i].group==group){
this._queue.splice(i, 1);
}}
if(this._currentImageData&&this._currentImageData.group==group){
this._currentImage.detachAll();
this._currentImage=null;
this._currentImageData=null;
if(this._queue.length > 0){
this._load();
}else{
this._loading=false;
}}
},
_load: function(){
this._loading=true;
this._currentImageData=this._queue.shift();
this._currentImage=Y.Node.create('<img />');
this._currentImage.on('error', Y.bind(this._loadComplete, this));
this._currentImage.on('load', Y.bind(this._loadComplete, this));
this._currentImage.set('src', this._currentImageData.src);
},
_loadComplete: function(){
if(this._currentImageData.callback){
this._currentImageData.callback(this._currentImage);
}
if(this._queue.length > 0){
this._load();
}else{
this._loading=false;
this._currentImage=null;
this._currentImageData=null;
}}
};
Y.namespace('FL').SlideshowImage=Y.Base.create('fl-slideshow-image', Y.Widget, [Y.WidgetChild], {
_imageInfo: null,
_image: null,
_loading: false,
_loadingURL: null,
_videoButton: null,
_videoBox: null,
_video: null,
CONTENT_TEMPLATE: null,
syncUI: function(){
var bb=this.get('boundingBox');
if(this.get('crop')){
bb.setStyle('overflow', 'hidden');
bb.addClass('fl-slideshow-image-cropped');
}},
load: function(imageInfo){
this._imageInfo=imageInfo;
this._loading=true;
this._load();
},
preload: function(imageInfo, width, height){
var isVideo=this._isVideo(),
loadVideos=this.get('loadVideos'),
showVideoButton=this.get('showVideoButton');
this.unload();
this.set('width', width);
this.set('height', height);
this._imageInfo=imageInfo;
if(!isVideo||!loadVideos||(isVideo&&loadVideos&&showVideoButton)){
Y.FL.SlideshowImageLoader.add(this.get('loadGroup'),
this._getImageURL(),
Y.bind(this._imagePreloaded, this),
this.get('loadPriority')
);
}},
_imagePreloaded: function(img){
this._image=img;
},
unload: function(){
if(this._image){
this._image.remove();
this._image.detachAll();
this._image.set('src', '');
this._image=null;
}
if(this._video){
this._video.remove();
this._video=null;
}
if(this._videoButton){
this._videoButton.remove();
this._videoButton=null;
}
if(this._videoBox){
this._removeVideoBox();
}
this._imageInfo=null;
this._loading=false;
this._loadingURL=null;
},
resize: function(width, height){
var borderWidth=parseInt(this.get('boundingBox').getComputedStyle('borderTopWidth'), 10) * 2,
bb=this.get('boundingBox');
this.set('width', width - borderWidth);
this.set('height', height - borderWidth);
bb.setStyle('width', width - borderWidth + 'px');
bb.setStyle('height', height - borderWidth + 'px');
if(this._videoButton){
this._positionVideoButton();
}
if(this._videoBox){
this._loadVideo();
}
if(!this._loading){
if(this._imageInfo){
this._load();
}
if(this._image){
this._positionImage();
}}
},
_load: function(){
var loadVideos=this.get('loadVideos'),
showVideoButton=this.get('showVideoButton');
if(this._isVideo()&&loadVideos&&!showVideoButton&&!('ontouchstart' in window)){
this._loadVideo();
}else{
this._loadImage();
}},
_loadImage: function(){
var url=this._getImageURL(),
loadVideos=this.get('loadVideos');
if(url==this._loadingURL){
return;
}
this._loadingURL=url;
Y.FL.SlideshowImageLoader.add(this.get('loadGroup'),
this._loadingURL,
Y.bind(this._loadImageComplete, this),
this.get('loadPriority')
);
if(this._loading){
if(this._isVideo()&&loadVideos){
this._insertVideoButton();
}
this.fire('loadStart');
}},
_loadImageComplete: function(img){
var bb=this.get('boundingBox'),
showVideoButton=this.get('showVideoButton'),
showAria=this.get('root').get('bgslideshow')
this._image=img;
this._image.setStyle('visibility', 'hidden');
this._image.addClass('fl-slideshow-image-img');
if(showAria){
this._image.set('aria-hidden', 'true')
this._image.set('alt', "")
}else{
this._image.set('alt', this._imageInfo.alt)
}
this._image.detachAll();
if(this._video&&!showVideoButton){
this._video.remove();
this._video=null;
}
bb.all('img').remove();
bb.append(this._image);
this._setupImage();
this._resizeImage();
this._positionImage();
this._image.setStyle('visibility', 'visible');
this._loadingURL=null;
if(this._loading){
this._loading=false;
this.fire('loadComplete');
}},
_setupImage: function(){
var bb=this.get('boundingBox');
if(typeof this._image._node.style.msInterpolationMode!='undefined'){
this._image._node.style.msInterpolationMode='bicubic';
}
if(this.get('protect')){
bb.delegate('contextmenu', this._protectImage, 'img');
bb.delegate('mousedown', this._protectImage, 'img');
}},
_protectImage: function(e){
e.preventDefault();
return false;
},
_resizeImage: function(){
var borderWidth=parseInt(this._image.getComputedStyle('borderTopWidth'), 10) * 2,
imageWidth=this._image.get('width'),
imageHeight=this._image.get('height'),
targetWidth=parseInt(this.get('boundingBox').getComputedStyle('width'), 10),
targetHeight=parseInt(this.get('boundingBox').getComputedStyle('height'), 10),
newWidth=0,
newHeight=0,
xScale=0,
yScale=0,
cropHorizontalsOnly=this.get('cropHorizontalsOnly'),
isHorizontal=imageHeight > imageWidth,
noCrop=false;
if(this._imageInfo&&this.get('checkFilenamesForNoCrop')){
noCrop=this._imageInfo.filename.indexOf('nocrop') > -1;
}
if(this.get('crop')&&!(cropHorizontalsOnly&&isHorizontal)&&!noCrop){
newWidth=targetWidth;
newHeight=Math.round(imageHeight * targetWidth/imageWidth);
if(newHeight < targetHeight){
newHeight=targetHeight;
newWidth=Math.round(imageWidth * targetHeight/imageHeight);
}}else{
xScale=imageWidth/targetWidth;
yScale=imageHeight/targetHeight;
if(yScale > xScale){
newWidth=Math.round(imageWidth * (1/yScale));
newHeight=Math.round(imageHeight * (1/yScale));
}else{
newWidth=Math.round(imageWidth * (1/xScale));
newHeight=Math.round(imageHeight * (1/xScale));
}}
if(!this.get('crop')&&!this.get('upsize')&&(newWidth > imageWidth||newHeight > imageHeight)){
newWidth=imageWidth;
newHeight=imageHeight;
}
newWidth -=borderWidth;
newHeight -=borderWidth;
this._image.setStyle('width', newWidth + 'px');
this._image.setStyle('height', newHeight + 'px');
if(!this.get('crop')&&this.get('constrainWidth')){
this.set('width', newWidth + 'px');
}
if(!this.get('crop')&&this.get('constrainHeight')){
this.set('height', newHeight + 'px');
}},
_positionImage: function(){
var pos=this.get('position').split(' '),
x=pos[0]==='' ? 'center':pos[0],
y=pos[1]==='' ? 'center':pos[1],
newX=0,
newY=0,
bbWidth=parseInt(this.get('boundingBox').getComputedStyle('width'), 10),
bbHeight=parseInt(this.get('boundingBox').getComputedStyle('height'), 10),
borderWidth=parseInt(this._image.getComputedStyle('borderTopWidth'), 10) * 2,
imageWidth=parseInt(this._image.getComputedStyle('width'), 10) + borderWidth,
imageHeight=parseInt(this._image.getComputedStyle('height'), 10) + borderWidth;
if(isNaN(imageWidth)&&isNaN(imageHeight)){
return;
}
if(x=='left'){
newX=0;
}
if(x=='center'){
newX=(bbWidth - imageWidth)/2;
}
if(x=='right'){
newX=bbWidth - imageWidth;
}
if(y=='top'){
newY=0;
}
if(y=='center'){
newY=(bbHeight - imageHeight)/2;
}
if(y=='bottom'){
newY=bbHeight - imageHeight;
}
this._image.setStyles({
'left': newX,
'top': newY
});
},
_getImageURL: function(){
var imageWidth=0,
imageHeight=0,
size=0,
targetWidth=this.get('width'),
targetHeight=this.get('height'),
useThumbSizes=this.get('useThumbSizes'),
i=this._imageInfo,
sizes=[
i.tinyURL||i.thumbURL||i.largeURL,
i.thumbURL||i.largeURL,
i.smallURL||i.largeURL,
i.mediumURL||i.largeURL||i.smallURL,
i.largeURL||i.mediumURL||i.smallURL,
i.xlargeURL||i.largeURL||i.mediumURL||i.smallURL,
i.x2largeURL||i.largeURL||i.mediumURL||i.smallURL,
i.x3largeURL||i.x2largeURL||i.largeURL||i.mediumURL||i.smallURL
];
if(useThumbSizes&&targetWidth <=100){
imageWidth=0;
}
else if(useThumbSizes&&targetWidth <=150){
imageWidth=1;
}
else if(targetWidth <=400){
imageWidth=2;
}
else if(targetWidth >=400&&targetWidth <=600){
imageWidth=3;
}
else if(targetWidth >=600&&targetWidth <=800){
imageWidth=4;
}
else if(targetWidth >=800&&targetWidth <=1024){
imageWidth=5;
}
else if(targetWidth >=1024&&targetWidth <=1280){
imageWidth=6;
}else{
imageWidth=7;
}
if(useThumbSizes&&targetHeight <=100){
imageHeight=0;
}
else if(useThumbSizes&&targetHeight <=150){
imageHeight=1;
}
else if(targetHeight <=300){
imageHeight=2;
}
else if(targetHeight >=300&&targetHeight <=450){
imageHeight=3;
}
else if(targetHeight >=450&&targetHeight <=600){
imageHeight=4;
}
else if(targetHeight >=600&&targetHeight <=768){
imageHeight=5;
}
else if(targetHeight >=768&&targetHeight <=960){
imageHeight=6;
}else{
imageHeight=7;
}
size=Math.max(imageWidth, imageHeight);
return sizes[size];
},
_isVideo: function(){
if(!this._imageInfo){
return false;
}
else if(this._imageInfo.format=='mp4'&&this._imageInfo.sourceType=='smugmug'){
return true;
}
else if(this._imageInfo.iframe!==''){
return true;
}
return false;
},
_loadVideo: function(){
var bb=this.get('boundingBox'),
showVideoButton=this.get('showVideoButton'),
autoPlay=showVideoButton ? true:false;
if(this._video){
this._video.remove();
this._video=null;
}
if(this._imageInfo.format=='mp4'&&this._imageInfo.sourceType=='smugmug'){
this._video=this._getSmugMugVideoEmbed(this._imageInfo, autoPlay);
}
else if(this._imageInfo.iframe!==''){
this._video=this._getIframeVideoEmbed(this._imageInfo, autoPlay);
}
if(this._videoBox){
this._videoBox.one('.fl-slideshow-video-wrap').insert(this._video);
}else{
bb.all('img').remove();
bb.append(this._video);
}
if(this._loading){
this._loading=false;
this.fire('loadComplete');
}},
_insertVideoButton: function(){
var bb=this.get('boundingBox'),
event='ontouchstart' in window ? 'touchstart':'click',
fallback=this.get('root').get('fallback');
if(fallback){
this._videoButton=Y.Node.create('<a class="fl-slideshow-video-button" role="button" aria-label="insert video" tabindex="0"></a>');
}else{
this._videoButton=Y.Node.create('<button class="fl-slideshow-video-button fl-content-ui-button" type="button" aria-label="insert video"></button>');
}
this._videoButton.on(event, Y.bind(this._showVideoBox, this));
bb.insert(this._videoButton);
this._positionVideoButton();
},
_positionVideoButton: function(){
var bbWidth=this.get('width'),
bbHeight=this.get('height'),
buttonWidth=parseInt(this._videoButton.getStyle('width'), 10),
buttonHeight=parseInt(this._videoButton.getStyle('height'), 10);
this._videoButton.setStyles({
left: (bbWidth - buttonWidth)/2,
top: (bbHeight - buttonHeight)/2
});
},
_showVideoBox: function(){
var root=this.get('root'),
fallback=root.get('fallback'),
wrap=Y.Node.create('<div class="fl-slideshow-video-wrap"></div>'),
event='ontouchstart' in window ? 'touchstart':'click',
tag=fallback ? 'a':'button',
attrs=fallback ? 'role="button"':'type="button"',
classes=fallback ? 'class="fl-slideshow-video-close"':'class="fl-slideshow-video-close fl-content-ui-button"',
close=Y.Node.create('<' + [tag, attrs, classes].join(' ') + '></' + tag + '>');
this._videoBox=Y.Node.create('<div class="fl-slideshow-video"></div>');
this._videoBox.setStyle('padding', root.get('boundingBox').getStyle('padding'));
this._videoBox.insert(wrap);
this._videoBox.insert(close);
this._videoBox.on(event, Y.bind(this._removeVideoBox, this));
close.on(event, Y.bind(this._removeVideoBox, this));
if(typeof YUI.Env.mods['sm-fonticon']!=='undefined'){
close.addClass('sm-fonticon sm-fonticon-XCrossEncircled sm-button-skin-default sm-button-nochrome');
}
Y.one('body').insert(this._videoBox);
this._loadVideo();
Y.one('body').on('fl-slideshow-image|keydown', this._onKey, this);
},
_getSmugMugVideoEmbed: function(imageInfo, autoPlay){
var test=document.createElement('video'),
width=0,
mp4='',
vars='',
code='';
if(Y.UA.mobile!==null&&!!test.canPlayType&&test.canPlayType('video/mp4')){
width=this.get('width');
mp4='https://www.smugmug.com/photos/' + imageInfo.id + '_' + imageInfo.key + '-' + width + '.mp4';
code +='<video width="100%" height="100%" poster="'+ this._getImageURL() +'" controls preload="none"';
if(autoPlay){
code +=' autoplay';
}
code +='>';
code +='<source src="'+ mp4 +'" type="video/mp4" />';
code +='</video>';
}else{
vars='imageId=' + imageInfo.id;
vars +='&amp;imageKey=' + imageInfo.key;
vars +='&amp;albumId=' + imageInfo.albumId;
vars +='&amp;albumKey=' + imageInfo.albumKey;
vars +='&amp;apiURL=https://api.smugmug.com/&amp;hostLevel=live&amp;isPro=true';
if(autoPlay){
vars +='&amp;autoPlay=true';
}else{
vars +='&amp;autoPlay=false';
}
code +='<object type="application/x-shockwave-flash" width="100%" height="100%" data="https://cdn.smugmug.com/img/ria/SmugPlayer/2012102601.swf">';
code +='<param name="movie" value="https://cdn.smugmug.com/img/ria/SmugPlayer/2012102601.swf">';
code +='<param name="allowFullScreen" value="true">';
code +='<param name="wmode" value="transparent">';
code +='<param name="flashVars" value="' + vars + '">';
code +='<embed src="https://cdn.smugmug.com/img/ria/SmugPlayer/2012102601.swf" flashvars="'+ vars +'" width="100%" height="100%" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent">';
code +='</object>';
}
return Y.Node.create(code);
},
_getIframeVideoEmbed: function(imageInfo, autoPlay){
var code='<iframe width="100%" height="100%" allowfullscreen ',
url=imageInfo.iframe;
if(autoPlay){
url +=url.indexOf('?') > -1 ? '&autoplay=1':'?autoplay=1';
}
code +='src="'+ url +'"></iframe>';
return Y.Node.create(code);
},
_removeVideoBox: function(e){
if(typeof e!=='undefined'&&e.target){
if(e.target.get('className').indexOf('fl-slideshow-video') < 0){
return;
}}
if(this._videoBox!==null){
this._videoBox.remove();
this._videoBox=null;
this._video=null;
}
Y.one('body').detach('fl-slideshow-image|keydown', this._onKey);
},
_onKey: function(e){
if(e.keyCode==27){
this._removeVideoBox();
return false;
}}
}, {
CSS_PREFIX: 'fl-slideshow-image',
ATTRS: {
loadGroup: {
value: 'none'
},
loadPriority: {
value: false
},
crop: {
value: false
},
checkFilenamesForNoCrop: {
value: true
},
cropHorizontalsOnly: {
value: false
},
position: {
value: 'center center'
},
protect: {
value: true
},
upsize: {
value: true
},
useThumbSizes: {
value: false
},
constrainWidth: {
value: false
},
constrainHeight: {
value: false
},
loadVideos: {
value: true
},
showVideoButton: {
value: true
}}
});
Y.namespace('FL').SlideshowMouseNav=Y.Base.create('fl-slideshow-mouse-nav', Y.Plugin.Base, [], {
initializer: function(){
var trigger=this.get('trigger');
trigger.on('click', this._triggerClick, this);
trigger.on('mousemove', this._showArrow, this);
trigger.on('mouseleave', this._hideArrow, this);
},
_triggerClick: function(e){
var host=this.get('host'),
trigger=this.get('trigger'),
triggerWidth=parseInt(trigger.getStyle('width'), 10),
triggerRegion=trigger.get('region'),
layerX=e.pageX - triggerRegion.left + 5;
if(layerX >=triggerWidth/2){
host.nextImage();
}else{
host.prevImage();
}},
_showArrow: function(e){
var host=this.get('host'),
trigger=this.get('trigger'),
triggerWidth=parseInt(trigger.getStyle('width'), 10),
triggerRegion=trigger.get('region'),
layerX=e.pageX - triggerRegion.left + 5;
if(host.albumInfo!==null&&host.albumInfo.images.length > 1){
if(layerX >=triggerWidth/2){
trigger.removeClass('fl-slideshow-mouse-nav-prev');
trigger.addClass('fl-slideshow-mouse-nav-next');
}else{
trigger.removeClass('fl-slideshow-mouse-nav-next');
trigger.addClass('fl-slideshow-mouse-nav-prev');
}}
},
_hideArrow: function(){
var trigger=this.get('trigger');
trigger.removeClass('fl-slideshow-mouse-nav-next');
trigger.removeClass('fl-slideshow-mouse-nav-prev');
}},	{
NS: 'mouseNav',
ATTRS: {
trigger: {
value: null
}}
});
Y.namespace('FL').SlideshowKenBurns=Y.Base.create('fl-slideshow-ken-burns', Y.Base, [], {
run: function(){
var imageNode=null,
transform=null;
if(Y.FL.Utils.cssSupport('transform')){
imageNode=this.get('image').one('img');
transform=this._getTransform();
imageNode.setStyles({
'-webkit-transform-origin': transform.origin,
'-moz-transform-origin': transform.origin,
'-ms-transform-origin': transform.origin,
'transform-origin': transform.origin,
'transform': transform.start
});
imageNode.transition({
easing: 'ease-out',
duration:this.get('duration'),
'transform':transform.end
});
}},
_getTransform: function(){
var zoom=this.get('zoom'),
image=this.get('image'),
i=0,
zoomDirection=null,
transform=null;
i=Math.floor(Math.random() * Y.FL.SlideshowKenBurns.ZOOM_DIRECTIONS.length);
zoomDirection=Y.FL.SlideshowKenBurns.ZOOM_DIRECTIONS[i];
i=Math.floor(Math.random() * Y.FL.SlideshowKenBurns.TRANSFORMS.length);
transform=Y.FL.SlideshowKenBurns.TRANSFORMS[i];
if(!image.hasClass('fl-slideshow-image-cropped')&&zoomDirection=='in'){
i=Math.floor(Math.random() * 2);
transform.start=i===0 ? 'scale(1) translate(100px, 0)':'scale(1) translate(-100px, 0)';
transform.end='scale(' + zoom + ') translate(0, 0)';
transform.origin='center center';
}
else if(zoomDirection=='out'){
transform.start='scale(' + zoom + ') ' + transform.translate;
transform.end='scale(1) translate(0, 0)';
}else{
transform.start='scale(1) translate(0, 0)';
transform.end='scale(' + zoom + ') ' + transform.translate;
}
return transform;
}}, {
ATTRS: {
image: {
value: null
},
zoom: {
value: 1.2
},
duration: {
value: 2
}},
ZOOM_DIRECTIONS: [
'in',
'out'
],
TRANSFORMS: [
{
origin:'left top',
translate:'translate(-30px, -15px)'
},{
origin:'left center',
translate:'translate(-30px, 0)'
},{
origin:'left bottom',
translate:'translate(-30px, 15px)'
},{
origin:'right top',
translate:'translate(30px, -15px)'
},{
origin:'right center',
translate:'translate(30px, 0)'
},{
origin:'right bottom',
translate:'translate(30px, 15px)'
}
]
});
Y.namespace('FL').SlideshowNav=Y.Base.create('fl-slideshow-nav', Y.Widget, [Y.WidgetChild], {
_buttons: null,
_buttonsContainer: null,
_buttonsLeftContainer: null,
_buttonsRightContainer: null,
_fontIcons: {
buy: 'Cart',
caption: 'InfoEncircled',
close: 'XCrossEncircled',
fullscreen: 'ScreenExpand',
next: 'ArrowRight',
nextPage: 'ArrowRight',
pause: 'PlayerPause',
play: 'PlayerPlay',
prev: 'ArrowLeft',
prevPage: 'ArrowLeft',
social: 'Heart',
thumbs: 'ViewThumbGrid'
},
CONTENT_TEMPLATE: null,
renderUI: function(){
this._renderContainers();
this._renderButtons();
this._renderFontIcons();
},
bindUI: function(){
var root=this.get('root'),
id=this.get('id');
if(this._buttons.prev){
this._buttons.prev.on('click', root.prevImage, root);
}
if(this._buttons.next){
this._buttons.next.on('click', root.nextImage, root);
}
if(this._buttons.play){
this._buttons.play.on('click', this._playClicked, this);
root.on(id + '|played', this._showPauseButton, this);
root.on(id + '|paused', this._showPlayButton, this);
if(root._playing){
this._showPauseButton();
}else{
this._showPlayButton();
}}
if(this._buttons.buy){
root.on(id + '|albumLoadComplete', this._updateBuy, this);
if(root.albumInfo!==null){
this._updateBuy();
}}
if(this._buttons.count){
root.on(id + '|imageLoadComplete', this._updateCount, this);
}
if(this._buttons.thumbs){
this._buttons.thumbs.on('click', root._toggleThumbs, root);
}
if(this._buttons.caption){
root.on(id + '|imageLoadComplete', this._updateCaption, this);
this._updateCaption();
}
if(this._buttons.social){
this._buttons.social.on('click', root._toggleSocial, root);
}
if(this._buttons.fullscreen&&root.fullscreen){
this._buttons.fullscreen.on('click', root.fullscreen.toggle, root.fullscreen);
}
if(this._buttons.close){
this._buttons.close.on('click', root.hide, root);
}},
destructor: function(){
var root=this.get('root'),
id=this.get('id');
root.detach(id + '|*');
},
_renderContainers: function(){
var cb=this.get('contentBox'),
buttonsLeft=this.get('buttonsLeft'),
buttonsRight=this.get('buttonsRight');
this._buttonsContainer=Y.Node.create('<div></div>');
this._buttonsContainer.addClass('fl-slideshow-nav-buttons');
cb.appendChild(this._buttonsContainer);
if(buttonsLeft.length > 0){
this._buttonsLeftContainer=Y.Node.create('<div></div>');
this._buttonsLeftContainer.addClass('fl-slideshow-nav-buttons-left');
cb.appendChild(this._buttonsLeftContainer);
}
if(buttonsRight.length > 0){
this._buttonsRightContainer=Y.Node.create('<div></div>');
this._buttonsRightContainer.addClass('fl-slideshow-nav-buttons-right');
cb.appendChild(this._buttonsRightContainer);
}},
_renderButtons: function(){
var name='',
fallback=this.get('root').get('fallback'),
tag=fallback ? 'a':'button',
attrs=fallback ? 'role="button" tabindex="0"':'type="button"',
i=0,
k=0,
b=[
{
names: this.get('buttons'),
container: this._buttonsContainer
},
{
names: this.get('buttonsLeft'),
container: this._buttonsLeftContainer
},
{
names: this.get('buttonsRight'),
container: this._buttonsRightContainer
}
];
this._buttons={};
for(; i < b.length; i++){
for(k=0; k < b[i].names.length; k++){
name=b[i].names[k];
if(name.indexOf('count') > -1){
this._buttons[name]=Y.Node.create('<span></span>');
this._updateCount();
}else{
this._buttons[name]=Y.Node.create('<' + tag + ' ' + attrs + '></' + tag + '>');
}
if(name.indexOf('buy') > -1){
this._buttons[name].setStyle('display', 'none');
}
this._buttons[name].set('name', name);
this._buttons[name].set('aria-label', name);
this._buttons[name].addClass('fl-slideshow-nav-' + name + (!fallback ? ' fl-content-ui-button':''));
b[i].container.appendChild(this._buttons[name]);
}}
},
_renderFontIcons: function(){
var name=null;
if(this.get('useFontIcons')&&typeof YUI.Env.mods['sm-fonticon']!=='undefined'){
for(name in this._buttons){
if(typeof this._buttons[name]!=='undefined'&&typeof this._fontIcons[name]!=='undefined'){
this._buttons[name].addClass('sm-fonticon-' + this._fontIcons[name]);
this._buttons[name].addClass('sm-fonticon sm-button-skin-default sm-button-nochrome');
}
else if(name.indexOf('count') > -1){
this._buttons[name].addClass('fonticons-enabled');
}}
}},
_updateCount: function(){
var html='',
countText=Y.FL.SlideshowNav.COUNT_TEXT,
current=1,
total=1;
if(this.get('root').albumInfo){
current=this.get('root').imageInfo.index + 1;
total=this.get('root').albumInfo.images.length;
}
html=countText.replace('{current}', current).replace('{total}', total);
this._buttons.count.set('innerHTML', html);
},
_updateCaption: function(){
var root=this.get('root'),
imageInfo=root.imageInfo;
if(imageInfo&&imageInfo.caption===''){
root.caption.slideshowOverlay.enable();
root.caption.slideshowOverlay.hide();
this._buttons.caption.detach('click');
this._buttons.caption.addClass('fl-slideshow-nav-caption-disabled');
}else{
this._buttons.caption.on('click', root._toggleCaption, root);
this._buttons.caption.removeClass('fl-slideshow-nav-caption-disabled');
}},
_updateBuy: function(){
var sm=null,
root=this.get('root'),
rootSource=root.get('source')[root.albumIndex],
albumIndex=root.albumIndex,
source=root.get('source')[albumIndex];
if(rootSource&&rootSource.type=='smugmug'){
if(typeof root.albumInfo.printable!=='undefined'){
this._updateBuyComplete();
}else{
sm=new Y.FL.SmugMugAPI();
sm.addParam('method', 'smugmug.albums.getInfo');
sm.addParam('AlbumID', source.id);
sm.addParam('AlbumKey', source.key);
sm.on('complete', this._updateBuyComplete, this);
sm.request();
}}
},
_updateBuyComplete: function(e){
var root=this.get('root'),
printable=typeof e=='undefined' ? root.albumInfo.printable:e.Album.Printable,
link=root.albumInfo.link;
if(printable){
root.albumInfo.printable=true;
this._buttons.buy.set('href', 'https://secure.smugmug.com/cart/batchadd/?url=' + encodeURIComponent(link));
this._buttons.buy.setStyle('display', 'inline-block');
}else{
root.albumInfo.printable=false;
this._buttons.buy.setStyle('display', 'none');
}
this.fire('resize');
},
_playClicked: function(){
var root=this.get('root');
if(root._playing){
root.pause();
}else{
root.play();
}},
_showPlayButton: function(){
this._buttons.play.removeClass('fl-slideshow-nav-pause');
this._buttons.play.addClass('fl-slideshow-nav-play');
if(this.get('useFontIcons')&&typeof YUI.Env.mods['sm-fonticon']!=='undefined'){
this._buttons.play.removeClass('sm-fonticon-PlayerPause');
this._buttons.play.addClass('sm-fonticon-PlayerPlay');
}},
_showPauseButton: function(){
this._buttons.play.removeClass('fl-slideshow-nav-play');
this._buttons.play.addClass('fl-slideshow-nav-pause');
if(this.get('useFontIcons')&&typeof YUI.Env.mods['sm-fonticon']!=='undefined'){
this._buttons.play.removeClass('sm-fonticon-PlayerPlay');
this._buttons.play.addClass('sm-fonticon-PlayerPause');
}}
}, {
CSS_PREFIX: 'fl-slideshow-nav',
COUNT_TEXT: '{current} of {total}',
ATTRS: {
buttons: {
value: [],
writeOnce: true
},
buttonsLeft: {
value: [],
writeOnce: true
},
buttonsRight: {
value: [],
writeOnce: true
},
useFontIcons: {
value: true,
writeOnce: true
}}
});
Y.namespace('FL').SlideshowOverlay=Y.Base.create('fl-slideshow-overlay', Y.Plugin.Base, [], {
_focus: false,
_visible: true,
_disabled: false,
_showProps: {
duration: 0.5,
easing: 'ease-out',
opacity: 1
},
_hideProps: {
duration: 0.5,
easing: 'ease-out',
opacity: 0
},
_hideTimer: null,
initializer: function(){
var bb=this.get('host').get('boundingBox');
this.afterHostEvent('render', this._initFocus);
this.afterHostEvent('render', this._initVisibility);
if(this.get('closeButton')){
this._initCloseButton();
}
bb.addClass('fl-slideshow-overlay');
},
destructor: function(){
this._hideTimerCancel();
},
_initFocus: function(){
var bb=this.get('host').get('boundingBox');
bb.on('mouseenter', Y.bind(this._setFocusOnMouseenter, this));
bb.on('mouseleave', Y.bind(this._setFocusOnMouseleave, this));
},
_initVisibility: function(){
var bb=this.get('host').get('boundingBox'),
hideStyle=this.get('hideStyle');
if(!this.get('visible')){
if(hideStyle=='display'){
bb.setStyle('display', 'none');
}
else if(hideStyle=='left'){
bb.setStyle('left', '-99999px');
}
bb.setStyle('opacity', '0');
this._visible=false;
}},
_initCloseButton: function(){
var bb=this.get('host').get('boundingBox'),
fallback=this.get('host').get('root').get('fallback'),
closeButton=null;
if(fallback){
closeButton=Y.Node.create('<a class="fl-slideshow-overlay-close" role="button" aria-label="close overlay" tabindex="0"></a>');
}else{
closeButton=Y.Node.create('<button class="fl-slideshow-overlay-close fl-content-ui-button" type="button" aria-label="close overlay"></button>');
}
closeButton.on('click', Y.bind(this._closeButtonClick, this));
if(typeof YUI.Env.mods['sm-fonticon']!=='undefined'){
closeButton.addClass('sm-fonticon sm-fonticon-XCrossEncircled sm-button-skin-default sm-button-nochrome');
}
bb.insert(closeButton);
},
_closeButtonClick: function(){
var bb=this.get('host').get('boundingBox');
bb.transition(this._hideProps, Y.bind(this._hideComplete, this));
},
_setFocusOnMouseenter: function(){
this._focus=true;
},
_setFocusOnMouseleave: function(){
this._focus=false;
},
disable: function(){
this._disabled=true;
},
enable: function(){
this._disabled=false;
},
show: function(){
var bb=this.get('host').get('boundingBox'),
hideStyle=this.get('hideStyle');
if(this._disabled){
return;
}
if(hideStyle=='display'){
bb.setStyle('display', 'block');
}
else if(hideStyle=='left'){
bb.setStyle('left', 'auto');
}
bb.transition(this._showProps, Y.bind(this._showComplete, this));
this.fire('showStart');
},
_showComplete: function(){
this._visible=true;
this.hideWithTimer();
this.fire('showComplete');
},
hide: function(){
if(this._focus||this._disabled){
return;
}
var bb=this.get('host').get('boundingBox');
bb.transition(this._hideProps, Y.bind(this._hideComplete, this));
this.fire('hideStart');
},
hideWithTimer: function(){
this._hideTimerCancel();
this._hideTimer=Y.later(this.get('hideDelay'), this, this.hide);
},
_hideTimerCancel: function(){
if(this._hideTimer){
this._hideTimer.cancel();
this._hideTimer=null;
}},
_hideComplete: function(){
var bb=this.get('host').get('boundingBox'),
hideStyle=this.get('hideStyle');
if(hideStyle=='display'){
bb.setStyle('display', 'none');
}
else if(hideStyle=='left'){
bb.setStyle('left', '-99999px');
}
this._visible=false;
this.fire('hideComplete');
}},	{
NS: 'slideshowOverlay',
ATTRS: {
closeButton: {
value: false,
writeOnce: true
},
hideDelay: {
value: 3000,
writeOnce: true
},
hideStyle: {
value: 'display',
writeOnce: true
},
visible: {
value: true,
writeOnce: true
}}
});
Y.namespace('FL').SlideshowSocial=Y.Base.create('fl-slideshow-social', Y.Widget, [Y.WidgetChild], {
_buttons: null,
renderUI: function(){
this._buttons={};},
bindUI: function(){
var root=this.get('root');
if(root.get('likeButtonEnabled')){
root.on('imageLoadComplete', Y.bind(this._updateLikeButton, this));
}
if(root.get('tweetButtonEnabled')){
root.on('imageLoadComplete', Y.bind(this._updateTweetButton, this));
}
if(root.get('pinterestButtonEnabled')){
root.on('imageLoadComplete', Y.bind(this._updatePinterestButton, this));
}},
_updateLikeButton: function(){
var src=null,
cb=this.get('contentBox'),
root=this.get('root'),
albumIndex=root.albumIndex,
rootSource=root.get('source')[albumIndex],
imageInfo=root.imageInfo;
if(this._buttons.like){
this._buttons.like.remove();
this._buttons.like=null;
}
if(rootSource.type=='smugmug'){
src='https://www.facebook.com/plugins/like.php?';
src +='href=' + 'https://www.smugmug.com/services/graph/gallery/';
src +=rootSource.id + '_' + rootSource.key +'/' + imageInfo.id + '_' + imageInfo.key;
}else{
src='https://www.facebook.com/plugins/like.php?';
src +='href=' + encodeURIComponent(imageInfo.largeURL);
}
src +='&send=false';
src +='&layout=button_count';
src +='&width=90';
src +='&show_faces=false';
src +='&action=like';
src +='&colorscheme=light';
src +='&height=21';
this._buttons.like=Y.Node.create('<iframe src="'+ src +'" scrolling="no" allowTransparency="true"></iframe>');
this._buttons.like.setStyles({
overflow: 'hidden',
width: '90px',
height: '21px'
});
cb.appendChild(this._buttons.like);
},
_updateTweetButton: function(){
var src=null,
imageInfo=this.get('root').imageInfo,
cb=this.get('contentBox');
if(this._buttons.tweet){
this._buttons.tweet.remove();
this._buttons.tweet=null;
}
src='https://platform.twitter.com/widgets/tweet_button.html?';
src +='url=' + encodeURIComponent(imageInfo.largeURL);
src +='&count=none';
this._buttons.tweet=Y.Node.create('<iframe src="'+ src +'" scrolling="no" allowTransparency="true"></iframe>');
this._buttons.tweet.setStyles({
overflow: 'hidden',
width: '90px',
height: '21px'
});
cb.appendChild(this._buttons.tweet);
},
_updatePinterestButton: function(){
var href='https://pinterest.com/pin/create/button/',
imageInfo=this.get('root').imageInfo,
cb=this.get('contentBox');
if(this._buttons.pin){
this._buttons.pin.remove();
this._buttons.pin=null;
}
href +='?url=' + encodeURIComponent(window.location.href);
href +='&media='+ encodeURIComponent(imageInfo.mediumURL);
href +='&description='+ encodeURIComponent(imageInfo.caption);
this._buttons.pin=Y.Node.create('<a></a>');
this._buttons.pin.setAttribute('data-pin-config', 'none');
this._buttons.pin.setAttribute('data-pin-do', 'buttonPin');
this._buttons.pin.setAttribute('href', href);
this._buttons.pin.setAttribute('target', '_blank');
this._buttons.pin.set('innerHTML', '<img src="https://assets.pinterest.com/images/pidgets/pin_it_button.png" border="0" />');
cb.appendChild(this._buttons.pin);
}}, {
CSS_PREFIX: 'fl-slideshow-social',
ATTRS: {
}});
Y.namespace('FL').SlideshowThumbs=Y.Base.create('fl-slideshow-thumbs', Y.Widget, [Y.WidgetParent, Y.WidgetChild], {
_clipBox: null,
_pagesBox: null,
_activePageBox: null,
_activePageIndex: 0,
_nextPageBox: null,
_activeImages: null,
_nextImages: null,
_prevImages: null,
_leftNav: null,
_rightNav: null,
_topNav: null,
_bottomNav: null,
_bbHeight: 0,
_bbWidth: 0,
_cbWidth: 0,
_clipBoxMarginLeft: 0,
_clipBoxTop: 0,
_colsPerPage: 0,
_rowsPerPage: 0,
_imagesPerPage: 0,
_numPages: 0,
_pageHeight: 0,
_pageWidth: 0,
_horizontalSpacing: 0,
_verticalSpacing: 0,
_leftNavWidth: 0,
_rightNavWidth: 0,
_transition: null,
_transitioning: false,
_transitionDirection: 'next',
_gestures: null,
initializer: function(){
this._activeImages=[];
this._nextImages=[];
this._prevImages=[];
},
renderUI: function(){
this._renderBoxes();
this._renderNavs();
},
bindUI: function(){
var root=this.get('root'),
id=this.get('id'),
transition=this.get('transition');
root.on(id + '|albumLoadComplete', this._albumLoadComplete, this);
if('ontouchstart' in window&&this.get('touchSupport')){
this._gestures=new Y.FL.SlideshowGestures({
direction: transition=='slideVertical' ? 'vertical':'horizontal',
activeItem: this._activePageBox,
nextItem: this._nextPageBox
});
this._gestures.on('moveStart', this._gesturesMoveStart, this);
this._gestures.on('endComplete', this._gesturesEndComplete, this);
}},
syncUI: function(){
this._syncBoxes();
this._syncNavs();
},
destructor: function(){
var root=this.get('root'),
id=this.get('id');
root.detach(id + '|*');
Y.FL.SlideshowImageLoader.removeGroup('thumbs');
},
unload: function(){
var root=this.get('root'),
id=this.get('id'),
i=0;
root.detach(id + '|imageLoadComplete');
Y.FL.SlideshowImageLoader.removeGroup('thumbs');
for(; i < this._activeImages.length; i++){
this._activeImages[i].unload();
}},
resize: function(){
this._setSizeInfo();
this._togglePageButtons();
this._resizeBoxes();
this._resizeNavs();
if(this.get('root').albumInfo){
Y.FL.SlideshowImageLoader.removeGroup('thumbs');
this._renderActivePage();
this._preloadNextPage();
this._preloadPrevPage();
}
if(this._gestures&&this._numPages < 2){
this._gestures.disable();
}
else if(this._gestures){
this._gestures.enable();
}},
prevPage: function(){
if(this._transitioning){
return;
}
this._transitionStart('prev');
},
nextPage: function(){
if(this._transitioning){
return;
}
this._transitionStart('next');
},
_albumLoadComplete: function(){
var root=this.get('root'),
id=this.get('id');
root.once(id + '|imageLoadComplete', this.resize, this);
root.on(id + '|imageLoadComplete', this._imageLoadComplete, this);
},
_imageLoadComplete: function(){
var albumInfo=this.get('root').albumInfo,
lastActive=Y.one('.fl-slideshow-image-active'),
lastInfo=lastActive ? lastActive._imageInfo:null,
nextActive=null,
nextInfo=this.get('root').imageInfo;
this._setActiveImage(this._activeImages);
nextActive=Y.one('.fl-slideshow-image-active');
if(lastActive&&!nextActive){
if(nextInfo.index===0&&lastInfo.index===albumInfo.images.length - 1){
this.nextPage();
}
else if(lastInfo.index===0&&nextInfo.index===albumInfo.images.length - 1){
this.prevPage();
}
else if(lastInfo.index < nextInfo.index){
this.nextPage();
}
else if(lastInfo.index > nextInfo.index){
this.prevPage();
}}
},
_renderBoxes: function(){
this._clipBox=Y.Node.create('<div></div>');
this._clipBox.addClass('fl-slideshow-thumbs-clip');
this.get('contentBox').insert(this._clipBox);
this._pagesBox=Y.Node.create('<div></div>');
this._pagesBox.addClass('fl-slideshow-thumbs-pages');
this._clipBox.insert(this._pagesBox);
this._activePageBox=Y.Node.create('<div></div>');
this._activePageBox.addClass('fl-slideshow-thumbs-page');
this._pagesBox.insert(this._activePageBox);
this._nextPageBox=Y.Node.create('<div></div>');
this._nextPageBox.addClass('fl-slideshow-thumbs-page');
this._pagesBox.insert(this._nextPageBox);
},
_syncBoxes: function(){
this._activePageBox.setStyle('left', '0');
this._nextPageBox.setStyle('left', '-9999px');
},
_resizeBoxes: function(){
this.set('width', this._bbWidth);
this.set('height', this._bbHeight);
this.get('contentBox').setStyle('width', this._cbWidth + 'px');
this._clipBox.setStyle('width', this._pageWidth + 'px');
this._clipBox.setStyle('height', this._pageHeight + 'px');
this._clipBox.setStyle('padding', this._verticalSpacing + 'px 0 0 ' + this._horizontalSpacing + 'px ');
this._clipBox.setStyle('margin',  '0 0 0 ' + this._clipBoxMarginLeft + 'px');
this._clipBox.setStyle('top', this._clipBoxTop);
this._pagesBox.setStyle('width', this._pageWidth + 'px');
this._pagesBox.setStyle('height', this._pageHeight + 'px');
this._activePageBox.setStyle('width', this._pageWidth + 'px');
this._activePageBox.setStyle('height', this._pageHeight + 'px');
this._nextPageBox.setStyle('width', this._pageWidth + 'px');
this._nextPageBox.setStyle('height', this._pageHeight + 'px');
},
_renderActivePage: function(){
var i=0,
root=this.get('root'),
imageIndex=this._imagesPerPage * this._activePageIndex,
endIndex=imageIndex + this._imagesPerPage,
images=root.albumInfo.images;
this._clearActiveImage();
for(; i < this._activeImages.length; i++){
this._activeImages[i].remove();
this._activeImages[i].unload();
this._activeImages[i].get('boundingBox')._imageInfo=null;
this._activeImages[i].get('boundingBox').remove();
}
for(i=0; imageIndex < endIndex; imageIndex++){
if(!images[imageIndex]){
break;
}
this._renderImage(this._activeImages, i, this._activePageBox, images[imageIndex]);
i++;
}
this._setActiveImage(this._activeImages);
},
_renderNextPage: function(){
var i=0,
imageArray=this._transitionDirection=='next' ? this._nextImages:this._prevImages;
this._nextPageBox.get('children').remove();
for(; i < imageArray.length; i++){
if(imageArray[i]._imageInfo){
this._renderImage(imageArray, i, this._nextPageBox, imageArray[i]._imageInfo);
}else{
break;
}}
this._setActiveImage(imageArray);
},
_preloadNextPage: function(){
var pageIndex=this._activePageIndex + 1 >=this._numPages ? 0:this._activePageIndex + 1;
this._preloadPage(pageIndex, this._nextImages);
},
_preloadPrevPage: function(){
var pageIndex=this._activePageIndex - 1 < 0 ? this._numPages - 1:this._activePageIndex - 1;
this._preloadPage(pageIndex, this._prevImages);
},
_preloadPage: function(pageIndex, imageArray){
var i=0,
root=this.get('root'),
images=root.albumInfo.images,
imageIndex=pageIndex * this._imagesPerPage,
endIndex=imageIndex + this._imagesPerPage,
imageConfig=this.get('imageConfig'),
width=imageConfig.width,
height=imageConfig.height;
if(this._numPages > 1){
for(; i < imageArray.length; i++){
imageArray[i].remove();
imageArray[i].unload();
}
for(i=0; imageIndex < endIndex; imageIndex++){
if(!images[imageIndex]){
continue;
}
this._renderImage(imageArray, i);
imageArray[i].preload(images[imageIndex], width, height);
i++;
}}
},
_renderImage: function(imageArray, i, page, imageInfo){
var imageBB=null,
imageConfig=this.get('imageConfig');
if(typeof imageArray[i]=='undefined'){
imageConfig.loadGroup='thumbs';
imageConfig.useThumbSizes=true;
imageConfig.loadVideos=false;
imageArray[i]=new Y.FL.SlideshowImage(imageConfig);
imageBB=imageArray[i].get('boundingBox');
imageBB.on('click', this._imageClick, this);
imageBB.on('mouseover', this._imageMouseover, this);
imageBB.on('mouseout', this._imageMouseout, this);
}
imageBB=imageArray[i].get('boundingBox');
imageBB.setStyle('margin', '0 ' + this._horizontalSpacing + 'px ' + this._verticalSpacing + 'px 0');
if(page){
this._childrenContainer=page;
this.add(imageArray[i]);
imageArray[i].resize(imageConfig.width, imageConfig.height);
}
if(imageInfo){
imageArray[i].load(imageInfo);
imageBB._imageInfo=imageInfo;
}},
_uiAddChild: function (child, parentNode){
child.render(parentNode);
parentNode.appendChild(child.get('boundingBox'));
},
_imageClick: function(e){
var root=this.get('root');
if(this.get('pauseOnClick')){
root.pause();
}
root.loadImage(e.currentTarget._imageInfo.index);
this.fire('imageClick');
},
_setActiveImage: function(imageArray){
var i=0;
this._clearActiveImage();
for(; i < imageArray.length; i++){
if(imageArray[i]._imageInfo){
if(imageArray[i]._imageInfo.index==this.get('root').imageInfo.index){
imageArray[i].get('boundingBox').addClass('fl-slideshow-image-active');
break;
}}
}},
_clearActiveImage: function(){
var active=Y.one('.fl-slideshow-image-active');
if(active){
active.removeClass('fl-slideshow-image-active');
}},
_getTransition: function(){
var transition=this.get('transition');
if(transition=='slideHorizontal'&&this._transitionDirection=='next'){
return 'slideLeft';
}
else if(transition=='slideHorizontal'&&this._transitionDirection=='prev'){
return 'slideRight';
}
else if(transition=='slideVertical'&&this._transitionDirection=='next'){
return 'slideUp';
}
else if(transition=='slideVertical'&&this._transitionDirection=='prev'){
return 'slideDown';
}
return transition;
},
_transitionStart: function(direction){
if(this._numPages > 1){
Y.FL.SlideshowImageLoader.removeGroup('thumbs');
this._transitionDirection=direction;
this._transitioning=true;
this._nextPageBox.setStyle('left', '0px');
this._renderNextPage();
this._transition=new Y.FL.SlideshowTransition({
itemIn: this._nextPageBox,
itemOut: this._activePageBox,
type: this._getTransition(),
duration: this.get('transitionDuration'),
easing: this.get('transitionEasing')
});
this._transition.once('complete', this._transitionComplete, this);
this._transition.run();
if(this._gestures){
this._gestures.disable();
}}
},
_transitionComplete: function(){
this._swapPageRefs();
this._transitioning=false;
this._transitionDirection='';
this._transition=null;
if(this._gestures){
this._gestures.enable();
}
this.fire('transitionComplete');
},
_gesturesMoveStart: function(e){
Y.FL.SlideshowImageLoader.removeGroup('thumbs');
this._transitionDirection=e.direction;
this._renderNextPage();
},
_gesturesEndComplete: function(){
this._swapPageRefs();
this._transitionDirection='';
this.fire('transitionComplete');
},
_swapPageRefs: function(){
var lastBox=this._activePageBox,
lastImages=this._activeImages;
this._activePageBox=this._nextPageBox;
this._nextPageBox=lastBox;
this._nextPageBox.setStyle('left', '-9999px');
if(this._transitionDirection=='next'){
this._activeImages=this._nextImages;
this._nextImages=lastImages;
}else{
this._activeImages=this._prevImages;
this._prevImages=lastImages;
}
if(this._transitionDirection=='next'&&this._activePageIndex + 1 < this._numPages){
this._activePageIndex++;
}
else if(this._transitionDirection=='next'){
this._activePageIndex=0;
}
else if(this._transitionDirection=='prev'&&this._activePageIndex - 1 > -1){
this._activePageIndex--;
}
else if(this._transitionDirection=='prev'){
this._activePageIndex=this._numPages - 1;
}
if(this._gestures){
this._gestures.set('activeItem', this._activePageBox);
this._gestures.set('nextItem', this._nextPageBox);
}
this._preloadNextPage();
this._preloadPrevPage();
},
_renderNavs: function(){
var topNavButtons=this.get('topNavButtons'),
rightNavButtons=this.get('rightNavButtons'),
bottomNavButtons=this.get('bottomNavButtons'),
leftNavButtons=this.get('leftNavButtons');
if(this.get('topNavEnabled')&&topNavButtons.length > 0){
this._topNav=new Y.FL.SlideshowNav({ buttons: topNavButtons });
this._topNav.get('boundingBox').addClass('fl-slideshow-thumbs-top-nav');
this.add(this._topNav);
this._topNav.render(this.get('contentBox'));
this._clipBox.insert(this._topNav.get('boundingBox'), 'before');
this._bindNavEvents(this._topNav);
}
if(this.get('rightNavEnabled')&&rightNavButtons.length > 0){
this._rightNav=new Y.FL.SlideshowNav({ buttons: rightNavButtons });
this._rightNav.get('boundingBox').addClass('fl-slideshow-thumbs-right-nav');
this.add(this._rightNav);
this._rightNav.render(this.get('contentBox'));
this._bindNavEvents(this._rightNav);
}
if(this.get('bottomNavEnabled')&&bottomNavButtons.length > 0){
this._bottomNav=new Y.FL.SlideshowNav({ buttons: bottomNavButtons });
this._bottomNav.get('boundingBox').addClass('fl-slideshow-thumbs-bottom-nav');
this.add(this._bottomNav);
this._bottomNav.render(this.get('contentBox'));
this._bindNavEvents(this._bottomNav);
}
if(this.get('leftNavEnabled')&&leftNavButtons.length > 0){
this._leftNav=new Y.FL.SlideshowNav({ buttons: leftNavButtons });
this._leftNav.get('boundingBox').addClass('fl-slideshow-thumbs-left-nav');
this.add(this._leftNav);
this._leftNav.render(this.get('contentBox'));
this._bindNavEvents(this._leftNav);
}},
_syncNavs: function(){
var rightNavBB, bottomNavBB, leftNavBB;
if(this._rightNav){
rightNavBB=this._rightNav.get('boundingBox');
rightNavBB.setStyle('position', 'absolute');
rightNavBB.setStyle('top', '0px');
rightNavBB.setStyle('right', '0px');
}
if(this._bottomNav){
bottomNavBB=this._bottomNav.get('boundingBox');
bottomNavBB.setStyle('position', 'absolute');
bottomNavBB.setStyle('bottom', '0px');
bottomNavBB.setStyle('width', '100%');
}
if(this._leftNav){
leftNavBB=this._leftNav.get('boundingBox');
leftNavBB.setStyle('position', 'absolute');
leftNavBB.setStyle('top', '0px');
leftNavBB.setStyle('left', '0px');
}},
_resizeNavs: function(){
var rightNavBB,
leftNavBB,
marginTop;
if(this._rightNav){
rightNavBB=this._rightNav.get('boundingBox');
marginTop=this._bbHeight/2 - parseInt(rightNavBB.getComputedStyle('height'), 10)/2;
rightNavBB.setStyle('marginTop', marginTop + 'px');
}
if(this._leftNav){
leftNavBB=this._leftNav.get('boundingBox');
marginTop=this._bbHeight/2 - parseInt(leftNavBB.getComputedStyle('height'), 10)/2;
leftNavBB.setStyle('marginTop', marginTop + 'px');
}},
_bindNavEvents: function(nav){
if(nav._buttons.prevPage){
nav._buttons.prevPage.on('click', this.prevPage, this);
}
if(nav._buttons.nextPage){
nav._buttons.nextPage.on('click', this.nextPage, this);
}
nav.on('resize', this.resize, this);
},
_togglePageButtons: function(){
var buttons=this.get('boundingBox').all('.fl-slideshow-nav-prevPage, .fl-slideshow-nav-nextPage'),
display=buttons.getStyle('display')[0];
if(this._numPages==1&&display=='inline-block'){
buttons.setStyle('display', 'none');
this._setSizeInfo();
}
else if(this._numPages > 1&&display=='none'){
buttons.setStyle('display', 'inline-block');
this._setSizeInfo();
}},
_setSizeInfo: function(){
var root=this.get('root'),
bb=this.get('boundingBox'),
bbPosition=bb.getStyle('position'),
bbLeftMargin=parseInt(bb.getStyle('marginLeft'), 10),
bbRightMargin=parseInt(bb.getStyle('marginRight'), 10),
bbTopMargin=parseInt(bb.getStyle('marginTop'), 10),
bbBottomMargin=parseInt(bb.getStyle('marginBottom'), 10),
bbLeftPadding=parseInt(bb.getStyle('paddingLeft'), 10),
bbRightPadding=parseInt(bb.getStyle('paddingRight'), 10),
bbTopPadding=parseInt(bb.getStyle('paddingTop'), 10),
bbBottomPadding=parseInt(bb.getStyle('paddingBottom'), 10),
parent=bb.get('parentNode'),
parentWidth=parseInt(parent.getComputedStyle('width'), 10),
parentHeight=parseInt(parent.getComputedStyle('height'), 10),
bbWidth=parentWidth - bbLeftPadding - bbRightPadding - bbLeftMargin - bbRightMargin,
bbHeight=parentHeight - bbTopPadding - bbBottomPadding - bbTopMargin - bbBottomMargin,
cbWidth=bbWidth,
pageWidth=bbWidth,
pageHeight=bbHeight,
columns=this.get('columns'),
rows=this.get('rows'),
imageConfig=this.get('imageConfig'),
horizontalSpacing=this.get('horizontalSpacing'),
verticalSpacing=this.get('verticalSpacing'),
spaceEvenly=this.get('spaceEvenly'),
centerSinglePage=this.get('centerSinglePage'),
leftNavWidth=0,
rightNavWidth=0,
topNavHeight=0,
bottomNavHeight=0,
colsPerPage=columns,
rowsPerPage=rows,
imagesPerPage=0,
numPages=1,
clipBoxMarginLeft=0,
clipBoxTop=0,
availHorizSpace=0,
availVerticalSpace=0;
bb.setStyle('position', 'relative');
if(!isNaN(columns)){
bbWidth=pageWidth=columns * (imageConfig.width + horizontalSpacing) + horizontalSpacing;
}
if(!isNaN(rows)){
bbHeight=pageHeight=rows * (imageConfig.height + verticalSpacing) + verticalSpacing;
}
if(this._leftNav){
leftNavWidth=parseInt(this._leftNav.get('boundingBox').getComputedStyle('width'), 10);
if(isNaN(columns)){
pageWidth -=leftNavWidth;
}else{
bbWidth +=leftNavWidth;
}}
if(this._rightNav){
rightNavWidth=parseInt(this._rightNav.get('boundingBox').getComputedStyle('width'), 10);
if(isNaN(columns)){
pageWidth -=rightNavWidth;
}else{
bbWidth +=rightNavWidth;
}}
if(this._topNav){
topNavHeight=parseInt(this._topNav.get('boundingBox').getComputedStyle('height'), 10);
if(isNaN(rows)){
pageHeight -=topNavHeight;
}else{
bbHeight +=topNavHeight;
}}
if(this._bottomNav){
bottomNavHeight=parseInt(this._bottomNav.get('boundingBox').getComputedStyle('height'), 10);
if(isNaN(rows)){
pageHeight -=bottomNavHeight;
}else{
bbHeight +=bottomNavHeight;
}}
if(isNaN(columns)){
colsPerPage=Math.floor(pageWidth/(imageConfig.width + horizontalSpacing));
colsPerPage=colsPerPage < 1 ? 1:colsPerPage;
}
if(isNaN(rows)){
rowsPerPage=Math.floor(pageHeight/(imageConfig.height + verticalSpacing));
rowsPerPage=rowsPerPage < 1 ? 1:rowsPerPage;
}
imagesPerPage=colsPerPage * rowsPerPage;
if(root.albumInfo){
numPages=Math.ceil(root.albumInfo.images.length/imagesPerPage);
}
if(isNaN(columns)&&spaceEvenly){
horizontalSpacing=Math.floor((pageWidth - (imageConfig.width * colsPerPage))/(colsPerPage + 1));
}
if(isNaN(rows)&&spaceEvenly){
verticalSpacing=Math.floor((pageHeight - (imageConfig.height * rowsPerPage))/(rowsPerPage + 1));
}
if(root.albumInfo&&centerSinglePage&&numPages==1&&rowsPerPage==1){
cbWidth=root.albumInfo.images.length * imageConfig.width;
cbWidth +=horizontalSpacing * (root.albumInfo.images.length + 1);
if(this._leftNav){
cbWidth +=leftNavWidth;
}
if(this._rightNav){
cbWidth +=rightNavWidth;
}}else{
cbWidth=bbWidth;
}
if(root.albumInfo&&centerSinglePage&&numPages==1&&rowsPerPage==1){
pageWidth=root.albumInfo.images.length * imageConfig.width;
pageWidth +=horizontalSpacing * root.albumInfo.images.length;
}else{
pageWidth=colsPerPage * (imageConfig.width + horizontalSpacing);
}
pageHeight=rowsPerPage * (imageConfig.height + verticalSpacing);
if(numPages < 2){
clipBoxMarginLeft=leftNavWidth;
}else{
availHorizSpace=bbWidth;
if(this._rightNav){
availHorizSpace -=rightNavWidth;
}
if(this._leftNav){
availHorizSpace -=leftNavWidth;
clipBoxMarginLeft=leftNavWidth + (availHorizSpace - pageWidth - horizontalSpacing)/2;
}else{
clipBoxMarginLeft=(availHorizSpace - pageWidth - horizontalSpacing)/2;
}}
if(numPages > 1&&!spaceEvenly){
availVerticalSpace=bbHeight;
if(this._topNav){
availVerticalSpace -=topNavHeight;
}
if(this._bottomNav){
availVerticalSpace -=bottomNavHeight;
}
clipBoxTop=(availVerticalSpace - (verticalSpacing + pageHeight))/2;
}
this._bbHeight=bbHeight;
this._bbWidth=bbWidth;
this._cbWidth=cbWidth;
this._clipBoxMarginLeft=clipBoxMarginLeft;
this._clipBoxTop=clipBoxTop;
this._colsPerPage=colsPerPage;
this._rowsPerPage=rowsPerPage;
this._imagesPerPage=imagesPerPage;
this._numPages=numPages;
this._pageHeight=pageHeight;
this._pageWidth=pageWidth;
this._leftNavWidth=leftNavWidth;
this._rightNavWidth=rightNavWidth;
this._horizontalSpacing=horizontalSpacing;
this._verticalSpacing=verticalSpacing;
this._activePageIndex=Math.floor(root.imageIndex/this._imagesPerPage);
bb.setStyle('position', bbPosition);
}}, {
CSS_PREFIX: 'fl-slideshow-thumbs',
ATTRS: {
columns: {
value: 'auto'
},
rows: {
value: 'auto'
},
horizontalSpacing: {
value: 15
},
verticalSpacing: {
value: 15
},
spaceEvenly: {
value: true
},
centerSinglePage: {
value: true
},
pauseOnClick: {
value: false
},
transition: {
value: 'slideHorizontal'
},
transitionDuration: {
value: 0.8
},
transitionEasing: {
value: 'ease-out'
},
imageConfig: {
value: {
crop: true,
width: 50,
height: 50
}},
topNavEnabled: {
value: false
},
topNavButtons: {
value: ['prevPage', 'nextPage']
},
rightNavEnabled: {
value: true
},
rightNavButtons: {
value: ['nextPage']
},
bottomNavEnabled: {
value: false
},
bottomNavButtons:{
value: ['prevPage', 'nextPage']
},
leftNavEnabled: {
value: true
},
leftNavButtons:{
value: ['prevPage']
},
touchSupport: {
value: false
}}
});
Y.namespace('FL').SlideshowTransition=Y.Base.create('fl-slideshow-transition', Y.Base, [], {
_transitionFunction: '_transitionFade',
_type: 'fade',
initializer: function(){
var type=this.get('type'),
typeArray=[],
types=Y.FL.SlideshowTransition.TYPES,
slideshowImageTypes=Y.FL.SlideshowTransition.SLIDESHOW_IMAGE_TYPES,
isSlideshowImageTransition=Y.Array.indexOf(slideshowImageTypes, type) > -1,
isSlideshowImage=this._isSlideshowImage(),
itemIn=this.get('itemIn'),
itemOut=this.get('itemOut');
if(type.indexOf(',') > -1){
typeArray=type.split(',');
typeArray.sort(function(){ return 0.5 - Math.random(); });
type=typeArray[0];
}
if(!isSlideshowImage&&isSlideshowImageTransition){
type='fade';
}
else if(isSlideshowImage){
if((itemIn&&itemIn.one('img')===null)||(itemOut&&itemOut.one('img')===null)){
type='none';
}
else if(isSlideshowImageTransition){
if((Y.UA.gecko&&Y.UA.gecko < 5)||Y.UA.opera > 0||(Y.UA.ie > 0&&Y.UA.ie < 9)){
type='fade';
}}
}
if(Y.FL.SlideshowTransition.TYPES[type]){
this._transitionFunction=types[type];
this._type=type;
}
this._setupItems();
},
run: function(){
this.fire('start');
this[this._transitionFunction].call(this);
},
_setupItems: function(){
var itemIn=this.get('itemIn'),
itemOut=this.get('itemOut');
if(itemIn){
itemIn.setStyle('zIndex', 2);
itemIn.setStyle('opacity', 1);
if(Y.FL.Utils.cssSupport('transform')){
itemIn.setStyle('transform', 'translate(0, 0)');
}else{
itemIn.setStyle('top', '0');
itemIn.setStyle('left', '0');
}}
if(itemOut){
itemOut.setStyle('zIndex', 1);
}},
_isSlideshowImage: function(){
var itemIn=this.get('itemIn'),
itemOut=this.get('itemOut');
if(itemIn&&itemIn.hasClass('fl-slideshow-image')){
return true;
}
else if(itemOut&&itemOut.hasClass('fl-slideshow-image')){
return true;
}
return false;
},
_transitionStart: function(propsIn, propsOut){
var itemIn=this.get('itemIn'),
itemOut=this.get('itemOut'),
itemInCallback=Y.bind(this._transitionComplete, this),
itemOutCallback 	= !itemIn ? itemInCallback:null,
duration=this.get('duration'),
easing=this.get('easing');
if(itemIn){
propsIn.duration=propsIn.duration||duration;
propsIn.easing=propsIn.easing||easing;
itemIn.transition(propsIn);
}
if(itemOut){
propsOut.duration=propsOut.duration||duration;
propsOut.easing=propsOut.easing||easing;
itemOut.transition(propsOut);
}
if(itemInCallback){
Y.later(propsIn.duration * 1000 + 100, null, itemInCallback);
}
else if(itemOutCallback){
Y.later(propsOut.duration * 1000 + 100, null, itemOutCallback);
}},
_transitionComplete: function(){
this._set('itemIn', null);
this._set('itemOut', null);
this.fire('complete');
},
_transitionNone: function(){
var itemIn=this.get('itemIn'),
itemOut=this.get('itemOut');
if(itemIn){
itemIn.setStyle('opacity', 1);
}
if(itemOut){
itemOut.setStyle('opacity', 0);
}
this._transitionComplete();
},
_transitionFade: function(){
var itemIn=this.get('itemIn');
if(itemIn){
itemIn.setStyle('opacity', 0);
}
this._transitionStart({ opacity: 1 },{ opacity: 0 });
},
_transitionSlideLeft: function(){
if(Y.FL.Utils.cssSupport('transform')){
this._cssTransitionSlide({
inStart: 'translate(100%, 0)',
inEnd: 'translate(0, 0)',
outStart: 'translate(0, 0)',
outEnd: 'translate(-100%, 0)'
});
}else{
this._jsTransitionSlide('left');
}},
_transitionSlideRight: function(){
if(Y.FL.Utils.cssSupport('transform')){
this._cssTransitionSlide({
inStart: 'translate(-100%, 0)',
inEnd: 'translate(0, 0)',
outStart: 'translate(0, 0)',
outEnd: 'translate(100%, 0)'
});
}else{
this._jsTransitionSlide('right');
}},
_transitionSlideUp: function(){
if(Y.FL.Utils.cssSupport('transform')){
this._cssTransitionSlide({
inStart: 'translate(0, 100%)',
inEnd: 'translate(0, 0)',
outStart: 'translate(0, 0)',
outEnd: 'translate(0, -100%)'
});
}else{
this._jsTransitionSlide('up');
}},
_transitionSlideDown: function(){
if(Y.FL.Utils.cssSupport('transform')){
this._cssTransitionSlide({
inStart: 'translate(0, -100%)',
inEnd: 'translate(0, 0)',
outStart: 'translate(0, 0)',
outEnd: 'translate(0, 100%)'
});
}else{
this._jsTransitionSlide('down');
}},
_jsTransitionSlide: function(direction){
var itemIn=this.get('itemIn'),
itemOut=this.get('itemOut'),
itemOutEnd=0;
if(itemOut&&direction=='left'){
itemOutEnd=-parseInt(itemOut.getStyle('width'), 10);
}
if(itemOut&&direction=='right'){
itemOutEnd=parseInt(itemOut.getStyle('width'), 10);
}
if(itemOut&&direction=='up'){
itemOutEnd=-parseInt(itemOut.getStyle('height'), 10);
}
if(itemOut&&direction=='down'){
itemOutEnd=parseInt(itemOut.getStyle('height'), 10);
}
if(itemIn){
itemIn.setStyle('opacity', 1);
}
if(itemIn&&direction=='left'){
itemIn.setStyle('left', itemIn.getStyle('width'));
}
if(itemIn&&direction=='right'){
itemIn.setStyle('left', '-' + itemIn.getStyle('width'));
}
if(itemIn&&direction=='up'){
itemIn.setStyle('top', itemIn.getStyle('height'));
}
if(itemIn&&direction=='down'){
itemIn.setStyle('top', '-' + itemIn.getStyle('height'));
}
if(direction=='left'||direction=='right'){
this._transitionStart({ left: 0 },{ left: itemOutEnd });
}else{
this._transitionStart({ top: 0 },{ top: itemOutEnd });
}},
_cssTransitionSlide: function(props){
var itemIn=this.get('itemIn'),
itemOut=this.get('itemOut'),
transformProp=Y.UA.chrome < 36 ? 'transform':'-webkit-transform',
inProps={},
outProps={};
inProps[transformProp]=props.inEnd;
outProps[transformProp]=props.outEnd;
if(itemIn){
itemIn.setStyle('transition', '');
itemIn.setStyle('opacity', 1);
itemIn.setStyle(transformProp, props.inStart);
}
if(itemOut){
itemOut.setStyle('transition', '');
itemOut.setStyle(transformProp, props.outStart);
}
this._transitionStart(inProps, outProps);
},
_transitionBars: function(){
this.get('itemIn').one('.fl-slideshow-image-img').setStyle('opacity', 0);
var numBars=this.get('bars'),
slices=this._renderSlices(1, numBars),
duration=this.get('duration'),
delay=0,
increment=100,
last=false,
i=0,
clone=null,
props={
duration: duration,
opacity: 1
};
if(this._type=='barsRandom'){
slices=this._randomizeSlices(slices);
}
for(; i < slices.length; i++){
clone=Y.clone(props);
if(this._type=='blinds'){
clone.width=parseFloat(slices[i].getComputedStyle('width'), 10) + 'px';
slices[i].setStyle('width', '0px');
increment=50;
}
last=i==slices.length - 1 ? true:false;
Y.later(delay, this, this._transitionSlice, [slices[i], clone, last]);
delay +=increment;
}
this._transitionSlicesFadeLast(delay);
},
_transitionBoxes: function(){
this.get('itemIn').one('.fl-slideshow-image-img').setStyle('opacity', 0);
var numCols=this.get('boxCols'),
numRows=this.get('boxRows'),
numSlices=numCols * numRows,
multi=this._type!='boxesRandom',
slices=this._renderSlices(numRows, numCols, multi),
duration=this.get('duration'),
delay=0,
increment=150,
last=false,
i=0,
row=0,
col=0,
startCol=-1,
clone=null,
props={
duration: duration,
opacity: 1
};
if(!multi){
slices=this._randomizeSlices(slices);
increment=30;
for(; i < slices.length; i++){
clone=Y.clone(props);
last=i==slices.length - 1 ? true:false;
Y.later(delay, this, this._transitionSlice, [slices[i], clone, last]);
delay +=increment;
}}else{
while(i < numSlices){
for(row=0; row < numRows; row++){
if(row===0){
startCol++;
col=startCol;
}
if(col > -1&&col < numCols){
i++;
clone=Y.clone(props);
if(this._type=='boxesGrow'){
clone.height=parseFloat(slices[row][col].getComputedStyle('height'), 10) + 'px';
clone.width=parseFloat(slices[row][col].getComputedStyle('width'), 10) + 'px';
slices[row][col].setStyle('height', '0px');
slices[row][col].setStyle('width', '0px');
increment=50;
}
last=i==numSlices - 1 ? true:false;
Y.later(delay, this, this._transitionSlice, [slices[row][col], clone, last]);
}
col--;
}
delay +=increment;
}}
this._transitionSlicesFadeLast(delay);
},
_renderSlices: function(numRows, numCols, multidimensional){
var itemIn=this.get('itemIn'),
itemHeight=parseFloat(itemIn.getComputedStyle('height'), 10),
itemWidth=parseFloat(itemIn.getComputedStyle('width'), 10),
img=itemIn.one('img'),
imgSrc=img.get('src'),
imgHeight=parseFloat(img.getComputedStyle('height'), 10),
imgWidth=parseFloat(img.getComputedStyle('width'), 10),
imgLeft=parseFloat(img.getComputedStyle('left'), 10),
imgTop=parseFloat(img.getComputedStyle('top'), 10),
col=0,
row=0,
sliceHeight=Math.round(itemHeight/numRows),
sliceWidth=Math.round(itemWidth/numCols),
slice=null,
sliceImg=null,
slices=[];
for(; row < numRows; row++){
if(typeof multidimensional!=='undefined'&&multidimensional){
slices[row]=[];
}
for(col=0; col < numCols; col++){
slice=Y.Node.create('<div class="fl-slideshow-transition-slice"></div>');
sliceImg=Y.Node.create('<img src="'+ imgSrc +'" />');
slice.setStyles({
left: (sliceWidth * col) + 'px',
top: (sliceHeight * row) + 'px',
width: col==numCols - 1 ? (itemWidth - (sliceWidth * col)) + 'px':sliceWidth + 'px',
height: row==numRows - 1 ? (itemHeight - (sliceHeight * row)) + 'px':sliceHeight + 'px',
opacity: 0
});
sliceImg.setStyles({
height: imgHeight + 'px',
width: imgWidth + 'px',
top: imgTop - ((sliceHeight + (row * sliceHeight)) - sliceHeight) + 'px',
left: imgLeft - ((sliceWidth + (col * sliceWidth)) - sliceWidth) + 'px'
});
slice.append(sliceImg);
itemIn.append(slice);
if(typeof multidimensional!=='undefined'&&multidimensional){
slices[row].push(slice);
}else{
slices.push(slice);
}}
}
return slices;
},
_transitionSlicesFadeLast: function(delay){
var itemOut=this.get('itemOut'),
width=parseInt(Y.one('body').get('winWidth'), 10),
delay=(width > FLBuilderLayoutConfig.breakpoints.medium) ? delay/1000:0;
if(itemOut&&!itemOut.hasClass('fl-slideshow-image-cropped')){
itemOut.transition({
duration: delay + this.get('duration'),
opacity: 0
});
}},
_transitionSlice: function(slice, props, last){
var callback=last ? Y.bind(this._transitionSlicesComplete, this):null;
slice.transition(props, callback);
},
_transitionSlicesComplete: function(){
var itemIn=this.get('itemIn');
itemIn.all('.fl-slideshow-transition-slice').remove();
itemIn.one('.fl-slideshow-image-img').setStyle('opacity', 1);
this._transitionComplete();
},
_randomizeSlices: function(slices){
var i=slices.length, j, temp;
if(i===0){
return;
}
while(--i){
j=Math.floor(Math.random() *(i + 1) );
temp=slices[i];
slices[i]=slices[j];
slices[j]=temp;
}
return slices;
},
_transitionKenBurns: function(){
var kbDuration=this.get('kenBurnsDuration'),
duration=this.get('duration'),
itemIn=this.get('itemIn'),
zoom=this.get('kenBurnsZoom');
this._transitionFade();
(new Y.FL.SlideshowKenBurns({
duration: kbDuration + duration + 4,
image: itemIn,
zoom: zoom
})).run();
}}, {
ATTRS: {
itemIn: {
value: null
},
itemOut: {
value: null
},
duration: {
value: 0.5
},
easing: {
value: 'ease-out'
},
type: {
value: 'fade'
},
bars: {
value: 15
},
boxCols: {
value: 8
},
boxRows: {
value: 4
},
kenBurnsDuration: {
value: 4
},
kenBurnsZoom: {
value: 1.2
}},
TYPES: {
fade: '_transitionFade',
none: '_transitionNone',
slideLeft: '_transitionSlideLeft',
slideRight: '_transitionSlideRight',
slideUp: '_transitionSlideUp',
slideDown: '_transitionSlideDown',
blinds: '_transitionBars',
bars: '_transitionBars',
barsRandom: '_transitionBars',
boxes: '_transitionBoxes',
boxesRandom: '_transitionBoxes',
boxesGrow: '_transitionBoxes',
kenBurns: '_transitionKenBurns'
},
SLIDESHOW_IMAGE_TYPES: [
'blinds',
'bars',
'barsRandom',
'boxes',
'boxesRandom',
'boxesGrow',
'kenBurns'
]
});
Y.namespace('FL').Slideshow=Y.Base.create('fl-slideshow', Y.FL.SlideshowBase, [], {
frame: null,
nav: null,
imageNavLeft: null,
imageNavRight: null,
thumbs: null,
verticalThumbs: null,
caption: null,
social: null,
_nextImagePreloader: null,
_initialNavSettings: null,
initializer: function(){
var imageConfig={
loadGroup: 'main-preload',
crop: this.get('crop'),
position: this.get('position'),
protect: this.get('protect'),
upsize: this.get('upsize')
};
this._nextImagePreloader=new Y.FL.SlideshowImage(imageConfig);
if(this._isMobile()){
this._removeNavButton('prevPage');
this._removeNavButton('nextPage');
this._removeNavButton('fullscreen');
}
if(this._hasNavButton('fullscreen')){
if(Y.FL.SlideshowFullscreen.OS_SUPPORT){
this.plug(Y.FL.SlideshowFullscreen);
}else{
this._removeNavButton('fullscreen');
}}
},
renderUI: function(){
Y.FL.Slideshow.superclass.renderUI.apply(this, arguments);
this._renderFrame();
this._renderVerticalThumbs();
this._renderNavAndThumbs();
this._renderImageNav();
this._renderMouseNav();
this._renderCaption();
this._renderSocial();
},
bindUI: function(){
var ssBB=this.get('boundingBox'),
frameBB=this.frame.get('boundingBox'),
navOverlay=this.get('navOverlay'),
navType=this.get('navType'),
nav=this._getNav(),
clickAction=this.get('clickAction');
Y.FL.Slideshow.superclass.bindUI.apply(this, arguments);
Y.Do.after(this._resizeChildWidgets, this, 'resize');
this.on('albumLoadStart', this._albumLoadStart, this);
this.on('albumLoadComplete', this._albumLoadComplete, this);
this.on('imageLoadComplete', this._loadFrame, this);
if(this.get('loadingImageAlwaysEnabled')){
this.frame.on('transitionInit', Y.bind(this._showLoadingImageWithDelay, this));
this.frame.on('transitionStart', Y.bind(this._hideLoadingImage, this));
}
if(this.get('overlayHideOnMousemove')){
if(nav&&navOverlay){
this.frame.once('transitionComplete', nav.slideshowOverlay.hideWithTimer, nav.slideshowOverlay);
ssBB.on('mousemove', Y.bind(this._toggleNav, this));
}
if(navType=='buttons'||navType=='thumbs'||navType=='custom'){
ssBB.on('mouseenter', Y.bind(this._checkOverlaysOnMouseenter, this));
ssBB.on('mouseleave', Y.bind(this._hideAllOverlays, this));
}}
ssBB.delegate('click', Y.bind(this._overlayCloseClick, this), '.fl-slideshow-overlay-close');
if(clickAction=='gallery'||clickAction=='url'){
frameBB.delegate('click', Y.bind(this._frameClick, this), '.fl-slideshow-image-img');
}},
syncUI: function(){
var bb=this.get('boundingBox');
Y.FL.Slideshow.superclass.syncUI.apply(this, arguments);
bb._node.onselectstart=function(){ return false; };
bb._node.unselectable="on";
bb._node.style.MozUserSelect="none";
if(this.get('clickAction')!='none'){
this.frame.get('boundingBox').addClass('fl-click-action-enabled');
}},
_isMobile: function(){
return /Mobile|Android|Silk\/|Kindle|BlackBerry|Opera Mini|Opera Mobi|webOS/i.test(navigator.userAgent);
},
unload: function(){
this.pause();
this.frame.unload();
if(this.thumbs!==null){
this.thumbs.unload();
}},
_albumLoadStart: function(){
this._showLoadingImage();
},
_albumLoadComplete: function(){
this.frame.once('transitionStart', Y.bind(this._hideLoadingImage, this));
},
_resizeChildWidgets: function(){
var bb=this.get('boundingBox'),
cb=this.get('contentBox'),
imageNavEnabled=this.get('imageNavEnabled');
this._renderNavAndThumbs();
if(this.get('verticalThumbsOverlay')){
this._resizeFrame(cb.get('offsetWidth'), bb.get('offsetHeight'));
this._resizeVerticalThumbs();
}else{
this._resizeVerticalThumbs();
this._resizeFrame(cb.get('offsetWidth'), bb.get('offsetHeight'));
}
if(imageNavEnabled){
this._positionImageNav();
}
this._positionLoadingImage();
},
_renderVerticalThumbs: function(){
var threshold=this.get('responsiveThreshold'),
ssBB=this.get('boundingBox'),
bbWidth=ssBB.get('offsetWidth'),
vtBB;
if(this.get('verticalThumbsEnabled')&&bbWidth > threshold){
this.verticalThumbs=new Y.FL.SlideshowThumbs(this._getVerticalThumbsConfig());
this.add(this.verticalThumbs);
this.verticalThumbs.render(ssBB);
vtBB=this.verticalThumbs.get('boundingBox');
vtBB.addClass('fl-slideshow-vertical-thumbs');
vtBB.setStyle(this.get('verticalThumbsPosition'), 0);
ssBB.append(vtBB);
if(this.get('verticalThumbsOverlay')){
this.verticalThumbs.plug(Y.FL.SlideshowOverlay, {
hideDelay: this.get('overlayHideDelay'),
hideStyle: 'left'
});
this.frame.get('boundingBox').append(vtBB);
this.verticalThumbs.resize();
}else{
this.verticalThumbs.resize();
this._adjustContentForVerticalThumbs();
}
this._bindVerticalThumbs();
}},
_getVerticalThumbsConfig: function(){
var attrs=this.getAttrs(),
config={
columns: 				attrs.verticalThumbsColumns,
rows: 					'auto',
centerSinglePage: 		false,
horizontalSpacing: 		attrs.verticalThumbsHorizontalSpacing,
verticalSpacing:	 	attrs.verticalThumbsVerticalSpacing,
spaceEvenly: 			attrs.verticalThumbsSpaceEvenly,
rightNavEnabled: 		false,
leftNavEnabled: 		false,
topNavEnabled: 			attrs.verticalThumbsTopNavEnabled,
topNavButtons:			attrs.verticalThumbsTopNavButtons,
bottomNavEnabled: 		attrs.verticalThumbsBottomNavEnabled,
bottomNavButtons:		attrs.verticalThumbsBottomNavButtons,
pauseOnClick: 			attrs.verticalThumbsPauseOnClick,
transition:				attrs.verticalThumbsTransition,
transitionDirection: 	attrs.verticalThumbsTransitionDirection,
transitionEasing:		attrs.verticalThumbsTransitionEasing,
touchSupport:			true,
imageConfig: {
crop: 				attrs.verticalThumbsImageCrop,
width: 				attrs.verticalThumbsImageWidth,
height: 			attrs.verticalThumbsImageHeight
}};
return config;
},
_bindVerticalThumbs: function(){
var ssBB=this.get('boundingBox'),
hideOnMouse=this.get('overlayHideOnMousemove'),
vtOverlay=this.get('verticalThumbsOverlay'),
vt=this.verticalThumbs;
if(vt&&hideOnMouse&&vtOverlay){
this.frame.once('transitionComplete', vt.slideshowOverlay.hideWithTimer, vt.slideshowOverlay);
ssBB.on('mousemove', Y.bind(this._toggleVerticalThumbs, this));
ssBB.on('mouseenter', Y.bind(this._toggleVerticalThumbs, this));
}},
_resizeVerticalThumbs: function(){
var vtEnabled=this.get('verticalThumbsEnabled'),
vtOverlay,
threshold,
ssBB,
bbWidth,
navOverlay,
navType,
nav,
navBB;
if(vtEnabled){
vtOverlay=this.get('verticalThumbsOverlay');
threshold=this.get('responsiveThreshold');
ssBB=this.get('boundingBox');
bbWidth=ssBB.get('offsetWidth');
navOverlay=this.get('navOverlay');
navType=this.get('navType');
nav=this._getNav();
if(this.verticalThumbs&&bbWidth > threshold){
this.verticalThumbs.get('boundingBox').setStyle('display', 'block');
this.verticalThumbs.resize();
if(!vtOverlay){
this._adjustContentForVerticalThumbs();
}
else if(nav&&navOverlay){
navBB=nav.get('boundingBox');
if(navType=='thumbs'){
this._adjustOverlayForVerticalThumbs(navBB, true);
this.thumbs.resize();
}else{
this._adjustOverlayForVerticalThumbs(navBB);
}}
}
else if(!this.verticalThumbs&&bbWidth > threshold){
this._renderVerticalThumbs();
}
else if(this.verticalThumbs&&bbWidth <=threshold){
this.verticalThumbs.get('boundingBox').setStyle('display', 'none');
if(!vtOverlay){
this.get('contentBox').setStyles({
left: 'auto',
position: 'relative',
right: 'auto',
width: 'auto'
});
}}
}},
_toggleVerticalThumbs: function(){
if(this.verticalThumbs){
if(this.verticalThumbs.slideshowOverlay._visible){
this.verticalThumbs.slideshowOverlay.hideWithTimer();
}else{
this.verticalThumbs.slideshowOverlay.show();
}}
},
_adjustContentForVerticalThumbs: function(){
var ssBB=this.get('boundingBox'),
vtBB=this.verticalThumbs.get('boundingBox'),
vtPos=this.get('verticalThumbsPosition'),
ssCB=this.get('contentBox'),
cbPos=vtPos=='left' ? 'right':'left',
cbWidth=ssBB.get('offsetWidth') - vtBB.get('offsetWidth');
ssCB.setStyle('position', 'absolute');
ssCB.setStyle(cbPos, 0);
ssCB.setStyle('width', cbWidth);
},
_adjustOverlayForVerticalThumbs: function(node, useMargin){
var vtEnabled=this.get('verticalThumbsEnabled'),
vtOverlay=this.get('verticalThumbsOverlay'),
vtBB=null,
vtPos=null,
margin=typeof useMargin==='undefined' ? '':'margin-',
vtWidth=0;
if(this.verticalThumbs&&vtEnabled&&vtOverlay){
vtBB=this.verticalThumbs.get('boundingBox');
vtWidth=vtBB.get('offsetWidth');
vtPos=this.get('verticalThumbsPosition');
if(vtPos=='left'){
node.setStyle(margin + 'left', vtWidth + 'px');
}else{
node.setStyle(margin + 'right', vtWidth + 'px');
}}
},
_renderFrame: function(){
this.frame=new Y.FL.SlideshowFrame({
imageConfig: {
loadGroup: 'main',
loadPriority: true,
crop: this.get('crop'),
cropHorizontalsOnly: this.get('cropHorizontalsOnly'),
position: this.get('position'),
protect: this.get('protect'),
upsize: this.get('upsize'),
showVideoButton: this.get('navOverlay')
},
touchSupport: this.get('touchSupport')
});
this.add(this.frame);
this.frame.render(this.get('contentBox'));
this.frame.get('boundingBox').addClass('fl-slideshow-main-image');
this._setPlayingTimerEvent(this.frame, 'transitionComplete');
this._loadingImageContainer=this.frame.get('contentBox');
},
_resizeFrame: function(width, height){
var navOverlay=this.get('navOverlay'),
nav=this._getNav();
if(nav&&!navOverlay){
height -=parseInt(nav.get('boundingBox').getComputedStyle('height'), 10);
}
this.frame.resize(width, height);
},
_loadFrame: function(e){
var activeIndex=this.imageInfo.index,
images=this.albumInfo.images,
nextIndex=activeIndex + 1 >=images.length ? 0:activeIndex + 1,
width=this.frame.get('width'),
height=this.frame.get('height');
this.frame.load(e.imageInfo);
Y.FL.SlideshowImageLoader.removeGroup('main-preload');
this._nextImagePreloader.preload(images[nextIndex], width, height);
},
_frameClick: function(){
var clickAction=this.get('clickAction'),
clickActionUrl=this.get('clickActionUrl');
if(clickAction=='url'){
window.location.href=clickActionUrl;
}
else if(clickAction=='gallery'){
window.location.href=this.imageInfo.link;
}},
_initMiniNav: function(){
var buttons=[];
if(this._hasNavButton('prev')){
buttons.push('prev');
}
if(this._hasNavButton('thumbs')||this.get('navType')=='thumbs'){
buttons.push('thumbs');
}
if(this._hasNavButton('caption')){
buttons.push('caption');
}
if(this._hasNavButton('social')){
buttons.push('social');
}
if(this._hasNavButton('buy')){
buttons.push('buy');
}
if(this._hasNavButton('play')){
buttons.push('play');
}
if(this._hasNavButton('fullscreen')&&!('ontouchstart' in window)){
buttons.push('fullscreen');
}
if(this._hasNavButton('next')){
buttons.push('next');
}
this._initialNavSettings={
buttons: this.get('navButtons'),
buttonsLeft: this.get('navButtonsLeft'),
buttonsRight: this.get('navButtonsRight'),
type: this.get('navType')
};
this._set('navButtons', buttons);
this._set('navButtonsLeft', []);
this._set('navButtonsRight', []);
this._set('navType', 'buttons');
},
_renderNavAndThumbs: function(){
var navType=this.get('navType'),
renderNav=false,
bbWidth,
threshold;
if(navType=='buttons'||navType=='thumbs'){
bbWidth=this.get('boundingBox').get('offsetWidth');
threshold=this.get('responsiveThreshold');
if(bbWidth <=threshold&&this._initialNavSettings===null){
this._initMiniNav();
renderNav=true;
}
else if(bbWidth > threshold&&this._initialNavSettings!==null){
this._set('navButtons', this._initialNavSettings.buttons);
this._set('navButtonsLeft', this._initialNavSettings.buttonsLeft);
this._set('navButtonsRight', this._initialNavSettings.buttonsRight);
this._set('navType', this._initialNavSettings.type);
this._initialNavSettings=null;
renderNav=true;
}
if(renderNav||this.nav===null){
this._renderNav();
}
if(renderNav||this.thumbs===null){
this._renderThumbs();
}
else if(this._thumbsEnabled()){
this._resizeThumbs();
}
if(renderNav&&this.caption!==null){
this._syncCaption();
}
if(renderNav&&this.social!==null){
this._syncSocial();
}}
},
_renderNav: function(){
var frameBB=this.frame.get('boundingBox'),
navBB=null,
navOverlay=this.get('navOverlay'),
navPosition=this.get('navPosition');
this._destroyNav();
if(this.get('navType')=='buttons'){
this.nav=new Y.FL.SlideshowNav({
buttons: this.get('navButtons'),
buttonsLeft: this.get('navButtonsLeft'),
buttonsRight: this.get('navButtonsRight')
});
this.add(this.nav);
this.nav.render(this.get('contentBox'));
navBB=this.nav.get('boundingBox');
if(navOverlay){
this.nav.plug(Y.FL.SlideshowOverlay, {
hideDelay: this.get('overlayHideDelay')
});
navBB.setStyle('position', 'absolute');
navBB.setStyle(navPosition, '0px');
}
if(navPosition=='top'){
frameBB.insert(navBB, 'before');
}else{
frameBB.insert(navBB, 'after');
}
navBB.addClass('fl-slideshow-main-nav');
}},
_destroyNav: function(){
if(this.nav!==null){
if(this.nav.slideshowOverlay){
this.nav.slideshowOverlay.destroy();
}
this.nav.get('boundingBox').remove();
this.remove(this.nav);
try { this.nav.destroy(true); } catch(e){}
this.nav=null;
}},
_getNav: function(){
var navType=this.get('navType');
if(navType=='buttons'){
return this.nav;
}
else if(navType=='thumbs'){
return this.thumbs;
}else{
return null;
}},
_toggleNav: function(){
var nav=this._getNav();
if(nav.slideshowOverlay){
if(nav.slideshowOverlay._visible){
nav.slideshowOverlay.hideWithTimer();
}else{
nav.slideshowOverlay.show();
}}
},
_renderImageNav: function(){
var ssBB;
if(this.get('imageNavEnabled')){
if(this._isMobile()){
this._set('imageNavEnabled', false);
}else{
ssBB=this.get('boundingBox');
this.imageNavLeft=new Y.FL.SlideshowNav({
buttons: ['prev'],
useFontIcons: false
});
this.imageNavRight=new Y.FL.SlideshowNav({
buttons: ['next'],
useFontIcons: false
});
this.add(this.imageNavLeft);
this.add(this.imageNavRight);
this.imageNavLeft.render(this.frame.get('boundingBox'));
this.imageNavRight.render(this.frame.get('boundingBox'));
this.imageNavLeft.plug(Y.FL.SlideshowOverlay, { hideDelay: this.get('overlayHideDelay') });
this.imageNavRight.plug(Y.FL.SlideshowOverlay, { hideDelay: this.get('overlayHideDelay') });
if(this.get('overlayHideOnMousemove')){
this.frame.once('transitionComplete', this.imageNavLeft.slideshowOverlay.hideWithTimer, this.imageNavLeft.slideshowOverlay);
this.frame.once('transitionComplete', this.imageNavRight.slideshowOverlay.hideWithTimer, this.imageNavRight.slideshowOverlay);
ssBB.on('mousemove', Y.bind(this._toggleImageNav, this));
ssBB.on('mouseenter', Y.bind(this._toggleImageNav, this));
}
this.imageNavLeft.get('boundingBox').addClass('fl-slideshow-image-nav-left');
this.imageNavRight.get('boundingBox').addClass('fl-slideshow-image-nav-right');
}}
},
_positionImageNav: function(){
var leftBB=this.imageNavLeft.get('boundingBox'),
rightBB=this.imageNavRight.get('boundingBox'),
imageNavHeight=leftBB.get('offsetHeight'),
frameHeight=this.frame.get('boundingBox').get('offsetHeight'),
top=frameHeight/2 - imageNavHeight/2,
styles={
top: top + 'px',
display: 'block'
};
leftBB.setStyles(styles);
rightBB.setStyles(styles);
this._adjustOverlayForVerticalThumbs(leftBB);
this._adjustOverlayForVerticalThumbs(rightBB);
},
_toggleImageNav: function(){
if(this.imageNavLeft.slideshowOverlay._visible){
this.imageNavLeft.slideshowOverlay.hideWithTimer();
}else{
this.imageNavLeft.slideshowOverlay.show();
}
if(this.imageNavRight.slideshowOverlay._visible){
this.imageNavRight.slideshowOverlay.hideWithTimer();
}else{
this.imageNavRight.slideshowOverlay.show();
}},
_renderMouseNav: function(){
if(this.get('mouseNavEnabled')&&!('ontouchstart' in window)&&!window.navigator.msPointerEnabled){
this.plug(Y.FL.SlideshowMouseNav, {
trigger: this.frame.get('boundingBox')
});
}},
_thumbsEnabled: function(){
var navType=this.get('navType');
if(navType=='thumbs'){
return true;
}
if((navType=='buttons'||navType=='custom')&&this._hasNavButton('thumbs')){
return true;
}else{
return false;
}},
_renderThumbs: function(){
var frameBB, navOverlay, navPosition, navType;
this._destroyThumbs();
if(this._thumbsEnabled()){
frameBB=this.frame.get('boundingBox');
navOverlay=this.get('navOverlay');
navPosition=this.get('navPosition');
navType=this.get('navType');
this.thumbs=new Y.FL.SlideshowThumbs(this._getThumbsConfig());
try { this.add(this.thumbs); } catch(e){}
if(navType=='buttons'||navType=='custom'){
this.thumbs.plug(Y.FL.SlideshowOverlay, {
hideDelay: this.get('overlayHideDelay'),
hideStyle: 'left',
visible: false
});
}
else if(navType=='thumbs'&&navOverlay){
this.thumbs.plug(Y.FL.SlideshowOverlay, {
hideDelay: this.get('overlayHideDelay'),
hideStyle: 'left'
});
}
this.thumbs.render(this.get('contentBox'));
if(navPosition=='top'){
frameBB.insert(this.thumbs.get('boundingBox'), 'before');
}else{
frameBB.insert(this.thumbs.get('boundingBox'), 'after');
}
if(this.get('thumbsHideOnClick')&&navType!='thumbs'){
this.thumbs.on('imageClick', Y.bind(this._hideThumbsOnImageClick, this));
}
this._syncThumbs();
}},
_destroyThumbs: function(){
if(this.thumbs!==null){
if(this.thumbs.slideshowOverlay){
this.thumbs.slideshowOverlay.destroy();
}
this.thumbs.get('boundingBox').remove();
this.remove(this.thumbs);
try { this.thumbs.destroy(true); } catch(e){}
this.thumbs=null;
}},
_syncThumbs: function(){
var thumbsBB=this.thumbs.get('boundingBox'),
navOverlay=this.get('navOverlay'),
navPosition=this.get('navPosition'),
navType=this.get('navType'),
paddingType='padding' + navPosition.charAt(0).toUpperCase() + navPosition.slice(1),
navHeight=0;
if(navType=='buttons'){
navHeight=parseInt(this.nav.get('boundingBox').getComputedStyle('height'), 10);
thumbsBB.setStyle('position', 'absolute');
if(navOverlay){
thumbsBB.setStyle(paddingType, navHeight + 'px');
thumbsBB.setStyle(navPosition, '0px');
}else{
thumbsBB.setStyle(navPosition, navHeight + 'px');
}}
if(navType=='custom'||(navType=='thumbs'&&navOverlay)){
thumbsBB.setStyle('position', 'absolute');
thumbsBB.setStyle(navPosition, '0px');
}
this.thumbs.resize();
},
_getThumbsConfig: function(){
var attrs=this.getAttrs(),
navType=this.get('navType'),
imageConfig={
crop: attrs.thumbsImageCrop,
width: attrs.thumbsImageWidth,
height: attrs.thumbsImageHeight
},
config={
columns: 				'auto',
rows: 					1,
horizontalSpacing: 		attrs.thumbsHorizontalSpacing,
verticalSpacing:	 	attrs.thumbsVerticalSpacing,
spaceEvenly: 			attrs.thumbsSpaceEvenly,
centerSinglePage:	 	attrs.thumbsCenterSinglePage,
pauseOnClick: 			attrs.thumbsPauseOnClick,
transition:				attrs.thumbsTransition,
transitionDirection: 	attrs.thumbsTransitionDirection,
transitionEasing:		attrs.thumbsTransitionEasing,
leftNavButtons: 		attrs.navButtonsLeft,
rightNavButtons: 		attrs.navButtonsRight,
imageConfig:			imageConfig,
touchSupport:			true
};
if(navType=='buttons'||navType=='custom'){
if('ontouchstart' in window){
config.leftNavEnabled=false;
config.rightNavEnabled=false;
}else{
config.centerSinglePage=false;
config.leftNavButtons=['prevPage'];
config.rightNavButtons=['nextPage'];
}}
return config;
},
_resizeThumbs: function(){
if(this.thumbs){
this.thumbs.resize();
}},
_toggleThumbs: function(){
this._toggleOverlay(this.thumbs.slideshowOverlay);
},
_hideThumbsOnImageClick: function(){
if(this.thumbs.slideshowOverlay){
this.thumbs.slideshowOverlay._focus=false;
this.thumbs.slideshowOverlay.enable();
this.thumbs.slideshowOverlay.hide();
if(this.nav&&this.nav.slideshowOverlay){
this.nav.slideshowOverlay.enable();
}}
},
_renderCaption: function(){
if(this._hasNavButton('caption')){
this.caption=new Y.FL.SlideshowCaption({
lessLinkText: this.get('captionLessLinkText'),
moreLinkText: this.get('captionMoreLinkText'),
textLength: this.get('captionTextLength'),
stripTags: this.get('captionStripTags')
});
this.add(this.caption);
this.caption.plug(Y.FL.SlideshowOverlay, {
hideDelay: this.get('overlayHideDelay'),
visible: false,
closeButton: true
});
this._syncCaption();
}},
_syncCaption: function(){
var captionBB=this.caption.get('boundingBox'),
navOverlay=this.get('navOverlay'),
navPosition=this.get('navPosition'),
nav=this._getNav(),
paddingType='padding' + navPosition.charAt(0).toUpperCase() + navPosition.slice(1),
navHeight=0;
captionBB.setStyle('position', 'absolute');
if(nav){
navHeight=parseInt(nav.get('boundingBox').getComputedStyle('height'), 10);
}
if(nav&&navOverlay){
captionBB.setStyle(paddingType, navHeight + 'px');
captionBB.setStyle(navPosition, '0px');
}else{
captionBB.setStyle(navPosition, navHeight + 'px');
}},
_toggleCaption: function(){
this._toggleOverlay(this.caption.slideshowOverlay);
},
_renderSocial: function(){
if(this._hasNavButton('social')){
this.social=new Y.FL.SlideshowSocial();
this.add(this.social);
this.social.plug(Y.FL.SlideshowOverlay, {
hideDelay: this.get('overlayHideDelay'),
visible: false,
closeButton: true
});
this._syncSocial();
}},
_syncSocial: function(){
var socialBB=this.social.get('boundingBox'),
navOverlay=this.get('navOverlay'),
navPosition=this.get('navPosition'),
nav=this._getNav(),
paddingType='padding' + navPosition.charAt(0).toUpperCase() + navPosition.slice(1),
navHeight=0;
socialBB.setStyle('position', 'absolute');
if(nav){
navHeight=parseInt(nav.get('boundingBox').getComputedStyle('height'), 10);
}
if(nav&&navOverlay){
socialBB.setStyle(paddingType, navHeight + 'px');
socialBB.setStyle(navPosition, '0px');
}else{
socialBB.setStyle(navPosition, navHeight + 'px');
}},
_toggleSocial: function(){
this._toggleOverlay(this.social.slideshowOverlay);
var iFrame=jQuery('.fl-slideshow-social-content').find('iframe');
iFrame.remove();
jQuery('.fl-slideshow-social-content').prepend(iFrame);
},
_toggleOverlay: function(overlay){
var navType=this.get('navType'),
nav=this._getNav();
if(overlay._visible){
if(nav&&nav.slideshowOverlay){
nav.slideshowOverlay.enable();
}
overlay.enable();
overlay.hide();
}else{
if(nav&&nav.slideshowOverlay){
nav.slideshowOverlay.disable();
}
overlay.show();
overlay.disable();
}
if(this.thumbs&&navType!='thumbs'&&this.thumbs.slideshowOverlay!==overlay){
this.thumbs.slideshowOverlay.enable();
this.thumbs.slideshowOverlay.hide();
}
if(this.caption&&this.caption.slideshowOverlay!==overlay){
this.caption.slideshowOverlay.enable();
this.caption.slideshowOverlay.hide();
}
if(this.social&&this.social.slideshowOverlay!==overlay){
this.social.slideshowOverlay.enable();
this.social.slideshowOverlay.hide();
}},
_overlayCloseClick: function(){
if(this.nav&&this.nav.slideshowOverlay){
this.nav.slideshowOverlay.enable();
}
if(this.thumbs&&this.thumbs.slideshowOverlay){
this.thumbs.slideshowOverlay.enable();
}
if(this.caption){
this.caption.slideshowOverlay.enable();
}
if(this.social){
this.social.slideshowOverlay.enable();
}
if(this.imageNavLeft){
this.imageNavLeft.slideshowOverlay.enable();
this.imageNavRight.slideshowOverlay.enable();
}},
_hideAllOverlays: function(){
if(this.nav&&this.nav.slideshowOverlay&&this.nav.slideshowOverlay._visible){
this.nav.slideshowOverlay.enable();
this.nav.slideshowOverlay.hideWithTimer();
}
if(this.thumbs&&this.thumbs.slideshowOverlay&&this.thumbs.slideshowOverlay._visible){
this.thumbs.slideshowOverlay.enable();
this.thumbs.slideshowOverlay.hideWithTimer();
}
if(this.caption&&this.caption.slideshowOverlay._visible){
this.caption.slideshowOverlay.enable();
this.caption.slideshowOverlay.hideWithTimer();
}
if(this.social&&this.social.slideshowOverlay._visible){
this.social.slideshowOverlay.enable();
this.social.slideshowOverlay.hideWithTimer();
}
if(this.imageNavLeft){
this.imageNavLeft.slideshowOverlay.enable();
this.imageNavLeft.slideshowOverlay.hideWithTimer();
this.imageNavRight.slideshowOverlay.enable();
this.imageNavRight.slideshowOverlay.hideWithTimer();
}},
_checkOverlaysOnMouseenter: function(){
var navType=this.get('navType'),
navOverlay=this.get('navOverlay'),
nav=this._getNav(),
overlayVisible=false;
if(this.thumbs&&navType!='thumbs'&&this.thumbs.slideshowOverlay._visible){
overlayVisible=true;
this.thumbs.slideshowOverlay.disable();
}
else if(this.caption&&this.caption.slideshowOverlay._visible){
overlayVisible=true;
this.caption.slideshowOverlay.disable();
}
else if(this.social&&this.social.slideshowOverlay._visible){
overlayVisible=true;
this.social.slideshowOverlay.disable();
}
if(nav&&overlayVisible&&navOverlay){
nav.slideshowOverlay.disable();
}},
_hasNavButton: function(button){
var navType=this.get('navType');
if(navType=='buttons'||navType=='thumbs'||navType=='custom'){
if(Y.Array.indexOf(this.get('navButtons'), button) > -1){
return true;
}
else if(Y.Array.indexOf(this.get('navButtonsLeft'), button) > -1){
return true;
}
else if(Y.Array.indexOf(this.get('navButtonsRight'), button) > -1){
return true;
}else{
return false;
}}else{
return false;
}},
_removeNavButton: function(button){
var buttons=this.get('navButtons'),
buttonsLeft=this.get('navButtonsLeft'),
buttonsRight=this.get('navButtonsRight'),
vtTopNavButtons=this.get('verticalThumbsTopNavButtons'),
vtBottomNavButtons=this.get('verticalThumbsBottomNavButtons');
if(Y.Array.indexOf(buttons, button) > -1){
buttons.splice(Y.Array.indexOf(buttons, button), 1);
}
if(Y.Array.indexOf(buttonsLeft, button) > -1){
buttonsLeft.splice(Y.Array.indexOf(buttonsLeft, button), 1);
}
if(Y.Array.indexOf(buttonsRight, button) > -1){
buttonsRight.splice(Y.Array.indexOf(buttonsRight, button), 1);
}
if(Y.Array.indexOf(vtTopNavButtons, button) > -1){
vtTopNavButtons.splice(Y.Array.indexOf(vtTopNavButtons, button), 1);
}
if(Y.Array.indexOf(vtBottomNavButtons, button) > -1){
vtBottomNavButtons.splice(Y.Array.indexOf(vtBottomNavButtons, button), 1);
}
this._set('navButtons', buttons);
this._set('navButtonsLeft', buttonsLeft);
this._set('navButtonsRight', buttonsRight);
this._set('verticalThumbsTopNavButtons', vtTopNavButtons);
this._set('verticalThumbsBottomNavButtons', vtBottomNavButtons);
}}, {
CSS_PREFIX: 'fl-slideshow',
ATTRS: {
clickAction: {
value: 'none'
},
clickActionUrl: {
value: ''
},
crop: {
value: false
},
cropHorizontalsOnly: {
value: false
},
loadingImageAlwaysEnabled: {
value: true
},
position: {
value: 'center center'
},
protect: {
value: true
},
upsize: {
value: true
},
transition: {
value: 'fade'
},
transitionDuration: {
value: 1
},
transitionEasing: {
value: 'ease-out'
},
kenBurnsZoom: {
value: 1.2
},
navType: {
value: 'none'
},
navPosition: {
value: 'bottom'
},
navOverlay: {
value: false
},
navButtons: {
value: []
},
navButtonsLeft: {
value: []
},
navButtonsRight: {
value: []
},
overlayHideOnMousemove: {
value: true
},
overlayHideDelay: {
value: 3000
},
imageNavEnabled: {
value: false
},
mouseNavEnabled: {
value: false
},
thumbsHideOnClick: {
value: true
},
thumbsHorizontalSpacing: {
value: 15
},
thumbsVerticalSpacing: {
value: 15
},
thumbsSpaceEvenly: {
value: true
},
thumbsCenterSinglePage: {
value: true
},
thumbsPauseOnClick: {
value: false
},
thumbsTransition: {
value: 'slideHorizontal'
},
thumbsTransitionDuration: {
value: 0.8
},
thumbsTransitionEasing: {
value: 'ease-out'
},
thumbsImageCrop: {
value: true
},
thumbsImageWidth: {
value: 50
},
thumbsImageHeight: {
value: 50
},
captionLessLinkText: {
value: 'Read Less'
},
captionMoreLinkText: {
value: 'Read More'
},
captionTextLength: {
value: 200
},
captionStripTags: {
value: false
},
verticalThumbsEnabled: {
value: false
},
verticalThumbsPosition: {
value: 'left'
},
verticalThumbsOverlay: {
value: false
},
verticalThumbsColumns: {
value: 1
},
verticalThumbsTopNavEnabled: {
value: false
},
verticalThumbsTopNavButtons: {
value: ['prevPage', 'nextPage']
},
verticalThumbsBottomNavEnabled: {
value: true
},
verticalThumbsBottomNavButtons: {
value: ['prevPage', 'nextPage']
},
verticalThumbsHorizontalSpacing: {
value: 15
},
verticalThumbsVerticalSpacing: {
value: 15
},
verticalThumbsSpaceEvenly: {
value: false
},
verticalThumbsPauseOnClick: {
value: false
},
verticalThumbsImageCrop: {
value: true
},
verticalThumbsImageWidth: {
value: 75
},
verticalThumbsImageHeight: {
value: 75
},
verticalThumbsTransition: {
value: 'slideVertical'
},
verticalThumbsTransitionDuration: {
value: 0.8
},
verticalThumbsTransitionEasing: {
value: 'ease-out'
},
likeButtonEnabled: {
value: true
},
pinterestButtonEnabled: {
value: true
},
tweetButtonEnabled: {
value: true
},
touchSupport: {
value: true
},
fallback: {
value: false
},
}});
}, '2.0.0' ,{requires:['anim', 'event-mouseenter', 'plugin', 'transition', 'fl-event-move', 'fl-slideshow-css', 'fl-slideshow-base', 'fl-utils', 'sm-fonticon']});
YUI.add('fl-slideshow-album-loader', function(Y){
Y.namespace('FL').SlideshowAlbumLoader=Y.Base.create('fl-slideshow-album-loader', Y.Base, [], {
_source: null,
load: function(source){
this._source=source;
this.fire('start');
this[Y.FL.SlideshowAlbumLoader.TYPES[source.type]].call(this);
},
_loadComplete: function(o){
o=this._randomize(o);
this.fire('complete', o);
},
_randomize: function(o){
var i;
if(this.get('randomize')){
o.albumInfo.images.sort(function(){ return 0.5 - Math.random(); });
for(i=0; i < o.albumInfo.images.length; i++){
o.albumInfo.images[i].index=i;
}}
return o;
},
_loadSmugMug: function(){
var sm=new Y.FL.SmugMugAPI();
sm.on('complete', this._loadSmugMugSuccess, this);
sm.addParam('method', 'smugmug.images.get');
sm.addParam('AlbumID', this._source.id);
sm.addParam('AlbumKey', this._source.key);
sm.addParam('Extras', 'Caption,Format,FileName');
if(this._source.password){
sm.addParam('Password', this._source.password);
}
if(this._source.sp){
sm.addParam('SitePassword', this._source.sp);
}
sm.request();
},
_loadSmugMugSuccess: function(e){
var images=e.Album.Images,
album={},
proxy=typeof this._source.proxy!=='undefined' ? this._source.proxy:'',
buyBase='',
baseURL='',
ext='',
format='',
i=0,
temp=null,
iframe=null;
album.index=this._source.index;
album.id=e.Album.id;
album.key=e.Album.Key;
album.link=e.Album.URL;
album.title=this._source.title ? this._source.title:'';
album.images=[];
buyBase=album.link.replace('https://', '').split('/').shift();
buyBase='https://' + buyBase + '/buy/' + e.Album.id + '_' + e.Album.Key + '/';
for(i=0; i < images.length; i++){
baseURL=proxy + e.Album.URL + '/' + images[i].id + '_' + images[i].Key;
format=images[i].Format.toLowerCase();
ext=format=='mp4' ? '.jpg':'.' + format;
album.images[i]={};
album.images[i].index=i;
album.images[i].sourceType='smugmug';
album.images[i].albumId=e.Album.id;
album.images[i].albumKey=e.Album.Key;
album.images[i].id=images[i].id;
album.images[i].key=images[i].Key;
album.images[i].filename=images[i].FileName;
album.images[i].format=format;
album.images[i].caption=images[i].Caption||'';
album.images[i].link=e.Album.URL + '#' + images[i].id + '_' + images[i].Key;
album.images[i].tinyURL=baseURL + '-Ti' + ext;
album.images[i].thumbURL=baseURL + '-Th' + ext;
album.images[i].smallURL=baseURL + '-S' + ext;
album.images[i].mediumURL=baseURL + '-M' + ext;
album.images[i].largeURL=baseURL + '-L' + ext;
album.images[i].xlargeURL=baseURL + '-XL' + ext;
album.images[i].x2largeURL=baseURL + '-X2' + ext;
album.images[i].x3largeURL=baseURL + '-X3' + ext;
album.images[i].buyURL=buyBase + images[i].id + '_' + images[i].Key;
album.images[i].iframe='';
if(album.images[i].caption.indexOf('iframe')){
temp=Y.Node.create('<div>'+ album.images[i].caption +'</div>');
iframe=temp.one('iframe');
if(iframe){
album.images[i].iframe=iframe.getAttribute('src');
album.images[i].caption=album.images[i].caption.replace(/<iframe.*>.*<\/iframe>/gi, '');
}}
}
this._loadComplete({ 'albumInfo': album });
},
_loadUrls: function(){
var album={},
i=0;
album.index=this._source.index;
album.title=this._source.title ? this._source.title:'';
album.images=[];
for(; i < this._source.urls.length; i++){
album.images[i]={};
album.images[i].index=i;
album.images[i].sourceType='urls';
album.images[i].filename=this._source.urls[i].largeURL.split('/').pop();
album.images[i].format='';
album.images[i].caption=this._source.urls[i].caption||'';
album.images[i].alt=this._source.urls[i].alt||'';
album.images[i].link=this._source.urls[i].largeURL;
album.images[i].thumbURL=this._source.urls[i].thumbURL||this._source.urls[i].largeURL;
album.images[i].smallURL=this._source.urls[i].smallURL||this._source.urls[i].largeURL;
album.images[i].mediumURL=this._source.urls[i].mediumURL||this._source.urls[i].largeURL;
album.images[i].largeURL=this._source.urls[i].largeURL;
album.images[i].xlargeURL=this._source.urls[i].xlargeURL||this._source.urls[i].largeURL;
album.images[i].x2largeURL=this._source.urls[i].x2largeURL||this._source.urls[i].largeURL;
album.images[i].x3largeURL=this._source.urls[i].x3largeURL||this._source.urls[i].largeURL;
album.images[i].buyURL=this._source.urls[i].buyURL||'';
album.images[i].iframe=this._source.urls[i].iframe||'';
}
this._loadComplete({ 'albumInfo': album });
}}, {
ATTRS: {
randomize: {
value: false
}},
TYPES: {
'smugmug': '_loadSmugMug',
'flickr': '_loadFlickr',
'picasa': '_loadPicasa',
'urls': '_loadUrls',
'html': '_loadHtml'
}});
}, '2.0.0' ,{requires:['base', 'fl-smugmug-api']});
YUI.add('fl-slideshow-base', function(Y){
Y.namespace('FL').SlideshowBase=Y.Base.create('fl-slideshow-base', Y.Widget, [Y.WidgetParent], {
_albumLoader: null,
albums: [],
albumInfo: null,
albumIndex: null,
imageInfo: null,
imageIndex: null,
lastImageIndex: null,
_resizeTimer: null,
_playing: false,
_playingTimer: null,
_playingTimerEvent: null,
_loadingImage: null,
_loadingImageWrap: null,
_loadingImageVisible: false,
_loadingImageTimer: null,
_loadingImageContainer: null,
_initialHeight: null,
_initialWidth: null,
initializer: function(){
this._albumLoader=new Y.FL.SlideshowAlbumLoader({
randomize: this.get('randomize')
});
},
renderUI: function(){
this._renderLoadingImage();
},
bindUI: function(){
this._albumLoader.on('complete', this._loadAlbumComplete, this);
Y.one(window).on('fl-slideshow-base|resize', this._delayResize, this);
Y.one(window).on('fl-slideshow-base|orientationchange', this._delayResize, this);
Y.Node.one('body').on('keydown', Y.bind(this._onKey, this));
},
syncUI: function(){
this.get('boundingBox').addClass('fl-slideshow-' + this.get('color'));
this.resize();
if(this.get('loadOnRender')){
this.loadAlbum(this.get('defaultAlbum'), this.get('defaultImage'));
}},
addAlbum: function(data){
var source=this.get('source'),
i=source.length;
source[i]=data;
source[i].index=i;
this.set('source', source);
},
loadAlbum: function(albumIndex, imageIndex){
var source=this.get('source'),
loadImageIndex=typeof imageIndex=='undefined' ? 0:imageIndex;
this.imageIndex=null;
this.lastImageIndex=null;
this.fire('albumLoadStart');
this.once('albumLoadComplete', Y.bind(this.loadImage, this, loadImageIndex));
if(source[albumIndex]&&source[albumIndex].type=='album-data'){
this.albums[albumIndex]=source[albumIndex].data;
this._loadAlbumComplete({albumInfo: this.albums[albumIndex]});
}
else if(source[albumIndex]&&this.albums[albumIndex]){
this._loadAlbumComplete({albumInfo: this.albums[albumIndex]});
}else{
this._albumLoader.load(source[albumIndex]||source[0]);
}},
_loadAlbumComplete: function(o){
this.albums[o.albumInfo.index]=o.albumInfo;
this.albumInfo=o.albumInfo;
this.albumIndex=o.albumInfo.index;
this.fire('albumLoadComplete');
if(this.get('autoPlay')){
this._playingTimerStart();
this.fire('played');
this._playing=true;
}},
loadImage: function(index){
if(this._playing){
this._playingTimerStart();
}
index=index < 0 ? this.albumInfo.images.length - 1:index;
index=index >=this.albumInfo.images.length ? 0:index;
this.lastImageIndex=this.imageIndex;
this.imageIndex=index;
this.imageInfo=this.albumInfo.images[index];
this.fire('imageLoadComplete', { 'imageInfo': this.imageInfo });
},
prevImage: function(){
if(this.get('pauseOnNextOrPrev')){
this.pause();
}
this.loadImage(this.imageIndex - 1);
this.fire('prevImage');
},
nextImage: function(){
if(this.get('pauseOnNextOrPrev')){
this.pause();
}
this.loadImage(this.imageIndex + 1);
this.fire('nextImage');
},
_onKey: function(e){
switch(e.keyCode){
case 37:
this.prevImage();
break;
case 39:
this.nextImage();
break;
}},
resize: function(){
var stretchy=this.get('stretchy'),
stretchyType=this.get('stretchyType'),
width=parseInt(Y.one('body').get('winWidth'), 10),
threshold=this.get('responsiveThreshold');
if(width > threshold&&stretchy&&stretchyType=='window'){
this._stretchyWindowResize();
}
else if((width <=threshold)||(stretchy&&stretchyType=='ratio')){
this._stretchyRatioResize();
}else{
this._standardResize();
}
this.fire('resize');
},
_standardResize: function(){
var stretchy=this.get('stretchy'),
stretchyType=this.get('stretchyType'),
bb=this.get('boundingBox'),
parent=bb.get('parentNode'),
parentHeight=parseInt(parent.getComputedStyle('height'), 10),
parentWidth=parseInt(parent.getComputedStyle('width'), 10),
height=this.get('height'),
width=this.get('width');
if(bb.hasClass('fl-fullscreen-active')){
this._stretchyWindowResize();
return;
}
else if(stretchy&&stretchyType=='contain'){
bb.setStyle('height', parentHeight + 'px');
bb.setStyle('width', parentWidth + 'px');
}
else if(!Y.Lang.isNumber(height)){
this._stretchyRatioResize();
return;
}else{
bb.setStyle('height', height + 'px');
if(width){
bb.setStyle('width', width + 'px');
}else{
bb.setStyle('width', parentWidth + 'px');
}}
},
_stretchyWindowResize: function(){
var bb=this.get('boundingBox'),
verticalSpace=this.get('stretchyVerticalSpace'),
paddingTop=parseInt(bb.getStyle('paddingTop'), 10),
paddingBottom=parseInt(bb.getStyle('paddingBottom'), 10),
height=parseInt(Y.one('body').get('winHeight'), 10),
width='';
if(bb.hasClass('fl-fullscreen-active')){
verticalSpace=0;
width=parseInt(Y.one('body').get('winWidth'), 10) + 'px';
}
height=(height - paddingTop - paddingBottom - verticalSpace) + 'px';
bb.setStyle('height', height);
bb.setStyle('width', width);
},
_stretchyRatioResize: function(){
var bb=this.get('boundingBox'),
parent=bb.get('parentNode'),
verticalSpace=0,
stretchyRatio=this.get('stretchyRatio'),
paddingTop=parseInt(bb.getStyle('paddingTop'), 10),
paddingBottom=parseInt(bb.getStyle('paddingBottom'), 10),
computedWidth=parseInt(parent.getComputedStyle('width'), 10),
winHeight=parseInt(Y.one('body').get('winHeight'), 10),
winWidth=parseInt(Y.one('body').get('winWidth'), 10),
height=computedWidth * stretchyRatio,
width='';
if(bb.hasClass('fl-fullscreen-active')){
height=winHeight;
width=winWidth;
}
height=(height - paddingTop - paddingBottom - verticalSpace) + 'px';
bb.setStyle('height', height);
bb.setStyle('width', width);
},
_delayResize: function(){
if(this._resizeTimer){
this._resizeTimer.cancel();
}
this._resizeTimer=Y.later(300, this, this.resize);
},
play: function(){
this._playingTimer=Y.later(this.get('speed'), this, this._playingTimerComplete);
this.fire('played');
this._playing=true;
},
pause: function(){
this._playingTimerCancel();
this.fire('paused');
this._playing=false;
},
_setPlayingTimerEvent: function(obj, e){
this._playingTimerEvent={
'obj': obj,
'e': e
};},
_playingTimerStart: function(e){
this._playingTimerCancel();
if(!e&&this._playingTimerEvent!==null){
this._playingTimerEvent.obj.once('fl-slideshow-base|' + this._playingTimerEvent.e, Y.bind(this._playingTimerStart, this));
}else{
this._playingTimer=Y.later(this.get('speed'), this, this._playingTimerComplete);
}},
_playingTimerComplete: function(){
this.loadImage(this.imageIndex + 1);
this.fire('playingTimerComplete');
},
_playingTimerCancel: function(){
if(this._playingTimer){
this._playingTimer.cancel();
}
if(this._playingTimerEvent){
this._playingTimerEvent.obj.detach('fl-slideshow-base|' + this._playingTimerEvent.e);
}},
_renderLoadingImage: function(){
var defaults={
lines: 11,
length: 6,
width: 2,
radius: 7,
color: '',
speed: 1,
trail: 60,
shadow: false
},
settings=Y.merge(defaults, this.get('loadingImageSettings'));
if(this.get('loadingImageEnabled')){
if(settings.color===''){
settings.color=this._colorToHex(Y.one('body').getStyle('color'));
}
this._loadingImage=new Y.FL.Spinner(settings);
this._loadingImageWrap=Y.Node.create('<div class="fl-loading-image"></div>');
this._loadingImageWrap.setStyles({
position:'absolute',
'z-index':'1000'
});
}},
_showLoadingImage: function(){
if(this._loadingImage&&!this._loadingImageVisible){
this._loadingImageVisible=true;
this._loadingImage.spin();
this._loadingImageWrap.insert(this._loadingImage.el);
if(this._loadingImageContainer!==null){
this._loadingImageContainer.insert(this._loadingImageWrap);
}else{
this.get('contentBox').insert(this._loadingImageWrap);
}
this._positionLoadingImage();
}},
_showLoadingImageWithDelay: function(){
if(this._loadingImage){
this._loadingImageTimer=Y.later(1000, this, this._showLoadingImage);
}},
_hideLoadingImage: function(){
if(this._loadingImageTimer){
this._loadingImageTimer.cancel();
this._loadingImageTimer=null;
}
if(this._loadingImage&&this._loadingImageVisible){
this._loadingImageVisible=false;
this._loadingImage.stop();
this._loadingImageWrap.remove();
}},
_positionLoadingImage: function(){
if(this._loadingImage&&this._loadingImageVisible){
var wrap=this._loadingImageWrap,
wrapHeight=parseInt(wrap.getComputedStyle('height'), 10),
wrapWidth=parseInt(wrap.getComputedStyle('width'), 10),
parent=wrap.get('parentNode'),
parentHeight=parseInt(parent.getComputedStyle('height'), 10),
parentWidth=parseInt(parent.getComputedStyle('width'), 10),
left=(parentWidth - wrapWidth)/2,
top=(parentHeight - wrapHeight)/2;
wrap.setStyles({
left:left + 'px',
top:top + 'px'
});
Y.one(this._loadingImage.el).setStyles({
left:'50%',
top:'50%'
});
}},
_colorToHex: function(color){
var digits, red, green, blue, rgb;
if(color.substr(0, 1)==='#'){
return color;
}
digits=/(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color);
if(null===digits){
return '#000';
}
red=parseInt(digits[2], 10);
green=parseInt(digits[3], 10);
blue=parseInt(digits[4], 10);
rgb=blue | (green << 8) | (red << 16);
rgb=rgb.toString(16);
if(rgb==='0'){
rgb='000';
}
return digits[1] + '#' + rgb;
}}, {
CSS_PREFIX: 'fl-slideshow-base',
ATTRS: {
color: {
value: 'dark',
writeOnce: true
},
source: {
value: [],
setter: function(source){
if(source.constructor==Object){
source=[source];
}
for(var i=0; i < source.length; i++){
source[i].index=i;
}
return source;
}},
defaultAlbum: {
value: 0
},
defaultImage: {
value: 0
},
loadOnRender: {
value: true
},
autoPlay: {
value: true
},
pauseOnNextOrPrev: {
value: true
},
randomize: {
value: false
},
speed: {
value: 4000
},
responsiveThreshold: {
value: 600
},
stretchy: {
value: false
},
stretchyType: {
value: 'ratio'
},
stretchyVerticalSpace: {
value: 0
},
stretchyRatio: {
value: 0.7
},
loadingImageEnabled: {
value: true
},
loadingImageSettings: {
value: {}}
}});
}, '2.0.0' ,{requires:['node', 'base', 'widget', 'widget-parent', 'widget-child', 'fl-slideshow-album-loader', 'fl-spinner']});
YUI.add('fl-smugmug-api', function(Y){
Y.namespace('FL').SmugMugAPI=Y.Base.create('fl-smugmug-api', Y.Base, [], {
_sessionID: null,
_requestURL: null,
initializer: function(){
this._resetRequestURL();
},
addParam: function(key, val){
this._requestURL=this._requestURL + '&' + key + '=' + val;
},
loginAnon: function(){
this.addParam('method', 'smugmug.login.anonymously');
this.once('complete', this._loginAnonComplete);
this.request();
},
_loginAnonComplete: function(data){
if(data.Login){
this._sessionID=data.Login.Session.id;
}},
request: function(){
this.addParam('Callback', '{callback}');
Y.jsonp(this._requestURL, {
on: {
success: this._requestComplete,
timeout: function(){}},
context: this,
timeout: 60000,
args: []
});
},
_requestComplete: function(data){
this._resetRequestURL();
this.fire('complete', data);
},
_resetRequestURL: function(){
this._requestURL=this.get('apiURL') + '?APIKey=' + this.get('apiKey');
if(this._sessionID){
this.addParam('SessionID', this._sessionID);
}}
}, {
ATTRS: {
apiURL: {
value: 'https://api.smugmug.com/services/api/json/1.3.0/'
},
apiKey: {
value: '7w6kuU5Ee6KSgRRExf2KLgppdkez9JD2'
}}
});
}, '2.0.0' ,{requires:['base', 'jsonp']});
YUI.add('fl-spinner', function(Y){
(function(window,document,undefined){var width="width",length="length",radius="radius",lines="lines",trail="trail",color="color",opacity="opacity",speed="speed",shadow="shadow",style="style",height="height",left="left",top="top",px="px",childNodes="childNodes",firstChild="firstChild",parentNode="parentNode",position="position",relative="relative",absolute="absolute",animation="animation",transform="transform",Origin="Origin",Timeout="Timeout",coord="coord",black="#000",styleSheets=style+"Sheets",prefixes="webkit0Moz0ms0O".split(0),animations={},useCssAnimations;function eachPair(args,it){var end=~~((args[length]-1)/2);for(var i=1;i<=end;i++){it(args[i*2-1],args[i*2])}}function createEl(tag){var el=document.createElement(tag||"div");eachPair(arguments,function(prop,val){el[prop]=val});return el}function ins(parent,child1,child2){if(child2&&!child2[parentNode]){ins(parent,child2)}parent.insertBefore(child1,child2||null);return parent}ins(document.getElementsByTagName("head")[0],createEl(style));var sheet=document[styleSheets][document[styleSheets][length]-1];function addAnimation(to,end){var name=[opacity,end,~~(to*100)].join("-"),dest="{"+opacity+":"+to+"}",i;if(!animations[name]){for(i=0;i<prefixes[length];i++){try{sheet.insertRule("@"+(prefixes[i]&&"-"+prefixes[i].toLowerCase()+"-"||"")+"keyframes "+name+"{0%{"+opacity+":1}"+end+"%"+dest+"to"+dest+"}",sheet.cssRules[length])}catch(err){}}animations[name]=1}return name}function vendor(el,prop){var s=el[style],pp,i;if(s[prop]!==undefined){return prop}prop=prop.charAt(0).toUpperCase()+prop.slice(1);for(i=0;i<prefixes[length];i++){pp=prefixes[i]+prop;if(s[pp]!==undefined){return pp}}}function css(el){eachPair(arguments,function(n,val){el[style][vendor(el,n)||n]=val});return el}function defaults(obj){eachPair(arguments,function(prop,val){if(obj[prop]===undefined){obj[prop]=val}});return obj}var Spinner=function Spinner(o){this.opts=defaults(o||{},lines,12,trail,100,length,7,width,5,radius,10,color,black,opacity,1/4,speed,1)},proto=Spinner.prototype={spin:function(target){var self=this,el=self.el=self[lines](self.opts);if(target){ins(target,css(el,left,~~(target.offsetWidth/2)+px,top,~~(target.offsetHeight/2)+px),target[firstChild])}if(!useCssAnimations){var o=self.opts,i=0,f=20/o[speed],ostep=(1-o[opacity])/(f*o[trail]/100),astep=f/o[lines];(function anim(){i++;for(var s=o[lines];s;s--){var alpha=Math.max(1-(i+s*astep)%f*ostep,o[opacity]);self[opacity](el,o[lines]-s,alpha,o)}self[Timeout]=self.el&&window["set"+Timeout](anim,50)})()}return self},stop:function(){var self=this,el=self.el;window["clear"+Timeout](self[Timeout]);if(el&&el[parentNode]){el[parentNode].removeChild(el)}self.el=undefined;return self}};proto[lines]=function(o){var el=css(createEl(),position,relative),animationName=addAnimation(o[opacity],o[trail]),i=0,seg;function fill(color,shadow){return css(createEl(),position,absolute,width,(o[length]+o[width])+px,height,o[width]+px,"background",color,"boxShadow",shadow,transform+Origin,left,transform,"rotate("+~~(360/o[lines]*i)+"deg) translate("+o[radius]+px+",0)","borderRadius","100em")}for(;i<o[lines];i++){seg=css(createEl(),position,absolute,top,1+~(o[width]/2)+px,transform,"translate3d(0,0,0)",animation,animationName+" "+1/o[speed]+"s linear infinite "+(1/o[lines]/o[speed]*i-1/o[speed])+"s");if(o[shadow]){ins(seg,css(fill(black,"0 0 4px "+black),top,2+px))}ins(el,ins(seg,fill(o[color],"0 0 1px rgba(0,0,0,.1)")))}return el};proto[opacity]=function(el,i,val){el[childNodes][i][style][opacity]=val};var behavior="behavior",URL_VML="url(#default#VML)",tag="group0roundrect0fill0stroke".split(0);(function(){var s=css(createEl(tag[0]),behavior,URL_VML),i;if(!vendor(s,transform)&&s.adj){for(i=0;i<tag[length];i++){sheet.addRule(tag[i],behavior+":"+URL_VML)}proto[lines]=function(){var o=this.opts,r=o[length]+o[width],s=2*r;function grp(){return css(createEl(tag[0],coord+"size",s+" "+s,coord+Origin,-r+" "+-r),width,s,height,s)}var g=grp(),margin=~(o[length]+o[radius]+o[width])+px,i;function seg(i,dx,filter){ins(g,ins(css(grp(),"rotation",360/o[lines]*i+"deg",left,~~dx),ins(css(createEl(tag[1],"arcsize",1),width,r,height,o[width],left,o[radius],top,-o[width]/2,"filter",filter),createEl(tag[2],color,o[color],opacity,o[opacity]),createEl(tag[3],opacity,0))))}if(o[shadow]){for(i=1;i<=o[lines];i++){seg(i,-2,"progid:DXImage"+transform+".Microsoft.Blur(pixel"+radius+"=2,make"+shadow+"=1,"+shadow+opacity+"=.3)")}}for(i=1;i<=o[lines];i++){seg(i)}return ins(css(createEl(),"margin",margin+" 0 0 "+margin,position,relative),g)};proto[opacity]=function(el,i,val,o){o=o[shadow]&&o[lines]||0;el[firstChild][childNodes][i+o][firstChild][firstChild][opacity]=val}}else{useCssAnimations=vendor(s,animation)}})();Y.namespace('FL').Spinner=Spinner})(window,document);
}, '2.0.0');
YUI.add('fl-utils', function(Y){
Y.namespace('FL').Utils={
cssSupport: function(p){
var b=document.body||document.documentElement,
s=b.style,
v=['Moz', 'Webkit', 'Khtml', 'O', 'ms', 'Icab'],
i=0;
if(p=='transform'&&Y.UA.gecko&&Y.UA.gecko < 4){ return false; }
if(p=='transform'&&Y.UA.opera > 0){ return false; }
if(p=='transform'&&Y.UA.ie > 0&&Y.UA.ie < 10){ return false; }
if(p=='transform'&&navigator.userAgent.match(/Trident/)){ return false; }
if(typeof s=='undefined'){ return false; }
if(typeof s[p]=='string'){ return true; }
p=p.charAt(0).toUpperCase() + p.substr(1);
for(; i < v.length; i++){
if(typeof s[v[i] + p]=='string'){ return true; }}
}};}, '2.0.0');