zoneminder/web/js/mootools.ext.js

58 lines
1.5 KiB
JavaScript

/*
* MooTools Extension script to support custom extensions to mootools
*/
var zmMooToolsVersion = '1.2.1';
/*
* Firstly, lets check that mootools has been included and thus is present
*/
if ( typeof(MooTools) == "undefined" )
{
alert( "MooTools not found! Please download from\nhttp://mootools.net and install in ZoneMinder web root." );
}
else
{
//console.log( "Got MooTools version "+MooTools.version );
/* Version check */
if ( MooTools.version < zmMooToolsVersion )
{
alert( "MooTools version "+MooTools.version+" found.\nVersion "+zmMooToolsVersion+" required, please upgrade." );
}
/*
* Ajax class extenstion to allow for request timeouts
*/
Request = Request.extend({
request: function( data )
{
if ( this.options.timeout )
{
if ( this.timeoutTimer )
{
this.removeTimer();
}
this.timeoutTimer = window.setTimeout( this.callTimeout.bindAsEventListener(this), this.options.timeout );
this.addEvent( 'onComplete', this.removeTimer );
}
this.parent( data );
},
callTimeout: function ()
{
this.transport.abort();
this.onFailure();
if ( this.options.onTimeout )
{
this.options.onTimeout();
}
},
removeTimer: function()
{
window.clearTimeout( this.timeoutTimer );
this.timeoutTimer = 0;
}
});
}