@@ -764,6 +764,7 @@ var CommentManager = (function() {
764764
765765 function CommentManager ( stageObject ) {
766766 var __timer = 0 ;
767+ this . _listeners = { } ;
767768 this . stage = stageObject ;
768769 this . options = {
769770 opacity :1 ,
@@ -833,17 +834,20 @@ var CommentManager = (function() {
833834 return 0 ;
834835 }
835836 } ) ;
837+ this . dispatchEvent ( "load" ) ;
836838 } ;
837839
838840 CommentManager . prototype . clear = function ( ) {
839841 while ( this . runline . length > 0 ) {
840842 this . runline [ 0 ] . finish ( ) ;
841843 }
844+ this . dispatchEvent ( "clear" ) ;
842845 } ;
843846
844847 CommentManager . prototype . setBounds = function ( ) {
845848 this . width = this . stage . offsetWidth ;
846849 this . height = this . stage . offsetHeight ;
850+ this . dispatchEvent ( "resize" ) ;
847851 for ( var comAlloc in this . csa ) {
848852 this . csa [ comAlloc ] . setBounds ( this . width , this . height ) ;
849853 }
@@ -924,10 +928,12 @@ var CommentManager = (function() {
924928 } break ;
925929 }
926930 cmt . y = cmt . y ;
931+ this . dispatchEvent ( "enterComment" , cmt ) ;
927932 this . runline . push ( cmt ) ;
928933 } ;
929934
930935 CommentManager . prototype . finish = function ( cmt ) {
936+ this . dispatchEvent ( "exitComment" , cmt ) ;
931937 this . stage . removeChild ( cmt . dom ) ;
932938 var index = this . runline . indexOf ( cmt ) ;
933939 if ( index >= 0 ) {
@@ -943,7 +949,24 @@ var CommentManager = (function() {
943949 case 7 :break ;
944950 }
945951 } ;
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+ } ;
947970 /** Static Functions **/
948971 CommentManager . prototype . onTimerEvent = function ( timePassed , cmObj ) {
949972 for ( var i = 0 ; i < cmObj . runline . length ; i ++ ) {
0 commit comments