room block enhancements (#1203)

* highlight current room block

* fix duplicated ids

* remove inline js

* remove some trailing whitespaces

* Fixed Server Rooms room settings name

Co-authored-by: farhatahmad <ahmad.af.farhat@gmail.com>
Co-authored-by: Jesus Federico <jesus@123it.ca>
This commit is contained in:
Klaus
2020-04-16 17:21:57 +02:00
committed by GitHub
parent 21cb768fc4
commit e7e0c7624c
8 changed files with 47 additions and 28 deletions

View File

@ -19,6 +19,10 @@ $(document).on('turbolinks:load', function(){
var controller = $("body").data('controller');
var action = $("body").data('action');
// highlight current room
$('.room-block').removeClass('current');
$('a[href="' + window.location.pathname + '"] .room-block').addClass('current');
// Only run on room pages.
if (controller == "rooms" && action == "show"){
var copy = $('#copy');
@ -57,7 +61,7 @@ $(document).on('turbolinks:load', function(){
$('#create-room-name').focus()
}
})
if (controller == "rooms" && action == "show" || controller == "admins" && action == "server_rooms"){
// Display and update all fields related to creating a room in the createRoomModal
$(".update-room").click(function(){
@ -120,13 +124,13 @@ $(document).on('turbolinks:load', function(){
let listItem = document.createElement("li")
listItem.setAttribute('class', 'list-group-item text-left not-saved add-access');
listItem.setAttribute("data-uid", uid)
let spanItem = "<span class='avatar float-left mr-2'>" + option.text().charAt(0) + "</span> <span class='shared-user'>" +
option.text() + " <span class='text-muted'>" + option.data("subtext") + "</span></span>" +
option.text() + " <span class='text-muted'>" + option.data("subtext") + "</span></span>" +
"<span class='text-primary float-right shared-user cursor-pointer' onclick='removeSharedUser(this)'><i class='fas fa-times'></i></span>"
listItem.innerHTML = spanItem
$("#user-list").append(listItem)
}
})
@ -160,9 +164,9 @@ function showCreateRoom(target) {
function showUpdateRoom(target) {
var modal = $(target)
var update_path = modal.closest("#room-block").data("path")
var update_path = modal.closest(".room-block").data("path")
var settings_path = modal.data("settings-path")
$("#create-room-name").val(modal.closest("#room-block").find("#room-name-text").text().trim())
$("#create-room-name").val(modal.closest(".room-block").find(".room-name-text").text().trim())
$("#createRoomModal form").attr("action", update_path)
//show all elements & their children with a update-only class
@ -178,8 +182,8 @@ function showUpdateRoom(target) {
})
updateCurrentSettings(settings_path)
var accessCode = modal.closest("#room-block").data("room-access-code")
var accessCode = modal.closest(".room-block").data("room-access-code")
if(accessCode){
$("#create-room-access-code").text(getLocalizedString("modal.create_room.access_code") + ": " + accessCode)
@ -199,7 +203,7 @@ function showDeleteRoom(target) {
function updateCurrentSettings(settings_path){
// Get current room settings and set checkbox
$.get(settings_path, function(room_settings) {
var settings = JSON.parse(room_settings)
var settings = JSON.parse(room_settings)
$("#room_mute_on_join").prop("checked", settings.muteOnStart)
$("#room_require_moderator_approval").prop("checked", settings.requireModeratorApproval)
$("#room_anyone_can_start").prop("checked", settings.anyoneCanStart)
@ -249,7 +253,7 @@ function displaySharedUsers(path) {
user_list_html += "<span class='text-primary float-right shared-user cursor-pointer' onclick='removeSharedUser(this)'><i class='fas fa-times'></i></span>"
user_list_html += "</li>"
})
$("#user-list").html(user_list_html)
});
}