|
180 | 180 | else allQueries[mode][property][value] += ','+selector;
|
181 | 181 | }
|
182 | 182 |
|
183 |
| - function getQuery() { |
| 183 | + function getQuery(container) { |
184 | 184 | var query;
|
185 |
| - if (document.querySelectorAll) query = document.querySelectorAll.bind(document); |
| 185 | + if (document.querySelectorAll) query = (container) ? container.querySelectorAll.bind(container) : document.querySelectorAll.bind(document); |
186 | 186 | if (!query && 'undefined' !== typeof $$) query = $$;
|
187 | 187 | if (!query && 'undefined' !== typeof jQuery) query = jQuery;
|
188 | 188 |
|
|
196 | 196 | /**
|
197 | 197 | * Start the magic. Go through all collected rules (readRules()) and attach the resize-listener.
|
198 | 198 | */
|
199 |
| - function findElementQueriesElements() { |
200 |
| - var query = getQuery(); |
| 199 | + function findElementQueriesElements(container) { |
| 200 | + var query = getQuery(container); |
201 | 201 |
|
202 | 202 | for (var mode in allQueries) if (allQueries.hasOwnProperty(mode)) {
|
203 | 203 |
|
204 | 204 | for (var property in allQueries[mode]) if (allQueries[mode].hasOwnProperty(property)) {
|
205 | 205 | for (var value in allQueries[mode][property]) if (allQueries[mode][property].hasOwnProperty(value)) {
|
206 |
| - var elements = query(allQueries[mode][property][value]); |
| 206 | + var elements = query(allQueries[mode][property][value], container); |
207 | 207 | for (var i = 0, j = elements.length; i < j; i++) {
|
208 | 208 | setupElement(elements[i], {
|
209 | 209 | mode: mode,
|
|
407 | 407 | findResponsiveImages();
|
408 | 408 | };
|
409 | 409 |
|
| 410 | + /** |
| 411 | + * Go through all collected rules (readRules()) and attach the resize-listener. |
| 412 | + * |
| 413 | + * @param {HTMLElement} container only elements of the container are considered (document.body if not set) |
| 414 | + */ |
| 415 | + this.findElementQueriesElements = function(container) { |
| 416 | + findElementQueriesElements(container); |
| 417 | + }; |
| 418 | + |
410 | 419 | /**
|
411 | 420 | *
|
412 | 421 | * @param {Boolean} withTracking allows and requires you to use detach, since we store internally all used elements
|
|
500 | 509 | else window.onload = callback;
|
501 | 510 | };
|
502 | 511 |
|
| 512 | + ElementQueries.findElementQueriesElements = function(container) { |
| 513 | + ElementQueries.instance.findElementQueriesElements(container); |
| 514 | + }; |
| 515 | + |
503 | 516 | ElementQueries.listen = function() {
|
504 | 517 | domLoaded(ElementQueries.init);
|
505 | 518 | };
|
|
0 commit comments