-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Banner options and native lazy loading
- added ability to provide custom options for each banner. - added support for native lazy loading. Feature can be enabled through banner options `loading=lazy` and `loading-offset=<offset>` (for multiple positions only) - the default templates have been modified and moved to the `./src/template` directory. - Updated docs. - Updated CHANGELOG
- Loading branch information
Showing
16 changed files
with
269 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class AttributesParser { | ||
static parseResources(element) { | ||
const resources = {}; | ||
|
||
const attributes = [].filter.call(element.attributes, attr => { | ||
return /^data-amp-resource-\S+/.test(attr.name); | ||
}); | ||
|
||
for (let attr of attributes) { | ||
if (attr.value) { | ||
resources[attr.name.slice(18)] = attr.value.split(',').map(v => v.trim()); | ||
} | ||
} | ||
|
||
return resources; | ||
} | ||
|
||
static parseOptions(element) { | ||
const options = {}; | ||
|
||
const attributes = [].filter.call(element.attributes, attr => { | ||
return /^data-amp-option-\S+/.test(attr.name); | ||
}); | ||
|
||
for (let opt of attributes) { | ||
if (opt.value) { | ||
options[opt.name.slice(16)] = opt.value.trim(); | ||
} | ||
} | ||
|
||
return options; | ||
} | ||
} | ||
|
||
module.exports = AttributesParser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Options { | ||
constructor(options) { | ||
this.options = options; | ||
} | ||
|
||
has(optionName) { | ||
return undefined !== this.options[optionName]; | ||
} | ||
|
||
get(optionName, defaultValue = undefined) { | ||
return this.options[optionName] || defaultValue; | ||
} | ||
} | ||
|
||
module.exports = Options; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.