Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mackrais-organization/yii2-btn-copy-html-block
Yii2 extension(widget) by copy html block
https://github.com/mackrais-organization/yii2-btn-copy-html-block
clone clone-html jqery multiple multiple-blocks multiple-inputs yii2
Last synced: 1 day ago
JSON representation
Yii2 extension(widget) by copy html block
- Host: GitHub
- URL: https://github.com/mackrais-organization/yii2-btn-copy-html-block
- Owner: mackrais-organization
- License: bsd-3-clause
- Created: 2017-05-12T19:04:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-05T12:04:59.000Z (about 5 years ago)
- Last Synced: 2024-04-23T23:55:37.303Z (7 months ago)
- Topics: clone, clone-html, jqery, multiple, multiple-blocks, multiple-inputs, yii2
- Language: JavaScript
- Size: 11.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGE.md
- License: LICENSE.md
Awesome Lists containing this project
README
# yii2-btn-copy-html-block
[![Latest Stable Version](https://poser.pugx.org/mackrais/yii2-btn-copy-html-block/v/stable)](https://packagist.org/packages/mackrais/yii2-btn-copy-html-block)
[![Latest Unstable Version](https://poser.pugx.org/mackrais/yii2-btn-copy-html-block/v/unstable)](https://packagist.org/packages/mackrais/yii2-btn-copy-html-block)
[![License](https://poser.pugx.org/mackrais/yii2-btn-copy-html-block/license)](https://packagist.org/packages/mackrais/yii2-btn-copy-html-block)
[![Total Downloads](https://poser.pugx.org/mackrais/yii2-btn-copy-html-block/downloads)](https://packagist.org/packages/mackrais/yii2-btn-copy-html-block)
[![Monthly Downloads](https://poser.pugx.org/mackrais/yii2-btn-copy-html-block/d/monthly)](https://packagist.org/packages/mackrais/yii2-btn-copy-html-block)
[![Daily Downloads](https://poser.pugx.org/mackrais/yii2-btn-copy-html-block/d/daily)](https://packagist.org/packages/mackrais/yii2-btn-copy-html-block)> NOTE: Widget should always be the block that we cloned.
Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist mackrais/yii2-btn-copy-html-block "dev-master"
```or
```
composer require --prefer-dist mackrais/yii2-btn-copy-html-block "dev-master"
```
or add```
"mackrais/yii2-btn-copy-html-block": "dev-master"
```to the require section of your `composer.json` file.
## Usage
```php
= $form->field($model, 'colors[]')->textInput(['type'=>'color','class'=>'product-color-input '])->label(false) ?>
= mackrais\copyblock\Widget::widget([
'caption'=>'', // any text button
'options'=>[
'class'=>'my-class', // Options yii\helpers\Html::a()
'classRemoveBtn' => 'my-class' // for example glyphicon glyphicon-trash
], // any text button
'beforeInsertBlock'=>'beforeClone(event, $this, $cloneBlock)', //
'afterInsertBlock'=>'afterClone(event, $this, $cloneBlock, $tmpBlock)', //
'beforeDeleteBlock'=>'beforeDelete(event, $this, $block)', //
'afterDeleteBlock'=>'afterDelete(event, $this, $block)', //
'selectorCloneBlock'=>'.mr-color-input', // selector clone block
]) ?>
```
## Usage js events```js
function beforeClone(event, $this, $cloneBlock) {
console.log('Block ',$cloneBlock,' will be cloned!');
}
function afterClone(event, $this, $cloneBlock, $tmpBlock) {
console.log('Block ',$tmpBlock,' was cloned!');
}
function beforeDelete(event, $this, $block) {
console.log('Block ',$block, ' will be deleted!');
}
function afterDelete(event, $this, $block) {
console.log('Block ',$block,' was deleted!');
}```
## Result
![Screenshot](https://archive.org/download/screen-yii2-btn-copy-html-block/screen-yii2-btn-copy-html-block.png)
![Screenshot](https://archive.org/download/screen-yii2-btn-copy-html-block1/screen-yii2-btn-copy-html-block1.png)## License
**yii2-btn-copy-html-block** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details.