Created
July 9, 2016 00:40
-
-
Save radmike/182445657a47d9a99de1d2fce7287c9e to your computer and use it in GitHub Desktop.
Sightly Helpers for ACS AEM Commons Touch UI Multifields
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
"use strict"; | |
/** | |
* Multifield Helper JS Use-api script (for json-based multifield storage) | |
* | |
* @see http://j.mp/29ByR1y [touchui-composite-multifield.js] | |
* | |
* @param mfName node name containing the multifield | |
*/ | |
use(["/libs/wcm/foundation/components/utils/AuthoringUtils.js"], function (AuthoringUtils) { | |
var parsed = { items: [] }, toParse; | |
try { | |
if (this.mfName) { | |
toParse = properties[this.mfName]; | |
toParse.forEach(function (item) { | |
var itemParsed = JSON.parse(item); | |
parsed.items.push(itemParsed); | |
}); | |
} | |
} | |
catch (e) { | |
console.error("ERROR: " + e); | |
} | |
return parsed; | |
}); |
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
"use strict"; | |
/** | |
* Multifield Helper JS Use-api script (for node-based multifield storage) | |
* | |
* @see http://j.mp/29BqSBQ [touchui-composite-multifield-nodestore.js] | |
* | |
* @param mfName node name containing the multifield (if empty grabs first child node) | |
*/ | |
use(["/libs/wcm/foundation/components/utils/AuthoringUtils.js"], function (AuthoringUtils) { | |
var mf = {}; | |
try { | |
if (this.mfName) { | |
var childnode = resource.getChild(this.mfName); | |
if (childnode) { | |
mf.items = childnode.getChildren(); | |
} | |
} | |
else { | |
var childnodes = resource.getChildren(); | |
if (childnodes && childnodes.length > 0) { | |
mf.items = childnodes[0].getChildren(); | |
} | |
} | |
} | |
catch (e) { | |
console.error("ERROR: " + e); | |
} | |
return mf; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment