|
@ -40,17 +40,18 @@ $.fn.form = function(fields, parameters) { |
|
|
$allModules |
|
|
$allModules |
|
|
.each(function() { |
|
|
.each(function() { |
|
|
var |
|
|
var |
|
|
$module = $(this), |
|
|
|
|
|
$field = $(this).find(selector.field), |
|
|
|
|
|
$group = $(this).find(selector.group), |
|
|
|
|
|
$message = $(this).find(selector.message), |
|
|
|
|
|
$prompt = $(this).find(selector.prompt), |
|
|
|
|
|
$submit = $(this).find(selector.submit), |
|
|
|
|
|
|
|
|
|
|
|
formErrors = [], |
|
|
|
|
|
|
|
|
|
|
|
element = this, |
|
|
|
|
|
instance = $module.data(moduleNamespace), |
|
|
|
|
|
|
|
|
$module = $(this), |
|
|
|
|
|
$field = $(this).find(selector.field), |
|
|
|
|
|
$group = $(this).find(selector.group), |
|
|
|
|
|
$message = $(this).find(selector.message), |
|
|
|
|
|
$prompt = $(this).find(selector.prompt), |
|
|
|
|
|
$submit = $(this).find(selector.submit), |
|
|
|
|
|
|
|
|
|
|
|
formErrors = [], |
|
|
|
|
|
keyStuckDown = false, |
|
|
|
|
|
|
|
|
|
|
|
element = this, |
|
|
|
|
|
instance = $module.data(moduleNamespace), |
|
|
module |
|
|
module |
|
|
; |
|
|
; |
|
|
|
|
|
|
|
@ -162,19 +163,22 @@ $.fn.form = function(fields, parameters) { |
|
|
; |
|
|
; |
|
|
} |
|
|
} |
|
|
if(!event.ctrlKey && key == keyCode.enter && $field.is(selector.input) && $field.not(selector.checkbox).length > 0 ) { |
|
|
if(!event.ctrlKey && key == keyCode.enter && $field.is(selector.input) && $field.not(selector.checkbox).length > 0 ) { |
|
|
module.debug('Enter key pressed, submitting form'); |
|
|
|
|
|
$submit |
|
|
$submit |
|
|
.addClass(className.down) |
|
|
|
|
|
; |
|
|
|
|
|
$field |
|
|
|
|
|
.one('keyup' + eventNamespace, module.event.field.keyup) |
|
|
|
|
|
|
|
|
.addClass(className.pressed) |
|
|
; |
|
|
; |
|
|
|
|
|
if(!keyStuckDown) { |
|
|
|
|
|
$field |
|
|
|
|
|
.one('keyup' + eventNamespace, module.event.field.keyup) |
|
|
|
|
|
; |
|
|
|
|
|
module.submit(); |
|
|
|
|
|
module.debug('Enter pressed on input submitting form'); |
|
|
|
|
|
} |
|
|
|
|
|
keyStuckDown = true; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
keyup: function() { |
|
|
keyup: function() { |
|
|
module.verbose('Doing keyboard shortcut form submit'); |
|
|
|
|
|
$submit.removeClass(className.down); |
|
|
|
|
|
module.submit(); |
|
|
|
|
|
|
|
|
keyStuckDown = false; |
|
|
|
|
|
$submit.removeClass(className.pressed); |
|
|
}, |
|
|
}, |
|
|
blur: function() { |
|
|
blur: function() { |
|
|
var |
|
|
var |
|
@ -212,14 +216,17 @@ $.fn.form = function(fields, parameters) { |
|
|
return 'change'; |
|
|
return 'change'; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
return (document.createElement('input').oninput !== undefined) |
|
|
|
|
|
? 'input' |
|
|
|
|
|
: (document.createElement('input').onpropertychange !== undefined) |
|
|
|
|
|
? 'propertychange' |
|
|
|
|
|
: 'keyup' |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
return module.get.inputEvent(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
inputEvent: function() { |
|
|
|
|
|
return (document.createElement('input').oninput !== undefined) |
|
|
|
|
|
? 'input' |
|
|
|
|
|
: (document.createElement('input').onpropertychange !== undefined) |
|
|
|
|
|
? 'propertychange' |
|
|
|
|
|
: 'keyup' |
|
|
|
|
|
; |
|
|
|
|
|
}, |
|
|
field: function(identifier) { |
|
|
field: function(identifier) { |
|
|
module.verbose('Finding field with identifier', identifier); |
|
|
module.verbose('Finding field with identifier', identifier); |
|
|
if( $field.filter('#' + identifier).length > 0 ) { |
|
|
if( $field.filter('#' + identifier).length > 0 ) { |
|
@ -365,6 +372,12 @@ $.fn.form = function(fields, parameters) { |
|
|
allValid = true, |
|
|
allValid = true, |
|
|
apiRequest |
|
|
apiRequest |
|
|
; |
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// input keydown event will fire submit repeatedly by browser default
|
|
|
|
|
|
if(keyStuckDown) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// reset errors
|
|
|
// reset errors
|
|
|
formErrors = []; |
|
|
formErrors = []; |
|
|
$.each(validation, function(fieldName, field) { |
|
|
$.each(validation, function(fieldName, field) { |
|
@ -676,7 +689,7 @@ $.fn.form.settings = { |
|
|
className : { |
|
|
className : { |
|
|
error : 'error', |
|
|
error : 'error', |
|
|
success : 'success', |
|
|
success : 'success', |
|
|
down : 'down', |
|
|
|
|
|
|
|
|
pressed : 'down', |
|
|
label : 'ui prompt label' |
|
|
label : 'ui prompt label' |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|