handling the visibility toggle event

This commit is contained in:
Faye Li 2017-02-01 14:22:13 -08:00
parent 6d55b3c82d
commit 3c3ff908b4
2 changed files with 24 additions and 4 deletions

View file

@ -261,17 +261,17 @@
<span class="glyphicon glyphicon-menu-down"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="visibility-toggle">
<li>
<li class="visibility-option" data-visibility="all">
<h6>Online</h6>
<p>You will be shown online to everyone else. Anybody will be able to find you from the users online list and jump to your current location.</p>
</li>
<li role="separator" class="divider"></li>
<li>
<li class="visibility-option" data-visibility="friends">
<h6>Available to Friends Only</h6>
<p>You will be shown online only to users you have added as friends. Other users may still interact with you in the same domain, but they won't be able to find you from the users online list.</p>
</li>
<li role="separator" class="divider"></li>
<li>
<li class="visibility-option" data-visibility="none">
<h6>Appear Offline</h6>
<p>No one will be able to find you from the users online list. However, this does not prevent other users in the same domain from interacting with you. For a complete "Do not disturb" mode, you may want to your own private domain and set allow entering to no one.</p>
</li>
@ -385,7 +385,7 @@
myVisibility = event.data.visibility;
$("#dev-div").append("<p>myUsername is " + myUsername + "</p>");
$("#dev-div").append("<p>myVisibility is " + myVisibility + "</p>");
//$("#visibility-toggle").prop("value", myVisibility);
$("#visibility-toggle").html(myVisibility + "<span class='glyphicon glyphicon-menu-down'></span>")
}
}
@ -426,6 +426,19 @@
EventBridge.emitWebEvent(JSON.stringify(jumpToObject));
});
// Click listener for toggling who can see me
$(".visibility-option").click(function() {
var newButtonText = $(this).find("h6").text();
$("#visibility-toggle").html(newButtonText + "<span class='glyphicon glyphicon-menu-down'></span>");
var visibilityObject = {
"type": "toggle-visibility",
"data": {
"visibility": $(this).data("visibility")
}
}
EventBridge.emitWebEvent(JSON.stringify(visibilityObject));
});
// Listen for events from hifi
EventBridge.scriptEventReceived.connect(onScriptEventReceived);

View file

@ -77,6 +77,13 @@
location.goToUser(event.data.username);
}
}
if (event.type === "toggle-visibility") {
if (typeof event.data.visibility !== undefined) {
// update your visibility (all, friends, or none)
myVisibility = event.data.visibility;
GlobalServices.findableBy = myVisibility;
}
}
}
button.clicked.connect(onClicked);