yii2-btn-copy-html-block Yii2 widget to copy html blocks by pressing the button

yii2-btn-copy-html-block

  1. Installation
  2. Usage
  3. Usage js events
  4. License

https://github.com/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.

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

   <div class="mr-color-input pull-left">
           <?= $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()  
                ], // 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
           ]) ?>
       </div>
       <div class="clearfix"></div>

Usage js events

    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!');
    }

License

yii2-btn-copy-html-block is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.

0 0
1 follower
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: Others
Developed by: mackrais
Created on: May 24, 2017
Last updated: 10 months ago

Related Extensions