define([], function() {
function ControlBar(dispatcher, visibility, rotation) { // constructor
// private variables
this._dispatcher = dispatcher;
this._visibility = visibility;
this._rotation = rotation;
this._state = null;
this._viewerID = '';
this.initialiseControlBar = function() {
var display = 'none';
if ( this._visibility == 'showOnLoad' )
{
display = 'block';
}
this._cbWidth = 50;
this._cbHeight = 25;
this._cbTop = 0;
this.rotationImg = "";
if (this._rotation)
{
this._cbWidth = 75;
var rotateSrc = RICHFX.settings.sBaseURL + 'ViewerDelivery/staticService?profileId=12056150&file=/assets/auto_rotate.png';
rotateSrc = RICHFX.media.buildRequiredUrl(rotateSrc);
this.rotationImg = '';
}
this._cbLeft = Math.ceil(RICHFX.jQuery('#RICHFXViewerContainer_' + this._viewerID).width() - this._cbWidth);
var zoomInSrc = RICHFX.settings.sBaseURL +'ViewerDelivery/staticService?profileId=12056150&file=/assets/zoomin.gif';
var zoomOutSrc = RICHFX.settings.sBaseURL +'ViewerDelivery/staticService?profileId=12056150&file=/assets/zoomout.gif';
zoomInSrc = RICHFX.media.buildRequiredUrl(zoomInSrc);
zoomOutSrc = RICHFX.media.buildRequiredUrl(zoomOutSrc);
this._vf = RICHFX.jQuery('#RICHFXViewerContainer_' + this._viewerID).append('
'+this.rotationImg+'
');
};
this.attachBindings = function() {
// Add bind's to buttons
if ( Modernizr.touch ) {
RICHFX.jQuery('#cbZoomIn').bind("touchstart", RICHFX.jQuery.proxy(function(event) {
this.handleControlBarZoomIn(event);
return false;
}, this));
RICHFX.jQuery('#cbZoomOut').bind("touchstart", RICHFX.jQuery.proxy(function(event) {
this.handleControlBarZoomOut(event);
return false;
}, this));
RICHFX.jQuery('#cbRotate').bind("touchstart", RICHFX.jQuery.proxy(function(event) {
this.handleControlBarRotate(event);
return false;
}, this));
}
else
{
RICHFX.jQuery('#cbZoomIn').bind("click", RICHFX.jQuery.proxy(function(event) {
this.handleControlBarZoomIn(event);
return false;
}, this));
RICHFX.jQuery('#cbZoomOut').bind("click", RICHFX.jQuery.proxy(function(event) {
this.handleControlBarZoomOut(event);
return false;
}, this));
RICHFX.jQuery('#cbRotate').bind("click", RICHFX.jQuery.proxy(function(event) {
this.handleControlBarRotate(event);
return false;
}, this));
}
};
this.handleControlBarZoomIn = function () {
RICHFX.jQuery('#RICHFXViewerContainer_' + this._viewerID).trigger("zoomin.zoombehavior");
return false;
};
this.handleControlBarZoomOut = function () {
RICHFX.jQuery('#RICHFXViewerContainer_' + this._viewerID).trigger("zoomout.zoombehavior");
return false;
};
this.handleControlBarRotate = function () {
RICHFX.jQuery('#RICHFXViewerContainer_' + this._viewerID).trigger("auto.rotatebehavior");
return false;
};
this.handleZoomModeChange = function () {
if ( this._state != null )
{
if ( this._state.getZoomOnly() )
{
RICHFX.jQuery('#cbRotate').hide();
}
else
{
RICHFX.jQuery('#cbRotate').show();
}
}
};
};
ControlBar.prototype = {
// variables
//functions
controlBarInit:function(){
},
controlBarReady:function(){
},
setVisibility: function(setting) {
this._visibility = setting;
if ( this._visibility )
{
RICHFX.jQuery('#RICHFXViewerContainer_' + this._viewerID +'_cb').show();
}
else
{
RICHFX.jQuery('#RICHFXViewerContainer_' + this._viewerID +'_cb').hide();
}
},
setState: function(assetState, viewerID) {
this._state = assetState;
this._viewerID = viewerID;
this.initialiseControlBar();
this.attachBindings();
// set original state
this.handleZoomModeChange();
if ( this._rotation ) {
RICHFX.jQuery('#RICHFXViewerContainer_' + this._viewerID).bind("state.zoomModeChange", RICHFX.jQuery.proxy(function(event) {
this.handleZoomModeChange();
}, this));
}
}
};
return ControlBar;
});