Created
October 28, 2014 07:54
-
-
Save teltploek/ce619b6077f04575ec08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
=================================== | |
Pentia (PT) Namespace | |
=================================== | |
*/ | |
var PT = PT || {}; | |
/* | |
=================================== | |
PT.FormInterceptEnter | |
=================================== | |
*/ | |
PT.FormInterceptEnter = { | |
/* | |
=================================== | |
Variables | |
=================================== | |
*/ | |
Variables: { | |
textboxes: jQuery('.js-intercept-enter') | |
}, | |
/* | |
=================================== | |
Setup | |
=================================== | |
*/ | |
Setup: function () { | |
PT.FormInterceptEnter.Variables.textboxes.keypress(function (e) { | |
var elem = jQuery(this); | |
var code = (e.keyCode ? e.keyCode : e.which); | |
if (code === 13 && jQuery('#' + elem.data('button-id')).length > 0) { | |
e.preventDefault(); | |
jQuery('#' + elem.data('button-id')).trigger('click'); | |
} | |
}); | |
} | |
}; | |
/* | |
=================================== | |
Initialize | |
=================================== | |
*/ | |
jQuery(document).ready(function () { | |
if (!jQuery('body').hasClass('pageedit')) { | |
PT.FormInterceptEnter.Setup(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment