FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

IE8 fix and updated read me file · steverife/JavaScriptButtons@efdb1c3 · GitHub

Repository navigation

Commit efdb1c3

Browse files
committed
IE8 fix and updated read me file
1 parent f1b298a commit efdb1c3

2 files changed

Lines changed: 40 additions & 26 deletions

File tree

‎README.md‎

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,33 @@ Button stored on PayPal will have hosted button id. Add `data-hosted_button_id`
8989
## Optional fields
9090
Creating custom dropdown field is by adding
9191

92-
`data-OPTIONnNAME`
93-
'data-L_OPTIONnSELECTx`
94-
`data-L_OPTIONnPRICEx`
92+
`data-optionNname`
93+
'data-optionNselectX`
94+
`data-optionNpriceX`
9595

96-
`data-OPTIONnREQUIRED="true"`
97-
`data-OPTIONnPATTERN="alphaNumericRegex|alphaRegex|numericRegex"`
96+
`data-optionNrequired="true"`
97+
`data-optionNpattern="alphaNumericRegex|alphaRegex|numericRegex"`
9898

9999
**Dropdown field**
100100

101101
Ex:
102-
data-OPTION0NAME="Color"
103-
data-L_OPTION0SELECT0="Red"
104-
data-L_OPTION0SELECT1="Blue"
105-
data-L_OPTION0SELECT2="Green"
106-
data-L_OPTION0PRICE0="10.00"
107-
data-L_OPTION0PRICE1="8.00"
108-
data-L_OPTION0PRICE2="12.00"
109-
110-
data-OPTION1NAME="Size"
111-
data-L_OPTION1SELECT0="Small"
112-
data-L_OPTION1SELECT1="Large"
113-
data-OPTION2REQUIRED="true"
114-
data-OPTION2PATTERN="alphaNumericRegex"
102+
data-option0name="Color"
103+
data-option0select0="Red"
104+
data-option0select1="Blue"
105+
data-option0select2="Green"
106+
data-option0price0="10.00"
107+
data-option0price1="8.00"
108+
data-option0price2="12.00"
109+
110+
data-option1name="Size"
111+
data-option1select0="Small"
112+
data-option1select1="Medium"
113+
data-option1select2="Large"
114+
115+
data-option2name="Coupon Number"
116+
data-option2select0=""
117+
data-option2required="true"
118+
data-option2pattern="alphaNumericRegex"
115119

116120
## Callback notification
117121
On completion of a transaction you can get a payment notification ([IPN](https://www.x.com/developers/paypal/documentation-tools/ipn/integration-guide/IPNIntro)) on a callback URL you specify using the `data-callback` attribute. An [IPN simulator](https://developer.paypal.com/webapps/developer/applications/ipn_simulator) is available on the sandbox.

‎src/paypal-button.js‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,19 @@ PAYPAL.apps = PAYPAL.apps || {};
352352
btn.appendChild(document.createTextNode(btnText));
353353
form.appendChild(btn);
354354

355-
form.addEventListener('submit', function (e) {
356-
e.preventDefault();
357-
if (validateFields(form.querySelectorAll('input[type=text]'), form.querySelectorAll('div[id=errorBox]')[0])) {
358-
form.submit();
359-
}
360-
}, false);
355+
if (window.addEventListener) {
356+
form.addEventListener('submit', function (e) {
357+
e.preventDefault();
358+
if (validateFields(form.querySelectorAll('input[type=text]'), form.querySelectorAll('div[id=errorBox]')[0])) {
359+
form.submit();
360+
}
361+
}, false);
362+
//For IE 8
363+
} else {
364+
form.attachEvent('onsubmit', function () {
365+
return validateFields(form.querySelectorAll('input[type=text]'), form.querySelectorAll('div[id=errorBox]')[0]);
366+
});
367+
}
361368

362369
// If the Mini Cart is present then register the form
363370
if ((MiniCart = PAYPAL.apps.MiniCart) && data.items.cmd.value === '_cart') {
@@ -409,8 +416,11 @@ PAYPAL.apps = PAYPAL.apps || {};
409416

410417
fieldLabel = field.getAttribute('data-label');
411418
patternName = field.getAttribute('data-pattern');
412-
field.value = field.value.trim();
413-
if (field.getAttribute('data-required') && field.value.trim() === '') {
419+
//Trim not supported in IE8
420+
if (field.value.trim) {
421+
field.value = field.value.trim();
422+
}
423+
if (field.getAttribute('data-required') && field.value === '') {
414424
errors.push(validateFieldHandlers.required.message.replace('%s', fieldLabel));
415425
addClass(field, 'field-error');
416426
} else if (field.getAttribute('data-pattern') && validateFieldHandlers[patternName] && !checkPattern(field, patternName)) {

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL