├── FancyBox.php ├── FancyBoxAsset.php ├── LICENSE ├── README.md ├── _config.yml └── composer.json /FancyBox.php: -------------------------------------------------------------------------------- 1 | 22 | * @since 1.0 23 | */ 24 | class FancyBox extends Widget 25 | { 26 | 27 | /** 28 | * @var type string target of the widget 29 | */ 30 | public $target = '[data-fancybox]'; 31 | 32 | /** 33 | * 34 | * @var type array of config settings for fancybox 35 | */ 36 | public $config = []; 37 | 38 | /** 39 | * @inheritdoc 40 | */ 41 | public function init() 42 | { 43 | if (is_null($this->target)) { 44 | throw new InvalidConfigException('"FancyBox.target has not been defined.'); 45 | } 46 | // publish the required assets 47 | $this->registerClientScript(); 48 | } 49 | 50 | /** 51 | * @inheritdoc 52 | */ 53 | public function run() 54 | { 55 | $view = $this->getView(); 56 | $config = Json::encode($this->config); 57 | $view->registerJs("jQuery('{$this->target}').fancybox({$config});"); 58 | } 59 | 60 | /** 61 | * Registers required script for the plugin to work as DatePicker 62 | */ 63 | public function registerClientScript() 64 | { 65 | $view = $this->getView(); 66 | FancyBoxAsset::register($view); 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /FancyBoxAsset.php: -------------------------------------------------------------------------------- 1 | js[] = 'dist/jquery.fancybox' . (!YII_DEBUG ? '.min' : '') . '.js'; 27 | $this->css[] = 'dist/jquery.fancybox' . (!YII_DEBUG ? '.min' : '') . '.css'; 28 | parent::registerAssetFiles($view); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Newerton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | yii2-fancybox-3 2 | ============= 3 | 4 | jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable. http://fancyapps.com/fancybox/3/ 5 | 6 | Installation 7 | ------------ 8 | 9 | - The minimum required PHP version is PHP 5.6 ([Concatenation](http://php.net/manual/en/language.oop5.properties.php)). 10 | - It works best with PHP 7. 11 | 12 | The preferred way to install this extension is through [composer](http://getcomposer.org/download/). 13 | 14 | Either run 15 | 16 | ``` 17 | php composer.phar require --prefer-dist newerton/yii2-fancybox-3 "*" 18 | ``` 19 | 20 | or add 21 | 22 | ``` 23 | "newerton/yii2-fancybox-3": "*" 24 | ``` 25 | 26 | to the require section of your `composer.json` file. 27 | 28 | 29 | Usage 30 | ----- 31 | 32 | Once the extension is installed, simply use it in your code by : 33 | 34 | ```php 35 | '[data-fancybox]', 45 | 'config' => [ 46 | // Enable infinite gallery navigation 47 | 'loop' => true, 48 | 49 | // Space around image, ignored if zoomed-in or viewport smaller than 800px 50 | 'margin' => [44,0], 51 | 52 | // Horizontal space between slides 53 | 'gutter' => 30, 54 | 55 | // Enable keyboard navigation 56 | 'keyboard' => true, 57 | 58 | // Should display navigation arrows at the screen edges 59 | 'arrows' => true, 60 | 61 | // Should display infobar (counter and arrows at the top) 62 | 'infobar' => true, 63 | 64 | // Should display toolbar (buttons at the top) 65 | 'toolbar' => true, 66 | 67 | // What buttons should appear in the top right corner. 68 | // Buttons will be created using templates from `btnTpl` option 69 | // and they will be placed into toolbar (class="fancybox-toolbar"` element) 70 | 'buttons' => [ 71 | 'slideShow', 72 | 'fullScreen', 73 | 'thumbs', 74 | 'close' 75 | ], 76 | 77 | // Detect "idle" time in seconds 78 | 'idleTime' => 4, 79 | 80 | // Should display buttons at top right corner of the content 81 | // If 'auto' - they will be created for content having type 'html', 'inline' or 'ajax' 82 | // Use template from `btnTpl.smallBtn` for customization 83 | 'smallBtn' => 'auto', 84 | 85 | // Disable right-click and use simple image protection for images 86 | 'protect' => false, 87 | 88 | // Shortcut to make content "modal" - disable keyboard navigtion, hide buttons, etc 89 | 'modal' => false, 90 | 91 | 'image' => [ 92 | // Wait for images to load before displaying 93 | // Requires predefined image dimensions 94 | // If 'auto' - will zoom in thumbnail if 'width' and 'height' attributes are found 95 | 'preload' => "auto", 96 | ], 97 | 98 | 'ajax' => [ 99 | // Object containing settings for ajax request 100 | 'settings' => [ 101 | // This helps to indicate that request comes from the modal 102 | // Feel free to change naming 103 | 'data' => [ 104 | 'fancybox' => true 105 | ] 106 | ] 107 | ], 108 | 109 | 'iframe' => [ 110 | 111 | // Iframe template 112 | 'tpl' => '', 113 | 114 | // Preload iframe before displaying it 115 | // This allows to calculate iframe content width and height 116 | // (note: Due to "Same Origin Policy", you can't get cross domain data). 'preload' => true, 117 | 118 | // Custom CSS styling for iframe wrapping element 119 | 'css' => [], 120 | 121 | // Iframe tag attributes 122 | 'attr' => [ 123 | 'scrolling' => 'auto' 124 | ] 125 | 126 | ], 127 | 128 | // Open/close animation type 129 | // Possible values: 130 | // false - disable 131 | // "zoom" - zoom images from/to thumbnail 132 | // "fade" 133 | // "zoom-in-out" 134 | // 135 | 'animationEffect' => "zoom", 136 | 137 | // Duration in ms for open/close animation 138 | 'animationDuration' => 366, 139 | 140 | // Should image change opacity while zooming 141 | // If opacity is 'auto', then opacity will be changed if image and thumbnail have different aspect ratios 142 | 'zoomOpacity' => 'auto', 143 | 144 | // Transition effect between slides 145 | // 146 | // Possible values: 147 | // false - disable 148 | // "fade' 149 | // "slide' 150 | // "circular' 151 | // "tube' 152 | // "zoom-in-out' 153 | // "rotate' 154 | // 155 | 'transitionEffect' => "fade", 156 | 157 | // Duration in ms for transition animation 158 | 'transitionDuration' => 366, 159 | 160 | // Custom CSS class for slide element 161 | 'slideClass' => '', 162 | 163 | // Custom CSS class for layout 164 | 'baseClass' => '', 165 | 166 | // Base template for layout 167 | 'baseTpl' => '
The requested content cannot be loaded.
Please try again later.