All files / src/visual muteElements.js

100% Statements 9/9
100% Branches 2/2
100% Functions 2/2
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42          31x                       191x             191x 3x 2x 2x   1x 1x         31x            
/**
 * Handles the visual state for all of the mute elements.
 *
 * @module visual/MuteElements
 */
let MuteElements = (function() {
  /**
   * Syncs mute for all of the mute buttons. This represents the
   * state of the player if it's muted or not.
   *
   * @access public
   * @param {string} state 	- The muted state of the player.
   */
  function setMuted(state) {
    /*
			Get all of the mute buttons.
		*/
    let muteClasses = document.getElementsByClassName("amplitude-mute");
 
    /*
			Iterate over all of the mute classes. If the state of the player
			is not-muted then we add the amplitude-not-muted classe and remove
			the amplitude muted class otherwise we do the opposite.
		*/
    for (let i = 0; i < muteClasses.length; i++) {
      if (!state) {
        muteClasses[i].classList.add("amplitude-not-muted");
        muteClasses[i].classList.remove("amplitude-muted");
      } else {
        muteClasses[i].classList.remove("amplitude-not-muted");
        muteClasses[i].classList.add("amplitude-muted");
      }
    }
  }
 
  return {
    setMuted: setMuted
  };
})();
 
export default MuteElements;