X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F06_net%2F04_XNetImage.js;h=86bbee3eb0c926f96bd297749d2a255389332004;hb=42e0982b02a99c71702ce8cd8740645aefdc8097;hp=2a872cb1884a219570d27a685b0e6f235ba45ba9;hpb=7911fddcbb190b99ad11412d283776ddbf77b479;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/06_net/04_XNetImage.js b/0.6.x/js/06_net/04_XNetImage.js index 2a872cb..86bbee3 100644 --- a/0.6.x/js/06_net/04_XNetImage.js +++ b/0.6.x/js/06_net/04_XNetImage.js @@ -9,7 +9,7 @@ var X_Net_Image_hasImage = !!window[ 'Image' ], X_Net_Image_image = X_Net_Image_hasImage && new Image(), // IE では厳密には HTMLImageElement ではなく、appendChild してもサイズが取れず、removeChild に失敗する - X_Net_Image_isElement = !( X_UA.IE < 9 ) && X.Type.isHTMLElement( X_Net_Image_image ); + X_Net_Image_isElement = !( X_UA[ 'IE' ] < 9 ) && X_Type_isHTMLElement( X_Net_Image_image ); if( !X_Net_Image_hasImage ){ @@ -27,7 +27,7 @@ if( X_Net_Image_isElement ){ * Opera7 では毎回 image を作る必要あり、src が異なればOK? */ X_NET_ImageWrapper = X_Class_override( - !X_Net_Image_isElement ? new X.EventDispatcher( X_Net_Image_image ) : new X.Node( X_Net_Image_image ), + !X_Net_Image_isElement ? X_EventDispatcher( X_Net_Image_image ) : Node( X_Net_Image_image ), { _busy : false, @@ -43,14 +43,13 @@ X_NET_ImageWrapper = X_Class_override( this.abspath = X.URL.toAbsolutePath( data.url ); this.delay = data.delay || 100; this.timeout = data.timeout || 5000; - //this.timerID = X.Timer.add( this.delay, 0, this, this._detect ); - this._rawObject.src = this.abspath; + this[ '_rawObject' ].src = this.abspath; - if( X_UA.Opera7 && this._rawObject.complete ){ - this.asyncDispatch( 'load' ); + if( X_UA[ 'Opera7' ] && this[ '_rawObject' ].complete ){ + this[ 'asyncDispatch' ]( 'load' ); } else { - this.timerID = X.Timer.add( this.delay, 0, this, this._detect ); + this.timerID = X_Timer_add( this.delay, 0, this, this._detect ); }; }, @@ -62,30 +61,30 @@ X_NET_ImageWrapper = X_Class_override( if( this.finish ) return; this._busy = false; this.finish = true; - this.timerID && X.Timer.remove( this.timerID ); - this.timerID = this.asyncDispatch( /*e.type === 'error' ?*/ X.Event.ERROR /*: X.Event.CANCELED*/ ); + this.timerID && X_Timer_remove( this.timerID ); + this.timerID = this[ 'asyncDispatch' ]( /*e.type === 'error' ?*/ X_EVENT_ERROR /*: X_EVENT_CANCELED*/ ); break; case 'load' : // if( finish === true ) return; // これがあると firefox3.6 で駄目、、、 // if( timer ) return; // これがあると safari3.2 で駄目、、、 this._busy = false; this.finish = true; - this.timerID && X.Timer.remove( this.timerID ); - if( X_UA.Opera && !this._rawObject.complete ){ - this.timerID = this.asyncDispatch( X.Event.ERROR ); + this.timerID && X_Timer_remove( this.timerID ); + if( X_UA[ 'Opera' ] && !this[ '_rawObject' ].complete ){ + this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR ); return; }; size = X.Util.Image.getActualDimension( !X_Net_Image_isElement ? this.abspath : this ); - this.timerID = this.asyncDispatch( { - type : X.Event.SUCCESS, + this.timerID = this[ 'asyncDispatch' ]( { + type : X_EVENT_SUCCESS, src : this.abspath, w : size[ 0 ], h : size[ 1 ] // TODO feedback net speed - // time , this._rawObject.fileSize + // time , this[ '_rawObject' ].fileSize } ); break; - case X.Event.KILL_INSTANCE : + case X_EVENT_KILL_INSTANCE : this.reset(); !X_Net_Image_hasImage && this.destroy(); // if xnode break; @@ -94,34 +93,34 @@ X_NET_ImageWrapper = X_Class_override( _detect : function(){ if( this.finish ) return; - if( this._rawObject && this._rawObject.complete ){ + if( this[ '_rawObject' ] && this[ '_rawObject' ].complete ){ this._busy = false; this.finish = true; - if( this._rawObject.width ) return; - X.Timer.remove( this.timerID ); - this.timerID = this.asyncDispatch( X.Event.ERROR ); + if( this[ '_rawObject' ].width ) return; + X_Timer_remove( this.timerID ); + this.timerID = this[ 'asyncDispatch' ]( X_EVENT_ERROR ); } else if( this.timeout < ( this.tick += this.delay ) ){ this._busy = false; this.finish = true; - X.Timer.remove( this.timerID ); - this.timerID = this.asyncDispatch( X.Event.TIMEOUT ); + X_Timer_remove( this.timerID ); + this.timerID = this[ 'asyncDispatch' ]( X_EVENT_TIMEOUT ); }; }, cancel : function(){ // abort がある? - this._rawObject && this._rawObject.abort && this._rawObject.abort(); - // this._rawObject.src = ''; + this[ '_rawObject' ] && this[ '_rawObject' ].abort && this[ '_rawObject' ].abort(); + // this[ '_rawObject' ].src = ''; this._busy = false; this.finish = true; - this.asyncDispatch( X.Event.CANCELED ); + this[ 'asyncDispatch' ]( X_EVENT_CANCELED ); }, reset : function(){ - this.timerID && X.Timer.remove( this.timerID ); - //X_Net_Image_isElement ? this._rawObject.removeAttribute( 'src' ) : ( this._rawObject.src = '' ); - this._rawObject.src = ''; + this.timerID && X_Timer_remove( this.timerID ); + //X_Net_Image_isElement ? this[ '_rawObject' ].removeAttribute( 'src' ) : ( this[ '_rawObject' ].src = '' ); + this[ '_rawObject' ].src = ''; this.timerID = 0; this._busy = false; this.finished = false; @@ -130,6 +129,6 @@ X_NET_ImageWrapper = X_Class_override( } ); -X_NET_ImageWrapper.listen( [ 'load', 'error' /*, 'abort'*/, X.Event.KILL_INSTANCE ] ); +X_NET_ImageWrapper[ 'listen' ]( [ 'load', 'error' /*, 'abort'*/, X_EVENT_KILL_INSTANCE ] ); -// X_Net_Image_isElement && X_NET_ImageWrapper.appendTo( X.X_Node_systemNode ); +// X_Net_Image_isElement && X_NET_ImageWrapper[ 'appendAt' ]( X.X_Node_systemNode );