Index: openacs-4/packages/acs-bootstrap-installer/installer/www/blank-master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-bootstrap-installer/installer/www/blank-master.tcl,v diff -u -N -r1.2.2.6 -r1.2.2.7 --- openacs-4/packages/acs-bootstrap-installer/installer/www/blank-master.tcl 6 Sep 2016 17:33:55 -0000 1.2.2.6 +++ openacs-4/packages/acs-bootstrap-installer/installer/www/blank-master.tcl 9 Sep 2016 08:12:25 -0000 1.2.2.7 @@ -91,21 +91,9 @@ # Add standard javascript # # Include core.js inclusion to the bottom of the body. -# The only function needed alread onload is acs_Focus() -# + template::add_body_script -type "text/javascript" -src "/resources/acs-subsite/core.js" -template::head::add_javascript -script { - function acs_Focus(form_name, element_name) { - if (document.forms == null) return; - if (document.forms[form_name] == null) return; - if (document.forms[form_name].elements[element_name] == null) return; - if (document.forms[form_name].elements[element_name].type == 'hidden') return; - - document.forms[form_name].elements[element_name].focus(); - } -} - # # Add css for the current subsite, defaulting to the old list/form css which was # hard-wired in previous versions of OpenACS. @@ -238,21 +226,36 @@ } if {[info exists focus] && $focus ne ""} { - # Handle elements where the name contains a dot + # + # Handle only values of focus where the provided name contains a + # dot. + # if { [regexp {^([^.]*)\.(.*)$} $focus match form_name element_name] } { - template::add_body_handler \ - -event onload \ - -script "acs_Focus('${form_name}', '${element_name}');" \ - -identifier "focus" + set focus_script { + function acs_Focus(form_name, element_name) { + if (document.forms == null) return; + if (document.forms[form_name] == null) return; + if (document.forms[form_name].elements[element_name] == null) return; + if (document.forms[form_name].elements[element_name].type == 'hidden') return; + + document.forms[form_name].elements[element_name].focus(); + }} + append focus_script "acs_Focus('${form_name}', '${element_name}');\n" + template::add_body_script -script $focus_script + } else { + ns_log warning "blank-master: variable focus has invalid value '$focus'" } } # Retrieve headers and footers set header [template::get_header_html] set footer [template::get_footer_html] template::head::prepare_multirows -set event_handlers [template::get_body_event_handlers] +# body event handlers are converted into body_scripts +template::get_body_event_handlers + + # Local variables: # mode: tcl # tcl-indent-level: 4