Skip to content

Commit

Permalink
JS resource documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed May 17, 2016
1 parent 76bb875 commit 9227d34
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
node_modules
.DS_Store
*.log
*.log
docs/resources
16 changes: 15 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var gulp = require( 'gulp' ),
uglify = require( 'gulp-uglify' ),
rename = require( 'gulp-rename' ),
using = require( 'gulp-using' ),
jsdoc = require( 'gulp-jsdoc3' ),
sourcemaps = require( 'gulp-sourcemaps' ),
strTwistSource = './src/Core/Resources/twist/',
strTwistDestination = './dist/twist/Core/Resources/twist/';
Expand Down Expand Up @@ -183,6 +184,19 @@ gulp.task( 'setup-test',
}
);

gulp.task( 'docs',
function() {
return gulp.src( strTwistSource + '**/*.js' )
.pipe( jsdoc( { opts: { destination: './docs/resources/' } } ) );
}
);

gulp.task( 'watch-docs',
function() {
return gulp.watch( strTwistSource + '**/*.js', ['docs'] );
}
);

gulp.task( 'ajax', ['ajax-js', 'ajax-css'] );
gulp.task( 'debug', ['debug-js', 'debug-css'] );
gulp.task( 'fileupload', ['fileupload-js', 'fileupload-css'] );
Expand Down Expand Up @@ -227,6 +241,6 @@ gulp.task( 'watch-setup',

gulp.task( 'test', ['ajax-test', 'debug-test', 'fileupload-test', 'manager-test', 'setup-test'] );

gulp.task( 'watch', ['default', 'watch-ajax', 'watch-cssreset', 'watch-debug', 'watch-fileupload', 'watch-manager', 'watch-setup'] );
gulp.task( 'watch', ['default', 'watch-ajax', 'watch-cssreset', 'watch-debug', 'watch-fileupload', 'watch-manager', 'watch-setup', 'watch-docs'] );

gulp.task( 'default', ['ajax', 'cssreset', 'debug', 'fileupload', 'manager', 'setup'] );
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"jshint": "^2.9.1"
},
"devDependencies": {
"gulp-watch": "^4.3.5"
"gulp-jsdoc3": "^0.2.1",
"gulp-watch": "^4.3.5",
"jsdoc": "^3.4.0"
}
}
124 changes: 114 additions & 10 deletions src/Core/Resources/twist/ajax/js/twistajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
* @author Shadow Technologies Ltd. <contact@shadow-technologies.co.uk>
* @license https://www.gnu.org/licenses/gpl.html GPL License
* @link https://twistphp.com
*
* --------------
* TwistPHP AJAX
* --------------
*/

