From 24bed97a51148a98485aa32042edf9f19e659cca Mon Sep 17 00:00:00 2001 From: niphlod Date: Thu, 29 Aug 2013 20:55:03 +0200 Subject: [PATCH] fixed the order of response.js execution. Thanks @Anthony --- applications/admin/static/js/web2py.js | 200 +++++++++++----------- applications/examples/static/js/web2py.js | 200 +++++++++++----------- applications/welcome/static/js/web2py.js | 194 +++++++++++---------- 3 files changed, 305 insertions(+), 289 deletions(-) diff --git a/applications/admin/static/js/web2py.js b/applications/admin/static/js/web2py.js index 507be9f5..de2a6e25 100644 --- a/applications/admin/static/js/web2py.js +++ b/applications/admin/static/js/web2py.js @@ -20,18 +20,22 @@ $.web2py = web2py = { popup: function (url) { + /* popup a window */ newwindow = window.open(url, 'name', 'height=400,width=600'); if(window.focus) newwindow.focus(); return false; }, collapse: function (id) { + /* toggle an element */ $('#' + id).slideToggle(); }, fade: function (id, value) { + /*fade something*/ if(value > 0) $('#' + id).hide().fadeIn('slow'); else $('#' + id).show().fadeOut('slow'); }, ajax: function (u, s, t) { + /*simple ajax function*/ query = ''; if(typeof s == "string") { d = $(s).serialize(); @@ -65,14 +69,15 @@ }); }, ajax_fields: function (target) { - /*this attaches something to a newly loaded fragment/page + /* + *this attaches something to a newly loaded fragment/page * Ideally all events should be bound to the document, so we can avoid calling * this over and over... all will be bound to the document */ var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d"; var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S"; $("input.date", target).each(function () { - $(this).attr('autocomplete','off'); + $(this).attr('autocomplete', 'off'); Calendar.setup({ inputField: this, ifFormat: date_format, @@ -80,7 +85,7 @@ }); }); $("input.datetime", target).each(function () { - $(this).attr('autocomplete','off'); + $(this).attr('autocomplete', 'off'); Calendar.setup({ inputField: this, ifFormat: datetime_format, @@ -89,25 +94,25 @@ }); }); $("input.time", target).each(function () { - $(this).timeEntry().attr('autocomplete','off'); + $(this).timeEntry().attr('autocomplete', 'off'); }); /*adds btn class to buttons*/ $('button', target).addClass('btn'); $('form input[type="submit"], form input[type="button"]', target).addClass('btn'); - /*no more inline javascript for PasswordWidget*/ + /* javascript for PasswordWidget*/ $('input[type=password][data-w2p_entropy]', target).each(function () { web2py.validate_entropy($(this)); }); - /*no more inline javascript for ListWidget*/ + /* javascript for ListWidget*/ $('ul.w2p_list', target).each(function () { function pe(ul, e) { var new_line = ml(ul); rel(ul); if($(e.target).parent().is(':visible')) { - //make sure we didn't delete the element before we insert after + /* make sure we didn't delete the element before we insert after */ new_line.insertAfter($(e.target).parent()); } else { - //the line we clicked on was deleted, just add to end of list + /* the line we clicked on was deleted, just add to end of list */ new_line.appendTo(ul); } new_line.find(":text").focus(); @@ -116,18 +121,20 @@ function rl(ul, e) { if($(ul).children().length > 1) { - //only remove if we have more than 1 item so the list is never empty + /* only remove if we have more than 1 item so the list is never empty */ $(e.target).parent().remove(); } } function ml(ul) { + /* clone the first field */ var line = $(ul).find("li:first").clone(true); line.find(':text').val(''); return line; } function rel(ul) { + /* keep only as many as needed*/ $(ul).find("li").each(function () { var trimmed = $.trim($(this.firstChild).val()); if(trimmed == '') $(this).remove(); @@ -147,19 +154,32 @@ }); }, ajax_init: function (target) { + /*called whenever a fragment gets loaded */ $('.hidden', target).hide(); web2py.manage_errors(target); web2py.ajax_fields(target); web2py.show_if_handler(target); web2py.component_handler(target); }, - //manage errors in forms + /* manage errors in forms */ manage_errors: function (target) { $('.error', target).hide().slideDown('slow'); - //jQuery('.error', target).hide().fadeIn('slow'); + /* jQuery('.error', target).hide().fadeIn('slow'); */ + }, + after_ajax: function (xhr) { + /* called whenever an ajax request completes */ + var command = xhr.getResponseHeader('web2py-component-command'); + var flash = xhr.getResponseHeader('web2py-component-flash'); + if(command !== null) { + eval(decodeURIComponent(command)); + } + if(flash) { + web2py.flash(decodeURIComponent(flash)) + } }, event_handlers: function () { - /* This is called once for page + /* + * This is called once for page * Ideally it should bound all the things that are needed */ var doc = $(document); @@ -167,9 +187,12 @@ var t = $(this); if(t.css('top') == '0px') t.slideUp('slow'); else t.fadeOut(); - //if I want to display a clickable something - //inside flash, I should not be prevented to follow it - //e.preventDefault(); + /* if I want to display a clickable something + * inside flash, I should not be prevented to follow it + * + * e.preventDefault(); + */ + }); doc.on('keyup', 'input.integer', function () { this.value = this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g, '').reverse(); @@ -185,24 +208,21 @@ doc.ajaxSuccess(function (e, xhr) { var redirect = xhr.getResponseHeader('web2py-redirect-location'); - var command = xhr.getResponseHeader('web2py-component-command'); - var flash = xhr.getResponseHeader('web2py-component-flash'); if(redirect !== null) { window.location = redirect; }; - if(command !== null) { - eval(decodeURIComponent(command)); - } - if(flash) { - web2py.flash(decodeURIComponent(flash)) - } + /* run this here only if this Ajax request is NOT for a web2py component. */ + if(xhr.getResponseHeader('web2py-component-content') == null) { + web2py.after_ajax(xhr); + }; }); doc.ajaxError(function (e, xhr, settings, exception) { - //personally I don't like it. - //if there's an error it it flashed and can be removed - //as any other message - //doc.off('click', '.flash') + /*personally I don't like it. + *if there's an error it it flashed and can be removed + *as any other message + *doc.off('click', '.flash') + */ switch(xhr.status) { case 500: web2py.flash(ajax_error_500); @@ -211,12 +231,14 @@ }, trap_form: function (action, target) { + /* traps any LOADed form */ + var disable_with_message = (typeof w2p_ajax_disable_with_message != 'undefined') ? w2p_ajax_disable_with_message : "Working..."; $('#' + target + ' form').each(function (i) { var form = $(this); form.attr('data-w2p_target', target); if(!form.hasClass('no_trap')) { - //should be there by default ? - form.find('input[type=submit]').attr('data-w2p_disable_with', 'Working...'); + /* should be there by default */ + form.find('input[type=submit]').attr('data-w2p_disable_with', disable_with_message); form.submit(function (e) { web2py.hide_flash(); web2py.ajax_page('post', action, form.serialize(), target, form); @@ -236,31 +258,30 @@ }); }, ajax_page: function (method, action, data, target, element) { - //element is a new parameter, but should be put be put in front + /* element is a new parameter, but should be put be put in front */ if(element == undefined) element = $(document); - if(web2py.fire(element, 'ajax:before')) { //test a usecase, should stop here if returns false + if(web2py.fire(element, 'ajax:before')) { /*test a usecase, should stop here if returns false */ $.ajax({ 'type': method, 'url': action, 'data': data, 'beforeSend': function (xhr, settings) { - //added xhr.setRequestHeader('web2py-component-location', document.location); xhr.setRequestHeader('web2py-component-element', target); return web2py.fire(element, 'ajax:beforeSend', [xhr, settings]); //test a usecase, should stop here if returns false }, - //added 'success': function (data, status, xhr) { - //bummer for form submissions....the element is not there after complete - //because it gets replaced by the new response.... + /*bummer for form submissions....the element is not there after complete + *because it gets replaced by the new response.... + */ element.trigger('ajax:success', [data, status, xhr]); }, - //added 'error': function (xhr, status, error) { - //bummer for form submissions....in addition to the element being not there after - //complete because it gets replaced by the new response, standard form - //handling just returns the same status code for good and bad - //form submissions (i.e. that triggered a validator error) + /*bummer for form submissions....in addition to the element being not there after + *complete because it gets replaced by the new response, standard form + *handling just returns the same status code for good and bad + *form submissions (i.e. that triggered a validator error) + */ element.trigger('ajax:error', [xhr, status, error]); }, 'complete': function (xhr, status) { @@ -274,24 +295,26 @@ web2py.trap_form(action, target); web2py.trap_link(target); web2py.ajax_init('#' + target); + web2py.after_ajax(xhr); } }); } }, component: function (action, target, timeout, times, el) { - //element is a new parameter, but should be put in front + /* element is a new parameter, but should be put in front */ $(function () { var jelement = $("#" + target); var element = jelement.get(0); var statement = "jQuery('#" + target + "').get(0).reload();"; element.reload = function () { - // Continue if times is Infinity or - // the times limit is not reached + /* Continue if times is Infinity or + * the times limit is not reached + */ if(element.reload_check()) { web2py.ajax_page('get', action, null, target, el); } - }; // reload - // Method to check timing limit + }; + /* Method to check timing limit */ element.reload_check = function () { if(jelement.hasClass('w2p_component_stop')) { clearInterval(this.timing); @@ -313,32 +336,33 @@ } } return false; - }; // reload check + }; if(!isNaN(timeout)) { element.timeout = timeout; element.reload_counter = times; if(times > 1) { - // Multiple or infinite reload - // Run first iteration + /* Multiple or infinite reload + * Run first iteration + */ web2py.ajax_page('get', action, null, target, el); element.run_once = false; element.timing = setInterval(statement, timeout); element.reload_counter -= 1; } else if(times == 1) { - // Run once with timeout + /* Run once with timeout */ element.run_once = true; element.setTimeout = setTimeout; element.timing = setTimeout(statement, timeout); } } else { - // run once (no timeout specified) + /* run once (no timeout specified) */ element.reload_counter = Infinity; web2py.ajax_page('get', action, null, target, el); } }); }, calc_entropy: function (mystring) { - //calculate a simple entropy for a given string + /* calculate a simple entropy for a given string */ var csets = new Array( 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789', '!@#$\%^&*()', '~`-_=+[]{}\|;:\'",.<>?/', @@ -346,7 +370,7 @@ var score = 0, other = {}, seen = {}, lastset = null, mystringlist = mystring.split(''); - for(var i = 0; i < mystringlist.length; i++) { // classify this character + for(var i = 0; i < mystringlist.length; i++) { /* classify this character */ var c = mystringlist[i], inset = 5; for(var j = 0; j < csets.length; j++) @@ -354,7 +378,7 @@ inset = j; break; } - //calculate effect of character on alphabet size + /*calculate effect of character on alphabet size */ if(!(inset in seen)) { seen[inset] = 1; score += csets[inset].length; @@ -371,7 +395,6 @@ return Math.round(entropy * 100) / 100 }, validate_entropy: function (myfield, req_entropy) { - //added if(myfield.data('w2p_entropy') != undefined) req_entropy = myfield.data('w2p_entropy'); var validator = function () { var v = (web2py.calc_entropy(myfield.val()) || 0) / req_entropy; @@ -401,23 +424,23 @@ ws.onopen = onopen ? onopen : (function () {}); ws.onmessage = onmessage; ws.onclose = onclose ? onclose : (function () {}); - return true; // supported - } else return false; // not supported + return true; /* supported */ + } else return false; /* not supported */ }, /* new from here */ - // Form input elements bound by jquery-ujs + /* Form input elements bound by jquery-uj */ formInputClickSelector: 'input[type=submit], input[type=image], button[type=submit], button:not([type])', - // Form input elements disabled during form submission + /* Form input elements disabled during form submission */ disableSelector: 'input, button, textarea, select', - // Form input elements re-enabled after form submission + /* Form input elements re-enabled after form submission */ enableSelector: 'input:disabled, button:disabled, textarea:disabled, select:disabled', - // Triggers an event on an element and returns false if the event result is false + /* Triggers an event on an element and returns false if the event result is false */ fire: function (obj, name, data) { var event = $.Event(name); obj.trigger(event, data); return event.result !== false; }, - // Helper function, needed to provide consistent behavior in IE + /* Helper function, needed to provide consistent behavior in IE */ stopEverything: function (e) { $(e.target).trigger('w2p:everythingStopped'); e.stopImmediatePropagation(); @@ -426,41 +449,42 @@ confirm: function (message) { return confirm(message); }, - // replace element's html with the 'data-disable-with' after storing original html - // and prevent clicking on it + /* replace element's html with the 'data-disable-with' after storing original html + * and prevent clicking on it */ disableElement: function (el) { el.addClass('disabled'); var method = el.prop('type') == 'submit' ? 'val' : 'html'; - // store enabled state + var disable_with_message = (typeof w2p_ajax_disable_with_message != 'undefined') ? w2p_ajax_disable_with_message : "Working..."; + /*store enabled state*/ el.data('w2p:enable-with', el[method]()); /* little addition by default*/ if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) { - el.data('w2p_disable_with', 'Working...'); + el.data('w2p_disable_with', disable_with_message); } - // set to disabled state + /* set to disabled state*/ el[method](el.data('w2p_disable_with')); - el.bind('click.w2pDisable', function (e) { // prevent further clicking + el.bind('click.w2pDisable', function (e) { /* prevent further clicking*/ return web2py.stopEverything(e); }); }, - // restore element to its original state which was disabled by 'disableElement' above + /* restore element to its original state which was disabled by 'disableElement' above*/ enableElement: function (el) { var method = el.prop('type') == 'submit' ? 'val' : 'html'; if(el.data('w2p:enable-with') !== undefined) { - // set to old enabled state + /* set to old enabled state */ el[method](el.data('w2p:enable-with')); - el.removeData('w2p:enable-with'); // clean up cache + el.removeData('w2p:enable-with'); } el.removeClass('disabled'); - el.unbind('click.w2pDisable'); // enable element + el.unbind('click.w2pDisable'); }, - //convenience wrapper, internal use only + /*convenience wrapper, internal use only */ simple_component: function (action, target, element) { web2py.component(action, target, 0, 1, element); }, - //helper for flash messages + /*helper for flash messages*/ flash: function (message, status) { var flash = $('.flash'); web2py.hide_flash(); @@ -525,34 +549,16 @@ if(target == undefined) { if(method == 'GET') { web2py.ajax_page('get', action, [], 'bogus', el); //fixme? - //web2py.simple_component(action, el.attr('id'), el); //not working with original } else if(method == 'POST') { - //should be web2py.ajax(action, [], ''); but it's too simple web2py.ajax_page('post', action, [], 'bogus', el); //fixme? } } else { if(method == 'GET') { web2py.ajax_page('get', action, [], target, el); - //web2py.simple_component(action, target, el); } else if(method == 'POST') { - //should be web2py.ajax(action, [], target); but it's too simple web2py.ajax_page('post', action, [], target, el); } } - /*this should happen only on ajaxsuccess - * and should block subsequent clicks until ajaxcomplete - * NB: introduce the first incompatibility because normally - * the element would be removed in either case - /* removal code moved to the ajax:success event - START - if(toremove != undefined) { - toremove = el.closest(toremove); - if(!toremove.length) { - //this enables removal of whatever selector if a closest is not found - toremove = jQuery(toremove); - } - toremove.remove(); - } - /* removal code moved to the ajax:success event - END */ }, a_handlers: function () { var el = $(document); @@ -566,7 +572,7 @@ if(toremove != undefined) { toremove = el.closest(toremove); if(!toremove.length) { - //this enables removal of whatever selector if a closest is not found + /*this enables removal of whatever selector if a closest is not found */ toremove = $(toremove); } toremove.remove(); @@ -622,8 +628,8 @@ } } - //end of functions - //main hook + /*end of functions */ + /*main hook*/ $(function () { var flash = $('.flash'); flash.hide(); @@ -641,11 +647,11 @@ ajax = jQuery.web2py.ajax; web2py_component = jQuery.web2py.component; web2py_websocket = jQuery.web2py.websocket; web2py_ajax_page = jQuery.web2py.ajax_page; -//needed for IS_STRONG(entropy) +/*needed for IS_STRONG(entropy)*/ web2py_validate_entropy = jQuery.web2py.validate_entropy; -//needed for crud.search and SQLFORM.grid's search +/*needed for crud.search and SQLFORM.grid's search*/ web2py_ajax_fields = jQuery.web2py.ajax_fields; -//used for LOAD(ajax=False) +/*used for LOAD(ajax=False)*/ web2py_trap_form = jQuery.web2py.trap_form; /*undocumented - rare*/ diff --git a/applications/examples/static/js/web2py.js b/applications/examples/static/js/web2py.js index 507be9f5..de2a6e25 100644 --- a/applications/examples/static/js/web2py.js +++ b/applications/examples/static/js/web2py.js @@ -20,18 +20,22 @@ $.web2py = web2py = { popup: function (url) { + /* popup a window */ newwindow = window.open(url, 'name', 'height=400,width=600'); if(window.focus) newwindow.focus(); return false; }, collapse: function (id) { + /* toggle an element */ $('#' + id).slideToggle(); }, fade: function (id, value) { + /*fade something*/ if(value > 0) $('#' + id).hide().fadeIn('slow'); else $('#' + id).show().fadeOut('slow'); }, ajax: function (u, s, t) { + /*simple ajax function*/ query = ''; if(typeof s == "string") { d = $(s).serialize(); @@ -65,14 +69,15 @@ }); }, ajax_fields: function (target) { - /*this attaches something to a newly loaded fragment/page + /* + *this attaches something to a newly loaded fragment/page * Ideally all events should be bound to the document, so we can avoid calling * this over and over... all will be bound to the document */ var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d"; var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S"; $("input.date", target).each(function () { - $(this).attr('autocomplete','off'); + $(this).attr('autocomplete', 'off'); Calendar.setup({ inputField: this, ifFormat: date_format, @@ -80,7 +85,7 @@ }); }); $("input.datetime", target).each(function () { - $(this).attr('autocomplete','off'); + $(this).attr('autocomplete', 'off'); Calendar.setup({ inputField: this, ifFormat: datetime_format, @@ -89,25 +94,25 @@ }); }); $("input.time", target).each(function () { - $(this).timeEntry().attr('autocomplete','off'); + $(this).timeEntry().attr('autocomplete', 'off'); }); /*adds btn class to buttons*/ $('button', target).addClass('btn'); $('form input[type="submit"], form input[type="button"]', target).addClass('btn'); - /*no more inline javascript for PasswordWidget*/ + /* javascript for PasswordWidget*/ $('input[type=password][data-w2p_entropy]', target).each(function () { web2py.validate_entropy($(this)); }); - /*no more inline javascript for ListWidget*/ + /* javascript for ListWidget*/ $('ul.w2p_list', target).each(function () { function pe(ul, e) { var new_line = ml(ul); rel(ul); if($(e.target).parent().is(':visible')) { - //make sure we didn't delete the element before we insert after + /* make sure we didn't delete the element before we insert after */ new_line.insertAfter($(e.target).parent()); } else { - //the line we clicked on was deleted, just add to end of list + /* the line we clicked on was deleted, just add to end of list */ new_line.appendTo(ul); } new_line.find(":text").focus(); @@ -116,18 +121,20 @@ function rl(ul, e) { if($(ul).children().length > 1) { - //only remove if we have more than 1 item so the list is never empty + /* only remove if we have more than 1 item so the list is never empty */ $(e.target).parent().remove(); } } function ml(ul) { + /* clone the first field */ var line = $(ul).find("li:first").clone(true); line.find(':text').val(''); return line; } function rel(ul) { + /* keep only as many as needed*/ $(ul).find("li").each(function () { var trimmed = $.trim($(this.firstChild).val()); if(trimmed == '') $(this).remove(); @@ -147,19 +154,32 @@ }); }, ajax_init: function (target) { + /*called whenever a fragment gets loaded */ $('.hidden', target).hide(); web2py.manage_errors(target); web2py.ajax_fields(target); web2py.show_if_handler(target); web2py.component_handler(target); }, - //manage errors in forms + /* manage errors in forms */ manage_errors: function (target) { $('.error', target).hide().slideDown('slow'); - //jQuery('.error', target).hide().fadeIn('slow'); + /* jQuery('.error', target).hide().fadeIn('slow'); */ + }, + after_ajax: function (xhr) { + /* called whenever an ajax request completes */ + var command = xhr.getResponseHeader('web2py-component-command'); + var flash = xhr.getResponseHeader('web2py-component-flash'); + if(command !== null) { + eval(decodeURIComponent(command)); + } + if(flash) { + web2py.flash(decodeURIComponent(flash)) + } }, event_handlers: function () { - /* This is called once for page + /* + * This is called once for page * Ideally it should bound all the things that are needed */ var doc = $(document); @@ -167,9 +187,12 @@ var t = $(this); if(t.css('top') == '0px') t.slideUp('slow'); else t.fadeOut(); - //if I want to display a clickable something - //inside flash, I should not be prevented to follow it - //e.preventDefault(); + /* if I want to display a clickable something + * inside flash, I should not be prevented to follow it + * + * e.preventDefault(); + */ + }); doc.on('keyup', 'input.integer', function () { this.value = this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g, '').reverse(); @@ -185,24 +208,21 @@ doc.ajaxSuccess(function (e, xhr) { var redirect = xhr.getResponseHeader('web2py-redirect-location'); - var command = xhr.getResponseHeader('web2py-component-command'); - var flash = xhr.getResponseHeader('web2py-component-flash'); if(redirect !== null) { window.location = redirect; }; - if(command !== null) { - eval(decodeURIComponent(command)); - } - if(flash) { - web2py.flash(decodeURIComponent(flash)) - } + /* run this here only if this Ajax request is NOT for a web2py component. */ + if(xhr.getResponseHeader('web2py-component-content') == null) { + web2py.after_ajax(xhr); + }; }); doc.ajaxError(function (e, xhr, settings, exception) { - //personally I don't like it. - //if there's an error it it flashed and can be removed - //as any other message - //doc.off('click', '.flash') + /*personally I don't like it. + *if there's an error it it flashed and can be removed + *as any other message + *doc.off('click', '.flash') + */ switch(xhr.status) { case 500: web2py.flash(ajax_error_500); @@ -211,12 +231,14 @@ }, trap_form: function (action, target) { + /* traps any LOADed form */ + var disable_with_message = (typeof w2p_ajax_disable_with_message != 'undefined') ? w2p_ajax_disable_with_message : "Working..."; $('#' + target + ' form').each(function (i) { var form = $(this); form.attr('data-w2p_target', target); if(!form.hasClass('no_trap')) { - //should be there by default ? - form.find('input[type=submit]').attr('data-w2p_disable_with', 'Working...'); + /* should be there by default */ + form.find('input[type=submit]').attr('data-w2p_disable_with', disable_with_message); form.submit(function (e) { web2py.hide_flash(); web2py.ajax_page('post', action, form.serialize(), target, form); @@ -236,31 +258,30 @@ }); }, ajax_page: function (method, action, data, target, element) { - //element is a new parameter, but should be put be put in front + /* element is a new parameter, but should be put be put in front */ if(element == undefined) element = $(document); - if(web2py.fire(element, 'ajax:before')) { //test a usecase, should stop here if returns false + if(web2py.fire(element, 'ajax:before')) { /*test a usecase, should stop here if returns false */ $.ajax({ 'type': method, 'url': action, 'data': data, 'beforeSend': function (xhr, settings) { - //added xhr.setRequestHeader('web2py-component-location', document.location); xhr.setRequestHeader('web2py-component-element', target); return web2py.fire(element, 'ajax:beforeSend', [xhr, settings]); //test a usecase, should stop here if returns false }, - //added 'success': function (data, status, xhr) { - //bummer for form submissions....the element is not there after complete - //because it gets replaced by the new response.... + /*bummer for form submissions....the element is not there after complete + *because it gets replaced by the new response.... + */ element.trigger('ajax:success', [data, status, xhr]); }, - //added 'error': function (xhr, status, error) { - //bummer for form submissions....in addition to the element being not there after - //complete because it gets replaced by the new response, standard form - //handling just returns the same status code for good and bad - //form submissions (i.e. that triggered a validator error) + /*bummer for form submissions....in addition to the element being not there after + *complete because it gets replaced by the new response, standard form + *handling just returns the same status code for good and bad + *form submissions (i.e. that triggered a validator error) + */ element.trigger('ajax:error', [xhr, status, error]); }, 'complete': function (xhr, status) { @@ -274,24 +295,26 @@ web2py.trap_form(action, target); web2py.trap_link(target); web2py.ajax_init('#' + target); + web2py.after_ajax(xhr); } }); } }, component: function (action, target, timeout, times, el) { - //element is a new parameter, but should be put in front + /* element is a new parameter, but should be put in front */ $(function () { var jelement = $("#" + target); var element = jelement.get(0); var statement = "jQuery('#" + target + "').get(0).reload();"; element.reload = function () { - // Continue if times is Infinity or - // the times limit is not reached + /* Continue if times is Infinity or + * the times limit is not reached + */ if(element.reload_check()) { web2py.ajax_page('get', action, null, target, el); } - }; // reload - // Method to check timing limit + }; + /* Method to check timing limit */ element.reload_check = function () { if(jelement.hasClass('w2p_component_stop')) { clearInterval(this.timing); @@ -313,32 +336,33 @@ } } return false; - }; // reload check + }; if(!isNaN(timeout)) { element.timeout = timeout; element.reload_counter = times; if(times > 1) { - // Multiple or infinite reload - // Run first iteration + /* Multiple or infinite reload + * Run first iteration + */ web2py.ajax_page('get', action, null, target, el); element.run_once = false; element.timing = setInterval(statement, timeout); element.reload_counter -= 1; } else if(times == 1) { - // Run once with timeout + /* Run once with timeout */ element.run_once = true; element.setTimeout = setTimeout; element.timing = setTimeout(statement, timeout); } } else { - // run once (no timeout specified) + /* run once (no timeout specified) */ element.reload_counter = Infinity; web2py.ajax_page('get', action, null, target, el); } }); }, calc_entropy: function (mystring) { - //calculate a simple entropy for a given string + /* calculate a simple entropy for a given string */ var csets = new Array( 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789', '!@#$\%^&*()', '~`-_=+[]{}\|;:\'",.<>?/', @@ -346,7 +370,7 @@ var score = 0, other = {}, seen = {}, lastset = null, mystringlist = mystring.split(''); - for(var i = 0; i < mystringlist.length; i++) { // classify this character + for(var i = 0; i < mystringlist.length; i++) { /* classify this character */ var c = mystringlist[i], inset = 5; for(var j = 0; j < csets.length; j++) @@ -354,7 +378,7 @@ inset = j; break; } - //calculate effect of character on alphabet size + /*calculate effect of character on alphabet size */ if(!(inset in seen)) { seen[inset] = 1; score += csets[inset].length; @@ -371,7 +395,6 @@ return Math.round(entropy * 100) / 100 }, validate_entropy: function (myfield, req_entropy) { - //added if(myfield.data('w2p_entropy') != undefined) req_entropy = myfield.data('w2p_entropy'); var validator = function () { var v = (web2py.calc_entropy(myfield.val()) || 0) / req_entropy; @@ -401,23 +424,23 @@ ws.onopen = onopen ? onopen : (function () {}); ws.onmessage = onmessage; ws.onclose = onclose ? onclose : (function () {}); - return true; // supported - } else return false; // not supported + return true; /* supported */ + } else return false; /* not supported */ }, /* new from here */ - // Form input elements bound by jquery-ujs + /* Form input elements bound by jquery-uj */ formInputClickSelector: 'input[type=submit], input[type=image], button[type=submit], button:not([type])', - // Form input elements disabled during form submission + /* Form input elements disabled during form submission */ disableSelector: 'input, button, textarea, select', - // Form input elements re-enabled after form submission + /* Form input elements re-enabled after form submission */ enableSelector: 'input:disabled, button:disabled, textarea:disabled, select:disabled', - // Triggers an event on an element and returns false if the event result is false + /* Triggers an event on an element and returns false if the event result is false */ fire: function (obj, name, data) { var event = $.Event(name); obj.trigger(event, data); return event.result !== false; }, - // Helper function, needed to provide consistent behavior in IE + /* Helper function, needed to provide consistent behavior in IE */ stopEverything: function (e) { $(e.target).trigger('w2p:everythingStopped'); e.stopImmediatePropagation(); @@ -426,41 +449,42 @@ confirm: function (message) { return confirm(message); }, - // replace element's html with the 'data-disable-with' after storing original html - // and prevent clicking on it + /* replace element's html with the 'data-disable-with' after storing original html + * and prevent clicking on it */ disableElement: function (el) { el.addClass('disabled'); var method = el.prop('type') == 'submit' ? 'val' : 'html'; - // store enabled state + var disable_with_message = (typeof w2p_ajax_disable_with_message != 'undefined') ? w2p_ajax_disable_with_message : "Working..."; + /*store enabled state*/ el.data('w2p:enable-with', el[method]()); /* little addition by default*/ if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) { - el.data('w2p_disable_with', 'Working...'); + el.data('w2p_disable_with', disable_with_message); } - // set to disabled state + /* set to disabled state*/ el[method](el.data('w2p_disable_with')); - el.bind('click.w2pDisable', function (e) { // prevent further clicking + el.bind('click.w2pDisable', function (e) { /* prevent further clicking*/ return web2py.stopEverything(e); }); }, - // restore element to its original state which was disabled by 'disableElement' above + /* restore element to its original state which was disabled by 'disableElement' above*/ enableElement: function (el) { var method = el.prop('type') == 'submit' ? 'val' : 'html'; if(el.data('w2p:enable-with') !== undefined) { - // set to old enabled state + /* set to old enabled state */ el[method](el.data('w2p:enable-with')); - el.removeData('w2p:enable-with'); // clean up cache + el.removeData('w2p:enable-with'); } el.removeClass('disabled'); - el.unbind('click.w2pDisable'); // enable element + el.unbind('click.w2pDisable'); }, - //convenience wrapper, internal use only + /*convenience wrapper, internal use only */ simple_component: function (action, target, element) { web2py.component(action, target, 0, 1, element); }, - //helper for flash messages + /*helper for flash messages*/ flash: function (message, status) { var flash = $('.flash'); web2py.hide_flash(); @@ -525,34 +549,16 @@ if(target == undefined) { if(method == 'GET') { web2py.ajax_page('get', action, [], 'bogus', el); //fixme? - //web2py.simple_component(action, el.attr('id'), el); //not working with original } else if(method == 'POST') { - //should be web2py.ajax(action, [], ''); but it's too simple web2py.ajax_page('post', action, [], 'bogus', el); //fixme? } } else { if(method == 'GET') { web2py.ajax_page('get', action, [], target, el); - //web2py.simple_component(action, target, el); } else if(method == 'POST') { - //should be web2py.ajax(action, [], target); but it's too simple web2py.ajax_page('post', action, [], target, el); } } - /*this should happen only on ajaxsuccess - * and should block subsequent clicks until ajaxcomplete - * NB: introduce the first incompatibility because normally - * the element would be removed in either case - /* removal code moved to the ajax:success event - START - if(toremove != undefined) { - toremove = el.closest(toremove); - if(!toremove.length) { - //this enables removal of whatever selector if a closest is not found - toremove = jQuery(toremove); - } - toremove.remove(); - } - /* removal code moved to the ajax:success event - END */ }, a_handlers: function () { var el = $(document); @@ -566,7 +572,7 @@ if(toremove != undefined) { toremove = el.closest(toremove); if(!toremove.length) { - //this enables removal of whatever selector if a closest is not found + /*this enables removal of whatever selector if a closest is not found */ toremove = $(toremove); } toremove.remove(); @@ -622,8 +628,8 @@ } } - //end of functions - //main hook + /*end of functions */ + /*main hook*/ $(function () { var flash = $('.flash'); flash.hide(); @@ -641,11 +647,11 @@ ajax = jQuery.web2py.ajax; web2py_component = jQuery.web2py.component; web2py_websocket = jQuery.web2py.websocket; web2py_ajax_page = jQuery.web2py.ajax_page; -//needed for IS_STRONG(entropy) +/*needed for IS_STRONG(entropy)*/ web2py_validate_entropy = jQuery.web2py.validate_entropy; -//needed for crud.search and SQLFORM.grid's search +/*needed for crud.search and SQLFORM.grid's search*/ web2py_ajax_fields = jQuery.web2py.ajax_fields; -//used for LOAD(ajax=False) +/*used for LOAD(ajax=False)*/ web2py_trap_form = jQuery.web2py.trap_form; /*undocumented - rare*/ diff --git a/applications/welcome/static/js/web2py.js b/applications/welcome/static/js/web2py.js index d96e685d..de2a6e25 100644 --- a/applications/welcome/static/js/web2py.js +++ b/applications/welcome/static/js/web2py.js @@ -20,18 +20,22 @@ $.web2py = web2py = { popup: function (url) { + /* popup a window */ newwindow = window.open(url, 'name', 'height=400,width=600'); if(window.focus) newwindow.focus(); return false; }, collapse: function (id) { + /* toggle an element */ $('#' + id).slideToggle(); }, fade: function (id, value) { + /*fade something*/ if(value > 0) $('#' + id).hide().fadeIn('slow'); else $('#' + id).show().fadeOut('slow'); }, ajax: function (u, s, t) { + /*simple ajax function*/ query = ''; if(typeof s == "string") { d = $(s).serialize(); @@ -65,14 +69,15 @@ }); }, ajax_fields: function (target) { - /*this attaches something to a newly loaded fragment/page + /* + *this attaches something to a newly loaded fragment/page * Ideally all events should be bound to the document, so we can avoid calling * this over and over... all will be bound to the document */ var date_format = (typeof w2p_ajax_date_format != 'undefined') ? w2p_ajax_date_format : "%Y-%m-%d"; var datetime_format = (typeof w2p_ajax_datetime_format != 'undefined') ? w2p_ajax_datetime_format : "%Y-%m-%d %H:%M:%S"; $("input.date", target).each(function () { - $(this).attr('autocomplete','off'); + $(this).attr('autocomplete', 'off'); Calendar.setup({ inputField: this, ifFormat: date_format, @@ -80,7 +85,7 @@ }); }); $("input.datetime", target).each(function () { - $(this).attr('autocomplete','off'); + $(this).attr('autocomplete', 'off'); Calendar.setup({ inputField: this, ifFormat: datetime_format, @@ -89,25 +94,25 @@ }); }); $("input.time", target).each(function () { - $(this).timeEntry().attr('autocomplete','off'); + $(this).timeEntry().attr('autocomplete', 'off'); }); /*adds btn class to buttons*/ $('button', target).addClass('btn'); $('form input[type="submit"], form input[type="button"]', target).addClass('btn'); - /*no more inline javascript for PasswordWidget*/ + /* javascript for PasswordWidget*/ $('input[type=password][data-w2p_entropy]', target).each(function () { web2py.validate_entropy($(this)); }); - /*no more inline javascript for ListWidget*/ + /* javascript for ListWidget*/ $('ul.w2p_list', target).each(function () { function pe(ul, e) { var new_line = ml(ul); rel(ul); if($(e.target).parent().is(':visible')) { - //make sure we didn't delete the element before we insert after + /* make sure we didn't delete the element before we insert after */ new_line.insertAfter($(e.target).parent()); } else { - //the line we clicked on was deleted, just add to end of list + /* the line we clicked on was deleted, just add to end of list */ new_line.appendTo(ul); } new_line.find(":text").focus(); @@ -116,18 +121,20 @@ function rl(ul, e) { if($(ul).children().length > 1) { - //only remove if we have more than 1 item so the list is never empty + /* only remove if we have more than 1 item so the list is never empty */ $(e.target).parent().remove(); } } function ml(ul) { + /* clone the first field */ var line = $(ul).find("li:first").clone(true); line.find(':text').val(''); return line; } function rel(ul) { + /* keep only as many as needed*/ $(ul).find("li").each(function () { var trimmed = $.trim($(this.firstChild).val()); if(trimmed == '') $(this).remove(); @@ -147,19 +154,32 @@ }); }, ajax_init: function (target) { + /*called whenever a fragment gets loaded */ $('.hidden', target).hide(); web2py.manage_errors(target); web2py.ajax_fields(target); web2py.show_if_handler(target); web2py.component_handler(target); }, - //manage errors in forms + /* manage errors in forms */ manage_errors: function (target) { $('.error', target).hide().slideDown('slow'); - //jQuery('.error', target).hide().fadeIn('slow'); + /* jQuery('.error', target).hide().fadeIn('slow'); */ + }, + after_ajax: function (xhr) { + /* called whenever an ajax request completes */ + var command = xhr.getResponseHeader('web2py-component-command'); + var flash = xhr.getResponseHeader('web2py-component-flash'); + if(command !== null) { + eval(decodeURIComponent(command)); + } + if(flash) { + web2py.flash(decodeURIComponent(flash)) + } }, event_handlers: function () { - /* This is called once for page + /* + * This is called once for page * Ideally it should bound all the things that are needed */ var doc = $(document); @@ -167,9 +187,12 @@ var t = $(this); if(t.css('top') == '0px') t.slideUp('slow'); else t.fadeOut(); - //if I want to display a clickable something - //inside flash, I should not be prevented to follow it - //e.preventDefault(); + /* if I want to display a clickable something + * inside flash, I should not be prevented to follow it + * + * e.preventDefault(); + */ + }); doc.on('keyup', 'input.integer', function () { this.value = this.value.reverse().replace(/[^0-9\-]|\-(?=.)/g, '').reverse(); @@ -185,24 +208,21 @@ doc.ajaxSuccess(function (e, xhr) { var redirect = xhr.getResponseHeader('web2py-redirect-location'); - var command = xhr.getResponseHeader('web2py-component-command'); - var flash = xhr.getResponseHeader('web2py-component-flash'); if(redirect !== null) { window.location = redirect; }; - if(command !== null) { - eval(decodeURIComponent(command)); - } - if(flash) { - web2py.flash(decodeURIComponent(flash)) - } + /* run this here only if this Ajax request is NOT for a web2py component. */ + if(xhr.getResponseHeader('web2py-component-content') == null) { + web2py.after_ajax(xhr); + }; }); doc.ajaxError(function (e, xhr, settings, exception) { - //personally I don't like it. - //if there's an error it it flashed and can be removed - //as any other message - //doc.off('click', '.flash') + /*personally I don't like it. + *if there's an error it it flashed and can be removed + *as any other message + *doc.off('click', '.flash') + */ switch(xhr.status) { case 500: web2py.flash(ajax_error_500); @@ -211,12 +231,13 @@ }, trap_form: function (action, target) { + /* traps any LOADed form */ var disable_with_message = (typeof w2p_ajax_disable_with_message != 'undefined') ? w2p_ajax_disable_with_message : "Working..."; $('#' + target + ' form').each(function (i) { var form = $(this); form.attr('data-w2p_target', target); if(!form.hasClass('no_trap')) { - //should be there by default ? + /* should be there by default */ form.find('input[type=submit]').attr('data-w2p_disable_with', disable_with_message); form.submit(function (e) { web2py.hide_flash(); @@ -237,31 +258,30 @@ }); }, ajax_page: function (method, action, data, target, element) { - //element is a new parameter, but should be put be put in front + /* element is a new parameter, but should be put be put in front */ if(element == undefined) element = $(document); - if(web2py.fire(element, 'ajax:before')) { //test a usecase, should stop here if returns false + if(web2py.fire(element, 'ajax:before')) { /*test a usecase, should stop here if returns false */ $.ajax({ 'type': method, 'url': action, 'data': data, 'beforeSend': function (xhr, settings) { - //added xhr.setRequestHeader('web2py-component-location', document.location); xhr.setRequestHeader('web2py-component-element', target); return web2py.fire(element, 'ajax:beforeSend', [xhr, settings]); //test a usecase, should stop here if returns false }, - //added 'success': function (data, status, xhr) { - //bummer for form submissions....the element is not there after complete - //because it gets replaced by the new response.... + /*bummer for form submissions....the element is not there after complete + *because it gets replaced by the new response.... + */ element.trigger('ajax:success', [data, status, xhr]); }, - //added 'error': function (xhr, status, error) { - //bummer for form submissions....in addition to the element being not there after - //complete because it gets replaced by the new response, standard form - //handling just returns the same status code for good and bad - //form submissions (i.e. that triggered a validator error) + /*bummer for form submissions....in addition to the element being not there after + *complete because it gets replaced by the new response, standard form + *handling just returns the same status code for good and bad + *form submissions (i.e. that triggered a validator error) + */ element.trigger('ajax:error', [xhr, status, error]); }, 'complete': function (xhr, status) { @@ -275,24 +295,26 @@ web2py.trap_form(action, target); web2py.trap_link(target); web2py.ajax_init('#' + target); + web2py.after_ajax(xhr); } }); } }, component: function (action, target, timeout, times, el) { - //element is a new parameter, but should be put in front + /* element is a new parameter, but should be put in front */ $(function () { var jelement = $("#" + target); var element = jelement.get(0); var statement = "jQuery('#" + target + "').get(0).reload();"; element.reload = function () { - // Continue if times is Infinity or - // the times limit is not reached + /* Continue if times is Infinity or + * the times limit is not reached + */ if(element.reload_check()) { web2py.ajax_page('get', action, null, target, el); } - }; // reload - // Method to check timing limit + }; + /* Method to check timing limit */ element.reload_check = function () { if(jelement.hasClass('w2p_component_stop')) { clearInterval(this.timing); @@ -314,32 +336,33 @@ } } return false; - }; // reload check + }; if(!isNaN(timeout)) { element.timeout = timeout; element.reload_counter = times; if(times > 1) { - // Multiple or infinite reload - // Run first iteration + /* Multiple or infinite reload + * Run first iteration + */ web2py.ajax_page('get', action, null, target, el); element.run_once = false; element.timing = setInterval(statement, timeout); element.reload_counter -= 1; } else if(times == 1) { - // Run once with timeout + /* Run once with timeout */ element.run_once = true; element.setTimeout = setTimeout; element.timing = setTimeout(statement, timeout); } } else { - // run once (no timeout specified) + /* run once (no timeout specified) */ element.reload_counter = Infinity; web2py.ajax_page('get', action, null, target, el); } }); }, calc_entropy: function (mystring) { - //calculate a simple entropy for a given string + /* calculate a simple entropy for a given string */ var csets = new Array( 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789', '!@#$\%^&*()', '~`-_=+[]{}\|;:\'",.<>?/', @@ -347,7 +370,7 @@ var score = 0, other = {}, seen = {}, lastset = null, mystringlist = mystring.split(''); - for(var i = 0; i < mystringlist.length; i++) { // classify this character + for(var i = 0; i < mystringlist.length; i++) { /* classify this character */ var c = mystringlist[i], inset = 5; for(var j = 0; j < csets.length; j++) @@ -355,7 +378,7 @@ inset = j; break; } - //calculate effect of character on alphabet size + /*calculate effect of character on alphabet size */ if(!(inset in seen)) { seen[inset] = 1; score += csets[inset].length; @@ -372,7 +395,6 @@ return Math.round(entropy * 100) / 100 }, validate_entropy: function (myfield, req_entropy) { - //added if(myfield.data('w2p_entropy') != undefined) req_entropy = myfield.data('w2p_entropy'); var validator = function () { var v = (web2py.calc_entropy(myfield.val()) || 0) / req_entropy; @@ -402,23 +424,23 @@ ws.onopen = onopen ? onopen : (function () {}); ws.onmessage = onmessage; ws.onclose = onclose ? onclose : (function () {}); - return true; // supported - } else return false; // not supported + return true; /* supported */ + } else return false; /* not supported */ }, /* new from here */ - // Form input elements bound by jquery-ujs + /* Form input elements bound by jquery-uj */ formInputClickSelector: 'input[type=submit], input[type=image], button[type=submit], button:not([type])', - // Form input elements disabled during form submission + /* Form input elements disabled during form submission */ disableSelector: 'input, button, textarea, select', - // Form input elements re-enabled after form submission + /* Form input elements re-enabled after form submission */ enableSelector: 'input:disabled, button:disabled, textarea:disabled, select:disabled', - // Triggers an event on an element and returns false if the event result is false + /* Triggers an event on an element and returns false if the event result is false */ fire: function (obj, name, data) { var event = $.Event(name); obj.trigger(event, data); return event.result !== false; }, - // Helper function, needed to provide consistent behavior in IE + /* Helper function, needed to provide consistent behavior in IE */ stopEverything: function (e) { $(e.target).trigger('w2p:everythingStopped'); e.stopImmediatePropagation(); @@ -427,42 +449,42 @@ confirm: function (message) { return confirm(message); }, - // replace element's html with the 'data-disable-with' after storing original html - // and prevent clicking on it + /* replace element's html with the 'data-disable-with' after storing original html + * and prevent clicking on it */ disableElement: function (el) { el.addClass('disabled'); var method = el.prop('type') == 'submit' ? 'val' : 'html'; var disable_with_message = (typeof w2p_ajax_disable_with_message != 'undefined') ? w2p_ajax_disable_with_message : "Working..."; - // store enabled state + /*store enabled state*/ el.data('w2p:enable-with', el[method]()); /* little addition by default*/ if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) { el.data('w2p_disable_with', disable_with_message); } - // set to disabled state + /* set to disabled state*/ el[method](el.data('w2p_disable_with')); - el.bind('click.w2pDisable', function (e) { // prevent further clicking + el.bind('click.w2pDisable', function (e) { /* prevent further clicking*/ return web2py.stopEverything(e); }); }, - // restore element to its original state which was disabled by 'disableElement' above + /* restore element to its original state which was disabled by 'disableElement' above*/ enableElement: function (el) { var method = el.prop('type') == 'submit' ? 'val' : 'html'; if(el.data('w2p:enable-with') !== undefined) { - // set to old enabled state + /* set to old enabled state */ el[method](el.data('w2p:enable-with')); - el.removeData('w2p:enable-with'); // clean up cache + el.removeData('w2p:enable-with'); } el.removeClass('disabled'); - el.unbind('click.w2pDisable'); // enable element + el.unbind('click.w2pDisable'); }, - //convenience wrapper, internal use only + /*convenience wrapper, internal use only */ simple_component: function (action, target, element) { web2py.component(action, target, 0, 1, element); }, - //helper for flash messages + /*helper for flash messages*/ flash: function (message, status) { var flash = $('.flash'); web2py.hide_flash(); @@ -527,34 +549,16 @@ if(target == undefined) { if(method == 'GET') { web2py.ajax_page('get', action, [], 'bogus', el); //fixme? - //web2py.simple_component(action, el.attr('id'), el); //not working with original } else if(method == 'POST') { - //should be web2py.ajax(action, [], ''); but it's too simple web2py.ajax_page('post', action, [], 'bogus', el); //fixme? } } else { if(method == 'GET') { web2py.ajax_page('get', action, [], target, el); - //web2py.simple_component(action, target, el); } else if(method == 'POST') { - //should be web2py.ajax(action, [], target); but it's too simple web2py.ajax_page('post', action, [], target, el); } } - /*this should happen only on ajaxsuccess - * and should block subsequent clicks until ajaxcomplete - * NB: introduce the first incompatibility because normally - * the element would be removed in either case - /* removal code moved to the ajax:success event - START - if(toremove != undefined) { - toremove = el.closest(toremove); - if(!toremove.length) { - //this enables removal of whatever selector if a closest is not found - toremove = jQuery(toremove); - } - toremove.remove(); - } - /* removal code moved to the ajax:success event - END */ }, a_handlers: function () { var el = $(document); @@ -568,7 +572,7 @@ if(toremove != undefined) { toremove = el.closest(toremove); if(!toremove.length) { - //this enables removal of whatever selector if a closest is not found + /*this enables removal of whatever selector if a closest is not found */ toremove = $(toremove); } toremove.remove(); @@ -624,8 +628,8 @@ } } - //end of functions - //main hook + /*end of functions */ + /*main hook*/ $(function () { var flash = $('.flash'); flash.hide(); @@ -643,11 +647,11 @@ ajax = jQuery.web2py.ajax; web2py_component = jQuery.web2py.component; web2py_websocket = jQuery.web2py.websocket; web2py_ajax_page = jQuery.web2py.ajax_page; -//needed for IS_STRONG(entropy) +/*needed for IS_STRONG(entropy)*/ web2py_validate_entropy = jQuery.web2py.validate_entropy; -//needed for crud.search and SQLFORM.grid's search +/*needed for crud.search and SQLFORM.grid's search*/ web2py_ajax_fields = jQuery.web2py.ajax_fields; -//used for LOAD(ajax=False) +/*used for LOAD(ajax=False)*/ web2py_trap_form = jQuery.web2py.trap_form; /*undocumented - rare*/