mirror of
https://github.com/e107inc/e107.git
synced 2025-04-22 13:41:52 +02:00
Pre and post sting option for CSS includes (js manager), js block removed from e_css
This commit is contained in:
parent
78588e2eda
commit
078a655523
@ -39,10 +39,5 @@ echo "
|
||||
span.e-hide-if-js,
|
||||
button.e-hide-if-js { display: inline; }
|
||||
</style>
|
||||
<script type='text/javascript'>
|
||||
//$('e-js-css').disabled=true;
|
||||
// 'disabled' is not valid style attribute, fails with Konqueror (tested on Fedora)
|
||||
$('e-js-css').remove();
|
||||
</script>
|
||||
";
|
||||
?>
|
@ -211,7 +211,7 @@ class e_jsmanager
|
||||
* @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
|
||||
* @return e_jsmanager
|
||||
*/
|
||||
public function coreCSS($file_path, $media = 'all')
|
||||
public function coreCSS($file_path, $media = 'all', $preComment = '', $postComment = '')
|
||||
{
|
||||
$this->addJs('core_css', $file_path, $media);
|
||||
return $this;
|
||||
@ -225,17 +225,17 @@ class e_jsmanager
|
||||
* @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
|
||||
* @return e_jsmanager
|
||||
*/
|
||||
public function pluginCSS($plugname, $file_path, $media = 'all')
|
||||
public function pluginCSS($plugname, $file_path, $media = 'all', $preComment = '', $postComment = '')
|
||||
{
|
||||
if(is_array($file_path))
|
||||
{
|
||||
foreach ($file_path as $fpath => $media_attr)
|
||||
{
|
||||
$this->addJs('plugin_css', $plugname.':'.$fpath, $media_attr);
|
||||
$this->addJs('plugin_css', $plugname.':'.$fpath, $media_attr, $preComment, $postComment);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
$this->addJs('plugin_css', $plugname.':'.$file_path, $media);
|
||||
$this->addJs('plugin_css', $plugname.':'.$file_path, $media, $preComment, $postComment);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -246,9 +246,9 @@ class e_jsmanager
|
||||
* @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
|
||||
* @return e_jsmanager
|
||||
*/
|
||||
public function themeCSS($file_path, $media = 'all')
|
||||
public function themeCSS($file_path, $media = 'all', $preComment = '', $postComment = '')
|
||||
{
|
||||
$this->addJs('theme_css', $file_path, $media);
|
||||
$this->addJs('theme_css', $file_path, $media, $preComment, $postComment);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -259,9 +259,9 @@ class e_jsmanager
|
||||
* @param string $media any valid media attribute string - http://www.w3schools.com/TAGS/att_link_media.asp
|
||||
* @return e_jsmanager
|
||||
*/
|
||||
public function otherCSS($file_path, $media = 'all')
|
||||
public function otherCSS($file_path, $media = 'all', $preComment = '', $postComment = '')
|
||||
{
|
||||
$this->addJs('other_css', $file_path, $media);
|
||||
$this->addJs('other_css', $file_path, $media, $preComment, $postComment);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -519,7 +519,7 @@ class e_jsmanager
|
||||
* @param string|integer $runtime_location admin|front|all (jslib), 0-5 (runtime inclusion), 'media' attribute (CSS)
|
||||
* @return object $this
|
||||
*/
|
||||
protected function addJs($type, $file_path, $runtime_location = '')
|
||||
protected function addJs($type, $file_path, $runtime_location = '', $pre = '', $post = '')
|
||||
{
|
||||
if(empty($file_path))
|
||||
{
|
||||
@ -562,7 +562,7 @@ class e_jsmanager
|
||||
break;
|
||||
|
||||
case 'core_css': //FIXME - core CSS should point to new e_WEB/css; add one more case - js_css -> e_WEB/jslib/
|
||||
$file_path = $runtime_location.'|{e_FILE}jslib/'.trim($file_path, '/');
|
||||
$file_path = $runtime_location.'|{e_FILE}jslib/'.trim($file_path, '/')."|{$pre}|{$post}";
|
||||
if(!isset($this->_e_css['core'])) $this->_e_css['core'] = array();
|
||||
$registry = &$this->_e_css['core'];
|
||||
$runtime = true;
|
||||
@ -570,14 +570,14 @@ class e_jsmanager
|
||||
|
||||
case 'plugin_css':
|
||||
$file_path = explode(':', $file_path);
|
||||
$file_path = $runtime_location.'|{e_PLUGIN}'.$file_path[0].'/'.trim($file_path[1], '/');
|
||||
$file_path = $runtime_location.'|{e_PLUGIN}'.$file_path[0].'/'.trim($file_path[1], '/')."|{$pre}|{$post}";
|
||||
if(!isset($this->_e_css['plugin'])) $this->_e_css['plugin'] = array();
|
||||
$registry = &$this->_e_css['plugin'];
|
||||
$runtime = true;
|
||||
break;
|
||||
|
||||
case 'theme_css':
|
||||
$file_path = $runtime_location.'|{e_THEME}'.$this->getCurrentTheme().'/'.trim($file_path, '/');
|
||||
$file_path = $runtime_location.'|{e_THEME}'.$this->getCurrentTheme().'/'.trim($file_path, '/')."|{$pre}|{$post}";
|
||||
if(!isset($this->_e_css['theme'])) $this->_e_css['theme'] = array();
|
||||
$registry = &$this->_e_css['theme'];
|
||||
$runtime = true;
|
||||
@ -806,10 +806,14 @@ class e_jsmanager
|
||||
{
|
||||
if('css' === $external)
|
||||
{
|
||||
$path = explode('|', $path, 2);
|
||||
$path = explode('|', $path, 4);
|
||||
$media = $path[0] ? $path[0] : 'all';
|
||||
// support of IE checks
|
||||
$pre = varset($path[2]) ? $path[2]."\n" : '';
|
||||
$post = varset($path[3]) ? "\n".$path[3] : '';
|
||||
$path = $path[1];
|
||||
echo '<link rel="stylesheet" media="'.$media.'" type="text/css" href="'.$tp->replaceConstants($path, 'abs').'?external=1&cacheid='.$this->getCacheId().'" />';
|
||||
|
||||
echo $pre.'<link rel="stylesheet" media="'.$media.'" type="text/css" href="'.$tp->replaceConstants($path, 'abs').'?external=1&cacheid='.$this->getCacheId().'" />'.$post;
|
||||
echo "\n";
|
||||
continue;
|
||||
}
|
||||
@ -829,10 +833,14 @@ class e_jsmanager
|
||||
{
|
||||
if('css' === $external)
|
||||
{
|
||||
$path = explode('|', $path, 2);
|
||||
$path = explode('|', $path, 4);
|
||||
$media = $path[0];
|
||||
// support of IE checks
|
||||
$pre = varset($path[2]) ? $path[2]."\n" : '';
|
||||
$post = varset($path[3]) ? "\n".$path[3] : '';
|
||||
$path = $path[1];
|
||||
echo '<link rel="stylesheet" media="'.$media.'" type="text/css" href="'.$tp->replaceConstants($path, 'abs').'?'.$this->getCacheId().'" />';
|
||||
|
||||
echo $pre.'<link rel="stylesheet" media="'.$media.'" type="text/css" href="'.$tp->replaceConstants($path, 'abs').'?'.$this->getCacheId().'" />'.$post;
|
||||
echo "\n";
|
||||
continue;
|
||||
}
|
||||
|
@ -290,6 +290,11 @@ if($e_pref->get('enable_png_image_fix') || (isset($sleight) && $sleight == true)
|
||||
echo "<![endif]-->\n";
|
||||
}
|
||||
|
||||
//
|
||||
// Style for unobtrusive JS, prevent 3rd party code overload
|
||||
//
|
||||
require_once(e_FILE."/e_css.php");
|
||||
|
||||
//
|
||||
// E: Send JS all in once
|
||||
// Read here why - http://code.google.com/speed/page-speed/docs/rtt.html#PutStylesBeforeScripts
|
||||
@ -428,12 +433,6 @@ elseif (file_exists(e_BASE."favicon.ico"))
|
||||
echo "<link rel='icon' href='".SITEURL."favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='".SITEURL."favicon.ico' type='image/xicon' />\n";
|
||||
}
|
||||
|
||||
//
|
||||
// Unobtrusive JS, prevent 3rd party code overload
|
||||
//
|
||||
require_once(e_FILE."/e_css.php");
|
||||
|
||||
|
||||
//
|
||||
// FIXME H: Generate JS for image preloads (do we really need this?)
|
||||
//
|
||||
@ -495,6 +494,7 @@ if (count($js_body_onload)) $body_onload = " onload=\"".implode(" ",$js_body_onl
|
||||
*/
|
||||
echo "<script type='text/javascript'>\n";
|
||||
echo "<!--\n";
|
||||
echo "$('e-js-css').remove();\n"; // unobtrusive JS - moved here from external e_css.php
|
||||
echo "document.observe('dom:loaded', function() {\n";
|
||||
echo "e107Event.trigger('loaded', {element: null}, document);\n";
|
||||
echo "});\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user