Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Features
~~~~~~~~

- pat-inject: Rename undocumented ``selector`` property to ``defaultSelector``.
- pat-inject: Fix typo in docs for the ``source`` property.
- scroll detection: Rework and optimize, set scroll classes on any scrolling event, fix problem with IE and set initial state. Fixes #701
- pat-scroll: Implement new special `selector:top` attribute value to scroll the scroll container just to the top of the page. Ref: #721.
- pat-scroll: To define the scrollable target search also for `overflow-x` and `overflow-y` declarations.
Expand Down
2 changes: 1 addition & 1 deletion src/pat/inject/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ You can customise the behaviour of injection through options in the `data-pat-in
| ----- | --------| -------- | ------- | ----------- |
| `confirm` | `class` | class, always, never, form-data | Should a confirmation prompt be shown to the user before injection happens? Setting this to `form-data` means a prompt will be shown if there are form fields with values that will be replaced with the injected content. A value of `class` means that the pattern will check for the `is-dirty` CSS class on the target element. If the class is there, a confirmation prompt will be shown. | One of the allowable values. |
| `confirm-message` | `Are you sure you want to leave this page?` | | What message should be shown to the user in the confirmation prompt? | |
| `selector` | `body` | | Selector identifying which section of the loaded document to inject. | Selector string|
| `source` | `body` | | Selector identifying which section of the loaded document to inject. | Selector string|
| `target` | `body` | | Selector identifying where to inject the loaded content. | Selector string |
| `data-type` | `html` | `html` `markdown`| The type of content that is loaded. This is normally detected automatically. | One of the mutually exclusive string values. |
| `next-href` | | | For anchors, you can specify an href to point to after injection was triggered. If that element exists already during initialisation, the injection is not initialised and the href changed to next-href. | |
Expand Down
12 changes: 6 additions & 6 deletions src/pat/inject/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define([
TEXT_NODE = 3,
COMMENT_NODE = 8;

parser.addArgument("selector");
parser.addArgument("default-selector");
parser.addArgument("target");
parser.addArgument("data-type", "html");
parser.addArgument("next-href");
Expand Down Expand Up @@ -235,7 +235,7 @@ define([
log.warn("Ignoring additional source ids:", urlparts.slice(2));
}

cfg.selector = cfg.selector || defaultSelector;
cfg.defaultSelector = cfg.defaultSelector || defaultSelector;
if (cfg.delay) {
try {
cfg.delay = utils.parseTime(cfg.delay);
Expand Down Expand Up @@ -323,8 +323,8 @@ define([
return false;
}
// defaults
cfg.source = cfg.source || cfg.selector;
cfg.target = cfg.target || cfg.selector;
cfg.source = cfg.source || cfg.defaultSelector;
cfg.target = cfg.target || cfg.defaultSelector;

if (!inject.extractModifiers(cfg)) {
return false;
Expand Down Expand Up @@ -908,7 +908,7 @@ define([
return false;
}
// check if the target element still exists. Otherwise halt and catch fire
var target = ($el.data("pat-inject")[0].target || cfgs[0].selector).replace(/::element/, '');
var target = ($el.data("pat-inject")[0].target || cfgs[0].defaultSelector).replace(/::element/, '');
if (target && target !== 'self' && $(target).length === 0) {
return false;
}
Expand Down Expand Up @@ -948,7 +948,7 @@ define([
return false;
}
// check if the target element still exists. Otherwise halt and catch fire
var target = ($el.data("pat-inject")[0].target || cfgs[0].selector).replace(/::element/, '');
var target = ($el.data("pat-inject")[0].target || cfgs[0].defaultSelector).replace(/::element/, '');
if (target && target !== 'self' && $(target).length === 0) {
return false;
}
Expand Down