summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-02-09 08:24:23 -0500
committerEvan Prodromou <evan@controlyourself.ca>2009-02-09 08:24:23 -0500
commit5d246299b630c55d98cc03eeb650561defbeeff4 (patch)
treec98c865125951e1d2ef4759d518896cfa71e39ef
parent60bf87bb34c4c0216fbbe42458d194e1e76c0aaa (diff)
add hooks for JavaScript handling
-rw-r--r--EVENTS.txt20
-rw-r--r--lib/action.php33
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));
+ }
}
/**