diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 5670afa985..888514a3ed 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -487,7 +487,7 @@ var Dashboard = { html += ''; html += '

'; - html += '

View Profile'; + html += '

View Profile'; html += '

'; html += ''; diff --git a/dashboard-ui/scripts/edituserpage.js b/dashboard-ui/scripts/useredit.js similarity index 65% rename from dashboard-ui/scripts/edituserpage.js rename to dashboard-ui/scripts/useredit.js index be3f1d38e1..98b1bb38c2 100644 --- a/dashboard-ui/scripts/edituserpage.js +++ b/dashboard-ui/scripts/useredit.js @@ -1,52 +1,12 @@ (function ($, window, document) { - function populateRatings(allParentalRatings, page) { - - var html = ""; - - html += ""; - - 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 += ""; - } - - $('#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); \ No newline at end of file diff --git a/dashboard-ui/scripts/userimagepage.js b/dashboard-ui/scripts/userimagepage.js index ee07c82a93..868f164764 100644 --- a/dashboard-ui/scripts/userimagepage.js +++ b/dashboard-ui/scripts/userimagepage.js @@ -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(); } }); diff --git a/dashboard-ui/scripts/userparentalcontrol.js b/dashboard-ui/scripts/userparentalcontrol.js new file mode 100644 index 0000000000..83cc2b209d --- /dev/null +++ b/dashboard-ui/scripts/userparentalcontrol.js @@ -0,0 +1,144 @@ +(function ($, window, document) { + + function populateRatings(allParentalRatings, page) { + + var html = ""; + + html += ""; + + 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 += ""; + } + + $('#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); \ No newline at end of file diff --git a/dashboard-ui/scripts/updatepasswordpage.js b/dashboard-ui/scripts/userpassword.js similarity index 94% rename from dashboard-ui/scripts/updatepasswordpage.js rename to dashboard-ui/scripts/userpassword.js index f654895830..61a1c5a5a4 100644 --- a/dashboard-ui/scripts/updatepasswordpage.js +++ b/dashboard-ui/scripts/userpassword.js @@ -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(); } }); diff --git a/dashboard-ui/scripts/userprofilespage.js b/dashboard-ui/scripts/userprofilespage.js index 5a8dd869ed..7b17cab8a4 100644 --- a/dashboard-ui/scripts/userprofilespage.js +++ b/dashboard-ui/scripts/userprofilespage.js @@ -22,7 +22,7 @@ html += "
  • "; - html += ""; + html += ""; if (user.PrimaryImageTag) { diff --git a/dashboard-ui/scripts/usersettings.js b/dashboard-ui/scripts/usersettings.js index f3140e0981..f9f91ecc51 100644 --- a/dashboard-ui/scripts/usersettings.js +++ b/dashboard-ui/scripts/usersettings.js @@ -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(); } }); diff --git a/dashboard-ui/edituser.html b/dashboard-ui/useredit.html similarity index 58% rename from dashboard-ui/edituser.html rename to dashboard-ui/useredit.html index 8ca68f3dae..554bfd97e1 100644 --- a/dashboard-ui/edituser.html +++ b/dashboard-ui/useredit.html @@ -10,9 +10,10 @@
      @@ -29,33 +30,20 @@
    - -
    +
    + + + + diff --git a/dashboard-ui/updatepassword.html b/dashboard-ui/userpassword.html similarity index 87% rename from dashboard-ui/updatepassword.html rename to dashboard-ui/userpassword.html index 11e18d10c8..fcff11c393 100644 --- a/dashboard-ui/updatepassword.html +++ b/dashboard-ui/userpassword.html @@ -9,10 +9,11 @@
    diff --git a/dashboard-ui/userprofiles.html b/dashboard-ui/userprofiles.html index 0dbdd3064d..44f90960f6 100644 --- a/dashboard-ui/userprofiles.html +++ b/dashboard-ui/userprofiles.html @@ -16,7 +16,7 @@

    -

    diff --git a/dashboard-ui/usersettings.html b/dashboard-ui/usersettings.html index d40c6f2ac6..237895bc18 100644 --- a/dashboard-ui/usersettings.html +++ b/dashboard-ui/usersettings.html @@ -8,11 +8,12 @@