Commit 1a5fc691 authored by jhawkins@chromium.org's avatar jhawkins@chromium.org

DOMUI: Several fixes for AutoFill page.

* Properly enable and disable the Edit and Remove buttons based on select
control state.
* Modify the title of the address/CC overlays when pressing the
'Add address/CC' buttons.
* Remove the ability to select multiple options.

BUG=49094
TEST=none

Review URL: http://codereview.chromium.org/3125039

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57129 0039d316-1c4b-4281-b951-d872f2087c98
parent cfb85cd9
...@@ -47,6 +47,10 @@ void AutoFillOptionsHandler::GetLocalizedValues( ...@@ -47,6 +47,10 @@ void AutoFillOptionsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_AUTOFILL_DELETE_BUTTON)); l10n_util::GetStringUTF16(IDS_AUTOFILL_DELETE_BUTTON));
localized_strings->SetString("helpButton", localized_strings->SetString("helpButton",
l10n_util::GetStringUTF16(IDS_AUTOFILL_HELP_LABEL)); l10n_util::GetStringUTF16(IDS_AUTOFILL_HELP_LABEL));
localized_strings->SetString("addAddressTitle",
l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_ADDRESS_CAPTION));
localized_strings->SetString("addCreditCardTitle",
l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_CREDITCARD_CAPTION));
} }
void AutoFillOptionsHandler::Initialize() { void AutoFillOptionsHandler::Initialize() {
......
<div class="page hidden" id="autoFillEditAddressOverlay"> <div class="page hidden" id="autoFillEditAddressOverlay">
<h1 i18n-content="autoFillEditAddressTitle"></h1> <h1 id="autoFillAddressTitle"></h1>
<div><label id="fullNameLabel"><span i18n-content="fullNameLabel"></span><br> <div><label id="fullNameLabel"><span i18n-content="fullNameLabel"></span><br>
<input type="text" id="fullName"></label></div> <input type="text" id="fullName"></label></div>
......
...@@ -38,6 +38,12 @@ cr.define('options', function() { ...@@ -38,6 +38,12 @@ cr.define('options', function() {
* @private * @private
*/ */
dismissOverlay_: function() { dismissOverlay_: function() {
AutoFillEditAddressOverlay.clearInputFields();
OptionsPage.clearOverlays();
},
};
AutoFillEditAddressOverlay.clearInputFields = function() {
$('fullName').value = ''; $('fullName').value = '';
$('companyName').value = ''; $('companyName').value = '';
$('addrLine1').value = ''; $('addrLine1').value = '';
...@@ -48,9 +54,10 @@ cr.define('options', function() { ...@@ -48,9 +54,10 @@ cr.define('options', function() {
$('phone').value = ''; $('phone').value = '';
$('fax').value = ''; $('fax').value = '';
$('email').value = ''; $('email').value = '';
OptionsPage.clearOverlays(); };
},
AutoFillEditAddressOverlay.setTitle = function(title) {
$('autoFillAddressTitle').textContent = title;
}; };
// Export // Export
......
<div class="page hidden" id="autoFillEditCreditCardOverlay"> <div class="page hidden" id="autoFillEditCreditCardOverlay">
<h1 i18n-content="autoFillEditCreditCardTitle"></h1> <h1 id="autoFillCreditCardTitle"></h1>
<div> <div>
<label id="nameOnCardLabel"> <label id="nameOnCardLabel">
......
...@@ -40,16 +40,7 @@ cr.define('options', function() { ...@@ -40,16 +40,7 @@ cr.define('options', function() {
* @private * @private
*/ */
dismissOverlay_: function() { dismissOverlay_: function() {
$('fullName').value = ''; AutoFillEditCreditCardOverlay.clearInputFields();
$('companyName').value = '';
$('addrLine1').value = '';
$('addrLine2').value = '';
$('city').value = '';
$('state').value = '';
$('zipCode').value = '';
$('phone').value = '';
$('fax').value = '';
$('email').value = '';
OptionsPage.clearOverlays(); OptionsPage.clearOverlays();
}, },
...@@ -96,6 +87,18 @@ cr.define('options', function() { ...@@ -96,6 +87,18 @@ cr.define('options', function() {
} }
}; };
AutoFillEditCreditCardOverlay.clearInputFields = function(title) {
$('nameOnCard').value = '';
$('billingAddress').value = '';
$('creditCardNumber').value = '';
$('expirationMonth').value = '';
$('expirationYear').value = '';
};
AutoFillEditCreditCardOverlay.setTitle = function(title) {
$('autoFillCreditCardTitle').textContent = title;
};
// Export // Export
return { return {
AutoFillEditCreditCardOverlay: AutoFillEditCreditCardOverlay AutoFillEditCreditCardOverlay: AutoFillEditCreditCardOverlay
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<div class="autofill-section" id="profileSelectContainer"> <div class="autofill-section" id="profileSelectContainer">
<div id="profileSelectLeftColumn"> <div id="profileSelectLeftColumn">
<select id="profileList" size="10" multiple> <select id="profileList" size="10">
<option value="addressesHeader" disabled <option value="addressesHeader" disabled
i18n-content="addressesHeader"></option> i18n-content="addressesHeader"></option>
<option value="addressesHorizontalRule" disabled></option> <option value="addressesHorizontalRule" disabled></option>
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
</button></div> </button></div>
<div><button id="addCreditCardButton" i18n-content="addCreditCardButton"> <div><button id="addCreditCardButton" i18n-content="addCreditCardButton">
</button></div> </button></div>
<div><button id="editButton" i18n-content="editButton"></button></div> <div><button id="autoFillEditButton" i18n-content="editButton">
</button></div>
<div><button id="autoFillRemoveButton" i18n-content="deleteButton"> <div><button id="autoFillRemoveButton" i18n-content="deleteButton">
</button></div> </button></div>
</div> </div>
......
...@@ -37,17 +37,17 @@ cr.define('options', function() { ...@@ -37,17 +37,17 @@ cr.define('options', function() {
var self = this; var self = this;
$('profileList').onchange = function(event) { $('profileList').onchange = function(event) {
self.updateRemoveButtonState_(); self.updateButtonState_();
}; };
$('addAddressButton').onclick = function(event) { $('addAddressButton').onclick = function(event) {
OptionsPage.showOverlay('autoFillEditAddressOverlay'); self.showAddAddressOverlay_();
}; };
$('addCreditCardButton').onclick = function(event) { $('addCreditCardButton').onclick = function(event) {
OptionsPage.showOverlay('autoFillEditCreditCardOverlay'); self.showAddCreditCardOverlay_();
}; };
Preferences.getInstance().addEventListener('autofill.enabled', Preferences.getInstance().addEventListener('autofill.enabled',
cr.bind(self.updateButtonState_, self)); cr.bind(self.updateEnabledState_, self));
}, },
/** /**
...@@ -55,13 +55,39 @@ cr.define('options', function() { ...@@ -55,13 +55,39 @@ cr.define('options', function() {
* of the |autoFillEnabled| checkbox. * of the |autoFillEnabled| checkbox.
* @private * @private
*/ */
updateButtonState_: function() { updateEnabledState_: function() {
var checkbox = $('autoFillEnabled'); var checkbox = $('autoFillEnabled');
$('addAddressButton').disabled = $('addCreditCardButton').disabled = $('addAddressButton').disabled = $('addCreditCardButton').disabled =
$('editButton').disabled = $('autoFillRemoveButton').disabled = $('editButton').disabled = $('autoFillRemoveButton').disabled =
!checkbox.checked; !checkbox.checked;
}, },
/**
* Shows the 'Add address' overlay, specifically by loading the
* 'Edit address' overlay, emptying the input fields and modifying the
* overlay title.
* @private
*/
showAddAddressOverlay_: function() {
var title = localStrings.getString('addAddressTitle');
AutoFillEditAddressOverlay.setTitle(title);
AutoFillEditAddressOverlay.clearInputFields();
OptionsPage.showOverlay('autoFillEditAddressOverlay');
},
/**
* Shows the 'Add credit card' overlay, specifically by loading the
* 'Edit credit card' overlay, emptying the input fields and modifying the
* overlay title.
* @private
*/
showAddCreditCardOverlay_: function() {
var title = localStrings.getString('addCreditCardTitle');
AutoFillEditCreditCardOverlay.setTitle(title);
AutoFillEditCreditCardOverlay.clearInputFields();
OptionsPage.showOverlay('autoFillEditCreditCardOverlay');
},
/** /**
* Resets the address list. This method leaves the header and horizontal * Resets the address list. This method leaves the header and horizontal
* rule unchanged. * rule unchanged.
...@@ -102,7 +128,7 @@ cr.define('options', function() { ...@@ -102,7 +128,7 @@ cr.define('options', function() {
profileList.add(option, blankAddress); profileList.add(option, blankAddress);
} }
this.updateRemoveButtonState_(); this.updateButtonState_();
}, },
/** /**
...@@ -120,16 +146,16 @@ cr.define('options', function() { ...@@ -120,16 +146,16 @@ cr.define('options', function() {
profileList.add(option, null); profileList.add(option, null);
} }
this.updateRemoveButtonState_(); this.updateButtonState_();
}, },
/** /**
* Sets the enabled state of the AutoFill Remove button based on the current * Sets the enabled state of the AutoFill Edit and Remove buttons based on
* selection in the profile list. * the current selection in the profile list.
* @private * @private
*/ */
updateRemoveButtonState_: function() { updateButtonState_: function() {
$('autoFillRemoveButton').disabled = $('autoFillRemoveButton').disabled = $('autoFillEditButton').disabled =
($('profileList').selectedIndex == -1); ($('profileList').selectedIndex == -1);
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment