diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-02-09 08:24:23 -0500 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-02-09 08:24:23 -0500 |
commit | 5d246299b630c55d98cc03eeb650561defbeeff4 (patch) | |
tree | c98c865125951e1d2ef4759d518896cfa71e39ef | |
parent | 60bf87bb34c4c0216fbbe42458d194e1e76c0aaa (diff) |
add hooks for JavaScript handling
-rw-r--r-- | EVENTS.txt | 20 | ||||
-rw-r--r-- | lib/action.php | 33 |
2 files changed, 41 insertions, 12 deletions
diff --git a/EVENTS.txt b/EVENTS.txt index bd511d75e..68e25fa3b 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -9,3 +9,23 @@ StartSecondaryNav: Showing the secondary nav menu EndSecondaryNav: At the end of the secondary nav menu - $action: the current action + +StartShowScripts: Showing JavaScript links +- $action: the current action + +EndShowScripts: End showing JavaScript links; good place to add custom + links like Google Analytics +- $action: the current action + +StartShowJQueryScripts: Showing JQuery script links (use this to link to e.g. Google mirrors) +- $action: the current action + +EndShowJQueryScripts: End showing JQuery script links +- $action: the current action + +StartShowLaconicaScripts: Showing Laconica script links (use this to link to a CDN or something) +- $action: the current action + +EndShowLaconicaScripts: End showing Laconica script links +- $action: the current action + diff --git a/lib/action.php b/lib/action.php index 36f598c57..0628dc70d 100644 --- a/lib/action.php +++ b/lib/action.php @@ -179,18 +179,27 @@ class Action extends HTMLOutputter // lawsuit */ function showScripts() { - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/jquery.min.js')), - ' '); - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/jquery.form.js')), - ' '); - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/xbImportNode.js')), - ' '); - $this->element('script', array('type' => 'text/javascript', - 'src' => common_path('js/util.js?version='.LACONICA_VERSION)), - ' '); + if (Event::handle('StartShowScripts', array($this))) { + if (Event::handle('StartShowJQueryScripts', array($this))) { + $this->element('script', array('type' => 'text/javascript', + 'src' => common_path('js/jquery.min.js')), + ' '); + $this->element('script', array('type' => 'text/javascript', + 'src' => common_path('js/jquery.form.js')), + ' '); + Event::handle('EndShowJQueryScripts', array($this)); + } + if (Event::handle('StartShowLaconicaScripts', array($this))) { + $this->element('script', array('type' => 'text/javascript', + 'src' => common_path('js/xbImportNode.js')), + ' '); + $this->element('script', array('type' => 'text/javascript', + 'src' => common_path('js/util.js?version='.LACONICA_VERSION)), + ' '); + Event::handle('EndShowLaconicaScripts', array($this)); + } + Event::handle('EndShowScripts', array($this)); + } } /** |