Browse Source

New modal for password.getDialog

Tobias Reich 9 years ago
parent
commit
42b4d60b13
1 changed files with 33 additions and 9 deletions
  1. 33 9
      src/scripts/password.js

+ 33 - 9
src/scripts/password.js

@@ -11,7 +11,7 @@ password = {
 
 password.get = function(albumID, callback) {
 
-	var passwd = $('.message input.text').val(),
+	var passwd = $('.basicModal input.text').val(),
 		params;
 
 	if (!lychee.publicMode)												callback();
@@ -35,11 +35,11 @@ password.get = function(albumID, callback) {
 		lychee.api(params, function(data) {
 
 			if (data===true) {
+				basicModal.close();
 				password.value = md5(passwd);
 				callback();
 			} else {
-				lychee.goto('');
-				loadingBar.show('error', 'Access denied. Wrong password!');
+				basicModal.error('password');
 			}
 
 		});
@@ -50,12 +50,36 @@ password.get = function(albumID, callback) {
 
 password.getDialog = function(albumID, callback) {
 
-	var buttons;
+	var action,
+		cancel,
+		msg = '';
 
-	buttons = [
-		['Enter', function() { password.get(albumID, callback) }],
-		['Cancel', lychee.goto]
-	];
-	modal.show("<a class='icon-lock'></a> Enter Password", "This album is protected by a password. Enter the password below to view the photos of this album: <input class='text' type='password' placeholder='password' value=''>", buttons, -110, false);
+	action = function() { password.get(albumID, callback) }
+
+	cancel = function() {
+		basicModal.close();
+		lychee.goto();
+	}
+
+	msg =	`
+			<p>
+				This album is protected by a password. Enter the password below to view the photos of this album:
+				<input data-name='password' class='text' type='password' placeholder='password' value=''>
+			</p>
+			`
+
+	basicModal.show({
+		body: msg,
+		buttons: {
+			action: {
+				title: 'Enter',
+				fn: action
+			},
+			cancel: {
+				title: 'Cancel',
+				fn: cancel
+			}
+		}
+	});
 
 }