Browse Source

fixed javascript

tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
b9c1eff373
  1. 2
      extensions/yii/apidoc/templates/html/Renderer.php
  2. 18
      extensions/yii/apidoc/templates/offline/Renderer.php
  3. 31
      extensions/yii/apidoc/templates/offline/assets/AssetBundle.php
  4. 26
      extensions/yii/apidoc/templates/offline/views/offline.php
  5. 2
      framework/yii/helpers/BaseHtml.php

2
extensions/yii/apidoc/templates/html/Renderer.php vendored

@ -76,7 +76,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
}
$this->_view->assetManager = new AssetManager([
'basePath' => $assetPath,
'baseUrl' => '/assets',
'baseUrl' => './assets',
]);
}
return $this->_view;

18
extensions/yii/apidoc/templates/offline/Renderer.php vendored

@ -23,22 +23,4 @@ class Renderer extends \yii\apidoc\templates\html\Renderer
public $indexView = '@yii/apidoc/templates/offline/views/index.php';
public $pageTitle = 'Yii Framework 2.0 API Documentation';
/**
* Renders a given [[Context]].
*
* @param Context $context the api documentation context to render.
* @param Controller $controller the apidoc controller instance. Can be used to control output.
*/
public function render($context, $controller)
{
parent::render($context, $controller);
$dir = Yii::getAlias($this->targetDir);
$controller->stdout('Copying asset files... ');
FileHelper::copyDirectory(__DIR__ . '/assets/css', $dir . '/css');
$controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
}
}

31
extensions/yii/apidoc/templates/offline/assets/AssetBundle.php vendored

@ -0,0 +1,31 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\apidoc\templates\offline\assets;
use yii\web\JqueryAsset;
use yii\web\View;
/**
* The asset bundle for the offline template.
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
class AssetBundle extends \yii\web\AssetBundle
{
public $sourcePath = '@yii/apidoc/templates/offline/assets/css';
public $css = [
'api.css',
'style.css',
];
public $depends = [
'yii\web\JqueryAsset',
];
public $jsOptions = [
'position' => View::POS_HEAD,
];
}

26
extensions/yii/apidoc/templates/offline/views/offline.php vendored

@ -4,6 +4,8 @@
* @var yii\web\View $this
*/
\yii\apidoc\templates\offline\assets\AssetBundle::register($this);
$this->beginPage();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -11,9 +13,6 @@ $this->beginPage();
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/api.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<?php $this->head(); ?>
<title><?php echo $this->context->pageTitle; ?></title>
</head>
@ -35,16 +34,22 @@ $this->beginPage();
All Rights Reserved.<br/>
</div><!-- end of footer -->
<?php \yii\web\JqueryAsset::register($this); ?>
<script type="text/javascript">
/*<![CDATA[*/
$("a.toggle").toggle(function(){
$(this).text($(this).text().replace(/Hide/,'Show'));
$(this).parents(".summary").find(".inherited").hide();
},function(){
$(this).text($(this).text().replace(/Show/,'Hide'));
$(this).parents(".summary").find(".inherited").show();
$("a.toggle").on('click', function() {
var $this = $(this);
if ($this.hasClass('properties-hidden')) {
$this.text($this.text().replace(/Show/,'Hide'));
$this.parents(".summary").find(".inherited").show();
$this.removeClass('properties-hidden');
} else {
$this.text($this.text().replace(/Hide/,'Show'));
$this.parents(".summary").find(".inherited").hide();
$this.addClass('properties-hidden');
}
return false;
});
/*
$(".sourceCode a.show").toggle(function(){
$(this).text($(this).text().replace(/show/,'hide'));
$(this).parents(".sourceCode").find("div.code").show();
@ -55,6 +60,7 @@ $(".sourceCode a.show").toggle(function(){
$("a.sourceLink").click(function(){
$(this).attr('target','_blank');
});
*/
/*]]>*/
</script>

2
framework/yii/helpers/BaseHtml.php

@ -1471,7 +1471,7 @@ class BaseHtml
return Yii::$app->getRequest()->getUrl();
} else {
$url = Yii::getAlias($url);
if ($url !== '' && ($url[0] === '/' || $url[0] === '#' || strpos($url, '://'))) {
if ($url !== '' && ($url[0] === '/' || $url[0] === '#' || strpos($url, '://') || !strncmp($url, './', 2))) {
return $url;
} else {
return Yii::$app->getRequest()->getBaseUrl() . '/' . $url;

Loading…
Cancel
Save