Select the password when you click the generated password label
authorRobert Sesek <rsesek@google.com>
Sat, 9 Jun 2012 21:24:48 +0000 (17:24 -0400)
committerRobert Sesek <rsesek@google.com>
Sat, 9 Jun 2012 21:24:48 +0000 (17:24 -0400)
core.js

diff --git a/core.js b/core.js
index 54a8f8a9e3f3462d2bb19120884f1b2279b1a9ff..78937c6b0d0485342c645da27b30d22e0688307a 100644 (file)
--- a/core.js
+++ b/core.js
@@ -68,6 +68,8 @@ SkeletonKey.prototype.MIN_LENGTH = 6;
  */
 SkeletonKey.prototype._init = function() {
   this._generateButton.onclick = this._onGenerate.bind(this);
+
+  this._password.labels[0].onclick = this._selectPassword.bind(this);
 };
 
 /**
@@ -84,8 +86,7 @@ SkeletonKey.prototype._onGenerate = function(e) {
   var hexString = key.toString();
   hexString = this._capitalizeKey(hexString);
   this._password.value = hexString;
-  this._password.focus();
-  this._password.select();
+  this._selectPassword();
 };
 
 /**
@@ -131,3 +132,12 @@ SkeletonKey.prototype._capitalizeKey = function(key) {
 
   return newKey;
 };
+
+/**
+ * Selects the contents of the generated password.
+ * @private
+ */
+SkeletonKey.prototype._selectPassword = function() {
+  this._password.focus();
+  this._password.select();
+};