From 5176890ff3fe82b0e4aacee994dd04f7aa394a0f Mon Sep 17 00:00:00 2001 From: ilvalle Date: Mon, 9 Sep 2013 08:43:07 +0200 Subject: [PATCH] updated web2py.js for all apps (examples and admin) --- applications/admin/static/js/web2py.js | 14 +++++++------- applications/examples/static/js/web2py.js | 14 +++++++------- applications/welcome/static/js/web2py.js | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/applications/admin/static/js/web2py.js b/applications/admin/static/js/web2py.js index 0c171be3..d5545fa1 100644 --- a/applications/admin/static/js/web2py.js +++ b/applications/admin/static/js/web2py.js @@ -277,7 +277,7 @@ ajax_page: function (method, action, data, target, element) { /* 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', null, target )) { /*test a usecase, should stop here if returns false */ $.ajax({ 'type': method, 'url': action, @@ -285,13 +285,13 @@ 'beforeSend': function (xhr, settings) { 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 + return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false }, 'success': function (data, status, xhr) { /*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]); + web2py.fire(element, 'ajax:success', [data, status, xhr], target); }, 'error': function (xhr, status, error) { /*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 *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) { - element.trigger('ajax:complete', [xhr, status]); + web2py.fire(element, 'ajax:complete', [xhr, status], target); var html = xhr.responseText; var content = xhr.getResponseHeader('web2py-component-content'); var t = $('#' + target); @@ -452,8 +452,8 @@ /* 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 */ - fire: function (obj, name, data) { - var event = $.Event(name); + fire: function (obj, type, data, target) { + var event = $.Event(type, {'containerTarget': $('#' + target)[0]}); obj.trigger(event, data); return event.result !== false; }, diff --git a/applications/examples/static/js/web2py.js b/applications/examples/static/js/web2py.js index 0c171be3..d5545fa1 100644 --- a/applications/examples/static/js/web2py.js +++ b/applications/examples/static/js/web2py.js @@ -277,7 +277,7 @@ ajax_page: function (method, action, data, target, element) { /* 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', null, target )) { /*test a usecase, should stop here if returns false */ $.ajax({ 'type': method, 'url': action, @@ -285,13 +285,13 @@ 'beforeSend': function (xhr, settings) { 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 + return web2py.fire(element, 'ajax:beforeSend', [xhr, settings], target); //test a usecase, should stop here if returns false }, 'success': function (data, status, xhr) { /*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]); + web2py.fire(element, 'ajax:success', [data, status, xhr], target); }, 'error': function (xhr, status, error) { /*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 *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) { - element.trigger('ajax:complete', [xhr, status]); + web2py.fire(element, 'ajax:complete', [xhr, status], target); var html = xhr.responseText; var content = xhr.getResponseHeader('web2py-component-content'); var t = $('#' + target); @@ -452,8 +452,8 @@ /* 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 */ - fire: function (obj, name, data) { - var event = $.Event(name); + fire: function (obj, type, data, target) { + var event = $.Event(type, {'containerTarget': $('#' + target)[0]}); obj.trigger(event, data); return event.result !== false; }, diff --git a/applications/welcome/static/js/web2py.js b/applications/welcome/static/js/web2py.js index 818f3f34..d5545fa1 100644 --- a/applications/welcome/static/js/web2py.js +++ b/applications/welcome/static/js/web2py.js @@ -291,7 +291,7 @@ /*bummer for form submissions....the element is not there after complete *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) { /*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 *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) { web2py.fire(element, 'ajax:complete', [xhr, status], target);