summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2005-10-15 20:44:04 +0200
committerAndreas Gohr <andi@splitbrain.org>2005-10-15 20:44:04 +0200
commit5e1632788b8a5f5b9eebd2acb72e1de7d9f0ac63 (patch)
treec204ba3e934a2e64928d4d59395516b7c0bb881f /inc/template.php
parent20d062ca5220daf6606e2b1bcdd73d84eebafa45 (diff)
downloadrpg-5e1632788b8a5f5b9eebd2acb72e1de7d9f0ac63.tar.gz
rpg-5e1632788b8a5f5b9eebd2acb72e1de7d9f0ac63.tar.bz2
more unobstrusive javascript
The edit form now is free of inline event handlers. There are still other places where inline javascript and even document.write is used which should be fixed as well. Currently the window.onload event is used to initialize everything which may not the best way to do so. Dean Edwards may have a solution: http://dean.edwards.name/weblog/2005/09/busted/ darcs-hash:20051015184404-7ad00-2404744d008e5ea7e1b5800c96800824b532ff47.gz
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php78
1 files changed, 45 insertions, 33 deletions
diff --git a/inc/template.php b/inc/template.php
index 8c84515c2..9d0d3ef9a 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -225,42 +225,55 @@ function tpl_metaheaders(){
ptln('<script language="javascript" type="text/javascript" charset="utf-8" src="'.
DOKU_BASE.'lib/scripts/domTT.js"></script>',$it);
- // add size control
- ptln('<script language="javascript" type="text/javascript" charset="utf-8">',$it);
- ptln("addEvent(window,'onload',function(){initSizeCtl('sizectl','wikitext')});",$it+2);
- ptln('</script>',$it);
// editing functions
- if(($ACT=='edit' || $ACT=='preview') && $INFO['writable']){
- // load toolbar functions
- ptln('<script language="javascript" type="text/javascript" charset="utf-8" src="'.
- DOKU_BASE.'lib/scripts/edit.js"></script>',$it);
+ if($ACT=='edit' || $ACT=='preview'){
+ // add size control
+ ptln('<script language="javascript" type="text/javascript" charset="utf-8">',$it);
+ ptln("addEvent(window,'onload',function(){initSizeCtl('sizectl','wikitext')});",$it+2);
+ ptln('</script>',$it);
- // load spellchecker functions if wanted
- if($conf['spellchecker']){
+ if($INFO['writable']){
+ // load toolbar functions
ptln('<script language="javascript" type="text/javascript" charset="utf-8" src="'.
- DOKU_BASE.'lib/scripts/spellcheck.js"></script>',$it+2);
- }
+ DOKU_BASE.'lib/scripts/edit.js"></script>',$it);
- ptln('<script language="javascript" type="text/javascript" charset="utf-8">',$it);
-
- // add toolbar
- require_once(DOKU_INC.'inc/toolbar.php');
- toolbar_JSdefines('toolbar');
- ptln("addEvent(window,'onload',function(){initToolbar('toolbar','wikitext',toolbar);});",$it+2);
-
- // add spellchecker
- if($conf['spellchecker']){
- //init here
- ptln("addEvent(window,'onload',function(){ ajax_spell.init('".$lang['spell_start']."','".
- $lang['spell_stop']."','".
- $lang['spell_wait']."','".
- $lang['spell_noerr']."','".
- $lang['spell_nosug']."','".
- $lang['spell_change']."'); });");
+ // load spellchecker functions if wanted
+ if($conf['spellchecker']){
+ ptln('<script language="javascript" type="text/javascript" charset="utf-8" src="'.
+ DOKU_BASE.'lib/scripts/spellcheck.js"></script>',$it+2);
+ }
+
+ ptln('<script language="javascript" type="text/javascript" charset="utf-8">',$it);
+
+ // add toolbar
+ require_once(DOKU_INC.'inc/toolbar.php');
+ toolbar_JSdefines('toolbar');
+ ptln("addEvent(window,'onload',function(){initToolbar('toolbar','wikitext',toolbar);});",$it+2);
+
+ // add pageleave check
+ ptln("addEvent(window,'onload',function(){initChangeCheck('".
+ str_replace('\\\\n','\\n',addslashes($lang['notsavedyet']))."');});",$it);
+
+ // add lock timer
+ ptln("addEvent(window,'onload',function(){init_locktimer(".
+ ($conf['locktime']-60).",'".
+ str_replace('\\\\n','\\n',addslashes($lang['willexpire']))."');});",$it);
+
+ // add spellchecker
+ if($conf['spellchecker']){
+ //init here
+ ptln("addEvent(window,'onload',function(){ ajax_spell.init('".
+ $lang['spell_start']."','".
+ $lang['spell_stop']."','".
+ $lang['spell_wait']."','".
+ $lang['spell_noerr']."','".
+ $lang['spell_nosug']."','".
+ $lang['spell_change']."'); });");
+ }
+ ptln('</script>',$it);
}
- ptln('</script>',$it);
}
// plugin stylesheets and Scripts
@@ -270,13 +283,12 @@ function tpl_metaheaders(){
/**
* Print a link
*
- * Just builds a link but adds additional JavaScript needed for
- * the unsaved data check needed in the edit form.
+ * Just builds a link.
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function tpl_link($url,$name,$more=''){
- print '<a href="'.$url.'" onclick="return svchk()" onkeypress="return svchk()"';
+ print '<a href="'.$url.'" ';
if ($more) print ' '.$more;
print ">$name</a>";
}
@@ -522,7 +534,7 @@ function tpl_searchform(){
global $lang;
global $ACT;
- print '<form action="'.wl().'" accept-charset="utf-8" class="search" name="search" onsubmit="return svchk()">';
+ print '<form action="'.wl().'" accept-charset="utf-8" class="search" name="search">';
print '<input type="hidden" name="do" value="search" />';
print '<input type="text" ';