Created
November 2, 2016 23:41
-
-
Save EliJDonahue/30c32c047838a6bec44cbf1e41d259c9 to your computer and use it in GitHub Desktop.
[ArasLabs/custom-form-css] Show contents of custom_icon form field
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
<img id="myIcon" name="myIcon" src="../customer/svg/package.svg" vspace="20" hspace="20" /> | |
<script> | |
chooseIcon = function() | |
{ | |
var icn = "../customer/svg/"; | |
// get classification, gets "none" if getProperty returns null | |
var thisItem = document.thisItem; | |
var classification = thisItem.getProperty("classification","none"); | |
// get icon fields | |
var defIcon = document.getElementById("large_icon_img"); | |
var myIcon = document.getElementById("myIcon"); | |
// choose file name | |
switch (classification) | |
{ | |
case "none": | |
// choose part icon file | |
icn = defIcon.getAttribute("src"); | |
break; | |
case "Assembly": | |
icn += "package.svg"; | |
break; | |
case "Component": | |
icn += "circuit-board.svg"; | |
break; | |
case "Material": | |
icn += "beaker.svg"; | |
break; | |
case "Software": | |
icn += "file-binary.svg"; | |
break; | |
} | |
// style custom icon | |
myIcon.setAttribute("src",icn); | |
myIcon.style.visibility = "visible"; | |
myIcon.style.display = "block"; | |
// hide default icon element | |
defIcon.style.visibility = "hidden"; | |
} | |
// choose icon onLoad | |
window.addEventListener("load", chooseIcon); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment