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
Copy file name to clipboardExpand all lines: src/pat/inject/documentation.md
+19-22Lines changed: 19 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -258,7 +258,7 @@ to build infinite lists, where the injection element replaces itself with the ne
258
258
259
259
A injection may be delayed, by providing a `delay` argument in `data-pat-inject`.
260
260
The delay is specified in milliseconds.
261
-
This is useful to build a polling loop or to prevent multiple injections happen at once by giving different delays to injections with an ``autoload`` trigger.
261
+
This is useful to build a polling loop or to prevent multiple injections happen at once by giving different delays to injections with an `autoload` trigger.
262
262
263
263
<a href="sources.html#id" class="pat-inject"
264
264
data-pat-inject="trigger: autoload">Autoloads as soon as initialised</a>
@@ -269,12 +269,10 @@ This is useful to build a polling loop or to prevent multiple injections happen
269
269
<a href="sources.html#id" class="pat-inject"
270
270
data-pat-inject="trigger: autoload; delay: 2000">Autoloads 2 seconds after the page is initialised.</a>
271
271
272
-
273
-
For ``trigger: autoload-visible`` injections, the default delay is 200ms.
272
+
For `trigger: autoload-visible` injections, the default delay is 200ms.
274
273
This allows for long pages to scroll over and past items witn an autoload-visible trigger without loading them.
275
274
If the item with the autoload-visible trigger is within the viewport for 200ms, the item is loaded.
276
-
You can set this to ``0`` or any other delay time by configuring the delay parameter.
277
-
275
+
You can set this to `0` or any other delay time by configuring the delay parameter.
278
276
279
277
<!--
280
278
XXX: example infinite list
@@ -337,17 +335,17 @@ After injection was triggered:
337
335
### Configurable error pages.
338
336
339
337
In cases of AJAX errors, you can provide custom error pages by providing custom meta tags.
340
-
For example, if you add this meta tag to the html ``<head>``:
338
+
For example, if you add this meta tag to the html `<head>`:
Then, in case of a ``404`` error, it will try to retrieve the error page and replace the document body contents with the body contents of the error page.
345
-
The code looks for a meta tag with the name ``pat-inject-status-`` plus the HTTP status code.
342
+
Then, in case of a `404` error, it will try to retrieve the error page and replace the document body contents with the body contents of the error page.
343
+
The code looks for a meta tag with the name `pat-inject-status-` plus the HTTP status code.
346
344
347
-
Another example: You can present the user with a login page in case the session has expired (``401`` error).
345
+
Another example: You can present the user with a login page in case the session has expired (`401` error).
348
346
349
347
You can disable this behavior for debugging by adding the following parameter to the query string:
350
-
``pat-inject-errorhandler.off``.
348
+
`pat-inject-errorhandler.off`.
351
349
352
350
### Options reference
353
351
@@ -374,21 +372,20 @@ You can customise the behaviour of injection through options in the `data-pat-in
374
372
|`history`||`none``record`| If set to `record` then injection will update the URL history and the title tag of the HTML page. | String or null. |
375
373
|`scroll`||`none`, `top`, `target`, CSS selector | After injection is done, scroll to to given position. The default or `none` is to not do any scrolling. `top` scrolls to the top of the scroll container. `target` scrolls to the pat-inject target. CSS selector scrolls to the given selector. Note: You have to define a scroll container by setting overflow classes, otherwise `window` is used. | String, CSS selector |
376
374
377
-
378
375
## Developer documentation
379
376
380
377
pat-inject fires several JavaScript events which bubble up the DOM tree:
381
378
382
-
| Event name | Type | Triggered on | Bubbles | Description |
383
-
| --- | --- | --- | --- | --- |
384
-
|`patterns-inject-triggered`| jQuery | pat-inject-element | true | Triggered, right after injection has been triggered. This can be on click, on submit, automatically and so on. |
385
-
|`pat-ajax-success`| jQuery | pat-inject element | true | Triggered after successful ajax call but before the response is injected into the document |
386
-
|`patterns-injected`| jQuery | parent of injected content | true | Triggered after successful injection |
387
-
|`pat-inject-success`| JavaScript | pat-inject element | true | Triggered after successful injection, right after `patterns-injected` but on the pat-inject element and not on the injected content itself. |
388
-
|`patterns-injected-scanned`| jQuery | injected content | true | Triggered after injected content was scanned by Pattern registry for new patterns. |
|`pat-inject-content-loaded`| jQuery | images within injected content | true | Triggered on images within the injected content when those images are loaded. |
391
-
|`pat-inject-missingSource`| jQuery | trigger which caused the injection | true | Triggered when no to-be-injected source could be found. |
392
-
|`pat-inject-missingTarget`| jQuery | trigger which caused the injection | true | Triggered when no target could be found. |
379
+
| Event name | Type | Triggered on | Bubbles | Description|
|`patterns-inject-triggered`| jQuery | pat-inject-element | true | Triggered, right after injection has been triggered. This can be on click, on submit, automatically and so on.|
382
+
|`pat-ajax-success`| jQuery | pat-inject element | true | Triggered after successful ajax call but before the response is injected into the document|
383
+
|`patterns-injected`| jQuery | parent of injected content | true | Triggered after successful injection|
384
+
|`pat-inject-success`| JavaScript | pat-inject element | true| Triggered after successful injection, right after `patterns-injected` but on the pat-inject element and not on the injected content itself. |
385
+
|`patterns-injected-scanned`| jQuery | injected content | true | Triggered after injected content was scanned by Pattern registry for new patterns.|
|`pat-inject-content-loaded`| jQuery | images within injected content | true | Triggered on images within the injected content when those images are loaded.|
388
+
|`pat-inject-missingSource`| jQuery | trigger which caused the injection | true | Triggered when no to-be-injected source could be found.|
389
+
|`pat-inject-missingTarget`| jQuery | trigger which caused the injection | true | Triggered when no target could be found.|
393
390
394
391
Please note: `jQuery.trigger` events can be catched with jQuery only while JavaScript `dispatchEvent` events can be catched with bare JavaScript `addEventListener` and `jQuery.on`.
0 commit comments