2007-11-11 23:59:29 +08:00
|
|
|
/*
|
|
|
|
* MooTools Extension script to support custom extensions to mootools
|
|
|
|
*/
|
2009-10-15 01:38:13 +08:00
|
|
|
var zmMooToolsVersion = '1.2.3';
|
2007-11-11 23:59:29 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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." );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-10-15 01:38:13 +08:00
|
|
|
* Ajax class extention to allow for request timeouts
|
2007-11-11 23:59:29 +08:00
|
|
|
*/
|
2009-10-15 01:38:13 +08:00
|
|
|
Request = Class.refactor(Request, {
|
|
|
|
|
|
|
|
options: { /*
|
|
|
|
onTimeout: $empty, */
|
|
|
|
timeout: 0,
|
|
|
|
},
|
|
|
|
|
2009-04-05 05:59:52 +08:00
|
|
|
send: function( data )
|
2007-11-11 23:59:29 +08:00
|
|
|
{
|
|
|
|
if ( this.options.timeout )
|
|
|
|
{
|
|
|
|
if ( this.timeoutTimer )
|
|
|
|
this.removeTimer();
|
2009-10-15 01:38:13 +08:00
|
|
|
this.timeoutTimer = this.onTimeout.delay( this.options.timeout, this );
|
2007-11-11 23:59:29 +08:00
|
|
|
this.addEvent( 'onComplete', this.removeTimer );
|
|
|
|
}
|
2009-10-15 01:38:13 +08:00
|
|
|
this.previous( data );
|
2009-04-03 20:07:45 +08:00
|
|
|
return( this );
|
2007-11-11 23:59:29 +08:00
|
|
|
},
|
2009-10-15 01:38:13 +08:00
|
|
|
|
|
|
|
timeout: function()
|
|
|
|
{
|
|
|
|
this.onTimeout();
|
|
|
|
},
|
|
|
|
|
|
|
|
onTimeout: function ()
|
2007-11-11 23:59:29 +08:00
|
|
|
{
|
2009-04-05 05:35:42 +08:00
|
|
|
this.cancel();
|
2009-10-15 01:38:13 +08:00
|
|
|
this.fireEvent('complete').fireEvent('failure').fireEvent('timeout');
|
2007-11-11 23:59:29 +08:00
|
|
|
},
|
2009-10-15 01:38:13 +08:00
|
|
|
|
2009-04-05 05:59:52 +08:00
|
|
|
removeTimer: function()
|
2007-11-11 23:59:29 +08:00
|
|
|
{
|
2009-04-03 20:07:45 +08:00
|
|
|
$clear( this.timeoutTimer );
|
2009-10-15 01:38:13 +08:00
|
|
|
this.timeoutTimer = null;
|
2009-04-05 05:59:52 +08:00
|
|
|
return( this );
|
2007-11-11 23:59:29 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|