Added MooTools extension script

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2236 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2007-11-11 15:59:29 +00:00
parent 54c577b3e3
commit 3e65614d4d
3 changed files with 85 additions and 1 deletions

View File

@ -11,6 +11,7 @@ SUBDIRS = \
web_DATA = \
favicon.ico \
mootools.ext.js \
zm.php \
zm_actions.php \
zm_config.php \
@ -128,9 +129,10 @@ web_DATA = \
zm_lang_hu_hu.php
EXTRA_DIST = \
favicon.ico \
retag.sh \
swap.pl \
favicon.ico \
mootools.ext.js \
zm.php \
zm_actions.php \
zm_config.php.in \

81
web/mootools.ext.js Normal file
View File

@ -0,0 +1,81 @@
/*
* MooTools Extension script to support custom extensions to mootools
*/
var zmMooToolsVersion = '1.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." );
}
/*
* Element class extension to add getAncestor function to allow searches
* up the DOM tree for ancestor element of give type, and class optionally
*/
Element.extend({
getAncestor: function( tagName, className )
{
if ( !tagName )
return( null );
tagName = tagName.toLowerCase();
var ancestor = this;
var ancestorTag = null;
while( (ancestor = $(ancestor).getParent()) && $(ancestor) != document )
{
if ( $(ancestor).getTag() != tagName )
continue;
if ( className && !$(ancestor).hasClass( className ) )
continue;
return( $(ancestor) );
}
return( null );
}
});
/*
* Ajax class extenstion to allow for request timeouts
*/
Ajax = Ajax.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;
}
});
}

View File

@ -25,6 +25,7 @@
?>
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript" src="mootools.ext.js"></script>
<script type="text/javascript" src="zm_html.js"></script>
<script type="text/javascript">
function eventWindow( eventId, eventFilter )