From 3e65614d4da380c862a18ee5428bf725e4ed3c2b Mon Sep 17 00:00:00 2001 From: stan Date: Sun, 11 Nov 2007 15:59:29 +0000 Subject: [PATCH] Added MooTools extension script git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2236 e3e1d417-86f3-4887-817a-d78f3d33393f --- web/Makefile.am | 4 ++- web/mootools.ext.js | 81 +++++++++++++++++++++++++++++++++++++++++++++ web/zm_html_js.php | 1 + 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 web/mootools.ext.js diff --git a/web/Makefile.am b/web/Makefile.am index 0527f711c..56e521b71 100644 --- a/web/Makefile.am +++ b/web/Makefile.am @@ -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 \ diff --git a/web/mootools.ext.js b/web/mootools.ext.js new file mode 100644 index 000000000..a3499f40f --- /dev/null +++ b/web/mootools.ext.js @@ -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; + } + }); +} diff --git a/web/zm_html_js.php b/web/zm_html_js.php index 25eef6a55..12f8bcbf9 100644 --- a/web/zm_html_js.php +++ b/web/zm_html_js.php @@ -25,6 +25,7 @@ ?> +