use fancybox for images, closes #11

This commit is contained in:
cornernote 2015-08-10 12:24:48 +09:30
parent ac85b27860
commit 20ce820214
6 changed files with 78 additions and 36 deletions

View File

@ -11,7 +11,8 @@
"yiisoft/yii2-bootstrap": "*",
"fxp/composer-asset-plugin": "*",
"kartik-v/yii2-widgets": "^3.4",
"cebe/markdown": "~1.0.1"
"cebe/markdown": "~1.0.1",
"bigpaulie/yii2-fancybox": "^1.0"
},
"require-dev": {
"yiisoft/yii2-debug": "*",

62
composer.lock generated
View File

@ -4,8 +4,52 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "2932f0af4cf2332e252af0e542d43751",
"hash": "3a3de782ca636438cd027ce7814594b5",
"packages": [
{
"name": "bigpaulie/yii2-fancybox",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/bigpaulie/yii2-fancybox.git",
"reference": "1b02ef28822697e7f73e627f0a8fc3bff0ee6398"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bigpaulie/yii2-fancybox/zipball/1b02ef28822697e7f73e627f0a8fc3bff0ee6398",
"reference": "1b02ef28822697e7f73e627f0a8fc3bff0ee6398",
"shasum": ""
},
"require": {
"bower-asset/fancybox": "~2.1",
"php": ">=5.4.0",
"yiisoft/yii2": "2.*"
},
"type": "library",
"autoload": {
"psr-4": {
"bigpaulie\\fancybox\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul P",
"email": "bigpaulie25ro@yahoo.com"
}
],
"description": "Yii2 FancyBox extension",
"keywords": [
"extension",
"fancybox",
"widget",
"yii2"
],
"time": "2015-05-01 15:50:39"
},
{
"name": "bower-asset/bootstrap",
"version": "v3.3.5",
@ -55,6 +99,22 @@
"web"
]
},
{
"name": "bower-asset/fancybox",
"version": "v2.1.5",
"source": {
"type": "git",
"url": "https://github.com/fancyapps/fancyBox.git",
"reference": "e2248f468dc4b45f5b1ef1776bde958b2b52775d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fancyapps/fancyBox/zipball/e2248f468dc4b45f5b1ef1776bde958b2b52775d",
"reference": "e2248f468dc4b45f5b1ef1776bde958b2b52775d",
"shasum": ""
},
"type": "bower-asset-library"
},
{
"name": "bower-asset/jquery",
"version": "2.1.4",

View File

@ -4,6 +4,7 @@ namespace app\models;
use app\components\Git;
use app\models\query\PackageQuery;
use bigpaulie\fancybox\FancyBox;
use cebe\markdown\GithubMarkdown;
use Yii;
use yii\behaviors\TimestampBehavior;
@ -182,8 +183,18 @@ class Package extends ActiveRecord
$screenshots = [];
if (isset($this->bowerData['screenshots'])) {
foreach ($this->bowerData['screenshots'] as $screenshot) {
$screenshots[] = Html::img($screenshot, [
'style' => 'max-width:100%',
$screenshots[] = FancyBox::widget([
'type' => 'image',
'item' => [
'href' => $screenshot,
'src' => $screenshot,
],
'htmlOptions' => [
'imageOptions' => [
'class' => 'thumbnail',
'style' => 'max-width:200px',
],
],
]);
}
}

View File

@ -12,36 +12,14 @@ use yii\widgets\DetailView;
<h2><?= Html::a(Html::encode($model->name), ['view', 'name' => $model->name]) ?></h2>
<?php //echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?>
<?php
//echo Html::a('Delete', ['delete', 'id' => $model->id], [
// 'class' => 'btn btn-danger',
// 'data' => [
// 'confirm' => 'Are you sure you want to delete this item?',
// 'method' => 'post',
// ],
//]);
?>
<div class="row">
<div class="col-sm-10">
<?= DetailView::widget([
'model' => $model,
'attributes' => [
//'name',
'description',
'keywords',
'homepage:url',
//[
// 'attribute' => 'url',
// 'value' => Git::getUrl($model->url),
// 'format' => 'url',
//],
//'hits',
//'bower:ntext',
//'created_at',
//'updated_at',
],
]) ?>
</div>
@ -49,7 +27,7 @@ use yii\widgets\DetailView;
<?= Html::a(Html::img($model->screenshot, [
'class' => 'thumbnail',
'style' => 'max-width:100%',
]), $model->screenshot) ?>
]), ['view', 'name' => $model->name]) ?>
</div>
</div>

View File

@ -15,10 +15,6 @@ $this->params['breadcrumbs'][] = $this->title;
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?php //echo Html::a('Create Package', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= ListView::widget([
'dataProvider' => $dataProvider,
'itemOptions' => ['class' => 'item'],

View File

@ -47,11 +47,6 @@ $this->params['breadcrumbs'][] = $this->title;
// 'value' => Git::getUrl($model->url),
// 'format' => 'url',
//],
[
'label' => 'Screenshots',
'value' => $model->getScreenshotsHtml(),
'format' => 'raw',
],
[
'label' => 'Authors',
'value' => $model->getAuthorsHtml(),
@ -74,6 +69,7 @@ $this->params['breadcrumbs'][] = $this->title;
]) ?>
<?php
echo $model->getScreenshotsHtml();
echo $model->getReadmeHtml();
?>