[open-ils-commits] r16175 - in branches/rel_1_6/Open-ILS/web: js/dojo/openils/opac/nls opac/skin/default/js opac/skin/default/xml/common (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Apr 8 15:26:44 EDT 2010
Author: dbs
Date: 2010-04-08 15:26:39 -0400 (Thu, 08 Apr 2010)
New Revision: 16175
Added:
branches/rel_1_6/Open-ILS/web/opac/skin/default/js/password_reset.js
Modified:
branches/rel_1_6/Open-ILS/web/js/dojo/openils/opac/nls/opac.js
branches/rel_1_6/Open-ILS/web/opac/skin/default/xml/common/login.xml
Log:
Stab wildly at a Dojo dialogue supporting basic password reset requests. With i18n, natch.
Modified: branches/rel_1_6/Open-ILS/web/js/dojo/openils/opac/nls/opac.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/js/dojo/openils/opac/nls/opac.js 2010-04-08 16:45:44 UTC (rev 16174)
+++ branches/rel_1_6/Open-ILS/web/js/dojo/openils/opac/nls/opac.js 2010-04-08 19:26:39 UTC (rev 16175)
@@ -1,4 +1,16 @@
{
+ "BARCODE_PROMPT": "Barcode: ",
+ "USERNAME_PROMPT": "User name: ",
+ "CANCEL_BUTTON_LABEL": "Cancel",
+ "SUBMIT_BUTTON_LABEL": "Submit",
+ "OK": "OK",
+ "PWD_RESET_RESPONSE_TITLE": "Password reset response",
+ "PWD_RESET_SUBMIT_SUCCESS": "Your request to begin the password reset process has been processed. If your account has a valid email address, you should soon receive an email containing further instructions for resetting your password.",
+ "PWD_RESET_SUBMIT_ERROR": "The system could not process your request for a password reset. Please try again, or contact circulation staff for assistance.",
+ "PWD_RESET_SUBMIT_STATUS": "Sending request...",
+ "PWD_RESET_FORGOT_PROMPT": "Forgot your password?",
+ "PWD_RESET_FORM_TITLE": "Request password reset",
+ "PWD_RESET_SUBMIT_PROMPT": "To begin the password reset process, enter either your barcode or user name in the following pwResetForm and click 'Submit'",
"CREATE_MFHD": "Add MFHD Record",
"CREATED_MFHD_RECORD": "Created MFHD record for ${0}",
"DELETE_MFHD": "Delete Record",
Added: branches/rel_1_6/Open-ILS/web/opac/skin/default/js/password_reset.js
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/skin/default/js/password_reset.js (rev 0)
+++ branches/rel_1_6/Open-ILS/web/opac/skin/default/js/password_reset.js 2010-04-08 19:26:39 UTC (rev 16175)
@@ -0,0 +1,104 @@
+dojo.require('dojo.parser');
+dojo.require('dijit.Dialog');
+dojo.require('dijit.form.Button');
+dojo.require('dijit.form.TextBox');
+
+dojo.requireLocalization("openils.opac", "opac");
+opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
+
+dojo.addOnLoad(function() {
+
+ // Create the password reset dialog
+ var pwResetFormDlg = createResetDialog();
+ dojo.parser.parse();
+
+ // Connect the buttons to submit / cancel events that override
+ // the default actions associated with the buttons to do
+ // pleasing Ajax things
+ dojo.connect(dijit.byId("cancelButton"), "onClick", function(event) {
+ event.preventDefault();
+ event.stopPropagation();
+ pwResetFormDlg.hide();
+ });
+ dojo.connect(dijit.byId("submitButton"), "onClick", function(event) {
+ event.preventDefault();
+ event.stopPropagation();
+ var xhrArgs = {
+ form: dojo.byId("requestReset"),
+ handleAs: "text",
+ load: function(data) {
+ pwResetFormDlg.hide();
+ passwordSubmission(opac_strings.PWD_RESET_SUBMIT_SUCCESS);
+ },
+ error: function(error) {
+ pwResetFormDlg.hide();
+ passwordSubmission(opac_strings.PWD_RESET_SUBMIT_ERROR);
+ }
+ }
+ var deferred = dojo.xhrPost(xhrArgs);
+ pwResetFormDlg.attr("content", opac_strings.PWD_RESET_SUBMIT_STATUS);
+ });
+ dojo.place("<tr><td colspan='2' align='center'><a class='classic_link' id='pwResetLink' onClick='dijit.byId(\"pwResetFormDlg\").show();'</a></td></tr>", "login_table_body");
+ dojo.query("#pwResetLink").attr("innerHTML", opac_strings.PWD_RESET_FORGOT_PROMPT);
+
+});
+
+function passwordSubmission( msg ) {
+ var responseDialog = new dijit.Dialog({
+ title: opac_strings.PWD_RESET_RESPONSE_TITLE
+ });
+ responseDialog.startup();
+ var requestStatusDiv = dojo.create("div", { style: "width: 30em" });
+ var requestStatusMsg = dojo.create("div", { innerHTML: msg }, requestStatusDiv);
+ var okButton = new dijit.form.Button({
+ id: "okButton",
+ type: "submit",
+ label: opac_strings.OK
+ }).placeAt(requestStatusDiv);
+ responseDialog.attr("content", requestStatusDiv);
+ responseDialog.show();
+ dojo.connect(dijit.byId("okButton"), "onClick", responseDialog, "hide");
+}
+
+function createResetDialog() {
+ var pwResetFormDlg = new dijit.Dialog({
+ id: "pwResetFormDlg",
+ title: opac_strings.PWD_RESET_FORM_TITLE
+ });
+ pwResetFormDlg.startup();
+
+ // Instantiate the form
+ var pwResetFormDiv = dojo.create("form", { id: "requestReset", style: "width: 30em", method: "post", action: "/opac/password/en-US" });
+ dojo.create("p", { innerHTML: opac_strings.PWD_RESET_SUBMIT_PROMPT }, pwResetFormDiv);
+ var pwResetFormTable = dojo.create("table", null, pwResetFormDiv);
+ var pwResetFormRow = dojo.create("tr", null, pwResetFormTable);
+ var pwResetFormCell = dojo.create("td", null, pwResetFormRow);
+ var pwResetFormLabel = dojo.create("label", null, pwResetFormCell);
+ dojo.attr(formCell, { innerHTML: opac_strings.BARCODE_PROMPT });
+ pwResetFormCell = dojo.create("td", null, pwResetFormRow);
+ var barcodeText = new dijit.form.TextBox({
+ name: "barcode"
+ }).placeAt(formCell);
+ pwResetFormRow = dojo.create("tr", {}, pwResetFormTable);
+ pwResetFormCell = dojo.create("td", {}, pwResetFormRow);
+ dojo.attr(formCell, { innerHTML: opac_strings.USERNAME_PROMPT });
+ pwResetFormCell = dojo.create("td", {}, pwResetFormRow);
+ var usernameText = new dijit.form.TextBox({
+ name: "username"
+ }).placeAt(formCell);
+ var submitButton = new dijit.form.Button({
+ id: "submitButton",
+ type: "submit",
+ label: opac_strings.SUBMIT_BUTTON_LABEL
+ }).placeAt(formDiv);
+ var cancelButton = new dijit.form.Button({
+ id: "cancelButton",
+ type: "cancel",
+ label: opac_strings.CANCEL_BUTTON_LABEL
+ }).placeAt(formDiv);
+
+ // Set the content of the Dialog to the pwResetForm
+ pwResetFormDlg.attr("content", pwResetFormDiv);
+ return pwResetFormDlg;
+}
+
Modified: branches/rel_1_6/Open-ILS/web/opac/skin/default/xml/common/login.xml
===================================================================
--- branches/rel_1_6/Open-ILS/web/opac/skin/default/xml/common/login.xml 2010-04-08 16:45:44 UTC (rev 16174)
+++ branches/rel_1_6/Open-ILS/web/opac/skin/default/xml/common/login.xml 2010-04-08 19:26:39 UTC (rev 16175)
@@ -11,6 +11,7 @@
config.ids.login.cancel = "login_cancel_button";
config.ids.altcanvas.login = config.ids.login.box;
</script>
+ <script type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/password-reset.js'></script>
<br/>
@@ -21,7 +22,7 @@
<br/>
<table id='login_table' class='data_grid' style='margin-left: 20px;' width='95%'>
- <tbody>
+ <tbody id='login_tbody'>
<tr>
<td><span class='login_text'>&login.username;</span></td>
<td>
More information about the open-ils-commits
mailing list