(
Expand All @@ -47,6 +43,31 @@
function( jQuery ) {
try {
if( jQuery ) {
/**
* Create a new instance of the TwistAJAX object
* @param strAJAXPostLocation
* @param {?(function|Object|number|string)} b B
* @param {?function} b Master callback success function
* @param {?Object} b Default data
* @param {?number} b Default timeout
* @param {?string} b Loader size
* @param {?function} c Master callback failure function
* @param {?Object} c Default data
* @param {?number} c Default timeout
* @param {?string} c Loader size
* @param {?Object} d Default data
* @param {?number} d Default timeout
* @param {?string} d Loader size
* @param {?number} e Default timeout
* @param {?string} e Loader size
* @param {?string} f Loader size
* @returns {boolean}
* @alias twistajax
* @constructor
* @author Shadow Technologies Ltd. <contact@shadow-technologies.co.uk>
* @version 1.0.0
* @license GPL-3.0
*/
var TwistAJAX = function( strAJAXPostLocation, b, c, d, e, f ) {
var thisTwistAJAX = this,
debugMode = false,
Expand Down Expand Up @@ -428,7 +449,7 @@
} else if( typeof d === 'string' ) {
strLoaderSize = d;
}
} else if( c === 'object' ) {
} else if( typeof c === 'object' ) {
objDefaultData = c;
if( typeof d === 'number' ) {
intMasterTimeout = d;
Expand All @@ -438,7 +459,7 @@
} else if( typeof d === 'string' ) {
strLoaderSize = d;
}
} else if( c === 'number' ) {
} else if( typeof c === 'number' ) {
intMasterTimeout = c;
if( typeof d === 'string' ) {
strLoaderSize = d;
Expand Down Expand Up @@ -466,55 +487,106 @@
}

$.ajaxSetup(
{
url: strAJAXPostLocation,
timeout: intMasterTimeout
}
{
url: strAJAXPostLocation,
timeout: intMasterTimeout
}
);

/**
* Number of active AJAX requests
* @type {number}
*/
this.count = 0;

/**
*
* @param blEnable
*/
this.debug = function( blEnable ) {
debugMode = ( blEnable !== false );
return thisTwistAJAX;
};

/**
*
* @type {{}}
*/
this.defaultArray = objDefaultData;

/**
*
* @param strFunction
* @param b
* @param c
* @param d
* @param e
* @returns {TwistAJAX.twistajax}
*/
this.delete = function( strFunction, b, c, d, e ) {
if( strFunction ) {
send( strFunction, 'DELETE', blCache, b, c, d, e );
}
return thisTwistAJAX;
};

/**
*
* @returns {TwistAJAX.twistajax}
*/
this.disableCache = function() {
blCache = false;
return thisTwistAJAX;
};

/**
*
* @returns {TwistAJAX.twistajax}
*/
this.disableLoader = function() {
blShowLoader = false;
return thisTwistAJAX;
};

/**
*
* @returns {TwistAJAX.twistajax}
*/
this.enableCache = function() {
blCache = true;
return thisTwistAJAX;
};

/**
*
* @returns {TwistAJAX.twistajax}
*/
this.enableLoader = function() {
blShowLoader = true;
return thisTwistAJAX;
};

/**
*
* @param strFunction
* @param b
* @param c
* @param d
* @param e
* @returns {TwistAJAX.twistajax}
*/
this.get = function( strFunction, b, c, d, e ) {
if( strFunction ) {
send( strFunction, 'GET', blCache, b, c, d, e );
}
return thisTwistAJAX;
};

/**
*
* @param strSize
* @returns {TwistAJAX.twistajax}
*/
this.loaderSize = function( strSize ) {
if( $( '#twist-ajax-loader' ).length ) {
$( '#twist-ajax-loader' ).attr( 'class', '' ).addClass( strSize );
Expand All @@ -525,25 +597,57 @@
return thisTwistAJAX;
};

/**
*
* @param strMessage
* @returns {TwistAJAX.twistajax}
*/
this.onfail = function( strMessage ) {
var strErrorMessage = ( typeof strMessage === 'string' && strMessage !== '' ) ? strMessage : 'An unexpected AJAX response was given';
error( strErrorMessage );

return thisTwistAJAX;
};

/**
*
* @param strFunction
* @param b
* @param c
* @param d
* @param e
* @returns {TwistAJAX.twistajax}
*/
this.patch = function( strFunction, b, c, d, e ) {
send( strFunction, 'PATCH', blCache, b, c, d, e );
return thisTwistAJAX;
};

/**
*
* @param strFunction
* @param b
* @param c
* @param d
* @param e
* @returns {TwistAJAX.twistajax}
*/
this.post = function( strFunction, b, c, d, e ) {
if( strFunction ) {
send( strFunction, 'POST', blCache, b, c, d, e );
}
return thisTwistAJAX;
};

/**
*
* @param strFunction
* @param b
* @param c
* @param d
* @param e
* @returns {TwistAJAX.twistajax}
*/
this.put = function( strFunction, b, c, d, e ) {
if( strFunction ) {
send( strFunction, 'PUT', blCache, b, c, d, e );
Expand Down

0 comments on commit 9227d34

Please sign in to comment.