OSDN Git Service

Version 0.6.78, bugfix & starting jsdoc.
[pettanr/clientJs.git] / 0.6.x / js / 01_dom / 20_XDomImage.js
index e3ba959..d1d417f 100644 (file)
@@ -100,19 +100,20 @@ X.Dom.Image = {
                        abspath : null,\r
                        delay   : null,\r
                        timeout : 0,\r
+                       \r
                        Constructor : function( abspath, delay, timeout ){\r
                                var img;\r
-                               \r
+\r
                                this.abspath = abspath;\r
                                this.delay   = delay || 100;\r
                                this.timeout = timeout || 10000;\r
                                this.xnode =\r
                                        (\r
                                                window[ 'Image' ] ?\r
-                                                       X.Dom.Node( img = new Image() ) :\r
+                                                       X.EventDispatcher( img = new Image() ) :\r
                                                        X.Dom.Node._systemNode.create( 'img', { src : abspath } )\r
                                        )\r
-                                       .listen( [ 'load', 'error', 'abort', X.Event.SUCCESS, X.Event.ERROR ], this );\r
+                                       .listen( [ 'load', 'error', 'abort', X.Event.SUCCESS, X.Event.ERROR, X.Event.KILL_INSTANCE ], this );\r
                                img && ( img.src = abspath );\r
                                this._detect();\r
                        },\r
@@ -134,7 +135,7 @@ X.Dom.Image = {
                                                        this.timerID = this.asyncDispatch( 0, { type : X.Event.ERROR } );\r
                                                        return;\r
                                                };\r
-                                               size = X.Dom.Image.getActualDimension( X.UA.IE && X.UA.IE < 9 && window.Image ? this.abspath : this.xnode );\r
+                                               size = X.Dom.Image.getActualDimension( X.UA.IE < 9 ? this.abspath : this.xnode );\r
                                                this.timerID = this.asyncDispatch( 0, {\r
                                                        type : X.Event.SUCCESS,\r
                                                        src  : this.abspath,\r
@@ -147,6 +148,11 @@ X.Dom.Image = {
                                                delete this.timerID;\r
                                                X.Timer.once( 0, this, this.kill );\r
                                                break;\r
+                                       case X.Event.KILL_INSTANCE :\r
+                                               this.timerID && X.Timer.remove( this.timerID );\r
+                                               this.xnode.destroy && this.xnode.destroy();\r
+                                               this.unlisten();\r
+                                               break;\r
                                };\r
                        },      \r
                        _detect : function(){\r
@@ -169,11 +175,6 @@ X.Dom.Image = {
                                \r
                                // this.dispacth( { type : X.Event.CANCELED } );\r
                                this.kill();\r
-                       },\r
-                       onKill : function(){\r
-                               this.timerID && X.Timer.remove( this.timerID );\r
-                               this.xnode.destroy();\r
-                               this.unlisten();\r
                        }\r
                }\r
        )\r