kartik-v/yii2-dialog
Composer 安装命令:
composer require kartik-v/yii2-dialog
包简介
An asset bundle for bootstrap3-dialog for Yii 2.0 framework.
README 文档
README
yii2-dialog
A widget component for Yii Framework 2.0 to easily configure and initialize popup notification dialog boxes. It provides a polyfill for the native javascript alert, confirm, and prompt dialog boxes. It includes inbuilt support for rendering rich dialog boxes via a customized plugin by Krajee based on and enhanced from bootstrap3-dialog. This plugin makes using Bootstrap's modal more monkey-friendly. The Krajee enhancements also includes enhanced support for Bootstrap 5.x, 4.x and 3.x. The key features provided by the library are:
- Control how you want to render JAVASCRIPT dialogs. Inbuilt quick support for following dialog types:
- ALERT dialog
- CONFIRM dialog
- PROMPT dialog
- CUSTOM dialog
- Includes a jQuery plugin
krajeeDialog(created by Krajee), that allows one to configure the bootstrap3-dialog library easily, or use the native JS alerting component, OR also configure any third party JS Notification Library to be used. - Ability to render pretty dialogs by overriding and enhancing confirmation dialog for links that use yii's
data-confirmmethods. - Advanced configuration via
kartik\dialog\Dialogwidget. This widget allows one to globally setup the native JS alert OR bootstrap3-dialog settings.
How to contribute via a pull request?
Refer this git workflow for contributors.
Installation
The preferred way to install this extension is through composer.
Pre-requisites
Note: Check the composer.json for this extension's requirements and dependencies. You must set the
minimum-stabilitytodevin the composer.json file in your application root folder before installation of this extension OR if yourminimum-stabilityis set to any other value other thandev, then set the following in the require section of your composer.json file
kartik-v/yii2-dialog: "@dev"
Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.
Release Changes
Refer the CHANGE LOG for details of various releases.
Install
Either run
$ php composer.phar require kartik-v/yii2-dialog "@dev"
or add
"kartik-v/yii2-dialog": "@dev"
to the require section of your composer.json file.
Documentation and Demo
View the documentation and demos at Krajee Yii 2 Demos for details on using the extension.
Usage
Basic Usage
In your view you can load the asset bundle and render the javascript to load the bootstrap 3 modal dialog.
// view.php use kartik\dialog\DialogAsset; DialogAsset::register($this); $this->registerJs("\$('#your-btn-id').on('click', function(){BootstrapDialog.alert('I want banana!');});");
Advanced Usage (Widget)
In your view OR view layout file, you can render the widget like this. This will not display any content directly - but will render all the javascript and css needed for initializing the BootstrapDialog as per your customized settings.
use kartik\dialog\Dialog; // Example 1 echo Dialog::widget([ 'libName' => 'krajeeDialog', 'options' => [], // default options ]); // Example 2 echo Dialog::widget([ 'libName' => 'krajeeDialogCust', 'options' => ['draggable' => true, 'closable' => true], // custom options ]);
Then in your view, you can write your own javascript to render your alert, confirm, and prompt boxes (or a custom dialog box). For example on click of HTML buttons btn-1 and btn-2, the dialogs can be popped up as shown below:
// NOTE: This is a javascript code and must be run in Yii via 'registerJs' // or via a JS File in an AssetBundle // use krajeeDialog object instance initialized by the widget $('#btn-1').on('click', function() { krajeeDialog.alert('An alert'); // or show a confirm krajeeDialog.confirm('Are you sure', function(out){ if(out) { alert('Yes'); // or do something on confirmation } }); }); // use krajeeDialogCust object instance $('#btn-2').on('click', function() { krajeeDialogCust.alert('An alert'); // or show a prompt krajeeDialogCust.prompt({label:'Provide reason', placeholder:'Upto 30 characters...'}, function(out){ if (out) { alert('Yes'); // or do something based on the value of out } }); });
Overriding Yii's Confirmation Dialog
Yii renders the native confirmation dialog on links that are rendered by setting data-confirm property on links. This widget
enhances and beautifies the native confirmation dialog using Krajee Dialog. This behavior can be controlled via the overrideYiiConfirm
property which defaults to true. This can be useful in rendering links and action buttons like the GridView ActionColumn
delete button.
// the rendered link will automatically show a Krajee Dialog Confirmation dialog use kartik\dialog\Dialog; echo Dialog::widget(['overrideYiiConfirm' => true]); echo Html::a( 'Delete', ['/item/delete', 'id' => $model->id], [ 'data-confirm' => 'Are you sure to delete this item?' 'data-method' => 'post' ] );
License
yii2-dialog is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.
kartik-v/yii2-dialog 适用场景与选型建议
kartik-v/yii2-dialog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.55M 次下载、GitHub Stars 达 49, 最近一次更新时间为 2016 年 01 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bootstrap」 「extension」 「dialog」 「modal」 「alert」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kartik-v/yii2-dialog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kartik-v/yii2-dialog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kartik-v/yii2-dialog 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Send events to a websocket real time engine though PHP
Adds more BBCode
统计信息
- 总下载量: 6.55M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 52
- 点击次数: 29
- 依赖项目数: 24
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2016-01-23