document.observe("dom:loaded", function() {
when('form[method=post]', function(form) {
var contButton = false,
lockField = $('page_lock_version'),
attachments = $('attachments')
$(form['continue']).observe('click', function() {
contButton = true
})
form.observe('submit', function(e) {
if (contButton && !this.down('input[type=file]')) {
form.request({
onFailure: function() { alert("Ajax saving failed!") },
onSuccess: function() {
lockField.setValue(parseInt(lockField.getValue()) + 1)
if (attachments)
when(attachments.select('input[name="page[delete_attachments][]"]'), function(inputs) {
inputs.invoke('remove')
attachments.down('.notice').remove()
})
}
})
contButton = false
e.stop()
}
})
})
})