@@ -52,9 +52,18 @@ module
5252 options = angular . extend ( options , data ) ;
5353 } ;
5454
55- this . $get = [ '$q' , '$timeout ' , '$rootScope' , function ( $q , $timeout , $rootScope ) {
55+ this . $get = [ '$q' , '$interval ' , '$rootScope' , function ( $q , $interval , $rootScope ) {
5656
5757 var me = { } ,
58+ getValue = function ( data ) {
59+ var i ;
60+ for ( i = 0 ; i < data . length ; i += 1 ) {
61+ if ( data [ i ] !== undefined ) {
62+ return data [ i ] ;
63+ }
64+ }
65+ return undefined ;
66+ } ,
5867 updatePersistence = function function_name ( amount ) {
5968 angular . forEach ( me . messages , function ( msg ) {
6069 msg . persist_counter += amount ;
@@ -85,12 +94,12 @@ module
8594 type : item . type ,
8695 data : data ,
8796 defer : $q . defer ( ) ,
88- persist : persist || types [ index ] . persist || options . persist || 0 ,
89- persist_counter : persist || types [ index ] . persist || options . persist || 0 ,
90- delay : delay || types [ index ] . delay || options . delay || 0 ,
91- template : template || types [ index ] . template || options . template || 0 ,
92- clickToClose : clickToClose || types [ index ] . clickToClose || options . clickToClose || 0 ,
93- showClose : showClose || types [ index ] . showClose || options . showClose || 0 ,
97+ persist : getValue ( [ persist , types [ index ] . persist , options . persist , 0 ] ) ,
98+ persist_counter : getValue ( [ persist , types [ index ] . persist , options . persist , 0 ] ) ,
99+ delay : getValue ( [ delay , types [ index ] . delay , options . delay , 0 ] ) ,
100+ template : getValue ( [ template , types [ index ] . template , options . template , 0 ] ) ,
101+ clickToClose : getValue ( [ clickToClose , types [ index ] . clickToClose , options . clickToClose , 0 ] ) ,
102+ showClose : getValue ( [ showClose , types [ index ] . showClose , options . showClose , 0 ] ) ,
94103 close : function ( data ) {
95104 if ( data === 'clickToClose' && ! msg . clickToClose ) {
96105 return ;
@@ -99,12 +108,14 @@ module
99108 var indexMsg = me . messages . map ( function ( x ) { return x . $$hashKey ; } ) . indexOf ( msg . $$hashKey ) ;
100109 me . messages . splice ( indexMsg , 1 ) ;
101110
111+ $interval . cancel ( me . timeout ) ;
112+
102113 msg . defer . resolve ( { result :data , msg :msg } ) ;
103114 }
104115 } ;
105116
106117 if ( msg . delay && msg . delay > 0 ) {
107- msg . timeout = $timeout ( function ( ) { msg . close ( 'timedout' ) ; } , msg . delay ) ;
118+ msg . timeout = $interval ( function ( ) { msg . close ( 'timedout' ) ; } , msg . delay ) ;
108119 }
109120
110121 me . messages . push ( msg ) ;
0 commit comments