Permalink
Browse files

ajaxQueue initial commit

  • Loading branch information...
gnarf committed Jan 16, 2013
0 parents commit 22adb7531f45c4bc37b5a6a4f8984cee6e82e12a
@@ -0,0 +1,2 @@
+node_modules
+dist/.sizecache.json
@@ -0,0 +1,14 @@
+{
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "undef": true,
+ "boss": true,
+ "eqnull": true,
+ "node": true,
+ "es5": true
+}
@@ -0,0 +1,109 @@
+'use strict';
+
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ // Metadata.
+ pkg: grunt.file.readJSON("package.json"),
+ // Task configuration.
+ concat: {
+ options: {
+ banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
+ '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
+ '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
+ '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
+ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n'
+ },
+ dist: {
+ src: ['src/jquery.ajaxQueue.js'],
+ dest: 'dist/jquery.ajaxQueue.js'
+ },
+ },
+ uglify: {
+ options: {
+ banner: "/*! jQuery Ajax Queue v<%= pkg.version %> | (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %> | Licensed <%= _.pluck(pkg.licenses, \"type\").join(\", \") %> */\n",
+ sourceMap: "dist/jquery.ajaxQueue.min.map",
+ beautify: {
+ ascii_only: true
+ }
+ },
+ all: {
+ files: {
+ "dist/jquery.ajaxQueue.min.js": ['src/jquery.ajaxQueue.js']
+ }
+ },
+ },
+ qunit: {
+ files: ['test/**/*.html']
+ },
+ jshint: {
+ gruntfile: {
+ options: {
+ jshintrc: '.jshintrc'
+ },
+ src: ['Gruntfile.js']
+ },
+ src: {
+ options: {
+ jshintrc: 'src/.jshintrc'
+ },
+ src: ['src/**/*.js']
+ },
+ test: {
+ options: {
+ jshintrc: 'test/.jshintrc'
+ },
+ src: ['test/**/*.js']
+ },
+ },
+ watch: {
+ gruntfile: {
+ files: '<config:jshint.gruntfile.src>',
+ tasks: ['jshint:gruntfile']
+ },
+ src: {
+ files: '<config:jshint.src.src>',
+ tasks: ['jshint:src', 'qunit']
+ },
+ test: {
+ files: '<config:jshint.test.src>',
+ tasks: ['jshint:test', 'qunit']
+ },
+ },
+ });
+
+ // Default task.
+ grunt.loadNpmTasks("grunt-contrib-concat");
+ grunt.loadNpmTasks("grunt-contrib-watch");
+ grunt.loadNpmTasks("grunt-contrib-jshint");
+ grunt.loadNpmTasks("grunt-contrib-uglify");
+ grunt.loadNpmTasks("grunt-contrib-qunit");
+ grunt.registerTask('default', ['jshint', 'concat', 'qunit', 'manifest', 'concat', 'uglify']);
+
+ grunt.registerTask( "manifest", function() {
+ var pkg = grunt.config( "pkg" );
+ grunt.file.write( "ajaxQueue.jquery.json", JSON.stringify({
+ name: "ajaxQueue",
+ title: pkg.title,
+ description: pkg.description,
+ keywords: pkg.keywords,
+ version: pkg.version,
+ author: {
+ name: pkg.author.name,
+ url: pkg.author.url.replace( "master", pkg.version )
+ },
+ maintainers: pkg.maintainers,
+ licenses: pkg.licenses.map(function( license ) {
+ license.url = license.url.replace( "master", pkg.version );
+ return license;
+ }),
+ bugs: pkg.bugs,
+ homepage: pkg.homepage,
+ docs: pkg.homepage,
+ dependencies: {
+ jquery: ">=1.8"
+ }
+ }, null, "\t" ) );
+ });
+};
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Corey Frang
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
+{
+ "name": "ajaxQueue",
+ "title": "jQuery Ajax Queue",
+ "description": "A simple queue for ajax requests",
+ "keywords": [
+ "animation",
+ "effects",
+ "easing"
+ ],
+ "version": "0.0.0pre",
+ "author": {
+ "name": "Corey Frang",
+ "url": "https://github.com/gnarf37"
+ },
+ "maintainers": [
+ {
+ "name": "Corey Frang",
+ "email": "gnarf37@gmail.com",
+ "url": "http://gnarf.net"
+ }
+ ],
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/jquery/gnarf37/jquery-ajaxQueue/blob/0.0.0pre/LICENSE-MIT"
+ }
+ ],
+ "bugs": "https://github.com/gnarf37/jquery-ajaxQueue/issues",
+ "homepage": "https://github.com/gnarf37/jquery-ajaxQueue",
+ "docs": "https://github.com/gnarf37/jquery-ajaxQueue",
+ "dependencies": {
+ "jquery": ">=1.8"
+ }
+}
@@ -0,0 +1,49 @@
+/*! jQuery Ajax Queue - v0.0.0pre - 2013-01-16
+* https://github.com/gnarf37/jquery-ajaxQueue
+* Copyright (c) 2013 Corey Frang; Licensed MIT */
+(function($) {
+
+// jQuery on an empty object, we are going to use this as our Queue
+var ajaxQueue = $({});
+
+$.ajaxQueue = function( ajaxOpts ) {
+ var jqXHR,
+ dfd = $.Deferred(),
+ promise = dfd.promise();
+
+ // run the actual query
+ function doRequest( next ) {
+ jqXHR = $.ajax( ajaxOpts )
+ .done( dfd.resolve )
+ .fail( dfd.reject )
+ .then( next, next );
+ }
+
+ // queue our ajax request
+ ajaxQueue.queue( doRequest );
+
+ // add the abort method
+ promise.abort = function( statusText ) {
+
+ // proxy abort to the jqXHR if it is active
+ if ( jqXHR ) {
+ return jqXHR.abort( statusText );
+ }
+
+ // if there wasn't already a jqXHR we need to remove from queue
+ var queue = ajaxQueue.queue(),
+ index = $.inArray( doRequest, queue );
+
+ if ( index > -1 ) {
+ queue.splice( index, 1 );
+ }
+
+ // and then reject the deferred
+ dfd.rejectWith( ajaxOpts.context || ajaxOpts, [ promise, statusText, "" ] );
+ return promise;
+ };
+
+ return promise;
+};
+
+})(jQuery);

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,12 @@
+(function() {
+ // Default to the local version.
+ var path = '../libs/jquery/jquery.js';
+ // Get any jquery=___ param from the query string.
+ var jqversion = location.search.match(/[?&]jquery=(.*?)(?=&|$)/);
+ // If a version was specified, use that version from code.jquery.com.
+ if (jqversion) {
+ path = 'http://code.jquery.com/jquery-' + jqversion[1] + '.js';
+ }
+ // This is the only time I'll ever use document.write, I promise!
+ document.write('<script src="' + path + '"></script>');
+}());
Oops, something went wrong.

0 comments on commit 22adb75

Please sign in to comment.