ref(UIUtil): add showOrHideElement

This commit is contained in:
paweldomas 2016-11-23 15:04:05 -06:00
parent 52847bd28d
commit 51da40e90c
7 changed files with 43 additions and 74 deletions

View File

@ -392,11 +392,7 @@ var Recording = {
let shouldShow = show && _isRecordingButtonEnabled(); let shouldShow = show && _isRecordingButtonEnabled();
let id = 'toolbar_button_record'; let id = 'toolbar_button_record';
if (shouldShow) { UIUtil.showOrHideElement(id, shouldShow);
UIUtil.showElement(id);
} else {
UIUtil.hideElement(id);
}
}, },
/** /**
@ -480,11 +476,8 @@ var Recording = {
// Recording spinner // Recording spinner
let spinnerId = 'recordingSpinner'; let spinnerId = 'recordingSpinner';
if(recordingState === Status.RETRYING) { UIUtil.showOrHideElement(
UIUtil.showElement(spinnerId); spinnerId, recordingState === Status.RETRYING);
} else {
UIUtil.hideElement(spinnerId);
}
}, },
// checks whether recording is enabled and whether we have params // checks whether recording is enabled and whether we have params
// to start automatically recording // to start automatically recording

View File

@ -268,11 +268,9 @@ export default {
* @param {boolean} show {true} to show those options, {false} to hide them * @param {boolean} show {true} to show those options, {false} to hide them
*/ */
showFollowMeOptions (show) { showFollowMeOptions (show) {
if (show && UIUtil.isSettingEnabled('moderator')) { UIUtil.showOrHideElement(
UIUtil.showElement("followMeOptions"); "followMeOptions",
} else { show && UIUtil.isSettingEnabled('moderator'));
UIUtil.hideElement("followMeOptions");
}
}, },
/** /**

View File

@ -403,11 +403,7 @@ Toolbar = {
*/ */
showAuthenticateButton (show) { showAuthenticateButton (show) {
let id = 'authenticationContainer'; let id = 'authenticationContainer';
if (show) { UIUtil.showOrHideElement(id, show);
UIUtil.showElement(id);
} else {
UIUtil.hideElement(id);
}
}, },
showEtherpadButton () { showEtherpadButton () {
@ -425,10 +421,8 @@ Toolbar = {
if (shouldShow) { if (shouldShow) {
let el = document.getElementById(id); let el = document.getElementById(id);
UIUtil.setTooltip(el, 'toolbar.sharedvideo', 'right'); UIUtil.setTooltip(el, 'toolbar.sharedvideo', 'right');
UIUtil.showElement(id);
} else {
UIUtil.hideElement(id);
} }
UIUtil.showOrHideElement(id, shouldShow);
}, },
// checks whether desktop sharing is enabled and whether // checks whether desktop sharing is enabled and whether
@ -446,22 +440,15 @@ Toolbar = {
&& UIUtil.isButtonEnabled('sip') && show; && UIUtil.isButtonEnabled('sip') && show;
let id = 'toolbar_button_sip'; let id = 'toolbar_button_sip';
if (shouldShow) { UIUtil.showOrHideElement(id, shouldShow);
UIUtil.showElement(id);
} else {
UIUtil.hideElement(id);
}
}, },
// Shows or hides the dialpad button // Shows or hides the dialpad button
showDialPadButton (show) { showDialPadButton (show) {
let shouldShow = UIUtil.isButtonEnabled('dialpad') && show; let shouldShow = UIUtil.isButtonEnabled('dialpad') && show;
let id = 'toolbar_button_dialpad'; let id = 'toolbar_button_dialpad';
if (shouldShow) {
UIUtil.showElement(id); UIUtil.showOrHideElement(id, shouldShow);
} else {
UIUtil.hideElement(id);
}
}, },
/** /**
@ -470,13 +457,13 @@ Toolbar = {
*/ */
setAuthenticatedIdentity (authIdentity) { setAuthenticatedIdentity (authIdentity) {
let id = 'toolbar_auth_identity'; let id = 'toolbar_auth_identity';
if(authIdentity) { if(authIdentity) {
UIUtil.showElement(id);
$(`#${id}`).text(authIdentity); $(`#${id}`).text(authIdentity);
} else { } else {
UIUtil.hideElement(id);
$(`#${id}`).text(''); $(`#${id}`).text('');
} }
UIUtil.showOrHideElement(id, !!authIdentity);
}, },
/** /**
@ -485,11 +472,8 @@ Toolbar = {
*/ */
showLoginButton (show) { showLoginButton (show) {
let id = 'toolbar_button_login'; let id = 'toolbar_button_login';
if (show) {
UIUtil.showElement(id); UIUtil.showOrHideElement(id, show);
} else {
UIUtil.hideElement(id);
}
}, },
/** /**
@ -498,11 +482,8 @@ Toolbar = {
*/ */
showLogoutButton (show) { showLogoutButton (show) {
let id = 'toolbar_button_logout'; let id = 'toolbar_button_logout';
if (show) {
UIUtil.showElement(id); UIUtil.showOrHideElement(id, show);
} else {
UIUtil.hideElement(id);
}
}, },
/** /**

View File

@ -265,6 +265,21 @@ const IndicatorFontSizes = {
element.classList.add(className); element.classList.add(className);
}, },
/**
* Shows or hides the element given (optionally by id).
*
* @param {string|HTMLElement} idOrElement the identifier or the element
* to show/hide
* @param {boolean} show <tt>true</tt> to show or <tt>false</tt> to hide
*/
showOrHideElement(idOrElement, show) {
if (show) {
this.showElement(idOrElement);
} else {
this.hideElement(idOrElement);
}
},
/** /**
* Hides the element given by id. * Hides the element given by id.
* *

View File

@ -333,13 +333,13 @@ export default class LargeVideoManager {
} }
let id = 'localConnectionMessage'; let id = 'localConnectionMessage';
UIUtil.showOrHideElement(id, show);
if (show) { if (show) {
UIUtil.showElement(id);
// Avatar message conflicts with 'videoConnectionMessage', // Avatar message conflicts with 'videoConnectionMessage',
// so it must be hidden // so it must be hidden
this.showRemoteConnectionMessage(false); this.showRemoteConnectionMessage(false);
} else {
UIUtil.hideElement(id);
} }
} }

View File

@ -215,13 +215,10 @@ SmallVideo.prototype.hideIndicator = function () {
* @param {boolean} isMuted indicates if the muted element should be shown * @param {boolean} isMuted indicates if the muted element should be shown
* or hidden * or hidden
*/ */
SmallVideo.prototype.showAudioIndicator = function(isMuted) { SmallVideo.prototype.showAudioIndicator = function (isMuted) {
let mutedIndicator = this.getAudioMutedIndicator(); let mutedIndicator = this.getAudioMutedIndicator();
if (isMuted) {
UIUtil.showElement(mutedIndicator); UIUtil.showOrHideElement(mutedIndicator, isMuted);
} else {
UIUtil.hideElement(mutedIndicator);
}
this.isAudioMuted = isMuted; this.isAudioMuted = isMuted;
}; };
@ -270,11 +267,8 @@ SmallVideo.prototype.setVideoMutedView = function(isMuted) {
this.updateView(); this.updateView();
let element = this.getVideoMutedIndicator(); let element = this.getVideoMutedIndicator();
if (isMuted) {
UIUtil.showElement(element); UIUtil.showOrHideElement(element, isMuted);
} else {
UIUtil.hideElement(element);
}
}; };
/** /**
@ -576,11 +570,7 @@ SmallVideo.prototype.showDominantSpeakerIndicator = function (show) {
tooltip: 'speaker' tooltip: 'speaker'
}); });
if (show) { UIUtil.showOrHideElement(indicatorSpan, show);
UIUtil.showElement(indicatorSpan);
} else {
UIUtil.hideElement(indicatorSpan);
}
}; };
/** /**
@ -604,11 +594,7 @@ SmallVideo.prototype.showRaisedHandIndicator = function (show) {
tooltip: 'raisedHand' tooltip: 'raisedHand'
}); });
if (show) { UIUtil.showOrHideElement(indicatorSpan, show);
UIUtil.showElement(indicatorSpan);
} else {
UIUtil.hideElement(indicatorSpan);
}
}; };
/** /**

View File

@ -1144,11 +1144,7 @@ var VideoLayout = {
updateResolutionLabel(isResolutionHD) { updateResolutionLabel(isResolutionHD) {
let id = 'videoResolutionLabel'; let id = 'videoResolutionLabel';
if (isResolutionHD) { UIUtil.showOrHideElement(id, isResolutionHD);
UIUtil.showElement(id);
} else {
UIUtil.hideElement(id);
}
}, },
/** /**