2005-04-16 12:30:48 +00:00
// Miscellaneous core Javascript functions for Moodle
2005-11-09 02:18:50 +00:00
function popupchecker ( msg ) {
var testwindow = window . open ( 'itestwin.html' , '' , 'width=1,height=1,left=0,top=0,scrollbars=no' ) ;
2009-03-16 02:11:15 +00:00
if ( ! testwindow ) {
alert ( msg ) ;
} else {
2005-11-09 02:18:50 +00:00
testwindow . close ( ) ;
}
}
2005-01-09 15:10:12 +00:00
function checkall ( ) {
2009-03-31 03:24:21 +00:00
var inputs = document . getElementsByTagName ( 'input' ) ;
for ( var i = 0 ; i < inputs . length ; i ++ ) {
if ( inputs [ i ] . type == 'checkbox' ) {
inputs [ i ] . checked = true ;
}
2007-01-06 19:22:58 +00:00
}
2005-01-09 15:10:12 +00:00
}
2005-03-06 12:00:46 +00:00
function checknone ( ) {
2009-03-31 03:24:21 +00:00
var inputs = document . getElementsByTagName ( 'input' ) ;
for ( var i = 0 ; i < inputs . length ; i ++ ) {
if ( inputs [ i ] . type == 'checkbox' ) {
inputs [ i ] . checked = false ;
}
2007-01-06 19:22:58 +00:00
}
2005-03-06 12:00:46 +00:00
}
2007-01-06 19:22:58 +00:00
function lockoptions ( formid , master , subitems ) {
2006-09-20 15:04:57 +00:00
// Subitems is an array of names of sub items.
// Optionally, each item in subitems may have a
2005-01-09 15:10:12 +00:00
// companion hidden item in the form with the
2006-09-20 15:04:57 +00:00
// same name but prefixed by "h".
2007-01-06 19:22:58 +00:00
var form = document . forms [ formid ] ;
if ( eval ( "form." + master + ".checked" ) ) {
2005-01-09 15:10:12 +00:00
for ( i = 0 ; i < subitems . length ; i ++ ) {
unlockoption ( form , subitems [ i ] ) ;
}
} else {
for ( i = 0 ; i < subitems . length ; i ++ ) {
lockoption ( form , subitems [ i ] ) ;
}
}
return ( true ) ;
}
2006-12-28 09:32:45 +00:00
function lockoption ( form , item ) {
2007-01-06 19:22:58 +00:00
eval ( "form." + item + ".disabled=true" ) ; /* IE thing */
if ( form . elements [ 'h' + item ] ) {
eval ( "form.h" + item + ".value=1" ) ;
2006-12-28 09:32:45 +00:00
}
}
function unlockoption ( form , item ) {
2007-01-06 19:22:58 +00:00
eval ( "form." + item + ".disabled=false" ) ; /* IE thing */
if ( form . elements [ 'h' + item ] ) {
eval ( "form.h" + item + ".value=0" ) ;
2006-12-28 09:32:45 +00:00
}
}
2007-01-12 09:38:02 +00:00
2009-03-16 06:09:05 +00:00
/ * *
* Get the value of the 'virtual form element' with a particular name . That is ,
* abstracts away the difference between a normal form element , like a select
* which is a single HTML element with a . value property , and a set of radio
* buttons , which is several HTML elements .
*
* @ param form a HTML form .
* @ param master the name of an element in that form .
* @ return the value of that element .
* /
function get _form _element _value ( form , name ) {
var element = form [ name ] ;
if ( ! element ) {
return null ;
}
if ( element . tagName ) {
// Ordinarly thing like a select box.
return element . value ;
}
// Array of things, like radio buttons.
for ( var j = 0 ; j < element . length ; j ++ ) {
var el = element [ j ] ;
if ( el . checked ) {
return el . value ;
}
}
return null ;
}
/ * *
* Set the disabled state of the 'virtual form element' with a particular name .
* This abstracts away the difference between a normal form element , like a select
* which is a single HTML element with a . value property , and a set of radio
* buttons , which is several HTML elements .
*
* @ param form a HTML form .
* @ param master the name of an element in that form .
* @ param disabled the disabled state to set .
* /
function set _form _element _disabled ( form , name , disabled ) {
var element = form [ name ] ;
if ( ! element ) {
return ;
}
if ( element . tagName ) {
// Ordinarly thing like a select box.
element . disabled = disabled ;
}
// Array of things, like radio buttons.
for ( var j = 0 ; j < element . length ; j ++ ) {
var el = element [ j ] ;
el . disabled = disabled ;
}
}
2007-01-12 09:38:02 +00:00
2006-11-21 09:17:46 +00:00
function lockoptionsall ( formid ) {
2007-01-12 09:38:02 +00:00
var form = document . forms [ formid ] ;
2009-03-16 06:09:05 +00:00
var dependons = eval ( formid + 'items' ) ;
var tolock = [ ] ;
2007-01-12 09:38:02 +00:00
for ( var dependon in dependons ) {
2007-08-05 12:15:27 +00:00
// change for MooTools compatibility
if ( ! dependons . propertyIsEnumerable ( dependon ) ) {
continue ;
}
2009-03-16 06:09:05 +00:00
if ( ! form [ dependon ] ) {
2007-07-12 09:17:55 +00:00
continue ;
}
2007-01-12 09:38:02 +00:00
for ( var condition in dependons [ dependon ] ) {
for ( var value in dependons [ dependon ] [ condition ] ) {
var lock ;
switch ( condition ) {
case 'notchecked' :
2009-03-16 06:09:05 +00:00
lock = ! form [ dependon ] . checked ; break ;
2007-01-12 09:38:02 +00:00
case 'checked' :
2009-03-16 06:09:05 +00:00
lock = form [ dependon ] . checked ; break ;
2007-01-12 09:38:02 +00:00
case 'noitemselected' :
2009-03-16 06:09:05 +00:00
lock = form [ dependon ] . selectedIndex == - 1 ; break ;
2007-01-12 09:38:02 +00:00
case 'eq' :
2009-03-16 06:09:05 +00:00
lock = get _form _element _value ( form , dependon ) == value ; break ;
2007-01-12 09:38:02 +00:00
default :
2009-03-16 06:09:05 +00:00
lock = get _form _element _value ( form , dependon ) != value ; break ;
2007-01-12 09:38:02 +00:00
}
for ( var ei in dependons [ dependon ] [ condition ] [ value ] ) {
2007-08-05 12:15:27 +00:00
// change for MooTools compatibility
if ( ! window . webkit && ( ! dependons [ dependon ] [ condition ] [ value ] . propertyIsEnumerable ( ei ) ) ) {
continue ;
}
2007-04-06 06:01:11 +00:00
var eltolock = dependons [ dependon ] [ condition ] [ value ] [ ei ] ;
2009-03-16 06:09:05 +00:00
if ( tolock [ eltolock ] != null ) {
tolock [ eltolock ] = lock || tolock [ eltolock ] ;
2007-04-06 06:01:11 +00:00
} else {
tolock [ eltolock ] = lock ;
}
2007-01-12 09:38:02 +00:00
}
}
2006-11-21 09:17:46 +00:00
}
2007-01-12 09:38:02 +00:00
}
2009-03-16 06:09:05 +00:00
for ( var el in tolock ) {
2007-08-05 12:15:27 +00:00
// change for MooTools compatibility
if ( ! tolock . propertyIsEnumerable ( el ) ) {
continue ;
}
2009-03-16 06:09:05 +00:00
set _form _element _disabled ( form , el , tolock [ el ] ) ;
2007-04-06 06:01:11 +00:00
}
2007-01-12 09:38:02 +00:00
return true ;
2006-11-21 09:17:46 +00:00
}
2006-11-22 08:53:35 +00:00
function lockoptionsallsetup ( formid ) {
2007-01-12 09:38:02 +00:00
var form = document . forms [ formid ] ;
var dependons = eval ( formid + 'items' ) ;
for ( var dependon in dependons ) {
2007-08-05 12:15:27 +00:00
// change for MooTools compatibility
if ( ! dependons . propertyIsEnumerable ( dependon ) ) {
continue ;
}
2009-03-16 06:09:05 +00:00
var masters = form [ dependon ] ;
if ( ! masters ) {
2007-07-12 09:17:55 +00:00
continue ;
}
2009-04-06 02:56:37 +00:00
if ( masters . tagName ) {
2009-03-16 06:09:05 +00:00
// If master is radio buttons, we get an array, otherwise we don't.
// Convert both cases to an array for convinience.
masters = [ masters ] ;
}
for ( var j = 0 ; j < masters . length ; j ++ ) {
master = masters [ j ] ;
master . formid = formid ;
master . onclick = function ( ) { return lockoptionsall ( this . formid ) ; } ;
master . onblur = function ( ) { return lockoptionsall ( this . formid ) ; } ;
master . onchange = function ( ) { return lockoptionsall ( this . formid ) ; } ;
}
2007-01-12 09:38:02 +00:00
}
2009-03-16 06:09:05 +00:00
for ( var i = 0 ; i < form . elements . length ; i ++ ) {
2007-01-12 09:38:02 +00:00
var formelement = form . elements [ i ] ;
if ( formelement . type == 'reset' ) {
2007-07-13 08:14:37 +00:00
formelement . formid = formid ;
formelement . onclick = function ( ) { this . form . reset ( ) ; return lockoptionsall ( this . formid ) ; } ;
formelement . onblur = function ( ) { this . form . reset ( ) ; return lockoptionsall ( this . formid ) ; } ;
formelement . onchange = function ( ) { this . form . reset ( ) ; return lockoptionsall ( this . formid ) ; } ;
2007-01-12 09:38:02 +00:00
}
}
return lockoptionsall ( formid ) ;
2006-11-22 08:53:35 +00:00
}
2006-11-21 09:17:46 +00:00
2005-03-08 04:22:38 +00:00
function submitFormById ( id ) {
var theform = document . getElementById ( id ) ;
if ( ! theform ) {
return false ;
}
2007-01-18 12:55:46 +00:00
if ( theform . tagName . toLowerCase ( ) != 'form' ) {
2005-03-08 04:22:38 +00:00
return false ;
}
if ( ! theform . onsubmit || theform . onsubmit ( ) ) {
return theform . submit ( ) ;
}
}
2005-03-18 14:36:10 +00:00
2009-06-12 12:01:16 +00:00
/ * *
* Either check , or uncheck , all checkboxes inside the element with id is
* @ param id the id of the container
* @ param checked the new state , either '' or 'checked' .
* /
function select _all _in _element _with _id ( id , checked ) {
var container = document . getElementById ( id ) ;
if ( ! container ) {
return ;
}
var inputs = container . getElementsByTagName ( 'input' ) ;
for ( var i = 0 ; i < inputs . length ; ++ i ) {
if ( inputs [ i ] . type == 'checkbox' || inputs [ i ] . type == 'radio' ) {
inputs [ i ] . checked = checked ;
}
}
}
2005-08-24 23:08:54 +00:00
function select _all _in ( elTagName , elClass , elId ) {
2007-01-06 19:22:58 +00:00
var inputs = document . getElementsByTagName ( 'input' ) ;
2005-08-24 23:08:54 +00:00
inputs = filterByParent ( inputs , function ( el ) { return findParentNode ( el , elTagName , elClass , elId ) ; } ) ;
2005-03-18 14:36:10 +00:00
for ( var i = 0 ; i < inputs . length ; ++ i ) {
2006-04-21 05:17:08 +00:00
if ( inputs [ i ] . type == 'checkbox' || inputs [ i ] . type == 'radio' ) {
2005-03-18 14:36:10 +00:00
inputs [ i ] . checked = 'checked' ;
}
}
}
2005-08-24 23:08:54 +00:00
function deselect _all _in ( elTagName , elClass , elId ) {
2005-03-18 14:36:10 +00:00
var inputs = document . getElementsByTagName ( 'INPUT' ) ;
2005-08-24 23:08:54 +00:00
inputs = filterByParent ( inputs , function ( el ) { return findParentNode ( el , elTagName , elClass , elId ) ; } ) ;
2005-03-18 14:36:10 +00:00
for ( var i = 0 ; i < inputs . length ; ++ i ) {
2006-04-21 05:17:08 +00:00
if ( inputs [ i ] . type == 'checkbox' || inputs [ i ] . type == 'radio' ) {
2005-03-18 14:36:10 +00:00
inputs [ i ] . checked = '' ;
}
}
}
function confirm _if ( expr , message ) {
if ( ! expr ) {
return true ;
}
return confirm ( message ) ;
}
2005-04-16 12:30:48 +00:00
/ *
findParentNode ( start , elementName , elementClass , elementID )
2006-11-21 09:17:46 +00:00
2005-04-16 12:30:48 +00:00
Travels up the DOM hierarchy to find a parent element with the
specified tag name , class , and id . All conditions must be met ,
but any can be ommitted . Returns the BODY element if no match
found .
* /
function findParentNode ( el , elName , elClass , elId ) {
2009-06-12 12:01:16 +00:00
while ( el . nodeName . toUpperCase ( ) != 'BODY' ) {
if ( ( ! elName || el . nodeName . toUpperCase ( ) == elName ) &&
2005-04-16 12:30:48 +00:00
( ! elClass || el . className . indexOf ( elClass ) != - 1 ) &&
2009-06-12 12:01:16 +00:00
( ! elId || el . id == elId ) ) {
2005-04-16 12:30:48 +00:00
break ;
}
el = el . parentNode ;
}
return el ;
}
2006-12-14 12:44:10 +00:00
/ *
findChildNode ( start , elementName , elementClass , elementID )
Travels down the DOM hierarchy to find all child elements with the
specified tag name , class , and id . All conditions must be met ,
but any can be ommitted .
2006-12-19 07:03:08 +00:00
Doesn ' t examine children of matches .
2006-12-14 12:44:10 +00:00
* /
function findChildNodes ( start , tagName , elementClass , elementID , elementName ) {
var children = new Array ( ) ;
2007-01-24 19:39:59 +00:00
for ( var i = 0 ; i < start . childNodes . length ; i ++ ) {
2006-12-19 07:03:08 +00:00
var classfound = false ;
2007-01-24 19:39:59 +00:00
var child = start . childNodes [ i ] ;
2006-12-19 07:03:08 +00:00
if ( ( child . nodeType == 1 ) && //element node type
2009-03-16 06:09:05 +00:00
( elementClass && ( typeof ( child . className ) == 'string' ) ) ) {
2006-12-19 07:03:08 +00:00
var childClasses = child . className . split ( /\s+/ ) ;
2009-03-16 06:09:05 +00:00
for ( var childClassIndex in childClasses ) {
if ( childClasses [ childClassIndex ] == elementClass ) {
2006-12-19 07:03:08 +00:00
classfound = true ;
break ;
}
}
}
2006-12-28 09:32:45 +00:00
if ( child . nodeType == 1 ) { //element node type
if ( ( ! tagName || child . nodeName == tagName ) &&
( ! elementClass || classfound ) &&
( ! elementID || child . id == elementID ) &&
( ! elementName || child . name == elementName ) )
{
children = children . concat ( child ) ;
} else {
children = children . concat ( findChildNodes ( child , tagName , elementClass , elementID , elementName ) ) ;
}
2006-12-14 12:44:10 +00:00
}
}
return children ;
}
/ *
elementSetHide ( elements , hide )
Adds or removes the "hide" class for the specified elements depending on boolean hide .
* /
function elementShowAdvanced ( elements , show ) {
2009-03-16 06:09:05 +00:00
for ( var elementIndex in elements ) {
2006-12-14 12:44:10 +00:00
element = elements [ elementIndex ] ;
element . className = element . className . replace ( new RegExp ( ' ?hide' ) , '' )
if ( ! show ) {
element . className += ' hide' ;
}
}
}
2008-08-28 07:52:09 +00:00
function showAdvancedInit ( addBefore , nameAttr , buttonLabel , hideText , showText ) {
var showHideButton = document . createElement ( "input" ) ;
showHideButton . type = 'button' ;
showHideButton . value = buttonLabel ;
showHideButton . name = nameAttr ;
showHideButton . moodle = {
2009-06-29 02:10:49 +00:00
hideLabel : mstr . form . hideadvanced ,
showLabel : mstr . form . showadvanced
2008-08-28 07:52:09 +00:00
} ;
YAHOO . util . Event . addListener ( showHideButton , 'click' , showAdvancedOnClick ) ;
el = document . getElementById ( addBefore ) ;
el . parentNode . insertBefore ( showHideButton , el ) ;
}
function showAdvancedOnClick ( e ) {
var button = e . target ? e . target : e . srcElement ;
2006-12-14 12:44:10 +00:00
var toSet = findChildNodes ( button . form , null , 'advanced' ) ;
var buttontext = '' ;
2007-01-12 10:48:11 +00:00
if ( button . form . elements [ 'mform_showadvanced_last' ] . value == '0' || button . form . elements [ 'mform_showadvanced_last' ] . value == '' ) {
2006-12-14 12:44:10 +00:00
elementShowAdvanced ( toSet , true ) ;
2008-08-28 07:52:09 +00:00
buttontext = button . moodle . hideLabel ;
2006-12-14 12:44:10 +00:00
button . form . elements [ 'mform_showadvanced_last' ] . value = '1' ;
} else {
elementShowAdvanced ( toSet , false ) ;
2008-08-28 07:52:09 +00:00
buttontext = button . moodle . showLabel ;
2006-12-14 12:44:10 +00:00
button . form . elements [ 'mform_showadvanced_last' ] . value = '0' ;
}
var formelements = button . form . elements ;
2007-10-23 22:29:04 +00:00
// Fixed MDL-10506
2009-03-16 06:09:05 +00:00
for ( var i = 0 ; i < formelements . length ; i ++ ) {
if ( formelements [ i ] && formelements [ i ] . name && ( formelements [ i ] . name == 'mform_showadvanced' ) ) {
2006-12-14 12:44:10 +00:00
formelements [ i ] . value = buttontext ;
}
}
//never submit the form if js is enabled.
return false ;
}
2005-04-16 12:30:48 +00:00
2007-04-30 18:03:19 +00:00
function unmaskPassword ( id ) {
2007-04-06 14:18:02 +00:00
var pw = document . getElementById ( id ) ;
2007-04-30 18:03:19 +00:00
var chb = document . getElementById ( id + 'unmask' ) ;
2007-04-06 14:18:02 +00:00
try {
// first try IE way - it can not set name attribute later
if ( chb . checked ) {
var newpw = document . createElement ( '<input type="text" name="' + pw . name + '">' ) ;
} else {
var newpw = document . createElement ( '<input type="password" name="' + pw . name + '">' ) ;
}
2007-04-26 07:08:12 +00:00
newpw . attributes [ 'class' ] . nodeValue = pw . attributes [ 'class' ] . nodeValue ;
2007-04-06 14:18:02 +00:00
} catch ( e ) {
var newpw = document . createElement ( 'input' ) ;
newpw . setAttribute ( 'name' , pw . name ) ;
if ( chb . checked ) {
newpw . setAttribute ( 'type' , 'text' ) ;
} else {
newpw . setAttribute ( 'type' , 'password' ) ;
}
2007-04-26 07:08:12 +00:00
newpw . setAttribute ( 'class' , pw . getAttribute ( 'class' ) ) ;
2007-04-06 14:18:02 +00:00
}
newpw . id = pw . id ;
newpw . size = pw . size ;
newpw . onblur = pw . onblur ;
newpw . onchange = pw . onchange ;
newpw . value = pw . value ;
pw . parentNode . replaceChild ( newpw , pw ) ;
}
2009-03-13 09:56:53 +00:00
/ * *
* Search a Moodle form to find all the fdate _time _selector and fdate _selector
* elements , and add date _selector _calendar instance to each .
* /
function init _date _selectors ( firstdayofweek ) {
var els = YAHOO . util . Dom . getElementsByClassName ( 'fdate_time_selector' , 'fieldset' ) ;
for ( var i = 0 ; i < els . length ; i ++ ) {
new date _selector _calendar ( els [ i ] , firstdayofweek ) ;
}
els = YAHOO . util . Dom . getElementsByClassName ( 'fdate_selector' , 'fieldset' ) ;
for ( i = 0 ; i < els . length ; i ++ ) {
new date _selector _calendar ( els [ i ] , firstdayofweek ) ;
}
}
/ * *
2009-03-16 02:27:08 +00:00
* Constructor for a JavaScript object that connects to a fdate _time _selector
2009-03-13 09:56:53 +00:00
* or a fdate _selector in a Moodle form , and shows a popup calendar whenever
* that element has keyboard focus .
* @ param el the fieldset class = "fdate_time_selector" or "fdate_selector" .
* /
function date _selector _calendar ( el , firstdayofweek ) {
// Ensure that the shared div and calendar exist.
if ( ! date _selector _calendar . panel ) {
date _selector _calendar . panel = new YAHOO . widget . Panel ( 'date_selector_calendar_panel' ,
2009-03-16 07:38:27 +00:00
{ visible : false , draggable : false } ) ;
2009-03-13 09:56:53 +00:00
var div = document . createElement ( 'div' ) ;
date _selector _calendar . panel . setBody ( div ) ;
date _selector _calendar . panel . render ( document . body ) ;
YAHOO . util . Event . addListener ( document , 'click' , date _selector _calendar . document _click ) ;
date _selector _calendar . panel . showEvent . subscribe ( function ( ) {
date _selector _calendar . panel . fireEvent ( 'changeContent' ) ;
} ) ;
2009-03-16 07:38:27 +00:00
date _selector _calendar . panel . hideEvent . subscribe ( date _selector _calendar . release _current ) ;
2009-03-13 09:56:53 +00:00
date _selector _calendar . calendar = new YAHOO . widget . Calendar ( div ,
{ iframe : false , hide _blank _weeks : true , start _weekday : firstdayofweek } ) ;
date _selector _calendar . calendar . renderEvent . subscribe ( function ( ) {
date _selector _calendar . panel . fireEvent ( 'changeContent' ) ;
2009-03-16 03:42:14 +00:00
date _selector _calendar . delayed _reposition ( ) ;
2009-03-13 09:56:53 +00:00
} ) ;
}
this . fieldset = el ;
var controls = el . getElementsByTagName ( 'select' ) ;
for ( var i = 0 ; i < controls . length ; i ++ ) {
if ( /\[year\]$/ . test ( controls [ i ] . name ) ) {
this . yearselect = controls [ i ] ;
2009-03-16 02:27:08 +00:00
} else if ( /\[month\]$/ . test ( controls [ i ] . name ) ) {
2009-03-13 09:56:53 +00:00
this . monthselect = controls [ i ] ;
2009-03-16 02:27:08 +00:00
} else if ( /\[day\]$/ . test ( controls [ i ] . name ) ) {
2009-03-13 09:56:53 +00:00
this . dayselect = controls [ i ] ;
2009-03-16 02:27:08 +00:00
} else {
2009-03-16 03:42:14 +00:00
YAHOO . util . Event . addFocusListener ( controls [ i ] , date _selector _calendar . cancel _any _timeout , this ) ;
2009-03-16 02:27:08 +00:00
YAHOO . util . Event . addBlurListener ( controls [ i ] , this . blur _event , this ) ;
2009-03-13 09:56:53 +00:00
}
}
if ( ! ( this . yearselect && this . monthselect && this . dayselect ) ) {
throw 'Failed to initialise calendar.' ;
}
2009-03-16 02:27:08 +00:00
YAHOO . util . Event . addFocusListener ( [ this . yearselect , this . monthselect , this . dayselect ] , this . focus _event , this ) ;
YAHOO . util . Event . addBlurListener ( [ this . yearselect , this . monthselect , this . dayselect ] , this . blur _event , this ) ;
2009-03-13 09:56:53 +00:00
this . enablecheckbox = el . getElementsByTagName ( 'input' ) [ 0 ] ;
if ( this . enablecheckbox ) {
YAHOO . util . Event . addFocusListener ( this . enablecheckbox , this . focus _event , this ) ;
YAHOO . util . Event . addListener ( this . enablecheckbox , 'change' , this . focus _event , this ) ;
YAHOO . util . Event . addBlurListener ( this . enablecheckbox , this . blur _event , this ) ;
}
}
/** The pop-up calendar that contains the calendar. */
date _selector _calendar . panel = null ;
/** The shared YAHOO.widget.Calendar used by all date_selector_calendars. */
date _selector _calendar . calendar = null ;
/** The date_selector_calendar that currently owns the shared stuff. */
date _selector _calendar . currentowner = null ;
/ * * U s e d a s a t i m e o u t w h e n h i d i n g t h e c a l e n d a r o n b l u r - s o w e d o n ' t h i d e t h e c a l e n d a r
* if we are just jumping from on of our controls to another . * /
date _selector _calendar . hidetimeout = null ;
2009-03-16 03:42:14 +00:00
/** Timeout for repositioning after a delay after a change of months. */
date _selector _calendar . repositiontimeout = null ;
2009-03-13 09:56:53 +00:00
2009-03-16 03:42:14 +00:00
/** Member variables. Pointers to various bits of the DOM. */
2009-03-13 09:56:53 +00:00
date _selector _calendar . prototype . fieldset = null ;
date _selector _calendar . prototype . yearselect = null ;
date _selector _calendar . prototype . monthselect = null ;
date _selector _calendar . prototype . dayselect = null ;
date _selector _calendar . prototype . enablecheckbox = null ;
2009-03-16 03:42:14 +00:00
date _selector _calendar . cancel _any _timeout = function ( ) {
2009-03-13 09:56:53 +00:00
if ( date _selector _calendar . hidetimeout ) {
clearTimeout ( date _selector _calendar . hidetimeout ) ;
date _selector _calendar . hidetimeout = null ;
}
2009-03-16 03:42:14 +00:00
if ( date _selector _calendar . repositiontimeout ) {
clearTimeout ( date _selector _calendar . repositiontimeout ) ;
date _selector _calendar . repositiontimeout = null ;
}
}
date _selector _calendar . delayed _reposition = function ( ) {
if ( date _selector _calendar . repositiontimeout ) {
clearTimeout ( date _selector _calendar . repositiontimeout ) ;
date _selector _calendar . repositiontimeout = null ;
}
2009-03-16 07:38:27 +00:00
date _selector _calendar . repositiontimeout = setTimeout ( date _selector _calendar . fix _position , 500 ) ;
2009-03-16 03:42:14 +00:00
}
date _selector _calendar . fix _position = function ( ) {
if ( date _selector _calendar . currentowner ) {
date _selector _calendar . panel . cfg . setProperty ( 'context' , [ date _selector _calendar . currentowner . fieldset , 'bl' , 'tl' ] ) ;
}
2009-03-13 09:56:53 +00:00
}
2009-03-16 07:38:27 +00:00
date _selector _calendar . release _current = function ( ) {
if ( date _selector _calendar . currentowner ) {
date _selector _calendar . currentowner . release _calendar ( ) ;
}
}
2009-03-13 09:56:53 +00:00
date _selector _calendar . prototype . focus _event = function ( e , me ) {
2009-03-16 03:42:14 +00:00
date _selector _calendar . cancel _any _timeout ( ) ;
2009-03-13 09:56:53 +00:00
if ( me . enablecheckbox == null || me . enablecheckbox . checked ) {
me . claim _calendar ( ) ;
} else {
if ( date _selector _calendar . currentowner ) {
date _selector _calendar . currentowner . release _calendar ( ) ;
}
}
}
date _selector _calendar . prototype . blur _event = function ( e , me ) {
2009-03-16 07:38:27 +00:00
date _selector _calendar . hidetimeout = setTimeout ( date _selector _calendar . release _current , 300 ) ;
2009-03-13 09:56:53 +00:00
}
date _selector _calendar . prototype . handle _select _change = function ( e , me ) {
me . set _date _from _selects ( ) ;
}
date _selector _calendar . document _click = function ( event ) {
if ( date _selector _calendar . currentowner ) {
var currentcontainer = date _selector _calendar . currentowner . fieldset ;
var eventarget = YAHOO . util . Event . getTarget ( event ) ;
2009-03-16 07:38:27 +00:00
if ( YAHOO . util . Dom . isAncestor ( currentcontainer , eventarget ) ) {
setTimeout ( function ( ) { date _selector _calendar . cancel _any _timeout ( ) } , 100 ) ;
} else {
2009-03-13 09:56:53 +00:00
date _selector _calendar . currentowner . release _calendar ( ) ;
}
}
}
date _selector _calendar . prototype . claim _calendar = function ( ) {
2009-03-16 03:42:14 +00:00
date _selector _calendar . cancel _any _timeout ( ) ;
2009-03-13 09:56:53 +00:00
if ( date _selector _calendar . currentowner == this ) {
return ;
}
if ( date _selector _calendar . currentowner ) {
date _selector _calendar . currentowner . release _calendar ( ) ;
}
2009-03-16 03:42:14 +00:00
if ( date _selector _calendar . currentowner != this ) {
this . connect _handlers ( ) ;
}
date _selector _calendar . currentowner = this ;
2009-03-13 09:56:53 +00:00
date _selector _calendar . calendar . cfg . setProperty ( 'mindate' , new Date ( this . yearselect . options [ 0 ] . value , 0 , 1 ) ) ;
date _selector _calendar . calendar . cfg . setProperty ( 'maxdate' , new Date ( this . yearselect . options [ this . yearselect . options . length - 1 ] . value , 11 , 31 ) ) ;
2009-03-16 03:42:14 +00:00
this . fieldset . insertBefore ( date _selector _calendar . panel . element , this . yearselect . nextSibling ) ;
2009-03-13 09:56:53 +00:00
this . set _date _from _selects ( ) ;
date _selector _calendar . panel . show ( ) ;
var me = this ;
2009-03-16 03:42:14 +00:00
setTimeout ( function ( ) { date _selector _calendar . cancel _any _timeout ( ) } , 100 ) ;
2009-03-13 09:56:53 +00:00
}
date _selector _calendar . prototype . set _date _from _selects = function ( ) {
var year = parseInt ( this . yearselect . value ) ;
var month = parseInt ( this . monthselect . value ) - 1 ;
var day = parseInt ( this . dayselect . value ) ;
date _selector _calendar . calendar . select ( new Date ( year , month , day ) ) ;
date _selector _calendar . calendar . setMonth ( month ) ;
date _selector _calendar . calendar . setYear ( year ) ;
2009-03-16 03:42:14 +00:00
date _selector _calendar . calendar . render ( ) ;
date _selector _calendar . fix _position ( ) ;
2009-03-13 09:56:53 +00:00
}
date _selector _calendar . prototype . set _selects _from _date = function ( eventtype , args ) {
var date = args [ 0 ] [ 0 ] ;
var newyear = date [ 0 ] ;
var newindex = newyear - this . yearselect . options [ 0 ] . value ;
this . yearselect . selectedIndex = newindex ;
this . monthselect . selectedIndex = date [ 1 ] - this . monthselect . options [ 0 ] . value ;
this . dayselect . selectedIndex = date [ 2 ] - this . dayselect . options [ 0 ] . value ;
}
date _selector _calendar . prototype . connect _handlers = function ( ) {
YAHOO . util . Event . addListener ( [ this . yearselect , this . monthselect , this . dayselect ] , 'change' , this . handle _select _change , this ) ;
date _selector _calendar . calendar . selectEvent . subscribe ( this . set _selects _from _date , this , true ) ;
}
date _selector _calendar . prototype . release _calendar = function ( ) {
date _selector _calendar . panel . hide ( ) ;
date _selector _calendar . currentowner = null ;
YAHOO . util . Event . removeListener ( [ this . yearselect , this . monthselect , this . dayselect ] , this . handle _select _change ) ;
date _selector _calendar . calendar . selectEvent . unsubscribe ( this . set _selects _from _date , this ) ;
}
/ * *
2005-04-16 12:30:48 +00:00
elementToggleHide ( element , elementFinder )
If elementFinder is not provided , toggles the "hidden" class for the specified element .
If elementFinder is provided , then the "hidden" class will be toggled for the object
returned by the function call elementFinder ( element ) .
If persistent == true , also sets a cookie for this .
* /
2007-12-18 17:18:19 +00:00
function elementToggleHide ( el , persistent , elementFinder , strShow , strHide ) {
2005-04-16 12:30:48 +00:00
if ( ! elementFinder ) {
2007-12-18 17:18:19 +00:00
var obj = el ; //el:container
el = document . getElementById ( 'togglehide_' + obj . id ) ;
2005-04-16 12:30:48 +00:00
}
else {
2007-12-18 17:18:19 +00:00
var obj = elementFinder ( el ) ; //el:button.
2005-04-16 12:30:48 +00:00
}
if ( obj . className . indexOf ( 'hidden' ) == - 1 ) {
obj . className += ' hidden' ;
2007-12-18 17:18:19 +00:00
if ( el . src ) {
el . src = el . src . replace ( 'switch_minus' , 'switch_plus' ) ;
el . alt = strShow ;
el . title = strShow ;
}
2006-12-14 12:44:10 +00:00
var shown = 0 ;
2005-04-16 12:30:48 +00:00
}
else {
2007-12-18 17:18:19 +00:00
obj . className = obj . className . replace ( new RegExp ( ' ?hidden' ) , '' ) ;
if ( el . src ) {
el . src = el . src . replace ( 'switch_plus' , 'switch_minus' ) ;
el . alt = strHide ;
el . title = strHide ;
}
2006-12-14 12:44:10 +00:00
var shown = 1 ;
2005-04-16 12:30:48 +00:00
}
2006-12-14 12:44:10 +00:00
2005-04-16 12:30:48 +00:00
if ( persistent == true ) {
new cookie ( 'hide:' + obj . id , 1 , ( shown ? - 1 : 356 ) , '/' ) . set ( ) ;
}
}
2007-12-18 17:18:19 +00:00
function elementCookieHide ( id , strShow , strHide ) {
2005-04-16 12:30:48 +00:00
var obj = document . getElementById ( id ) ;
var cook = new cookie ( 'hide:' + id ) . read ( ) ;
if ( cook != null ) {
2007-12-18 17:18:19 +00:00
elementToggleHide ( obj , false , null , strShow , strHide ) ;
2005-04-16 12:30:48 +00:00
}
}
function filterByParent ( elCollection , parentFinder ) {
var filteredCollection = [ ] ;
2009-06-12 12:01:16 +00:00
for ( var i = 0 ; i < elCollection . length ; ++ i ) {
2005-04-16 12:30:48 +00:00
var findParent = parentFinder ( elCollection [ i ] ) ;
2009-06-12 12:01:16 +00:00
if ( findParent . nodeName . toUpperCase != 'BODY' ) {
2005-04-16 12:30:48 +00:00
filteredCollection . push ( elCollection [ i ] ) ;
}
}
return filteredCollection ;
}
2005-05-12 14:45:16 +00:00
/ *
All this is here just so that IE gets to handle oversized blocks
in a visually pleasing manner . It does a browser detect . So sue me .
* /
function fix _column _widths ( ) {
var agt = navigator . userAgent . toLowerCase ( ) ;
if ( ( agt . indexOf ( "msie" ) != - 1 ) && ( agt . indexOf ( "opera" ) == - 1 ) ) {
fix _column _width ( 'left-column' ) ;
fix _column _width ( 'right-column' ) ;
}
}
function fix _column _width ( colName ) {
if ( column = document . getElementById ( colName ) ) {
if ( ! column . offsetWidth ) {
setTimeout ( "fix_column_width('" + colName + "')" , 20 ) ;
return ;
}
var width = 0 ;
var nodes = column . childNodes ;
for ( i = 0 ; i < nodes . length ; ++ i ) {
if ( nodes [ i ] . className . indexOf ( "sideblock" ) != - 1 ) {
if ( width < nodes [ i ] . offsetWidth ) {
width = nodes [ i ] . offsetWidth ;
}
}
}
for ( i = 0 ; i < nodes . length ; ++ i ) {
if ( nodes [ i ] . className . indexOf ( "sideblock" ) != - 1 ) {
nodes [ i ] . style . width = width + 'px' ;
}
}
}
}
2006-03-14 05:26:40 +00:00
/ *
2007-05-08 16:25:18 +00:00
Insert myValue at current cursor position
* /
2006-03-14 05:26:40 +00:00
function insertAtCursor ( myField , myValue ) {
2007-05-08 16:25:18 +00:00
// IE support
if ( document . selection ) {
myField . focus ( ) ;
sel = document . selection . createRange ( ) ;
sel . text = myValue ;
}
// Mozilla/Netscape support
else if ( myField . selectionStart || myField . selectionStart == '0' ) {
var startPos = myField . selectionStart ;
var endPos = myField . selectionEnd ;
myField . value = myField . value . substring ( 0 , startPos )
+ myValue + myField . value . substring ( endPos , myField . value . length ) ;
} else {
myField . value += myValue ;
}
2006-03-14 05:26:40 +00:00
}
2007-06-25 14:38:02 +00:00
/ *
2007-07-13 08:14:37 +00:00
Call instead of setting window . onload directly or setting body onload = .
Adds your function to a chain of functions rather than overwriting anything
that exists .
* /
2007-06-25 14:38:02 +00:00
function addonload ( fn ) {
var oldhandler = window . onload ;
window . onload = function ( ) {
if ( oldhandler ) oldhandler ( ) ;
2007-07-13 08:14:37 +00:00
fn ( ) ;
2007-06-25 14:38:02 +00:00
}
}
2008-09-24 09:32:46 +00:00
2009-03-16 06:09:05 +00:00
function getElementsByClassName ( oElm , strTagName , oClassNames ) {
2008-09-24 09:32:46 +00:00
var arrElements = ( strTagName == "*" && oElm . all ) ? oElm . all : oElm . getElementsByTagName ( strTagName ) ;
var arrReturnElements = new Array ( ) ;
var arrRegExpClassNames = new Array ( ) ;
2009-03-16 06:09:05 +00:00
if ( typeof oClassNames == "object" ) {
for ( var i = 0 ; i < oClassNames . length ; i ++ ) {
2008-09-24 09:32:46 +00:00
arrRegExpClassNames . push ( new RegExp ( "(^|\\s)" + oClassNames [ i ] . replace ( /\-/g , "\\-" ) + "(\\s|$)" ) ) ;
}
}
else {
arrRegExpClassNames . push ( new RegExp ( "(^|\\s)" + oClassNames . replace ( /\-/g , "\\-" ) + "(\\s|$)" ) ) ;
}
var oElement ;
var bMatchesAll ;
2009-03-16 06:09:05 +00:00
for ( var j = 0 ; j < arrElements . length ; j ++ ) {
2008-09-24 09:32:46 +00:00
oElement = arrElements [ j ] ;
bMatchesAll = true ;
2009-03-16 06:09:05 +00:00
for ( var k = 0 ; k < arrRegExpClassNames . length ; k ++ ) {
if ( ! arrRegExpClassNames [ k ] . test ( oElement . className ) ) {
2008-09-24 09:32:46 +00:00
bMatchesAll = false ;
break ;
}
}
2009-03-16 06:09:05 +00:00
if ( bMatchesAll ) {
2008-09-24 09:32:46 +00:00
arrReturnElements . push ( oElement ) ;
}
}
return ( arrReturnElements )
}
2008-09-25 03:14:24 +00:00
function openpopup ( url , name , options , fullscreen ) {
2008-11-20 09:57:20 +00:00
var fullurl = url ;
if ( ! url . match ( /https?:\/\// ) ) {
2009-03-31 03:24:21 +00:00
fullurl = moodle _cfg . wwwroot + url ;
2008-11-20 09:57:20 +00:00
}
2008-09-25 03:14:24 +00:00
var windowobj = window . open ( fullurl , name , options ) ;
2009-03-31 03:24:21 +00:00
if ( ! windowobj ) {
return true ;
}
2008-09-25 03:14:24 +00:00
if ( fullscreen ) {
windowobj . moveTo ( 0 , 0 ) ;
windowobj . resizeTo ( screen . availWidth , screen . availHeight ) ;
}
windowobj . focus ( ) ;
return false ;
}
2008-09-25 10:07:11 +00:00
/* This is only used on a few help pages. */
emoticons _help = {
inputarea : null ,
init : function ( formname , fieldname , listid ) {
if ( ! opener || ! opener . document . forms [ formname ] ) {
return ;
}
emoticons _help . inputarea = opener . document . forms [ formname ] [ fieldname ] ;
if ( ! emoticons _help . inputarea ) {
return ;
}
var emoticons = document . getElementById ( listid ) . getElementsByTagName ( 'li' ) ;
for ( var i = 0 ; i < emoticons . length ; i ++ ) {
var text = emoticons [ i ] . getElementsByTagName ( 'img' ) [ 0 ] . alt ;
YAHOO . util . Event . addListener ( emoticons [ i ] , 'click' , emoticons _help . inserttext , text ) ;
}
} ,
inserttext : function ( e , text ) {
text = ' ' + text + ' ' ;
if ( emoticons _help . inputarea . createTextRange && emoticons _help . inputarea . caretPos ) {
var caretPos = emoticons _help . inputarea . caretPos ;
caretPos . text = caretPos . text . charAt ( caretPos . text . length - 1 ) == ' ' ? text + ' ' : text ;
} else {
emoticons _help . inputarea . value += text ;
}
emoticons _help . inputarea . focus ( ) ;
}
2008-10-31 08:25:19 +00:00
}
/ * *
* Makes a best effort to connect back to Moodle to update a user preference ,
* however , there is no mechanism for finding out if the update succeeded .
*
* Before you can use this function in your JavsScript , you must have called
* user _preference _allow _ajax _update from moodlelib . php to tell Moodle that
* the udpate is allowed , and how to safely clean and submitted values .
*
* @ param String name the name of the setting to udpate .
* @ param String the value to set it to .
* /
function set _user _preference ( name , value ) {
// Don't generate a script error if the library has not been loaded,
// unless we are a Developer, in which case we want the error.
if ( YAHOO && YAHOO . util && YAHOO . util . Connect || moodle _cfg . developerdebug ) {
var url = moodle _cfg . wwwroot + '/lib/ajax/setuserpref.php?sesskey=' +
moodle _cfg . sesskey + '&pref=' + encodeURI ( name ) + '&value=' + encodeURI ( value ) ;
// If we are a developer, ensure that failures are reported.
var callback = { } ;
if ( moodle _cfg . developerdebug ) {
callback . failure = function ( ) {
var a = document . createElement ( 'a' ) ;
a . href = url ;
a . classname = 'error' ;
a . appendChild ( document . createTextNode ( "Error updating user preference '" + name + "' using ajax. Clicking this link will repeat the Ajax call that failed so you can see the error." ) ) ;
document . body . insertBefore ( a , document . body . firstChild ) ;
}
}
// Make the request.
YAHOO . util . Connect . asyncRequest ( 'GET' , url , callback ) ;
}
2008-10-31 08:45:35 +00:00
}
function moodle _initialise _body ( ) {
document . body . className += ' jsenabled' ;
2008-11-03 05:04:23 +00:00
}
/ * *
* Oject to handle a collapsible region , see print _collapsible _region in weblib . php
* @ constructor
* @ param String id the HTML id for the div .
* @ param String userpref the user preference that records the state of this box . false if none .
* @ param Boolean startcollapsed whether the box should start collapsed .
* /
2009-07-03 06:38:41 +00:00
function collapsible _region ( id , userpref , strtooltip , collapsedicon , expandedicon ) {
2008-11-03 05:04:23 +00:00
// Record the pref name
this . userpref = userpref ;
2009-07-03 06:38:41 +00:00
this . collapsedicon = collapsedicon ;
this . expandedicon = expandedicon ;
2008-11-03 05:04:23 +00:00
// Find the divs in the document.
this . div = document . getElementById ( id ) ;
2008-11-04 05:12:12 +00:00
this . innerdiv = document . getElementById ( id + '_sizer' ) ;
2008-11-03 05:04:23 +00:00
this . caption = document . getElementById ( id + '_caption' ) ;
this . caption . title = strtooltip ;
// Put the contents of caption in an <a> to make it focussable.
var a = document . createElement ( 'a' ) ;
while ( e = this . caption . firstChild ) {
a . appendChild ( e ) ;
}
a . href = '#' ;
this . caption . appendChild ( a ) ;
// Create the animation.
this . animation = new YAHOO . util . Anim ( this . div , { } , 0.3 , YAHOO . util . Easing . easeBoth ) ;
// Get to the right initial state.
if ( this . div . className . match ( /\bcollapsed\b/ ) ) {
this . collapsed = true ;
2008-11-04 09:14:03 +00:00
var self = this ;
setTimeout ( function ( ) {
var region = YAHOO . util . Region . getRegion ( self . caption ) ;
self . div . style . height = ( region . bottom - region . top + 3 ) + 'px' ;
} , 10 ) ;
2008-11-03 05:04:23 +00:00
}
// Add the appropriate image.
this . icon = document . createElement ( 'img' ) ;
this . icon . id = id + '_icon' ;
this . icon . alt = '' ;
if ( this . collapsed ) {
2009-07-03 06:38:41 +00:00
this . icon . src = this . collapsedicon ;
2008-11-03 05:04:23 +00:00
} else {
2009-07-03 06:38:41 +00:00
this . icon . src = this . expandedicon ;
2008-11-03 05:04:23 +00:00
}
2008-11-03 06:06:08 +00:00
a . appendChild ( this . icon ) ;
2008-11-03 05:04:23 +00:00
// Hook up the event handler.
2008-11-04 05:12:12 +00:00
var self = this ;
2008-11-03 05:04:23 +00:00
YAHOO . util . Event . addListener ( a , 'click' , function ( e ) { self . handle _click ( e ) ; } ) ;
2008-11-04 05:12:12 +00:00
// Handler for the animation finishing.
this . animation . onComplete . subscribe ( function ( ) { self . handle _animation _complete ( ) ; } ) ;
2008-11-03 05:04:23 +00:00
}
/ * *
* The user preference that stores the state of this box .
2009-03-05 03:35:13 +00:00
* @ property userpref
2008-11-03 05:04:23 +00:00
* @ type String
* /
collapsible _region . prototype . userpref = null ;
/ * *
* The key divs that make up this
* @ property div , innerdiv , captiondiv
* @ type HTMLDivElement
* /
collapsible _region . prototype . div = null ;
collapsible _region . prototype . innerdiv = null ;
collapsible _region . prototype . captiondiv = null ;
/ * *
* The key divs that make up this
* @ property icon
* @ type HTMLImageElement
* /
collapsible _region . prototype . icon = null ;
/ * *
* Whether the region is currently collapsed .
* @ property collapsed
* @ type Boolean
* /
collapsible _region . prototype . collapsed = false ;
/ * *
* @ property animation
* @ type YAHOO . util . Anim
* /
collapsible _region . prototype . animation = null ;
2008-11-04 05:12:12 +00:00
/** When clicked, toggle the collapsed state, and trigger the animation. */
2008-11-03 05:04:23 +00:00
collapsible _region . prototype . handle _click = function ( e ) {
// Toggle the state.
this . collapsed = ! this . collapsed ;
// Stop the click following the link.
YAHOO . util . Event . stopEvent ( e ) ;
// Animate to the appropriate size.
if ( this . animation . isAnimated ( ) ) {
this . animation . stop ( ) ;
}
if ( this . collapsed ) {
2008-11-04 07:22:23 +00:00
var region = YAHOO . util . Region . getRegion ( this . caption ) ;
var targetheight = region . bottom - region . top + 3 ;
2008-11-03 05:04:23 +00:00
} else {
2008-11-04 07:22:23 +00:00
var region = YAHOO . util . Region . getRegion ( this . innerdiv ) ;
var targetheight = region . bottom - region . top + 2 ;
2008-11-03 05:04:23 +00:00
this . div . className = this . div . className . replace ( /\s*\bcollapsed\b\s*/ , ' ' ) ;
}
2008-11-04 07:22:23 +00:00
this . animation . attributes . height = { to : targetheight , unit : 'px' } ;
2008-11-03 05:04:23 +00:00
this . animation . animate ( ) ;
// Set the appropriate icon.
if ( this . collapsed ) {
2009-07-03 06:38:41 +00:00
this . icon . src = this . collapsedicon ;
2008-11-03 05:04:23 +00:00
} else {
2009-07-03 06:38:41 +00:00
this . icon . src = this . expandedicon ;
2008-11-03 05:04:23 +00:00
}
// Update the user preference.
if ( this . userpref ) {
set _user _preference ( this . userpref , this . collapsed ) ;
}
}
2008-11-04 05:12:12 +00:00
/** When when the animation is finished, add the collapsed class name in relevant. */
collapsible _region . prototype . handle _animation _complete = function ( ) {
if ( this . collapsed ) {
this . div . className += ' collapsed' ;
}
2008-12-10 08:57:50 +00:00
}
/** Close the current browser window. */
function close _window ( ) {
window . close ( ) ;
}
/ * *
* Close the current browser window , forcing the window / tab that opened this
* popup to reload itself . * /
function close _window _reloading _opener ( ) {
if ( window . opener ) {
window . opener . location . reload ( 1 ) ;
close _window ( ) ;
// Intentionally, only try to close the window if there is some evidence we are in a popup.
}
2009-03-13 09:56:53 +00:00
}
2009-06-23 01:18:22 +00:00
/ * *
* Used in a couple of modules to hide navigation areas when using AJAX
* /
function hide _item ( itemid ) {
var item = document . getElementById ( itemid ) ;
if ( item ) {
item . style . display = "none" ;
}
2009-06-26 09:06:16 +00:00
}
/ * *
* Tranfer keyboard focus to the HTML element with the given id , if it exists .
* @ param controlid the control id .
* /
function focuscontrol ( controlid ) {
var control = document . getElementById ( controlid ) ;
if ( control ) {
control . focus ( ) ;
}
2009-06-26 09:38:14 +00:00
}
2009-07-07 09:09:16 +00:00
/ * *
* Transfers keyboard focus to an HTML element based on the old style style of focus
* This function should be removed as soon as it is no longer used
* /
function old _onload _focus ( parentname , controlname ) {
if ( window [ parentname ] ) {
window [ parentname ] [ controlname ] . focus ( ) ;
}
}
2009-06-26 09:38:14 +00:00
function scroll _to _end ( ) {
window . scrollTo ( 0 , 5000000 ) ;
}
var scrolltoendtimeout ;
function repeatedly _scroll _to _end ( ) {
scrolltoendtimeout = setInterval ( scroll _to _end , 50 ) ;
}
function cancel _scroll _to _end ( ) {
if ( scrolltoendtimeout ) {
clearTimeout ( scrolltoendtimeout ) ;
scrolltoendtimeout = null ;
}
}
2009-07-08 04:12:11 +00:00
function create _UFO _object ( eid ) {
UFO . create ( FO , eid ) ;
}