Skip to content

Commit

Permalink
Updates to release v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Oct 20, 2017
1 parent b4ccb2c commit d8daf8c
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 26 deletions.
35 changes: 21 additions & 14 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
Change Log: `yii2-dialog`
===================================

## Version 1.0.3

**Date** 03-Jul-2017
- Fixed accept custom options for dialog

## Version 1.0.2

**Date:** 01-Dec-2016

**Date:** 20-Oct-2017

- (enh #28): Add feature to override Yii `data-confirm` dialog
- (enh #26): Add Russian translations
- (enh #23): Add Serbian (Latin) translations
- (enh #22): Add callback to alert
- (enh #21): Fixed accept custom options for dialog
- (enh #20): Add Italian translations
- (enh #17): Add Traditional Chinese translations
- (enh #16): Add Turkish translations
- (enh #15): Add Portugese Brazilian translations
- (enh #13): Add Portugese translations
- (enh #12): Correct typo in readme.md
- (enh #10): Add German translations
- Enhance KrajeeDialog variables to be registered in global namespace.

## Version 1.0.1

**Date:** 13-Sep-2016

- (enh #3): Add Chinese Translations.
- Add github contribution and issue/PR logging templates.
- (enh #4,#5): Add Ukranian Translations.
- (enh #6): Add Polish Translations.
- (enh #7): Update Polish Translations.
- (enh #9): Allow configuration of krajee dialog JS registration position.
- Enhance PHP Documentation for all classes and methods in the extension.
- Initialize all common language i18n message files.
- Enhance PHP Documentation for all classes and methods in the extension.
- (enh #9): Allow configuration of krajee dialog JS registration position.
- (enh #7): Update Polish Translations.
- (enh #6): Add Polish Translations.
- (enh #4,#5): Add Ukranian Translations.
- Add github contribution and issue/PR logging templates.
- (enh #3): Add Chinese Translations.

## Version 1.0.0

Expand Down
16 changes: 13 additions & 3 deletions Dialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @package yii2-dialog
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
* @version 1.0.3
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2017
* @version 1.0.2
*/

namespace kartik\dialog;
Expand Down Expand Up @@ -155,6 +155,12 @@ class Dialog extends Widget
*/
public $showDraggable = true;

/**
* @var boolean whether to override the yii javascript confirmation dialog (set via `data-confirm`)
* with KrajeeDialog confirmation dialog.
*/
public $overrideYiiConfirm = true;

/**
* @var string the identifying name of the public javascript id that will hold the settings for KrajeeDialog
* javascript object instance. Defaults to `krajeeDialog`.
Expand Down Expand Up @@ -207,7 +213,7 @@ public function initOptions()
'title' => $info,
'buttons' => [
['label' => $cancel, 'icon' => self::ICON_CANCEL],
['label' => $ok, 'icon' => self::ICON_OK, 'class' => 'btn-primary'],
['label' => $ok, 'icon' => self::ICON_OK, 'cssClass' => 'btn-primary'],
]
];
$otherDialog['draggable'] = true;
Expand Down Expand Up @@ -255,5 +261,9 @@ public function registerAssets()
window.{$this->libName}=new KrajeeDialog({$flag},{$optsVar},{$defaultsVar});
JS;
$view->registerJs($script, $pos);
if ($this->overrideYiiConfirm) {
DialogYiiAsset::register($view);
$view->registerJs("krajeeYiiConfirm('{$this->libName}');");
}
}
}
2 changes: 1 addition & 1 deletion DialogAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-dialog
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2016
* @version 1.0.3
* @version 1.0.2
*/

namespace kartik\dialog;
Expand Down
2 changes: 1 addition & 1 deletion DialogBootstrapAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-dialog
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2016
* @version 1.0.3
* @version 1.0.2
*/

namespace kartik\dialog;
Expand Down
40 changes: 40 additions & 0 deletions DialogYiiAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* @package yii2-dialog
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015 - 2016
* @version 1.0.2
*/

namespace kartik\dialog;

use yii\web\View;
use kartik\base\AssetBundle;

/**
* Asset bundle that overrides Yii's default confirm dialog
*
* @author Kartik Visweswaran <[email protected]>
* @since 1.0
*/
class DialogYiiAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public $depends = [
'yii\web\YiiAsset',
'kartik\dialog\DialogAsset',
];

/**
* @inheritdoc
*/
public function init()
{
$this->setSourcePath(__DIR__ . '/assets');
$this->setupAssets('js', ['js/dialog-yii']);
parent::init();
}
}
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 - 2016, Kartik Visweswaran
Copyright (c) 2014 - 2017, Kartik Visweswaran
Krajee.com
All rights reserved.

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ A widget component for Yii Framework 2.0 to easily configure and initialize popu
- 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-confirm` methods.
- Advanced configuration via `kartik\dialog\Dialog` widget. This widget allows one to globally setup the native JS alert OR bootstrap3-dialog settings.

## Installation
Expand Down Expand Up @@ -115,6 +116,27 @@ $('#btn-2').on('click', function() {
});
```

### 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.

```php
// 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.
33 changes: 33 additions & 0 deletions assets/js/dialog-yii.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*!
* @package yii2-dialog
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2017
* @version 1.0.2
*
* Override Yii confirmation dialog with Krajee Dialog.
*
* Author: Kartik Visweswaran
* Copyright: 2015, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
*/
var krajeeYiiConfirm;
(function () {
"use strict";
krajeeYiiConfirm = function(dialog) {
dialog = dialog || 'krajeeDialog';
var krajeeDialog = window[dialog] || '';
if (!krajeeDialog) {
return;
}
yii.confirm = function (message, ok, cancel) {
krajeeDialog.confirm(message, function(result) {
if (result) {
!ok || ok();
} else {
!cancel || cancel();
}
});
};
};
})();
13 changes: 13 additions & 0 deletions assets/js/dialog-yii.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*!
* @package yii2-dialog
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2017
* @version 1.0.2
*
* Override Yii confirmation dialog with Krajee Dialog.
*
* Author: Kartik Visweswaran
* Copyright: 2015, Kartik Visweswaran, Krajee.com
* For more JQuery plugins visit http://plugins.krajee.com
* For more Yii related demos visit http://demos.krajee.com
*/var krajeeYiiConfirm;!function(){"use strict";krajeeYiiConfirm=function(i){i=i||"krajeeDialog";var n=window[i]||"";n&&(yii.confirm=function(i,o,r){n.confirm(i,function(i){i?!o||o():!r||r()})})}}();
7 changes: 4 additions & 3 deletions assets/js/dialog.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*!
* @package yii2-dialog
* @author Kartik Visweswaran <[email protected]>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
* @version 1.0.3
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2017
* @version 1.0.2
*
* Provides a polyfill for javascript native alert, confirm, and prompt boxes. The BootstrapDialog will be used if
* available or needed, else the javascript native dialogs will be rendered.
Expand Down Expand Up @@ -72,10 +72,11 @@ var KrajeeDialog;
window.BootstrapDialog.show(opts);
}
},
alert: function (message) {
alert: function (message, callback) {
var self = this, opts = self.getOpts('alert');
if (self.usePlugin()) {
opts.message = message;
opts.callback = callback;
window.BootstrapDialog.alert(opts);
} else {
window.alert(message);
Expand Down
6 changes: 3 additions & 3 deletions assets/js/dialog.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d8daf8c

Please sign in to comment.