Comment
Kat
Tera Contributor

Hi @Community Alums ,

 

I tried the same code in my scoped application with two new UI actions - Up Vote and Down Vote with up and down arrow icons before them but for some reason the width doesn't auto adjust and the button messed up in the classic UI.

 

Also, doesn't it work in service portal? It isn't on my end.

 

FYI: 

Client Script UI type set to All

 

function onLoad() {
    //Change the color of the 'Up Vote' button to green
    transformButton('upvote', '#77FF77', 'white', 'icon-arrow-up');
    //Change the color of the 'Down Vote' button to red
    transformButton('downvote', '#FF0022', 'white', 'icon-arrow-down');
 
  //Change the color of the 'Up Vote' button to green
    transformButton('upvote_bottom', '#77FF77', 'white', 'icon-arrow-up');
    //Change the color of the 'Down Vote' button to red
    transformButton('downvote_bottom', '#FF0022', 'white', 'icon-arrow-down');
    
}
 
function transformButton(buttonID, buttonBackgroundColor, buttonTextColor, buttonIconName) {
    try{
        //Find the button(s) by ID and change the background color
        $$('button[id=' + buttonID + ']').each(function(elmt) {
//elmt.style.width = 100 rem;
            elmt.style.backgroundColor = buttonBackgroundColor;
            if(buttonTextColor){
                elmt.style.color = buttonTextColor;
            }
            if(buttonIconName){
                elmt.addClassName(buttonIconName);
                //Add some spacing between the icon and button label
                elmt.innerHTML = ' ' + elmt.innerHTML;
            }
        });
    }catch(e){}
}
 
 
Kat_0-1689359231109.png