dominus77/yii2-fontawesome-iconpicker

为Yii2框架的Twitter Bootstrap小部件提供Font Awesome图标选择器插件。

安装次数: 14,243

依赖: 0

建议: 0

安全: 0

星标: 6

关注者: 2

分支: 2

公开问题: 1

语言:JavaScript

类型:yii2-extension

v3.0.1 2020-11-12 22:28 UTC

This package is auto-updated.

Last update: 2024-09-22 16:15:14 UTC


README

Latest Stable Version License Build Status codecov Scrutinizer Code Quality Total Downloads PayPal donate button SymfonyInsight

为Yii2渲染一个Font Awesome v5 图标选择器小部件。

注意

如果您想支持Font Awesome版本4,请使用小部件版本2

安装

安装此扩展的首选方式是通过composer

运行以下命令:

php composer.phar require dominus77/yii2-fontawesome-iconpicker "^3.0"

或者将以下内容添加到您的composer.json文件的require部分:

"dominus77/yii2-fontawesome-iconpicker": "^3.0"

使用方法

扩展安装后,只需在您的代码中使用它即可

<?php
...
use dominus77\iconpicker\IconPicker;
...
?>

<?= $form->field($model, 'icon')->widget(IconPicker::class, []) ?>

客户端选项

<?= $form->field($model, 'icon')->widget(IconPicker::class, [
    'clientOptions' => [
        'title' => 'Font Awesome Icon', // Popover title (optional) only if specified in the template
        'selected' => false, // use this value as the current item and ignore the original
        'defaultValue' => false, // use this value as the current item if input or element value is empty
        'placement' => 'bottom', // (has some issues with auto and CSS). auto, top, bottom, left, right
        'collision' => 'none', // If true, the popover will be repositioned to another position when collapses with the window borders
        'animation' => true, // fade in/out on show/hide ?
        //hide iconpicker automatically when a value is picked. it is ignored if mustAccept is not false and the accept button is visible
        'hideOnSelect' => false,
        'showFooter' => false,
        'searchInFooter' => false, // If true, the search will be added to the footer instead of the title'
        'mustAccept' => false, // only applicable when there's an iconpicker-btn-accept button in the popover footer
        'selectedCustomClass' => 'bg-primary', // Appends this class when to the selected item
        //'icons' => [], // list of icon classes (declared at the bottom of this script for maintainability)
        'fullClassFormatter' => new \yii\web\JsExpression("function(val){return val;}"),
        'input' => 'input,.iconpicker-input', // children input selector
        'inputSearch' => false, // use the input as a search box too?
        'container' => false, //  Appends the popover to a specific element. If not set, the selected element or element parent is used
        'component' => '.input-group-addon,.iconpicker-component', // children component jQuery selector or object, relative to the container element
        // Plugin templates:
        'templates' => [
            'popover' => '<div class="iconpicker-popover popover"><div class="arrow"></div><div class="popover-title"></div><div class="popover-content"></div></div>',
            'footer' => '<div class="popover-footer"></div>',
            'buttons' => '<button class="iconpicker-btn iconpicker-btn-cancel btn btn-default btn-sm">Cancel</button> <button class="iconpicker-btn iconpicker-btn-accept btn btn-primary btn-sm">Accept</button>',
            'search' => '<input type="search" class="form-control iconpicker-search" placeholder="Type to filter" />',
            'iconpicker' => '<div class="iconpicker"><div class="iconpicker-items"></div></div>',
            'iconpickerItem' => '<a role="button" href="#" class="iconpicker-item"><i></i></a>',
        ],
    ],
]) ?>

代码检查器

检查样式

composer check-style

修复样式

composer fix-style

测试

composer test

资源

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。

Sensio Labs

SymfonyInsight