2011-12-06 07:50:25 +04:00
|
|
|
|
|
|
|
(function( $ ){
|
|
|
|
|
|
|
|
|
2011-12-14 02:57:40 +04:00
|
|
|
$.ControlAnchor = {
|
|
|
|
NONE: 0,
|
|
|
|
TOP_LEFT: 1,
|
|
|
|
TOP_RIGHT: 2,
|
|
|
|
BOTTOM_RIGHT: 3,
|
|
|
|
BOTTOM_LEFT: 4
|
|
|
|
};
|
|
|
|
|
2012-01-24 07:48:45 +04:00
|
|
|
$.Control = function ( elmt, anchor, container ) {
|
|
|
|
this.elmt = elmt;
|
|
|
|
this.anchor = anchor;
|
|
|
|
this.container = container;
|
|
|
|
this.wrapper = $.makeNeutralElement( "span" );
|
2011-12-06 07:50:25 +04:00
|
|
|
this.wrapper.style.display = "inline-block";
|
2012-01-24 07:48:45 +04:00
|
|
|
this.wrapper.appendChild( this.elmt );
|
2011-12-14 02:57:40 +04:00
|
|
|
|
2012-01-24 07:48:45 +04:00
|
|
|
if ( this.anchor == $.ControlAnchor.NONE ) {
|
2011-12-14 02:57:40 +04:00
|
|
|
// IE6 fix
|
|
|
|
this.wrapper.style.width = this.wrapper.style.height = "100%";
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
|
|
|
|
2011-12-14 02:57:40 +04:00
|
|
|
if ( this.anchor == $.ControlAnchor.TOP_RIGHT ||
|
|
|
|
this.anchor == $.ControlAnchor.BOTTOM_RIGHT ) {
|
2012-01-24 07:48:45 +04:00
|
|
|
this.container.insertBefore(
|
|
|
|
this.wrapper,
|
|
|
|
this.container.firstChild
|
|
|
|
);
|
2011-12-06 07:50:25 +04:00
|
|
|
} else {
|
2012-01-24 07:48:45 +04:00
|
|
|
this.container.appendChild( this.wrapper );
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$.Control.prototype = {
|
2012-01-24 07:48:45 +04:00
|
|
|
|
2011-12-06 07:50:25 +04:00
|
|
|
destroy: function() {
|
2012-01-24 07:48:45 +04:00
|
|
|
this.wrapper.removeChild( this.elmt );
|
|
|
|
this.container.removeChild( this.wrapper );
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
2012-01-24 07:48:45 +04:00
|
|
|
|
2011-12-06 07:50:25 +04:00
|
|
|
isVisible: function() {
|
|
|
|
return this.wrapper.style.display != "none";
|
|
|
|
},
|
2012-01-24 07:48:45 +04:00
|
|
|
|
|
|
|
setVisible: function( visible ) {
|
|
|
|
this.wrapper.style.display = visible ?
|
|
|
|
"inline-block" :
|
|
|
|
"none";
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
2012-01-24 07:48:45 +04:00
|
|
|
|
|
|
|
setOpacity: function( opacity ) {
|
|
|
|
if ( this.elmt[ $.SIGNAL ] && $.Browser.vendor == $.BROWSERS.IE ) {
|
|
|
|
$.setElementOpacity( this.elmt, opacity, true );
|
2011-12-06 07:50:25 +04:00
|
|
|
} else {
|
2012-01-24 07:48:45 +04:00
|
|
|
$.setElementOpacity( this.wrapper, opacity, true );
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}( OpenSeadragon ));
|