From 570a913d56ba10b68f6be9fed6f4c562827f3236 Mon Sep 17 00:00:00 2001 From: Akaryatrh Date: Wed, 17 Jul 2013 08:34:11 +0200 Subject: [PATCH 1/5] Filled read me --- README | 0 README.md | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed34f9a --- /dev/null +++ b/README.md @@ -0,0 +1,91 @@ +#AJAX Queue/Cache/Abort/Block Manager v. 3.0 +Helps you to manage AJAX requests and responses (i.e. abort requests, block requests, order requests). It is inspired by the AJAX Queue Plugin and the AjaxQueue document in the jQuery-Wiki. + +$.manageAjax.create (uniqueName, options) +Creates a new ajaxmanager and returns it. + +##Takes a list of options: + +* normal [jQuery-Ajax-Options](http://docs.jquery.com/Ajax/jQuery.ajax#options) +* queue: (true|false|'clear') the queue-type specifies the queue-behaviour. The clear option clears the queue, before it adds a new ajax-task to the queue (similiar to: last in first out) +* abortOld (true|false): aborts all "older" requests, if there is a response to a newer request +* abortIsNoSuccess: (true|false): jQuery 1.4 calls the success-callback, if an XHR was aborted. If this option is set to true. Only the complete - callback will be called with status 'abort'. +* abort: (function): callback, that will be called, if a XHR is aborted. +* beforeCreate ([function]): a function that will be called, before the XHR-object is created. If you return false, the XHR won´t be created. +* maxRequests: (number (1)) limits the number of simultaneous request in the queue. queue-option must be true or 'clear'. +* preventDoubleRequests (true|false): prevents multiple equal requests (compares url, data and type) +* cacheResponse (true|false): caches the response data of succesfull responses (not the xhr-object!) +* domCompleteTrigger (false| DOM-Element, DOMNodelist, Selector or jQuery-List). Triggers the events uniqueName + "DOMComplete" and "DOMComplete" on the specified element. +* domSuccessTrigger (false | DOM-Element, DOMNodelist, Selector or jQuery-List). Triggers the events uniqueName + "DOMSuccess" and "DOMSuccess" on the specified element. + + +##Your constructed ajaxmanager knows the following methods: + +* add: ([uniqueName], options) returns an id of your XHR object and takes the following options: +* normal [jQuery-Ajax-Options](http://docs.jquery.com/Ajax/jQuery.ajax#options) +* all additional ajaxmanager options, but not 'maxRequests' and 'queue'. +* clear: ([uniqueName], [shouldAbort: true|false]) Clears the ajax queue of waiting requests. If the second parameter is true, all requests in proccess will be aborted, too. +* abort: ([uniqueName], [id]) Aborts all managed XHR-requests. If you pass the optional index number of your XHR object only this XHR will be aborted. +* getXHR: ([uniqueName], id) Returns the XHR-Object, if it is already constructed or the queue-function + + +##Note: + +First you have to construct/configure a new Ajaxmanager + +//create an ajaxmanager named someAjaxProfileName + var someManagedAjax = $.manageAjax.create('someAjaxProfileName', { queue: true, cacheResponse: true }); + +You have two different ways to call your methods (don´t mix them). + +Calling Ajaxmanager with uniqueName and add an ajaxrequest + $.manageAjax.add('someAjaxProfileName', { success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); + +Calling Ajaxmanager with the returned ajaxmanger-Object and add an ajaxrequest with the returned object + $.manageAjax.add({ success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); + +Example: +//Create an ajaxmanager named cacheQueue + var ajaxManager = $.manageAjax.create('cacheQueue', { queue: true, cacheResponse: true }); //and add an ajaxrequest with the returned object ajaxManager.add({ success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); + +//Or only with the uniqueName parameter +// Generate an ajaxmanger named clearQueue + $.manageAjax.create('clearQueue', {queue: 'clear', maxRequests: 2}); //and add an ajaxrequest with the name parameter $.manageAjax.add('clearQueue', { success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); + + +// Destroys an existing Ajaxmanager. Any requests in progress are aborted and waiting requests are cleared. + $.manageAjax.destroy (uniqueName) + +##Events/Callbacks: + +The ajaxmanager adds some new events or enhances some existing callbacks. +------------------------------------------------------------------------------------------------------------------------------------------------------- +name | arguments | new/enhanced +------------------------------------------------------------------------------------------------------------------------------------------------------- +beforeCreate (local) | XHR-ID, options | new +------------------------------------------------------------------------------------------------------------------------------------------------------- +beforeSend (local) | XMLHttpRequest, options | enhanced: options arguments is passed +------------------------------------------------------------------------------------------------------------------------------------------------------- +managerName + 'AjaxStart' (global) | event | new +------------------------------------------------------------------------------------------------------------------------------------------------------- +complete (local) | xhr*, status, options | enhanced: the options arguments is additionally passed. +------------------------------------------------------------------------------------------------------------------------------------------------------- +managerName + 'AjaxComplete' (global) | event, xhr*, status, options | new +------------------------------------------------------------------------------------------------------------------------------------------------------- +managerName + 'DOMComplete' (DOM-Event**) | event, xhr*, status, options | new +------------------------------------------------------------------------------------------------------------------------------------------------------- +'DOMComplete' (DOM-Event**) | event, xhr*, status, options | new +------------------------------------------------------------------------------------------------------------------------------------------------------- +success (local) | data, textStatus, xhr*, options | enhanced: the options arguments is additionally passed. +------------------------------------------------------------------------------------------------------------------------------------------------------- +managerName + 'AjaxSuccess' (global) | event, xhr, options, data | new +------------------------------------------------------------------------------------------------------------------------------------------------------- +managerName + 'DOMSuccess' (DOM-Event**) | event, data, options | new +------------------------------------------------------------------------------------------------------------------------------------------------------- +'DOMSuccess' (DOM-Event**) | event, data, options | new +------------------------------------------------------------------------------------------------------------------------------------------------------- +managerName + 'AjaxStop' (global) | event | new +------------------------------------------------------------------------------------------------------------------------------------------------------- + +*Note: If the cacheResponse - option is true, the xhr-argument can be an empty object. +**Note: You need to configure 'domCompleteTrigger' / 'domSuccessTrigger' to trigger these events. \ No newline at end of file From f8648fc2a65ea1515dc60c10231768c898879db4 Mon Sep 17 00:00:00 2001 From: Akaryatrh Date: Wed, 17 Jul 2013 08:35:42 +0200 Subject: [PATCH 2/5] delete table style --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ed34f9a..2220c49 100644 --- a/README.md +++ b/README.md @@ -59,33 +59,33 @@ Example: ##Events/Callbacks: The ajaxmanager adds some new events or enhances some existing callbacks. -------------------------------------------------------------------------------------------------------------------------------------------------------- + name | arguments | new/enhanced -------------------------------------------------------------------------------------------------------------------------------------------------------- + beforeCreate (local) | XHR-ID, options | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + beforeSend (local) | XMLHttpRequest, options | enhanced: options arguments is passed -------------------------------------------------------------------------------------------------------------------------------------------------------- + managerName + 'AjaxStart' (global) | event | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + complete (local) | xhr*, status, options | enhanced: the options arguments is additionally passed. -------------------------------------------------------------------------------------------------------------------------------------------------------- + managerName + 'AjaxComplete' (global) | event, xhr*, status, options | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + managerName + 'DOMComplete' (DOM-Event**) | event, xhr*, status, options | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + 'DOMComplete' (DOM-Event**) | event, xhr*, status, options | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + success (local) | data, textStatus, xhr*, options | enhanced: the options arguments is additionally passed. -------------------------------------------------------------------------------------------------------------------------------------------------------- + managerName + 'AjaxSuccess' (global) | event, xhr, options, data | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + managerName + 'DOMSuccess' (DOM-Event**) | event, data, options | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + 'DOMSuccess' (DOM-Event**) | event, data, options | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + managerName + 'AjaxStop' (global) | event | new -------------------------------------------------------------------------------------------------------------------------------------------------------- + *Note: If the cacheResponse - option is true, the xhr-argument can be an empty object. **Note: You need to configure 'domCompleteTrigger' / 'domSuccessTrigger' to trigger these events. \ No newline at end of file From 5bd97e08f7cbfcbca0e4883b539d589650c5ffd5 Mon Sep 17 00:00:00 2001 From: Akaryatrh Date: Wed, 17 Jul 2013 08:42:14 +0200 Subject: [PATCH 3/5] Simplify events lists and add code formatting --- README.md | 58 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 2220c49..995be07 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ #AJAX Queue/Cache/Abort/Block Manager v. 3.0 Helps you to manage AJAX requests and responses (i.e. abort requests, block requests, order requests). It is inspired by the AJAX Queue Plugin and the AjaxQueue document in the jQuery-Wiki. -$.manageAjax.create (uniqueName, options) Creates a new ajaxmanager and returns it. +``` +$.manageAjax.create (uniqueName, options) + +``` + ##Takes a list of options: @@ -33,58 +37,72 @@ Creates a new ajaxmanager and returns it. First you have to construct/configure a new Ajaxmanager -//create an ajaxmanager named someAjaxProfileName +Create an ajaxmanager named someAjaxProfileName +``` var someManagedAjax = $.manageAjax.create('someAjaxProfileName', { queue: true, cacheResponse: true }); +``` You have two different ways to call your methods (don´t mix them). Calling Ajaxmanager with uniqueName and add an ajaxrequest +``` $.manageAjax.add('someAjaxProfileName', { success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); +``` Calling Ajaxmanager with the returned ajaxmanger-Object and add an ajaxrequest with the returned object +``` $.manageAjax.add({ success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); +``` Example: -//Create an ajaxmanager named cacheQueue + +Create an ajaxmanager named cacheQueue +``` var ajaxManager = $.manageAjax.create('cacheQueue', { queue: true, cacheResponse: true }); //and add an ajaxrequest with the returned object ajaxManager.add({ success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); +``` -//Or only with the uniqueName parameter -// Generate an ajaxmanger named clearQueue +Or only with the uniqueName parameter +Generate an ajaxmanger named clearQueue +``` $.manageAjax.create('clearQueue', {queue: 'clear', maxRequests: 2}); //and add an ajaxrequest with the name parameter $.manageAjax.add('clearQueue', { success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); - +``` -// Destroys an existing Ajaxmanager. Any requests in progress are aborted and waiting requests are cleared. +Destroys an existing Ajaxmanager. Any requests in progress are aborted and waiting requests are cleared. +``` $.manageAjax.destroy (uniqueName) +``` + + ##Events/Callbacks: The ajaxmanager adds some new events or enhances some existing callbacks. -name | arguments | new/enhanced +###NAME >> ARGUMENTS -beforeCreate (local) | XHR-ID, options | new +* beforeCreate (local) >> XHR-ID, options -beforeSend (local) | XMLHttpRequest, options | enhanced: options arguments is passed +* beforeSend (local) >> XMLHttpRequest, options -managerName + 'AjaxStart' (global) | event | new +* managerName + 'AjaxStart' (global) >> event -complete (local) | xhr*, status, options | enhanced: the options arguments is additionally passed. +* complete (local) >> xhr*, status, options -managerName + 'AjaxComplete' (global) | event, xhr*, status, options | new +* managerName + 'AjaxComplete' (global) >> event, xhr*, status, options -managerName + 'DOMComplete' (DOM-Event**) | event, xhr*, status, options | new +* managerName + 'DOMComplete' (DOM-Event**) >> event, xhr*, status, options -'DOMComplete' (DOM-Event**) | event, xhr*, status, options | new +* 'DOMComplete' (DOM-Event**) >> event, xhr*, status, options -success (local) | data, textStatus, xhr*, options | enhanced: the options arguments is additionally passed. +* success (local) >> data, textStatus, xhr*, options -managerName + 'AjaxSuccess' (global) | event, xhr, options, data | new +* managerName + 'AjaxSuccess' (global) >> event, xhr, options, data -managerName + 'DOMSuccess' (DOM-Event**) | event, data, options | new +* managerName + 'DOMSuccess' (DOM-Event**) >> event, data, options -'DOMSuccess' (DOM-Event**) | event, data, options | new +* 'DOMSuccess' (DOM-Event**) >> event, data, options -managerName + 'AjaxStop' (global) | event | new +* managerName + 'AjaxStop' (global) >> event *Note: If the cacheResponse - option is true, the xhr-argument can be an empty object. From d84bd9f8b95289e69935bd6f58aeb785949faaf6 Mon Sep 17 00:00:00 2001 From: Akaryatrh Date: Wed, 17 Jul 2013 20:08:11 +0200 Subject: [PATCH 4/5] Code examples formatting --- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 995be07..2a02da2 100644 --- a/README.md +++ b/README.md @@ -37,38 +37,90 @@ $.manageAjax.create (uniqueName, options) First you have to construct/configure a new Ajaxmanager -Create an ajaxmanager named someAjaxProfileName ``` - var someManagedAjax = $.manageAjax.create('someAjaxProfileName', { queue: true, cacheResponse: true }); + // Create an ajaxmanager named someAjaxProfileName + var someManagedAjax = $.manageAjax.create('someAjaxProfileName', + { + queue: true, + cacheResponse: true + } + ); ``` You have two different ways to call your methods (don´t mix them). -Calling Ajaxmanager with uniqueName and add an ajaxrequest + ``` - $.manageAjax.add('someAjaxProfileName', { success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); + // Calling Ajaxmanager with uniqueName and add an ajaxrequest + $.manageAjax.add('someAjaxProfileName', + { + success: function(html) { + $('ul').append('
  • '+html+'
  • '); + }, + url: 'test.html' + } + ); ``` -Calling Ajaxmanager with the returned ajaxmanger-Object and add an ajaxrequest with the returned object ``` - $.manageAjax.add({ success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); + // Calling Ajaxmanager with the returned ajaxmanger-Object + // and add an ajaxrequest with the returned object + $.manageAjax.add( + { + success: function(html) { + $('ul').append('
  • '+html+'
  • '); + }, + url: 'test.html' + } + ); ``` -Example: +##Examples : -Create an ajaxmanager named cacheQueue ``` - var ajaxManager = $.manageAjax.create('cacheQueue', { queue: true, cacheResponse: true }); //and add an ajaxrequest with the returned object ajaxManager.add({ success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); + // Create an ajaxmanager named cacheQueue + var ajaxManager = $.manageAjax.create('cacheQueue', + { + queue: true, + cacheResponse: true + } + ); + // and add an ajaxrequest with the returned object + ajaxManager.add( + { + success: function(html) { + $('ul').append('
  • '+html+'
  • '); + }, + url: 'test.html' + } + ); ``` Or only with the uniqueName parameter -Generate an ajaxmanger named clearQueue + ``` - $.manageAjax.create('clearQueue', {queue: 'clear', maxRequests: 2}); //and add an ajaxrequest with the name parameter $.manageAjax.add('clearQueue', { success: function(html) { $('ul').append('
  • '+html+'
  • '); }, url: 'test.html' }); + // Generate an ajaxmanger named clearQueue + $.manageAjax.create('clearQueue', + { + queue: 'clear', + maxRequests: 2 + } + ); + // and add an ajaxrequest with the name parameter + $.manageAjax.add('clearQueue', + { + success: function(html) { + $('ul').append('
  • '+html+'
  • '); + }, + url: 'test.html' + } + ); ``` -Destroys an existing Ajaxmanager. Any requests in progress are aborted and waiting requests are cleared. + ``` + // Destroys an existing Ajaxmanager. + // Any requests in progress are aborted and waiting requests are cleared. $.manageAjax.destroy (uniqueName) ``` From 73f38185fff9c95e62f4c74099de53c57664f2bd Mon Sep 17 00:00:00 2001 From: Akaryatrh Date: Wed, 17 Jul 2013 20:44:16 +0200 Subject: [PATCH 5/5] reduce font sizes --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2a02da2..c933993 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -#AJAX Queue/Cache/Abort/Block Manager v. 3.0 +##AJAX Queue/Cache/Abort/Block Manager v. 3.0 Helps you to manage AJAX requests and responses (i.e. abort requests, block requests, order requests). It is inspired by the AJAX Queue Plugin and the AjaxQueue document in the jQuery-Wiki. -Creates a new ajaxmanager and returns it. -``` -$.manageAjax.create (uniqueName, options) +``` + //Creates a new ajaxmanager and returns it. + $.manageAjax.create(uniqueName, options); ``` -##Takes a list of options: +###Takes a list of options: * normal [jQuery-Ajax-Options](http://docs.jquery.com/Ajax/jQuery.ajax#options) * queue: (true|false|'clear') the queue-type specifies the queue-behaviour. The clear option clears the queue, before it adds a new ajax-task to the queue (similiar to: last in first out) @@ -23,7 +23,7 @@ $.manageAjax.create (uniqueName, options) * domSuccessTrigger (false | DOM-Element, DOMNodelist, Selector or jQuery-List). Triggers the events uniqueName + "DOMSuccess" and "DOMSuccess" on the specified element. -##Your constructed ajaxmanager knows the following methods: +###Your constructed ajaxmanager knows the following methods: * add: ([uniqueName], options) returns an id of your XHR object and takes the following options: * normal [jQuery-Ajax-Options](http://docs.jquery.com/Ajax/jQuery.ajax#options) @@ -33,7 +33,7 @@ $.manageAjax.create (uniqueName, options) * getXHR: ([uniqueName], id) Returns the XHR-Object, if it is already constructed or the queue-function -##Note: +###Note: First you have to construct/configure a new Ajaxmanager @@ -130,7 +130,7 @@ Or only with the uniqueName parameter The ajaxmanager adds some new events or enhances some existing callbacks. -###NAME >> ARGUMENTS +#####NAME >> ARGUMENTS * beforeCreate (local) >> XHR-ID, options