update password page to new js format

This commit is contained in:
Luke Pulverenti 2013-04-18 15:09:07 -04:00
parent 9e3190a060
commit 05a6467c35
5 changed files with 97 additions and 54 deletions

View File

@ -12,7 +12,7 @@
<a href="#" data-role="button" class="ui-btn-active">Profile</a>
<a href="#" data-role="button" onclick="Dashboard.navigate('userimage.html', true);">Image</a>
<a href="#" data-role="button" onclick="Dashboard.navigate('updatepassword.html', true);">Password</a>
<a class="lnkMediaLibrary" style="display:none;" href="#" data-role="button" onclick="Dashboard.navigate('library.html', true);">Media Library</a>
<a href="#" data-role="button" onclick="Dashboard.navigate('library.html', true);" class="lnkMediaLibrary" style="display:none;">Media Library</a>
</div>
<form id="editUserProfileForm">
<ul data-role="listview" class="ulForm">

View File

@ -34,10 +34,6 @@
function loadUser(page, user, loggedInUser, parentalRatingsPromise, allCulturesPromise) {
if (loggedInUser.Configuration.IsAdministrator) {
$('.lnkMediaLibrary', page).show();
}
if (!loggedInUser.Configuration.IsAdministrator || user.Id == loggedInUser.Id) {
$('#fldIsAdmin', page).hide();
@ -155,12 +151,10 @@
window.EditUserPage = new editUserPage();
$(document).on('pageshow', "#editUserPage", function () {
$(document).on('pagebeforeshow', "#editUserPage", function () {
var page = this;
Dashboard.showLoadingMsg();
var userId = getParameterByName("userId");
if (userId) {
@ -169,6 +163,23 @@
$('#userProfileNavigation', page).hide();
}
Dashboard.getCurrentUser().done(function (loggedInUser) {
if (loggedInUser.Configuration.IsAdministrator) {
$('.lnkMediaLibrary', page).show().prev().removeClass('ui-last-child');
} else {
$('.lnkMediaLibrary', page).hide().prev().addClass('ui-last-child');
}
});
}).on('pageshow', "#editUserPage", function () {
var page = this;
Dashboard.showLoadingMsg();
var userId = getParameterByName("userId");
var promise1;
if (!userId) {
@ -188,7 +199,7 @@
var promise2 = Dashboard.getCurrentUser();
var parentalRatingsPromise = ApiClient.getParentalRatings();
var allCulturesPromise = ApiClient.getCultures();
$.when(promise1, promise2).done(function (response1, response2) {

View File

@ -1,11 +1,6 @@
var UpdatePasswordPage = {
(function ($, document, window) {
onPageShow: function () {
UpdatePasswordPage.loadUser();
},
loadUser: function() {
var page = $.mobile.activePage;
function loadUser(page) {
var userid = getParameterByName("userId");
@ -28,65 +23,96 @@
$('#txtCurrentPassword', page).val('');
$('#txtNewPassword', page).val('');
$('#txtNewPasswordConfirm', page).val('');
},
}
save: function () {
function save(page) {
var userId = getParameterByName("userId");
var page = $($.mobile.activePage);
var currentPassword = $('#txtCurrentPassword', page).val();
var newPassword = $('#txtNewPassword', page).val();
ApiClient.updateUserPassword(userId, currentPassword, newPassword).done(UpdatePasswordPage.saveComplete);
},
ApiClient.updateUserPassword(userId, currentPassword, newPassword).done(function () {
saveComplete: function () {
Dashboard.hideLoadingMsg();
Dashboard.hideLoadingMsg();
Dashboard.alert("Password saved.");
loadUser(page);
Dashboard.alert("Password saved.");
UpdatePasswordPage.loadUser();
},
});
resetPassword: function () {
}
var msg = "Are you sure you wish to reset the password?";
function updatePasswordPage() {
Dashboard.confirm(msg, "Password Reset", function (result) {
var self = this;
if (result) {
var userId = getParameterByName("userId");
self.onSubmit = function () {
Dashboard.showLoadingMsg();
var page = $.mobile.activePage;
ApiClient.resetUserPassword(userId).done(function () {
if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) {
Dashboard.hideLoadingMsg();
Dashboard.alert("The password has been reset.");
UpdatePasswordPage.loadUser();
Dashboard.showError("Password and password confirmation must match.");
return false;
}
});
Dashboard.showLoadingMsg();
save(page);
// Disable default form submission
return false;
};
self.resetPassword = function () {
var msg = "Are you sure you wish to reset the password?";
var page = $.mobile.activePage;
Dashboard.confirm(msg, "Password Reset", function (result) {
if (result) {
var userId = getParameterByName("userId");
Dashboard.showLoadingMsg();
ApiClient.resetUserPassword(userId).done(function () {
Dashboard.hideLoadingMsg();
Dashboard.alert("The password has been reset.");
loadUser(page);
});
}
});
};
}
window.UpdatePasswordPage = new updatePasswordPage();
$(document).on('pagebeforeshow', "#updatePasswordPage", function () {
var page = this;
Dashboard.getCurrentUser().done(function (loggedInUser) {
if (loggedInUser.Configuration.IsAdministrator) {
$('.lnkMediaLibrary', page).show().prev().removeClass('ui-last-child');
} else {
$('.lnkMediaLibrary', page).hide().prev().addClass('ui-last-child');
}
});
},
onSubmit: function () {
var page = $($.mobile.activePage);
}).on('pageshow', "#updatePasswordPage", function () {
if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) {
var page = this;
Dashboard.showError("Password and password confirmation must match.");
return false;
}
loadUser(page);
Dashboard.showLoadingMsg();
});
UpdatePasswordPage.save();
// Disable default form submission
return false;
}
};
$(document).on('pageshow', "#updatePasswordPage", UpdatePasswordPage.onPageShow);
})(jQuery, document, window);

View File

@ -21,6 +21,12 @@
var page = $($.mobile.activePage);
if (user.Configuration.IsAdministrator) {
$('.lnkMediaLibrary', page).show();
} else {
$('.lnkMediaLibrary', page).hide();
}
$('#uploadUserImage', page).val('').trigger('change');
Dashboard.setPageTitle(user.Name);

View File

@ -12,7 +12,7 @@
<a href="#" onclick="Dashboard.navigate('edituser.html', true);" data-role="button">Profile</a>
<a href="#" data-role="button" onclick="Dashboard.navigate('userimage.html', true);">Image</a>
<a href="#" data-role="button" class="ui-btn-active">Password</a>
<a href="#" data-role="button" onclick="Dashboard.navigate('library.html', true);">Media Library</a>
<a href="#" data-role="button" class="lnkMediaLibrary" style="display:none;" onclick="Dashboard.navigate('library.html', true);">Media Library</a>
</div>
<h3 style="display: none;">Create Password</h3>
<form id="updatePasswordForm">