25
25
function web2py_ajax_init() {
26
26
jQuery('.hidden').hide();
27
27
jQuery('.error').hide().slideDown('slow');
28
jQuery('.flash').click(function() { jQuery(this).fadeOut('slow'); return false; });
28
jQuery('.flash').click(function(e) { jQuery(this).fadeOut('slow'); e.preventDefault(); });
29
29
// jQuery('input[type=submit]').click(function(){var t=jQuery(this);t.hide();t.after('<input class="submit_disabled" disabled="disabled" type="submit" name="'+t.attr("name")+'_dummy" value="'+t.val()+'">')});
30
30
jQuery('input.integer').live('keyup', function(){this.value=this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g,'').reverse();});
31
31
jQuery('input.double,input.decimal').live('keyup', function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();});
32
32
var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?";
33
33
jQuery("input[type='checkbox'].delete").live('click', function(){ if(this.checked) if(!confirm(confirm_message)) this.checked=false; });
34
34
var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d";
35
try {jQuery("input.date").live('focus',function() {Calendar.setup({
36
inputField:this, ifFormat:date_format, showsTime:false
37
}); }); } catch(e) {};
38
35
var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S";
39
try { jQuery("input.datetime").live('focus', function() {Calendar.setup({
40
inputField:this, ifFormat:datetime_format, showsTime: true,timeFormat: "24"
41
}); }); } catch(e) {};
43
jQuery("input.time").live('focus', function() { var el = jQuery(this);
44
if (!el.hasClass('hasTimeEntry')) try { el.timeEntry(); } catch(e) {};
37
jQuery("input.datetime").AnyTime_picker({
38
format: datetime_format.replace('%M','%i')});
39
jQuery("input.date").AnyTime_picker({
40
format: date_format.replace('%M','%i')});
41
jQuery("input.time").AnyTime_picker({
48
46
jQuery(function() {
55
53
jQuery('#'+target+' form').each(function(i){
56
54
var form=jQuery(this);
57
55
if(!form.hasClass('no_trap'))
58
form.submit(function(obj){
56
form.submit(function(e){
59
57
jQuery('.flash').hide().html('');
60
58
web2py_ajax_page('post',action,form.serialize(),target);