j-Part
This component can handle different contents asynchronously. If the element doesn't contain any content then the component downloads the content according to the url defined in configuration.
- NEW
pathcan contain{String Array}
Configuration:
url {String}required, a relative URL addressif {String}required, condition, it's compared with the value within ofpath(NEW: supports multiple paths divided by thecomma)reload {String}optional, a link to functionfunction(init) {}, it's executed when the part is visible (always)hidden {String}optional, a link to function, it's executed when the part is hidden (always)init {String}optional, a link to function, it's executed when the part is visible and onetimedefault {String}optional, a short alias forDEFAULT(default)hide {Boolean}optional, auto-hide element if theifcondition is not valid (default:true)cleaner {Number}optional, idle time (in minutes) for running of cleaning (default:0)clean {String}optional, a link to function, it's executed before the part is cleanedloading {Boolean}optional, enables loading viaSETTER('loading')(default:true)path {String}optional, the component replace all~PATH~andCLASSphrases for the value of thepathin the downloaded templatereplace {String}optional, a link to methodfunction(content) { return content }which can modify downloaded templateabsolute {Boolean}optional, enables absolute position (defaultfalse)check {String}optional, a link to functionfunction(next) { next(); }, it's executed when the part is wanting to showinvisible {Boolean}enables adding ofinvisibleclass when the part is going to hide (default:false)delay {Number}a delay (in ms) for removing ofinvisibleclass and hiding ofloading(default:500)autofocus {Boolean/String}focuses the first input, textarea (default:false)delayloading {Number}a delay (in ms) for hiding of ofloading(default:800)id {String}a custom identifier for replacing~ID~phrases in the imported HTML (default: empty)
Good to know 1:
- all
CLASSand~PATH~phrases will be replaced byconfig.pathorconfig.ifautomatically - all
~ID~phrases will be replaced byconfig.idautomatically
Good to know 2:
Part component emits an event in the form: parts. + config.if for extending of parts. This can be very usefull for some plugin systems. Example:
Good to know 3:
If the part component isn't within scope then the value from the config.if will replace ? characters in all config keys.
ON('parts.YOURIFCONDITION', function(element, pagecomponent) {
// It's executed only when the part is initialized
});Use it with <ui-component name="part">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.
<ui-component name="part" path="currentpart" config="if:home;url:/bla/bla/home.html"></ui-component>
<ui-component name="part" path="currentpart" config="if:services;url:/bla/bla/services.html;reload:services_reload"></ui-component>
<ui-component name="part" path="currentpart" config="if:contact;url:/bla/bla/contact.html;reload:contact_reload"></ui-component>
<pre><code>SET('currentpart', 'home');</code></pre>
<script>
var currentpart = '';
</script>