supplyhog/yii2-clipboardjs

dev-master 2016-10-31 13:13 UTC

This package is not auto-updated.

Last update: 2024-12-16 08:33:50 UTC


README

An easy way to use Clipboardjs in your project. Clipboardjs is a javascript only way to copy text to the clipboard.

Installation

Install this extension via composer. Add this line to your project’s composer.json

"supplyhog/yii2-clipboardjs" : "dev-master"

Usage

//Button to copy text
<?= \supplyhog\ClipboardJs\ClipboardJsWidget::widget([
    'text' => "Hello World",
    // 'label' => 'Copy to clipboard',
    // 'htmlOptions' => ['class' => 'btn'],
    // 'tag' => 'button',
]) ?>

//Button to copy text from input id
<?= \supplyhog\ClipboardJs\ClipboardJsWidget::widget([
    'inputId' => "#input-url",
    // 'cut' => false, // Cut the text out of the input instead of copy?
    // 'label' => 'Copy to clipboard',
    // 'htmlOptions' => ['class' => 'btn'],
    // 'tag' => 'button',
]) ?>

Just the Asset?

Yes, you can use just the asset. php \supplyhog\ClipboardJs\ClipboardJsAsset::register($view) It will auto init anything with the "clipboard-js-init" class.