yii2-slider-pro

Yii2 wrapper for https://github.com/bqworks/slider-pro

  • 所有者: Edofre/yii2-slider-pro
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Yii2 slider-pro widget

Latest Stable Version
Total Downloads
Latest Unstable Version
License
composer.lock

Installation

The preferred way to install this extension is through composer.

To install, either run

$ php composer.phar require edofre/yii2-slider-pro "V1.1.6"

or add

"edofre/yii2-slider-pro": "V1.1.6"

to the require section of your composer.json file.

Usage

Not all available modules are available as objects, these will be implemented at a later date,
if you need exact/precise control please use the second method of creating the slider.

The following 2 ways are available to instantiate the slider:

1. You can use either the supplied php classes to generate the HTML

use edofre\sliderpro\models\Slide;
use edofre\sliderpro\models\slides\Caption;
use edofre\sliderpro\models\slides\Image;
use edofre\sliderpro\models\slides\Layer;

$slides = [
	new Slide([
		'items' => [
			new Image(['src' => '/images/test.jpg']),
		],
	]),
	new Slide([
		'items' => [
			new Image(['src' => '/images/test1.png']),
			new Caption(['tag' => 'p', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.']),
		],
	]),
	new Slide([
		'items' => [
			new Image(['src' => '/images/test2.png']),
			new Layer(['tag' => 'h3', 'content' => 'Lorem ipsum dolor sit amet', 'htmlOptions' => ['class' => 'sp-black', 'data-position' => "bottomLeft", 'data-horizontal' => "10%", 'data-show-transition' => "left", 'data-show-delay' => "300", 'data-hide-transition' => "right"]]),
			new Layer(['tag' => 'p', 'content' => 'consectetur adipisicing elit', 'htmlOptions' => ['class' => 'sp-white sp-padding', 'data-width' => "200", 'data-horizontal' => "center", 'data-vertical' => "40%", 'data-show-transition' => "down", 'data-hide-transition' => "up"]]),
			new Layer(['tag' => 'div', 'content' => 'Static content', 'htmlOptions' => ['class' => 'sp-static']]),
		],
	]),
	new Slide([
		'content' =>
			'<a class="sp-video" href="http://vimeo.com/109354891">
				<img src="http://lorempixel.com/960/500/sports/5" width="500" height="300"/>
			</a>'
		,
	]),
	new Slide([
		'items' => [
			new Layer(['tag' => 'h3', 'content' => 'Lorem ipsum dolor sit amet']),
			new Layer(['tag' => 'p', 'content' => 'Consectetur adipisicing elit']),
		],
	]),
];

$thumbnails = [
	new \edofre\sliderpro\models\Thumbnail(['tag' => 'img', 'htmlOptions' => ['src' => "/images/ttest.jpg", 'data-src' => "/images/test.jpg"]]),
	new \edofre\sliderpro\models\Thumbnail(['tag' => 'img', 'htmlOptions' => ['src' => "/images/ttest1.png", 'data-src' => "/images/test1.png"]]),
	new \edofre\sliderpro\models\Thumbnail(['tag' => 'img', 'htmlOptions' => ['src' => "/images/ttest2.png", 'data-src' => "/images/test2.png"]]),
	new \edofre\sliderpro\models\Thumbnail(['tag' => 'p', 'content' => 'Thumbnail for video']),
	new \edofre\sliderpro\models\Thumbnail(['tag' => 'p', 'content' => 'Thumbnail 5']),
];
?>

<?= \edofre\sliderpro\SliderPro::widget([
	'id'            => 'my-slider',
	'slides'        => $slides,
	'thumbnails'    => $thumbnails,
	'sliderOptions' => [
		'width'  => 960,
		'height' => 500,
		'arrows' => true,
		'init'   => new \yii\web\JsExpression("
			function() {
				console.log('slider is initialized');
			}
		"),
	],
]);
?>

2. Or you can create your own HTML code to generate the slider

<?= \edofre\sliderpro\SliderPro::widget([
	'id'            => 'my-slider',
	'sliderOptions' => [
		'width'  => 960,
		'height' => 500,
		'arrows' => true,
		'init'   => new \yii\web\JsExpression("
			function() {
				console.log('slider is initialized');
			}
		"),
	],
]);
?>

<div class="slider-pro" id="my-slider">
	<div class="sp-slides">
		<!-- Slide 1 -->
		<div class="sp-slide">
			<img class="sp-image" src="http://lorempixel.com/960/500/sports/1"/>
		</div>
		<!-- Slide 2 -->
		<div class="sp-slide">
			<img class="sp-image" src="http://lorempixel.com/960/500/sports/2"/>
			<p class="sp-caption">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
		</div>
		<!-- Slide 3 -->
		<div class="sp-slide">
			<p>Lorem ipsum dolor sit amet</p>
		</div>
		<!-- Slide 4 -->
		<div class="sp-slide">
			<img class="sp-image" src="http://lorempixel.com/960/500/sports/3"/>
			<h3 class="sp-layer sp-black"
				data-position="bottomLeft" data-horizontal="10%"
				data-show-transition="left" data-show-delay="300" data-hide-transition="right">
				Lorem ipsum dolor sit amet
			</h3>
			<p class="sp-layer sp-white sp-padding"
			   data-width="200" data-horizontal="center" data-vertical="40%"
			   data-show-transition="down" data-hide-transition="up">
				consectetur adipisicing elit
			</p>
			<div class="sp-layer sp-static">Static content</div>
		</div>
		<!-- Slide 5 -->
		<div class="sp-slide">
			<h3 class="sp-layer">Lorem ipsum dolor sit amet</h3>
			<p class="sp-layer">consectetur adipisicing elit</p>
		</div>

		<!-- thumbnails -->
		<div class="sp-thumbnails">
			<img class="sp-thumbnail" src="http://lorempixel.com/960/500/sports/1" data-src="http://lorempixel.com/480/250/sports/1"/>
			<img class="sp-thumbnail" src="http://lorempixel.com/960/500/sports/2" data-src="http://lorempixel.com/480/250/sports/2"/>
			<img class="sp-thumbnail" src="http://lorempixel.com/960/500/sports/3" data-src="http://lorempixel.com/480/250/sports/3"/>
			<p class="sp-thumbnail">Thumbnail 4</p>
			<p class="sp-thumbnail">Thumbnail 5</p>
		</div>
	</div>
</div>

主要指標

概覽
名稱與所有者Edofre/yii2-slider-pro
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2016-06-20 07:56:23
推送於2018-01-08 22:14:57
最后一次提交2018-01-08 23:14:53
發布數6
最新版本名稱V1.1.6 (發布於 )
第一版名稱V1.0.0 (發布於 )
用户参与
星數11
關注者數1
派生數3
提交數32
已啟用問題?
問題數0
打開的問題數0
拉請求數3
打開的拉請求數0
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?