X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F01_dom%2F20_XDomImage.js;h=e5769b804a74feb5082502173251f1d7c4a7eaed;hb=3525f9ca3b6a7e3e419fa1ea988925a6a9ff5ad5;hp=f7823c10ba3fd2c29a9544193a970fd8e265f4b8;hpb=27420d0fbdf56a5cda68f5b10de6565de8a5c010;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/01_dom/20_XDomImage.js b/0.6.x/js/01_dom/20_XDomImage.js index f7823c1..e5769b8 100644 --- a/0.6.x/js/01_dom/20_XDomImage.js +++ b/0.6.x/js/01_dom/20_XDomImage.js @@ -23,15 +23,19 @@ X.Dom.Image = { } ); Node._body._startUpdate(); - img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawNode; + img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawObject; remove = true; } else { if( XnodeOrImageElemOrSrc.constructor === X.Dom.Node ){ xnode = XnodeOrImageElemOrSrc; - img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawNode; + img = xnode._ie4getRawNode ? xnode._ie4getRawNode() : xnode._rawObject; } else if( X.Type.isHTMLElement( XnodeOrImageElemOrSrc ) ){ img = XnodeOrImageElemOrSrc; + } else + if( XnodeOrImageElemOrSrc.constructor === X.EventDispatcher && X.Type.isImage( XnodeOrImageElemOrSrc._rawObject ) ){ + xnode = XnodeOrImageElemOrSrc; + img = xnode._rawObject; } else { return; }; @@ -100,19 +104,20 @@ X.Dom.Image = { abspath : null, delay : null, timeout : 0, + Constructor : function( abspath, delay, timeout ){ var img; - + this.abspath = abspath; this.delay = delay || 100; this.timeout = timeout || 10000; this.xnode = ( window[ 'Image' ] ? - X.Dom.Node( img = new Image() ) : + X.EventDispatcher( img = new Image() ) : X.Dom.Node._systemNode.create( 'img', { src : abspath } ) ) - .listen( [ 'load', 'error', 'abort', X.Event.SUCCESS, X.Event.ERROR ], this ); + .listen( [ 'load', 'error', 'abort', X.Event.SUCCESS, X.Event.ERROR, X.Event.KILL_INSTANCE ], this ); img && ( img.src = abspath ); this._detect(); }, @@ -130,11 +135,11 @@ X.Dom.Image = { // if( timer ) return; // これがあると safari3.2 で駄目、、、 this.finish = true; this.timerID && X.Timer.remove( this.timerID ); - if( window.opera && !this.xnode._rawNode.complete ){ + if( window.opera && !this.xnode._rawObject.complete ){ this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); return; }; - size = X.Dom.Image.getActualDimension( X.UA.IE && X.UA.IE < 9 && window.Image ? this.abspath : this.xnode ); + size = X.Dom.Image.getActualDimension( X.UA.IE < 9 ? this.abspath : this.xnode ); this.timerID = this.asyncDispatch( 0, { type : X.Event.SUCCESS, src : this.abspath, @@ -147,13 +152,18 @@ X.Dom.Image = { delete this.timerID; X.Timer.once( 0, this, this.kill ); break; + case X.Event.KILL_INSTANCE : + this.timerID && X.Timer.remove( this.timerID ); + this.xnode.destroy && this.xnode.destroy(); + this.unlisten(); + break; }; }, _detect : function(){ if( this.finish === true ) return; - if( this.xnode._rawNode && this.xnode._rawNode.complete ){ + if( this.xnode._rawObject && this.xnode._rawObject.complete ){ this.finish = true; - if( this.xnode._rawNode.width ) return; + if( this.xnode._rawObject.width ) return; this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } ); return; }; @@ -169,11 +179,6 @@ X.Dom.Image = { // this.dispacth( { type : X.Event.CANCELED } ); this.kill(); - }, - onKill : function(){ - this.timerID && X.Timer.remove( this.timerID ); - this.xnode.destroy(); - this.unlisten(); } } )