Skip to content

fix Asset for prod mode #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ Lightbox2 widget for Yii2
The Lightbox2 widget is a customized lightbox script based on [Lightbox](https://lokeshdhakar.com/projects/lightbox2/). and
This widget used to overlay images on top of the current page.

![alt text](https://github.com/coderius/github-images/blob/master/pic1.png "Description goes here")

Installation
------------
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require coderius/yii2-lightbox2-widget "@dev"
php composer.phar require crestoff/yii2-lightbox2-widget "@dev"
```

or add

```json
"coderius/yii2-lightbox2-widget" : "@dev"
"crestoff/yii2-lightbox2-widget" : "@dev"
```

to the require section of your application's `composer.json` file.
Expand All @@ -28,9 +26,9 @@ Usage
* In view:

```php
use coderius\lightbox2\Lightbox2;
use crestoff\lightbox2\Lightbox2;

<?= coderius\lightbox2\Lightbox2::widget([
<?= crestoff\lightbox2\Lightbox2::widget([
'clientOptions' => [
'resizeDuration' => 200,
'wrapAround' => true,
Expand Down Expand Up @@ -59,6 +57,4 @@ to set group images, then put identic names to data-lightbox attribute for each

*Thumbnail picture, by clicking on which opens the widget is wrapped with a link



Reference to plugin [github](https://github.com/lokesh/lightbox2/) repository that is used in this widget.
Reference to plugin [github](https://github.com/lokesh/lightbox2/) repository that is used in this widget.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "coderius/yii2-lightbox2-widget",
"name": "crestoff/yii2-lightbox2-widget",
"description": "Yii 2 lightbox2-widget",
"keywords": ["lightbox", "widget", "lightbox2", "yii2"],
"type": "yii2-extension",
Expand All @@ -22,7 +22,7 @@
},
"autoload": {
"psr-4": {
"coderius\\lightbox2\\": "src/"
"crestoff\\lightbox2\\": "src/"
}
},
"extra": {
Expand All @@ -38,4 +38,4 @@
}

]
}
}
40 changes: 5 additions & 35 deletions src/Lightbox2.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
<?php

/**
* @package yii2-extentions
* @license The MIT License
* @copyright Copyright (C) 2012-2018 Sergio coderius <coderius>
* @contacts [email protected] - Have suggestions, contact me :)
* @link https://github.com/coderius - My github
*/
namespace coderius\lightbox2;
namespace crestoff\lightbox2;

use yii\base\Widget;
use yii\helpers\Json;

class Lightbox2 extends Widget
{
/**
* @var array the options for the lightbox2 JS plugin.
* @see https://lokeshdhakar.com/projects/lightbox2/
*/
public $clientOptions = [];

/**
* @inheritdoc
*/
public function init()
{
parent::init();

parent::init();
}

/**
* @inheritdoc
*/
public function run()
{
$plugin = $this->makePlugin('lightbox');
$this->registerAssets($plugin);

$this->registerAssets($plugin);
}

/**
* @param string $name
* @return string
*/
protected function makePlugin($name)
{
$js = false;
Expand All @@ -55,17 +32,10 @@ protected function makePlugin($name)

return $js;
}

/**
* @param string $plugin
*/

protected function registerAssets($plugin){
$view = $this->getView();
$bundle = Lightbox2Asset::register($view);
$view->registerJs($plugin);
}




}
}
24 changes: 5 additions & 19 deletions src/Lightbox2Asset.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<?php

/**
* @package yii2-extentions
* @license The MIT License
* @copyright Copyright (C) 2012-2018 Sergio coderius <coderius>
* @contacts [email protected] - Have suggestions, contact me :)
* @link https://github.com/coderius - My github
*/

namespace coderius\lightbox2;
namespace crestoff\lightbox2;

use Yii;
use yii\web\AssetBundle;
Expand All @@ -17,24 +9,18 @@ class Lightbox2Asset extends AssetBundle
{
public $sourcePath = '@bower/lightbox2/dist';

public $css = [];

public $js = [];

// public $jsOptions = [
// 'position' => \yii\web\View::POS_END,
// ];
public $css = [];

public $depends = [
'yii\web\JqueryAsset',
];

public function init()
{
parent::init();

$this->js[] = YII_DEBUG ? 'js/lightbox.js' : 'lightbox.min.js';
$this->css[] = YII_DEBUG ? 'css/lightbox.css' : 'lightbox.min.css';
$this->js[] = YII_DEBUG ? 'js/lightbox.js' : 'js/lightbox.min.js';
$this->css[] = YII_DEBUG ? 'css/lightbox.css' : 'css/lightbox.min.css';
}

}