@@ -1737,7 +1737,10 @@ var Gmail = function(localJQuery) {
1737
1737
$ . each ( api . tracker . dom_observers , function ( act , config ) {
1738
1738
if ( ! $ . isArray ( config . class ) ) config . class = [ config . class ] ;
1739
1739
$ . each ( config . class , function ( idx , className ) {
1740
- api . tracker . dom_observer_map [ className ] = act ;
1740
+ if ( ! api . tracker . dom_observer_map [ className ] ) {
1741
+ api . tracker . dom_observer_map [ className ] = [ ] ;
1742
+ }
1743
+ api . tracker . dom_observer_map [ className ] . push ( act ) ;
1741
1744
} ) ;
1742
1745
} ) ;
1743
1746
//console.log( "observer_config", api.tracker.dom_observers, "dom_observer_map", api.tracker.dom_observer_map);
@@ -1813,7 +1816,7 @@ var Gmail = function(localJQuery) {
1813
1816
// this listener will check every element inserted into the DOM
1814
1817
// for specified classes (as defined in api.tracker.dom_observers above) which indicate
1815
1818
// related actions which need triggering
1816
- $ ( window . document ) . bind ( "DOMNodeInserted" , function ( e ) {
1819
+ $ ( window . document ) . on ( "DOMNodeInserted" , function ( e ) {
1817
1820
api . tools . insertion_observer ( e . target , api . tracker . dom_observers , api . tracker . dom_observer_map ) ;
1818
1821
} ) ;
1819
1822
@@ -1880,46 +1883,52 @@ var Gmail = function(localJQuery) {
1880
1883
var classes = cn . trim ? cn . trim ( ) . split ( / \s + / ) : [ ] ;
1881
1884
if ( ! classes . length ) classes . push ( "" ) ; // if no class, then check for anything observing nodes with no class
1882
1885
$ . each ( classes , function ( idx , className ) {
1883
- var observer = dom_observer_map [ className ] ;
1886
+ var observers = dom_observer_map [ className ] ;
1887
+ if ( ! observers ) {
1888
+ return ;
1889
+ }
1884
1890
1885
- // check if this is a defined observer, and callbacks are bound to that observer
1886
- if ( observer && api . tracker . watchdog . dom [ observer ] ) {
1887
- var element = $ ( target ) ;
1888
- var config = dom_observers [ observer ] ;
1891
+ for ( var observer of observers ) {
1889
1892
1890
- // if a config id specified for this observer, ensure it matches for this element
1891
- if ( config . selector && ! element . is ( config . selector ) ) {
1892
- return ;
1893
- }
1893
+ // check if this is a defined observer, and callbacks are bound to that observer
1894
+ if ( observer && api . tracker . watchdog . dom [ observer ] ) {
1895
+ var element = $ ( target ) ;
1896
+ var config = dom_observers [ observer ] ;
1894
1897
1895
- // check for any defined sub_selector match - if not found, then this is not a match for this observer
1896
- // if found, then set the matching element to be the one that matches the sub_selector
1897
- if ( config . sub_selector ) {
1898
- element = element . find ( config . sub_selector ) ;
1899
- // console.log("checking for subselector", config.sub_selector, element);
1900
- }
1898
+ // if a config id specified for this observer, ensure it matches for this element
1899
+ if ( config . selector && ! element . is ( config . selector ) ) {
1900
+ return ;
1901
+ }
1901
1902
1902
- // if an element has been found, execute the observer handler (or if none defined, execute the callback)
1903
- if ( element . length ) {
1903
+ // check for any defined sub_selector match - if not found, then this is not a match for this observer
1904
+ // if found, then set the matching element to be the one that matches the sub_selector
1905
+ if ( config . sub_selector ) {
1906
+ element = element . find ( config . sub_selector ) ;
1907
+ // console.log("checking for subselector", config.sub_selector, element);
1908
+ }
1904
1909
1905
- var handler = config . handler ? config . handler : function ( match , callback ) { callback ( match ) ; } ;
1906
- // console.log( "inserted DOM: class match in watchdog",observer,api.tracker.watchdog.dom[observer] );
1907
- api . observe . trigger_dom ( observer , element , handler ) ;
1910
+ // if an element has been found, execute the observer handler (or if none defined, execute the callback)
1911
+ if ( element . length ) {
1908
1912
1909
- // if sub_observers are configured for this observer, bind a DOMNodeInsertion listener to this element & to check for specific elements being added to this particular element
1910
- if ( config . sub_observers ) {
1913
+ var handler = config . handler ? config . handler : function ( match , callback ) { callback ( match ) ; } ;
1914
+ // console.log( "inserted DOM: class match in watchdog",observer,api.tracker.watchdog.dom[observer] );
1915
+ api . observe . trigger_dom ( observer , element , handler ) ;
1911
1916
1912
- // create observer_map for the sub_observers
1913
- var observer_map = { } ;
1914
- $ . each ( config . sub_observers , function ( act , cfg ) {
1915
- observer_map [ cfg . class ] = act ;
1916
- } ) ;
1917
+ // if sub_observers are configured for this observer, bind a DOMNodeInsertion listener to this element & to check for specific elements being added to this particular element
1918
+ if ( config . sub_observers ) {
1917
1919
1918
- // this listener will check every element inserted into the DOM below the current element
1919
- // and repeat this method, but specifically below the current element rather than the global DOM
1920
- element . bind ( "DOMNodeInserted" , function ( e ) {
1921
- api . tools . insertion_observer ( e . target , config . sub_observers , observer_map , "SUB " ) ;
1922
- } ) ;
1920
+ // create observer_map for the sub_observers
1921
+ var observer_map = { } ;
1922
+ $ . each ( config . sub_observers , function ( act , cfg ) {
1923
+ observer_map [ cfg . class ] = act ;
1924
+ } ) ;
1925
+
1926
+ // this listener will check every element inserted into the DOM below the current element
1927
+ // and repeat this method, but specifically below the current element rather than the global DOM
1928
+ element . on ( "DOMNodeInserted" , function ( e ) {
1929
+ api . tools . insertion_observer ( e . target , config . sub_observers , observer_map , "SUB " ) ;
1930
+ } ) ;
1931
+ }
1923
1932
}
1924
1933
}
1925
1934
}
@@ -2833,7 +2842,7 @@ var Gmail = function(localJQuery) {
2833
2842
2834
2843
center ( ) ;
2835
2844
2836
- container . bind ( "DOMSubtreeModified" , center ) ;
2845
+ container . on ( "DOMSubtreeModified" , center ) ;
2837
2846
$ ( window ) . resize ( center ) ;
2838
2847
} ;
2839
2848
0 commit comments