You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow an application to register a custom DOM observer specific to their application.
1096
1096
Adds it to the configured DOM observers that will then be supported by the dom insertion observer.
@@ -1102,7 +1102,6 @@ This method can be called two different ways:
1102
1102
Simple:
1103
1103
- action - the name of the new DOM observer
1104
1104
- class - the class of an inserted DOM element that identifies that this action should be triggered
1105
-
- parent - optional - if specified, this observer will be registered as a sub_observer for the specified parent (meaning it will only be checked for if the parent observer has something bound to it, and has been triggered).
1106
1105
1107
1106
Complex:
1108
1107
- action - the name of the new DOM observer
@@ -1111,7 +1110,6 @@ Complex:
1111
1110
- selector - if you need to match more than just the className of a specific element to indicate a match, you can use this selector for further checking (uses element.is(selector) on matched element). E.g. if there are multiple elements with a class indicating an observer should fire, but you only want it to fire on a specific id, then you would use this
1112
1111
- sub_selector - if specified, we do a jquery element.find for the passed selector on the inserted element and ensure we can find a match
1113
1112
- handler - if specified this handler is called if a match is found. Otherwise default calls the callback & passes the jQuery matchElement
Copy file name to clipboardExpand all lines: src/gmail.js
+4-29Lines changed: 4 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -1608,13 +1608,12 @@ var Gmail = function(localJQuery) {
1608
1608
// map observers to DOM class names
1609
1609
// as elements are inserted into the DOM, these classes will be checked for and mapped events triggered,
1610
1610
// receiving "e" event object, and a jquery bound inserted DOM element
1611
-
// NOTE: supported observers and sub_observers must be registered in the supported_observers array as well as the dom_observers config
1611
+
// NOTE: supported observers must be registered in the supported_observers array as well as the dom_observers config
1612
1612
// Config example: event_name: {
1613
1613
// class: "className", // required - check for this className in the inserted DOM element
1614
1614
// selector: "div.className#myId", // if you need to match more than just the className of a specific element to indicate a match, you can use this selector for further checking (uses element.is(selector) on matched element). E.g. if there are multiple elements with a class indicating an observer should fire, but you only want it to fire on a specific id, then you would use this
1615
1615
// sub_selector: "div.className", // if specified, we do a jquery element.find for the passed selector on the inserted element and ensure we can find a match
1616
-
// handler: function( matchElement, callback ) {}, // if specified this handler is called if a match is found. Otherwise default calls the callback & passes the jQuery matchElement
1617
-
// sub_observers: { }, // hash of event_name: config_hash"s - config hash supports all properties of this config hash. Observer will be bound as DOMNodeInserted to the matching class+sub_selector element.
1616
+
// handler: function( matchElement, callback ) {} // if specified this handler is called if a match is found. Otherwise default calls the callback & passes the jQuery matchElement
1618
1617
// },
1619
1618
// TODO: current limitation allows only 1 action per watched className (i.e. each watched class must be
1620
1619
// unique). If this functionality is needed this can be worked around by pushing actions to an array
@@ -1747,9 +1746,8 @@ var Gmail = function(localJQuery) {
1747
1746
action - the name of the new DOM observer
1748
1747
className / args - for a simple observer, this arg can simply be the class on an inserted DOM element that identifies this event should be
1749
1748
triggered. For a more complicated observer, this can be an object containing properties for each of the supported DOM observer config arguments
1750
-
parent - optional - if specified, this observer will be registered as a sub_observer for the specified parent
// 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
1911
-
if(config.sub_observers){
1912
-
1913
-
// create observer_map for the sub_observers
1914
-
varobserver_map={};
1915
-
$.each(config.sub_observers,function(act,cfg){
1916
-
observer_map[cfg.class]=act;
1917
-
});
1918
-
1919
-
// this listener will check every element inserted into the DOM below the current element
1920
-
// and repeat this method, but specifically below the current element rather than the global DOM
0 commit comments