home *** CD-ROM | disk | FTP | other *** search
- use( "thing.point" );
- if( is.ns4 ) use( "thing.resize" );
- init( "Thing.init()" );
-
- /********************************************************************************
-
- Thing Object
-
- Initialization
- Thing.init() -- looks through document & gets all divs ending in "Div"
- adds that to the Thing.all array without the "Div"
- Member Variables
- myThing.name -- "myThing"
- myThing.id -- "myThingDiv"
- myThing.div -- the actual html object
- myThing.style -- the style of the object
- myThing.position -- a Point with the thing's position
- myThing.size -- a Point with the thing's size
-
- ********************************************************************************/
- function Thing( div ){
- this.id = div.id;
- this.name = div.id.replace(/Div/, "");
-
- this.div = div;
- this.style = ( is.ns4 ) ? this.div : this.div.style;
-
- this.position = this.getPosition();
- this.size = this.getSize();
- }
-
- Thing.add = function( div ){
- var name = div.id.slice(0, -3);
- if( div.id == name + "Div" ){
-
- //alert(name);
-
- Thing.all[ name ] = new Thing( div );
- eval( name + " = Thing.all." + name );
- }
- }
- Thing.all = new Array();
- Thing.init = function( doc ){
- this.isLoaded = true;
- if( document.layers ){
- if( doc == null ) doc = document;
- for( var i=0; i<doc.layers.length; i++ ){
- Thing.add( doc.layers[i] );
- Thing.init( doc.layers[i].document );
- }
- return true;
- }
-
- var allD = false;
- if( is.ie4 ) allD = document.all.tags("DIV");
- else if( is.ie5 || is.ie6 ) allD = document.getElementsByTagName("DIV");
- else if( is.ns6 ) allD = document.getElementsByTagName("DIV");
-
- if( allD ){
- for( var i=0; i<allD.length; i++ )
- Thing.add( allD[i] );
- return true;
- }
- return false;
- }
-
- /********************************************************************************
-
- Style Initialization
-
- Point myThing.getPosition(); -- set this.position and return it
- Point myThing.getSize(); -- set this.size and return it
-
- ********************************************************************************/
- if( is.ns4 )
- Thing.prototype.getPosition = function(){
- this.position = new Point(
- parseInt(this.style.left),
- parseInt(this.style.top)
- );
- return this.position;
- }
- else
- Thing.prototype.getPosition = function(){
- this.position = new Point(
- parseInt(this.div.offsetLeft),
- parseInt(this.div.offsetTop)
- );
- return this.position;
- }
-
-
-
-
-
-
- if( is.ns4 )
- Thing.prototype.getSize = function(){
- this.size = new Point(
- this.div.document.width,
- this.div.document.height
- );
- return this.size;
- }
- else if( is.ie4 )
- Thing.prototype.getSize = function(){
- this.size = new Point(
- parseInt( this.div.scrollWidth ),
- parseInt( this.div.scrollHeight )
- );
- return this.size;
- }
- else
- Thing.prototype.getSize = function(){
- this.size = new Point(
- parseInt(this.div.offsetWidth),
- parseInt(this.div.offsetHeight)
- );
- this.style.offsetWidth = this.size.x;
- this.style.offsetHeight = this.size.y;
- return this.size;
- }
-
-
-
-
-
-
- /********************************************************************************
-
- Position Manipulation
-
- myThing.setPosition() -- updates the html object to match the position
- called by moveTo, moveBy, etc
- myThing.moveTo(p) -- move to point
- myThing.moveTo(x,y) -- move to specified location
- myThing.moveBy(p) -- move by point values
- myThing.moveBy(x,y) -- move by specified increments
-
- ********************************************************************************/
- Thing.prototype.setPosition = function(){
- this.style.left = this.position.x;
- this.style.top = this.position.y;
- }
- Thing.prototype.moveTo = function( /*x,y or p*/ ){
- this.position = new Point( arguments[0], arguments[1] );
- this.setPosition();
- }
- Thing.prototype.moveBy = function( /*x,y or p*/ ){
- this.position = this.position.add( arguments[0], arguments[1] );
- this.setPosition();
- }
-
- /********************************************************************************
-
- Visibility Manipulation
-
- myThing.show() -- show the div
- myThing.hide() -- hide the div
- myThing.isVisible() -- return true if visible, false if not
- myThing.toggle() -- hide if visible, show if not
-
- ********************************************************************************/
-
- Thing.prototype.show = function(){
- this.style.visibility = "visible";
- }
- Thing.prototype.hide = function(){
- this.style.visibility = "hidden";
- }
- Thing.prototype.isVisible = function(){
- return ( this.style.visibility.indexOf("d") == -1 );
- }
- Thing.prototype.toggle = function(){
- return ( this.isVisible() ) ? this.hide() : this.show();
- }
-
-
-
- /********************************************************************************
-
- Miscellaneous Manipulation
-
- myThing.setBackground( color ) -- set the bgcolor to "color"
-
- myThing.getZindex() -- get the zIndex
- myThing.setZindex( n ) -- set the zIndex to n
-
- ********************************************************************************/
- if ( is.ns4 )
- Thing.prototype.setBackground = function( color ){
- this.div.document.bgColor=color;
- }
- else
- Thing.prototype.setBackground = function( color ){
- this.style.backgroundColor = color;
- }
-
- Thing.prototype.setZindex = function( n ){
- this.style.zIndex = n;
- }
-