@@ -764,6 +764,7 @@ var CommentManager = (function() {
764
764
765
765
function CommentManager ( stageObject ) {
766
766
var __timer = 0 ;
767
+ this . _listeners = { } ;
767
768
this . stage = stageObject ;
768
769
this . options = {
769
770
opacity :1 ,
@@ -833,17 +834,20 @@ var CommentManager = (function() {
833
834
return 0 ;
834
835
}
835
836
} ) ;
837
+ this . dispatchEvent ( "load" ) ;
836
838
} ;
837
839
838
840
CommentManager . prototype . clear = function ( ) {
839
841
while ( this . runline . length > 0 ) {
840
842
this . runline [ 0 ] . finish ( ) ;
841
843
}
844
+ this . dispatchEvent ( "clear" ) ;
842
845
} ;
843
846
844
847
CommentManager . prototype . setBounds = function ( ) {
845
848
this . width = this . stage . offsetWidth ;
846
849
this . height = this . stage . offsetHeight ;
850
+ this . dispatchEvent ( "resize" ) ;
847
851
for ( var comAlloc in this . csa ) {
848
852
this . csa [ comAlloc ] . setBounds ( this . width , this . height ) ;
849
853
}
@@ -924,10 +928,12 @@ var CommentManager = (function() {
924
928
} break ;
925
929
}
926
930
cmt . y = cmt . y ;
931
+ this . dispatchEvent ( "enterComment" , cmt ) ;
927
932
this . runline . push ( cmt ) ;
928
933
} ;
929
934
930
935
CommentManager . prototype . finish = function ( cmt ) {
936
+ this . dispatchEvent ( "exitComment" , cmt ) ;
931
937
this . stage . removeChild ( cmt . dom ) ;
932
938
var index = this . runline . indexOf ( cmt ) ;
933
939
if ( index >= 0 ) {
@@ -943,7 +949,24 @@ var CommentManager = (function() {
943
949
case 7 :break ;
944
950
}
945
951
} ;
946
-
952
+ CommentManager . prototype . addEventListener = function ( event , listener ) {
953
+ if ( typeof this . _listeners [ event ] !== "undefined" ) {
954
+ this . _listeners [ event ] . push ( listener ) ;
955
+ } else {
956
+ this . _listeners [ event ] = [ listener ] ;
957
+ }
958
+ } ;
959
+ CommentManager . prototype . dispatchEvent = function ( event , data ) {
960
+ if ( typeof this . _listeners [ event ] !== "undefined" ) {
961
+ for ( var i = 0 ; i < this . _listeners [ event ] . length ; i ++ ) {
962
+ try {
963
+ this . _listeners [ event ] [ i ] ( data ) ;
964
+ } catch ( e ) {
965
+ console . err ( e . stack ) ;
966
+ }
967
+ }
968
+ }
969
+ } ;
947
970
/** Static Functions **/
948
971
CommentManager . prototype . onTimerEvent = function ( timePassed , cmObj ) {
949
972
for ( var i = 0 ; i < cmObj . runline . length ; i ++ ) {
0 commit comments