updated web2py.js for all apps (examples and admin)

This commit is contained in:
ilvalle
2013-09-09 08:43:07 +02:00
parent 029915f2f9
commit 5176890ff3
3 changed files with 16 additions and 16 deletions
+7 -7
View File
@@ -277,7 +277,7 @@
ajax_page: function (method, action, data, target, element) { 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(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', null, target )) { /*test a usecase, should stop here if returns false */
$.ajax({ $.ajax({
'type': method, 'type': method,
'url': action, 'url': action,
@@ -285,13 +285,13 @@
'beforeSend': function (xhr, settings) { 'beforeSend': function (xhr, settings) {
xhr.setRequestHeader('web2py-component-location', document.location); xhr.setRequestHeader('web2py-component-location', document.location);
xhr.setRequestHeader('web2py-component-element', target); xhr.setRequestHeader('web2py-component-element', target);
return web2py.fire(element, 'ajax:beforeSend', [xhr, settings]); //test a usecase, should stop here if returns false return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false
}, },
'success': function (data, status, xhr) { 'success': function (data, status, xhr) {
/*bummer for form submissions....the element is not there after complete /*bummer for form submissions....the element is not there after complete
*because it gets replaced by the new response.... *because it gets replaced by the new response....
*/ */
element.trigger('ajax:success', [data, status, xhr]); web2py.fire(element, 'ajax:success', [data, status, xhr], target);
}, },
'error': function (xhr, status, error) { 'error': function (xhr, status, error) {
/*bummer for form submissions....in addition to the element being not there after /*bummer for form submissions....in addition to the element being not there after
@@ -299,10 +299,10 @@
*handling just returns the same status code for good and bad *handling just returns the same status code for good and bad
*form submissions (i.e. that triggered a validator error) *form submissions (i.e. that triggered a validator error)
*/ */
element.trigger('ajax:error', [xhr, status, error]); web2py.fire(element, 'ajax:error', [xhr, status, error], target);
}, },
'complete': function (xhr, status) { 'complete': function (xhr, status) {
element.trigger('ajax:complete', [xhr, status]); web2py.fire(element, 'ajax:complete', [xhr, status], target);
var html = xhr.responseText; var html = xhr.responseText;
var content = xhr.getResponseHeader('web2py-component-content'); var content = xhr.getResponseHeader('web2py-component-content');
var t = $('#' + target); var t = $('#' + target);
@@ -452,8 +452,8 @@
/* 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', 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) { fire: function (obj, type, data, target) {
var event = $.Event(name); var event = $.Event(type, {'containerTarget': $('#' + target)[0]});
obj.trigger(event, data); obj.trigger(event, data);
return event.result !== false; return event.result !== false;
}, },
+7 -7
View File
@@ -277,7 +277,7 @@
ajax_page: function (method, action, data, target, element) { 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(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', null, target )) { /*test a usecase, should stop here if returns false */
$.ajax({ $.ajax({
'type': method, 'type': method,
'url': action, 'url': action,
@@ -285,13 +285,13 @@
'beforeSend': function (xhr, settings) { 'beforeSend': function (xhr, settings) {
xhr.setRequestHeader('web2py-component-location', document.location); xhr.setRequestHeader('web2py-component-location', document.location);
xhr.setRequestHeader('web2py-component-element', target); xhr.setRequestHeader('web2py-component-element', target);
return web2py.fire(element, 'ajax:beforeSend', [xhr, settings]); //test a usecase, should stop here if returns false return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false
}, },
'success': function (data, status, xhr) { 'success': function (data, status, xhr) {
/*bummer for form submissions....the element is not there after complete /*bummer for form submissions....the element is not there after complete
*because it gets replaced by the new response.... *because it gets replaced by the new response....
*/ */
element.trigger('ajax:success', [data, status, xhr]); web2py.fire(element, 'ajax:success', [data, status, xhr], target);
}, },
'error': function (xhr, status, error) { 'error': function (xhr, status, error) {
/*bummer for form submissions....in addition to the element being not there after /*bummer for form submissions....in addition to the element being not there after
@@ -299,10 +299,10 @@
*handling just returns the same status code for good and bad *handling just returns the same status code for good and bad
*form submissions (i.e. that triggered a validator error) *form submissions (i.e. that triggered a validator error)
*/ */
element.trigger('ajax:error', [xhr, status, error]); web2py.fire(element, 'ajax:error', [xhr, status, error], target);
}, },
'complete': function (xhr, status) { 'complete': function (xhr, status) {
element.trigger('ajax:complete', [xhr, status]); web2py.fire(element, 'ajax:complete', [xhr, status], target);
var html = xhr.responseText; var html = xhr.responseText;
var content = xhr.getResponseHeader('web2py-component-content'); var content = xhr.getResponseHeader('web2py-component-content');
var t = $('#' + target); var t = $('#' + target);
@@ -452,8 +452,8 @@
/* 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', 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) { fire: function (obj, type, data, target) {
var event = $.Event(name); var event = $.Event(type, {'containerTarget': $('#' + target)[0]});
obj.trigger(event, data); obj.trigger(event, data);
return event.result !== false; return event.result !== false;
}, },
+2 -2
View File
@@ -291,7 +291,7 @@
/*bummer for form submissions....the element is not there after complete /*bummer for form submissions....the element is not there after complete
*because it gets replaced by the new response.... *because it gets replaced by the new response....
*/ */
web2py.fire(element, 'ajax:success', [xhr, status], target); web2py.fire(element, 'ajax:success', [data, status, xhr], target);
}, },
'error': function (xhr, status, error) { 'error': function (xhr, status, error) {
/*bummer for form submissions....in addition to the element being not there after /*bummer for form submissions....in addition to the element being not there after
@@ -299,7 +299,7 @@
*handling just returns the same status code for good and bad *handling just returns the same status code for good and bad
*form submissions (i.e. that triggered a validator error) *form submissions (i.e. that triggered a validator error)
*/ */
web2py.fire(element, 'ajax:error', [xhr, status], target); web2py.fire(element, 'ajax:error', [xhr, status, error], target);
}, },
'complete': function (xhr, status) { 'complete': function (xhr, status) {
web2py.fire(element, 'ajax:complete', [xhr, status], target); web2py.fire(element, 'ajax:complete', [xhr, status], target);