Use script() and cssLink() methods everywhere instead of manually writing out javascript and css each time

This commit is contained in:
Craig Andrews 2009-08-05 19:45:12 -04:00
parent 6a76addbe8
commit 304db1d30b
5 changed files with 21 additions and 96 deletions

View File

@ -382,13 +382,7 @@ class AvatarsettingsAction extends AccountSettingsAction
function showStylesheets() function showStylesheets()
{ {
parent::showStylesheets(); parent::showStylesheets();
$jcropStyle = $this->cssLink('css/jquery.Jcrop.css','base','screen, projection, tv');
common_path('theme/base/css/jquery.Jcrop.css?version='.LACONICA_VERSION);
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => $jcropStyle,
'media' => 'screen, projection, tv'));
} }
/** /**
@ -402,13 +396,8 @@ class AvatarsettingsAction extends AccountSettingsAction
parent::showScripts(); parent::showScripts();
if ($this->mode == 'crop') { if ($this->mode == 'crop') {
$jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js'); $this->script('js/jcrop/jquery.Jcrop.pack.js');
$jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js'); $this->script('js/jcrop/jquery.Jcrop.go.js');
$this->element('script', array('type' => 'text/javascript',
'src' => $jcropPack));
$this->element('script', array('type' => 'text/javascript',
'src' => $jcropGo));
} }
} }
} }

View File

@ -428,13 +428,7 @@ class GrouplogoAction extends GroupDesignAction
function showStylesheets() function showStylesheets()
{ {
parent::showStylesheets(); parent::showStylesheets();
$jcropStyle = $this->cssLink('css/jquery.Jcrop.css','base','screen, projection, tv');
common_path('theme/base/css/jquery.Jcrop.css?version='.LACONICA_VERSION);
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => $jcropStyle,
'media' => 'screen, projection, tv'));
} }
/** /**
@ -448,13 +442,8 @@ class GrouplogoAction extends GroupDesignAction
parent::showScripts(); parent::showScripts();
if ($this->mode == 'crop') { if ($this->mode == 'crop') {
$jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js'); $this->script('js/jcrop/jquery.Jcrop.pack.js');
$jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js'); $this->script('js/jcrop/jquery.Jcrop.go.js');
$this->element('script', array('type' => 'text/javascript',
'src' => $jcropPack));
$this->element('script', array('type' => 'text/javascript',
'src' => $jcropGo));
} }
} }

View File

@ -193,21 +193,12 @@ class Action extends HTMLOutputter // lawsuit
if (Event::handle('StartShowStyles', array($this))) { if (Event::handle('StartShowStyles', array($this))) {
if (Event::handle('StartShowLaconicaStyles', array($this))) { if (Event::handle('StartShowLaconicaStyles', array($this))) {
$this->element('link', array('rel' => 'stylesheet', $this->cssLink('css/display.css',null,'screen, projection, tv');
'type' => 'text/css',
'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION,
'media' => 'screen, projection, tv'));
if (common_config('site', 'mobile')) { if (common_config('site', 'mobile')) {
$this->element('link', array('rel' => 'stylesheet', // TODO: "handheld" CSS for other mobile devices
'type' => 'text/css', $this->cssLink('css/mobile.css','base','only screen and (max-device-width: 480px)'); // Mobile WebKit
'href' => theme_path('css/mobile.css', 'base') . '?version=' . LACONICA_VERSION,
// TODO: "handheld" CSS for other mobile devices
'media' => 'only screen and (max-device-width: 480px)')); // Mobile WebKit
} }
$this->element('link', array('rel' => 'stylesheet', $this->cssLink('css/print.css','base','print');
'type' => 'text/css',
'href' => theme_path('css/print.css', 'base') . '?version=' . LACONICA_VERSION,
'media' => 'print'));
Event::handle('EndShowLaconicaStyles', array($this)); Event::handle('EndShowLaconicaStyles', array($this));
} }
@ -253,26 +244,14 @@ class Action extends HTMLOutputter // lawsuit
{ {
if (Event::handle('StartShowScripts', array($this))) { if (Event::handle('StartShowScripts', array($this))) {
if (Event::handle('StartShowJQueryScripts', array($this))) { if (Event::handle('StartShowJQueryScripts', array($this))) {
$this->element('script', array('type' => 'text/javascript', $this->script('js/jquery.min.js');
'src' => common_path('js/jquery.min.js')), $this->script('js/jquery.form.js');
' '); $this->script('js/jquery.joverlay.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/jquery.joverlay.min.js')),
' ');
Event::handle('EndShowJQueryScripts', array($this)); Event::handle('EndShowJQueryScripts', array($this));
} }
if (Event::handle('StartShowLaconicaScripts', array($this))) { if (Event::handle('StartShowLaconicaScripts', array($this))) {
$this->element('script', array('type' => 'text/javascript', $this->script('js/xbImportNode.js');
'src' => common_path('js/xbImportNode.js')), $this->script('js/util.js');
' ');
$this->element('script', array('type' => 'text/javascript',
'src' => common_path('js/util.js?version='.LACONICA_VERSION)),
' ');
// Frame-busting code to avoid clickjacking attacks. // Frame-busting code to avoid clickjacking attacks.
$this->element('script', array('type' => 'text/javascript'), $this->element('script', array('type' => 'text/javascript'),
'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }'); 'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }');

View File

@ -311,13 +311,7 @@ class DesignSettingsAction extends AccountSettingsAction
function showStylesheets() function showStylesheets()
{ {
parent::showStylesheets(); parent::showStylesheets();
$farbtasticStyle = $this->cssLink('css/farbtastic.css','base','screen, projection, tv');
common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION);
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => $farbtasticStyle,
'media' => 'screen, projection, tv'));
} }
/** /**
@ -330,13 +324,8 @@ class DesignSettingsAction extends AccountSettingsAction
{ {
parent::showScripts(); parent::showScripts();
$farbtasticPack = common_path('js/farbtastic/farbtastic.js'); $this->script('js/farbtastic/farbtastic.js');
$userDesignGo = common_path('js/userdesign.go.js'); $this->script('js/farbtastic/farbtastic.go.js');
$this->element('script', array('type' => 'text/javascript',
'src' => $farbtasticPack));
$this->element('script', array('type' => 'text/javascript',
'src' => $userDesignGo));
} }
/** /**

View File

@ -95,34 +95,13 @@ class FacebookAction extends Action
function showStylesheets() function showStylesheets()
{ {
// Add a timestamp to the file so Facebook cache wont ignore our changes $this->cssLink('css/display.css', 'base');
$ts = filemtime(INSTALLDIR.'/theme/base/css/display.css'); $this->cssLink('css/facebookapp.css', 'base');
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => theme_path('css/display.css', 'base') . '?ts=' . $ts));
$theme = common_config('site', 'theme');
$ts = filemtime(INSTALLDIR. '/theme/' . $theme .'/css/display.css');
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => theme_path('css/display.css', null) . '?ts=' . $ts));
$ts = filemtime(INSTALLDIR.'/theme/base/css/facebookapp.css');
$this->element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => theme_path('css/facebookapp.css', 'base') . '?ts=' . $ts));
} }
function showScripts() function showScripts()
{ {
// Add a timestamp to the file so Facebook cache wont ignore our changes $this->script('js/facebookapp.js');
$ts = filemtime(INSTALLDIR.'/js/facebookapp.js');
$this->element('script', array('src' => common_path('js/facebookapp.js') . '?ts=' . $ts));
} }
/** /**