Skip to content

Instantly share code, notes, and snippets.

@adjohu
Created May 21, 2012 13:41
Show Gist options
  • Save adjohu/2762384 to your computer and use it in GitHub Desktop.
Save adjohu/2762384 to your computer and use it in GitHub Desktop.
(test = {
_html: function (arr) {
return $(arr.join(""));
},
_urlMatch: function (regex, callback) {
if (regex.test(window.location.href)) {
return callback();
}
},
init: function () {
test.fixAddressInputSize();
test.addNumericValidation();
test.creditCardToRadio();
},
fixAddressInputSize: function () {
var inputs, matchWidth;
inputs = $("input[name ^= 'billing[street]']");
matchWidth = $("input[name='billing[city]']").width();
inputs.width(matchWidth);
},
addNumericValidation: function () {
$("input[title *= 'Telephone']").addClass("validate-number");
},
creditCardToRadio: function () {
var select, radioContainer;
select = $("select#sagepaydirectpro_cc_type");
select.hide();
select.find("option").each(function () {
var val, label;
val = $(this).val();
if (val.length > 0) {
label = test._html([
"<label>",
"<input type='radio' name='cc_type' />",
" " + $(this).text(),
"</label>"
]);
label.find("input").val(val);
select.after(label);
}
});
},
inputs: {
}
}).init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment