1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

split out parental controls into a separate edit page

This commit is contained in:
Luke Pulverenti 2013-12-26 10:40:38 -05:00
parent c8cd49ffe7
commit c27d378e34
13 changed files with 234 additions and 123 deletions

View file

@ -487,7 +487,7 @@ var Dashboard = {
html += '<img style="max-height:125px;max-width:200px;" src="' + imageUrl + '" />';
html += '</p>';
html += '<p><a data-mini="true" data-role="button" href="edituser.html?userId=' + user.Id + '" data-icon="user">View Profile</button></a>';
html += '<p><a data-mini="true" data-role="button" href="useredit.html?userId=' + user.Id + '" data-icon="user">View Profile</button></a>';
html += '<p><button data-mini="true" type="button" onclick="Dashboard.logout();" data-icon="lock">Sign Out</button></p>';
html += '</div>';

View file

@ -1,52 +1,12 @@
(function ($, window, document) {
function populateRatings(allParentalRatings, page) {
var html = "";
html += "<option value=''></option>";
var ratings = [];
var i, length, rating;
for (i = 0, length = allParentalRatings.length; i < length; i++) {
rating = allParentalRatings[i];
if (ratings.length) {
var lastRating = ratings[ratings.length - 1];
if (lastRating.Value === rating.Value) {
lastRating.Name += "/" + rating.Name;
continue;
}
}
ratings.push({ Name: rating.Name, Value: rating.Value });
}
for (i = 0, length = ratings.length; i < length; i++) {
rating = ratings[i];
html += "<option value='" + rating.Value + "'>" + rating.Name + "</option>";
}
$('#selectMaxParentalRating', page).html(html).selectmenu("refresh");
}
function loadUser(page, user, loggedInUser, parentalRatingsPromise) {
function loadUser(page, user, loggedInUser) {
if (!loggedInUser.Configuration.IsAdministrator) {
$('#parentalControlDiv', page).hide();
$('#fldIsAdmin', page).hide();
$('#fldEnableRemoteControlOtherUsers', page).hide();
$('#accessControlDiv', page).hide();
} else {
$('#parentalControlDiv', page).show();
$('#accessControlDiv', page).show();
$('#fldIsAdmin', page).show();
$('#fldEnableRemoteControlOtherUsers', page).show();
@ -56,27 +16,6 @@
$('#txtUserName', page).val(user.Name);
parentalRatingsPromise.done(function (allParentalRatings) {
populateRatings(allParentalRatings, page);
var ratingValue = "";
if (user.Configuration.MaxParentalRating) {
for (var i = 0, length = allParentalRatings.length; i < length; i++) {
var rating = allParentalRatings[i];
if (user.Configuration.MaxParentalRating >= rating.Value) {
ratingValue = rating.Value;
}
}
}
$('#selectMaxParentalRating', page).val(ratingValue).selectmenu("refresh");
});
$('#chkIsAdmin', page).checked(user.Configuration.IsAdministrator || false).checkboxradio("refresh");
$('#chkBlockNotRated', page).checked(user.Configuration.BlockNotRated || false).checkboxradio("refresh");
@ -105,7 +44,6 @@
function saveUser(user, page) {
user.Name = $('#txtUserName', page).val();
user.Configuration.MaxParentalRating = $('#selectMaxParentalRating', page).val() || null;
user.Configuration.IsAdministrator = $('#chkIsAdmin', page).checked();
@ -172,9 +110,9 @@
Dashboard.getCurrentUser().done(function (loggedInUser) {
if (loggedInUser.Configuration.IsAdministrator) {
$('.lnkMediaLibrary', page).show().prev().removeClass('ui-last-child');
$('#lnkParentalControl', page).show();
} else {
$('.lnkMediaLibrary', page).hide().prev().addClass('ui-last-child');
$('#lnkParentalControl', page).hide();
}
});
@ -204,15 +142,13 @@
var promise2 = Dashboard.getCurrentUser();
var parentalRatingsPromise = ApiClient.getParentalRatings();
$.when(promise1, promise2).done(function (response1, response2) {
loadUser(page, response1[0] || response1, response2[0], parentalRatingsPromise);
loadUser(page, response1[0] || response1, response2[0]);
});
$("#editUserProfileForm input:first").focus();
$("form input:first", page).focus();
});
})(jQuery, window, document);

View file

@ -185,9 +185,9 @@
Dashboard.getCurrentUser().done(function (loggedInUser) {
if (loggedInUser.Configuration.IsAdministrator) {
$('.lnkMediaLibrary', page).show().prev().removeClass('ui-last-child');
$('#lnkParentalControl', page).show();
} else {
$('.lnkMediaLibrary', page).hide().prev().addClass('ui-last-child');
$('#lnkParentalControl', page).hide();
}
});

View file

@ -0,0 +1,144 @@
(function ($, window, document) {
function populateRatings(allParentalRatings, page) {
var html = "";
html += "<option value=''></option>";
var ratings = [];
var i, length, rating;
for (i = 0, length = allParentalRatings.length; i < length; i++) {
rating = allParentalRatings[i];
if (ratings.length) {
var lastRating = ratings[ratings.length - 1];
if (lastRating.Value === rating.Value) {
lastRating.Name += "/" + rating.Name;
continue;
}
}
ratings.push({ Name: rating.Name, Value: rating.Value });
}
for (i = 0, length = ratings.length; i < length; i++) {
rating = ratings[i];
html += "<option value='" + rating.Value + "'>" + rating.Name + "</option>";
}
$('#selectMaxParentalRating', page).html(html).selectmenu("refresh");
}
function loadUser(page, user, loggedInUser, allParentalRatings) {
Dashboard.setPageTitle(user.Name);
populateRatings(allParentalRatings, page);
var ratingValue = "";
if (user.Configuration.MaxParentalRating) {
for (var i = 0, length = allParentalRatings.length; i < length; i++) {
var rating = allParentalRatings[i];
if (user.Configuration.MaxParentalRating >= rating.Value) {
ratingValue = rating.Value;
}
}
}
$('#selectMaxParentalRating', page).val(ratingValue).selectmenu("refresh");
$('#chkBlockNotRated', page).checked(user.Configuration.BlockNotRated || false).checkboxradio("refresh");
Dashboard.hideLoadingMsg();
}
function onSaveComplete(page) {
Dashboard.hideLoadingMsg();
Dashboard.validateCurrentUser(page);
Dashboard.alert("Settings saved.");
}
function saveUser(user, page) {
user.Configuration.MaxParentalRating = $('#selectMaxParentalRating', page).val() || null;
user.Configuration.BlockNotRated = $('#chkBlockNotRated', page).checked();
ApiClient.updateUser(user).done(function () {
onSaveComplete(page);
});
}
window.UserParentalControlPage = {
onSubmit: function () {
var page = $(this).parents('.page');
Dashboard.showLoadingMsg();
var userId = getParameterByName("userId");
ApiClient.getUser(userId).done(function (result) {
saveUser(result, page);
});
// Disable default form submission
return false;
}
};
$(document).on('pageshow', "#userParentalControlPage", function () {
var page = this;
Dashboard.showLoadingMsg();
var userId = getParameterByName("userId");
var promise1;
if (!userId) {
var deferred = $.Deferred();
deferred.resolveWith(null, [{
Configuration: {}
}]);
promise1 = deferred.promise();
} else {
promise1 = ApiClient.getUser(userId);
}
var promise2 = Dashboard.getCurrentUser();
var promise3 = ApiClient.getParentalRatings();
$.when(promise1, promise2, promise3).done(function (response1, response2, response3) {
loadUser(page, response1[0] || response1, response2[0], response3[0]);
});
$("form input:first", page).focus();
});
})(jQuery, window, document);

View file

@ -101,9 +101,9 @@
Dashboard.getCurrentUser().done(function (loggedInUser) {
if (loggedInUser.Configuration.IsAdministrator) {
$('.lnkMediaLibrary', page).show().prev().removeClass('ui-last-child');
$('#lnkParentalControl', page).show();
} else {
$('.lnkMediaLibrary', page).hide().prev().addClass('ui-last-child');
$('#lnkParentalControl', page).hide();
}
});

View file

@ -22,7 +22,7 @@
html += "<li>";
html += "<a href='edituser.html?userId=" + user.Id + "'>";
html += "<a href='useredit.html?userId=" + user.Id + "'>";
if (user.PrimaryImageTag) {

View file

@ -91,20 +91,12 @@
var page = this;
var userId = getParameterByName("userId");
if (userId) {
$('#userProfileNavigation', page).show();
} else {
$('#userProfileNavigation', page).hide();
}
Dashboard.getCurrentUser().done(function (loggedInUser) {
if (loggedInUser.Configuration.IsAdministrator) {
$('.lnkMediaLibrary', page).show().prev().removeClass('ui-last-child');
$('#lnkParentalControl', page).show();
} else {
$('.lnkMediaLibrary', page).hide().prev().addClass('ui-last-child');
$('#lnkParentalControl', page).hide();
}
});