From ae6de7328251b084de7f1a66bac1f7c6279c9ad1 Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Mon, 6 Nov 2017 21:34:54 +0530 Subject: [PATCH] Updates to release v1.0.3 --- .github/CONTRIBUTING.md | 187 ++++++++++++------------------------ .github/GIT-WORKFLOW.md | 185 +++++++++++++++++++++++++++++++++++ CHANGE.md | 8 ++ Dialog.php | 11 +-- DialogAsset.php | 2 +- DialogBootstrapAsset.php | 2 +- DialogYiiAsset.php | 2 +- README.md | 4 + assets/js/dialog-yii.js | 2 +- assets/js/dialog-yii.min.js | 2 +- assets/js/dialog.js | 6 +- assets/js/dialog.min.js | 4 +- 12 files changed, 273 insertions(+), 142 deletions(-) create mode 100755 .github/GIT-WORKFLOW.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bb0c4fc..ac751c3 100755 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,126 +1,63 @@ -Contributing to yii2-dialog -=========================== -Looking to contribute something to yii2-dialog? **Here's how you can help.** - -Please take a moment to review this document in order to make the contribution -process easy and effective for everyone involved. - -Following these guidelines helps to communicate that you respect the time of -the developers managing and developing this open source project. In return, -they should reciprocate that respect in addressing your issue or assessing -patches and features. - -Using the issue tracker ------------------------ -When [reporting bugs][reporting-bugs] or -[requesting features][requesting-features], the -[issue tracker on GitHub][issue-tracker] is the recommended channel to use. - -The issue tracker **is not** a place for support requests. Refer the -[extension documentation and demos](http://demos.krajee.com/dialog) and/or refer to the -[webtips Q & A forum](http://webtips.krajee.com/questions) which are the better places to get help. - -Reporting bugs with yii2-dialog -------------------------------- -We really appreciate clear bug reports that _consistently_ show an issue -_within yii2-dialog_. - -The ideal bug report follows these guidelines: - -1. **Use the [GitHub issue search][issue-search]** — Check if the issue - has already been reported. -2. **Check if the issue has been fixed** — Try to reproduce the problem - using the code in the `master` branch. -3. **Isolate the problem** — Try to share a demo or a test case that - consistently reproduces the problem. - -Please try to be as detailed as possible in your bug report, especially if an -isolated test case cannot be made. Some useful questions to include the answer -to are: - -- What steps can be used to reproduce the issue? -- What is the bug and what is the expected outcome? -- What browser(s) and Operating System have you tested with? -- Does the bug happen consistently across all tested browsers? -- What version of jQuery are you using? And what version of yii2-dialog? -- Are you using yii2-dialog with other plugins? - -All of these questions will help others fix and identify any potential bugs. - -Requesting features in yii2-dialog ------------------------------------------- -Before starting work on a major feature for yii2-dialog, **read the -[documentation](http://demos.krajee.com/dialog) first** or you may risk spending a considerable amount of -time on something which the project developers are not interested in bringing into the project. - -### Submitting a pull request - -We use GitHub's pull request system for submitting patches. Here are some -guidelines to follow when creating the pull request for your fix. - -1. Make sure to create a ticket for your pull request. This will serve as the -bug ticket, and any discussion about the bug will take place there. Your pull -request will be focused on the specific changes that fix the bug. -2. Make sure to reference the ticket you are fixing within your pull request. -This will allow us to close off the ticket once we merge the pull request, or -follow up on the ticket if there are any related blocking issues. -3. Explain why the specific change was made. Not everyone who is reviewing your -pull request will be familiar with the problem it is fixing. -4. Run your tests first. If your tests aren't passing, the pull request won't -be able to be merged. If you're breaking existing tests, make sure that you -aren't causing any breaking changes. -5. Only include source changes. While it's not required, only including changes -from the `src` directory will prevent merge conflicts from occuring. Making -this happen can be as a simple as not committing changes from the `dist` -directory. - -By following these steps, you will make it easier for your pull request to be -reviewed and eventually merged. - -Triaging issues and pull requests ---------------------------------- -Anyone can help the project maintainers triage issues and review pull requests. - -### Handling new issues - -yii2-dialog regularly receives new issues which need to be tested and organized. - -When a new issue that comes in that is similar to another existing issue, it -should be checked to make sure it is not a duplicate. Duplicates issues should -be marked by replying to the issue with "Duplicate of #[issue number]" where -`[issue number]` is the url or issue number for the existing issue. This will -allow the project maintainers to quickly close off additional issues and keep -the discussion focused within a single issue. - -If you can test issues that are reported to yii2-dialog that contain test cases and -confirm under what conditions bugs happen, that will allow others to identify -what causes a bug quicker. - -### Reviewing pull requests - -It is very common for pull requests to be opened for issues that contain a clear -solution to the problem. These pull requests should be rigorously reviewed by -the community before being accepted. If you are not sure about a piece of -submitted code, or know of a better way to do something, do not hesitate to make -a comment on the pull request. - -### Reviving old tickets - -If you come across tickets which have not been updated for a while, you are -encouraged to revive them. While this can be as simple as saying `:+1:`, it is -best if you can include more information on the issue. Common bugs and feature -requests are more likely to be fixed, whether it is by the community or the -developers, so keeping tickets up to date is encouraged. - -Licensing ---------- - -It should also be made clear that **all code contributed to yii2-dialog** must be -licensable under the [BSD-3 license][licensing]. Code that cannot be released -under this license **cannot be accepted** into the project. - -[issue-search]: https://github.com/kartik-v/yii2-dialog/search?q=&type=Issues -[issue-tracker]: https://github.com/kartik-v/yii2-dialog/issues -[licensing]: https://github.com/kartik-v/yii2-dialog/blob/master/LICENSE.md -[reporting-bugs]: #reporting-bugs-with-yii2-dialog +Contributing to yii2-dialog +=========================== +Looking to contribute something to yii2-dialog? **Here's how you can help.** + +Using the issue tracker +----------------------- +When [reporting bugs][reporting-bugs] or +[requesting features][requesting-features], the +[issue tracker on GitHub][issue-tracker] is the recommended channel to use. + +The issue tracker **is not** a place for support requests. Refer the +[extension documentation and demos](http://demos.krajee.com/dynadialog) and/or refer to the +[webtips Q & A forum](http://webtips.krajee.com/questions) which are the better places to get help. + +How to contribute via a pull request? +------------------------------------- +Refer this [git workflow for contributors](.github/GIT-WORKFLOW.md). + +Reporting bugs with yii2-dialog +------------------------------- +We really appreciate clear bug reports that _consistently_ show an issue +within _yii2-dialog_. + +The ideal bug report follows these guidelines: + +1. **Use the [GitHub issue search][issue-search]** — Check if the issue + has already been reported. +2. **Check if the issue has been fixed** — Try to reproduce the problem + using the code in the `master` branch. +3. **Isolate the problem** — Try to share a demo or a test case that + consistently reproduces the problem. + +Please try to be as detailed as possible in your bug report, especially if an +isolated test case cannot be made. Some useful questions to include the answer +to are: + +- What steps can be used to reproduce the issue? +- What is the bug and what is the expected outcome? +- What browser(s) and Operating System have you tested with? +- Does the bug happen consistently across all tested browsers? +- What version of jQuery are you using? And what version of yii2-dialog? +- Are you using yii2-dialog with other plugins? + +All of these questions will help others fix and identify any potential bugs. + +Requesting features in yii2-dialog +------------------------------------------ +Before starting work on a major feature for yii2-dialog, **read the +[documentation](http://demos.krajee.com/dynadialog) first** or you may risk spending a considerable amount of +time on something which the project developers are not interested in bringing into the project. + +Licensing +--------- + +It should also be made clear that **all code contributed to yii2-dialog** must be +licensable under the [BSD-3 license][licensing]. Code that cannot be released +under this license **cannot be accepted** into the project. + +[issue-search]: https://github.com/kartik-v/yii2-dialog/search?q=&type=Issues +[issue-tracker]: https://github.com/kartik-v/yii2-dialog/issues +[licensing]: https://github.com/kartik-v/yii2-dialog/blob/master/LICENSE.md +[reporting-bugs]: #reporting-bugs-with-yii2-dialog [requesting-features]: #requesting-features-in-yii2-dialog \ No newline at end of file diff --git a/.github/GIT-WORKFLOW.md b/.github/GIT-WORKFLOW.md new file mode 100755 index 0000000..2c82f9a --- /dev/null +++ b/.github/GIT-WORKFLOW.md @@ -0,0 +1,185 @@ +Git workflow for yii2-dialog contributors +========================================= + +So you want to contribute to yii2-dialog? Great! But to increase the chances of your changes being accepted quickly, please +follow the following steps. If you are new to Git and GitHub, you might want to first check out [GitHub help](http://help.github.com/), [try Git](https://try.github.com) +or learn something about [Git internal data model](http://nfarina.com/post/9868516270/git-is-simpler). + +Setup the development environment +--------------------------------- + +Assuming you already have a yii2 development environment, carry out the following steps to create a development environment for the repo. + +### 1. [Fork](http://help.github.com/fork-a-repo/) the yii2-dialog repository on GitHub and clone your fork to your development environment + +``` +git clone git@github.com:YOUR-GITHUB-USERNAME/yii2-dialog.git +``` + +If you have trouble setting up Git with GitHub in Linux, or are getting errors like "Permission Denied (publickey)", +then you must [setup your Git installation to work with GitHub](http://help.github.com/linux-set-up-git/) + +> Tip: if you're not fluent with Git, we recommend reading excellent free [Pro Git book](https://git-scm.com/book/en/v2). + +### 2. Add the main yii2-dialog repository as an additional git remote called "upstream" + +Change to the directory where you cloned yii2-dialog, normally, "yii2-dialog". Then enter the following command: + +``` +git remote add upstream git://github.com/kartik-v/yii2-dialog.git +``` + +### 3. Prepare the testing environment + +- You should have a working yii 2 development environment in which you have already installed `yii2-dialog` and includes latest and updated `yii2-dialog` fork from source. +- Ensure you have the latest `dev-master` releases of all dependent extensions via your composer updates +- Ensure you use the above cloned latest `yii2-dialog` code in your testing environment + +**Now you have a working playground for hacking on yii2-dialog.** + +Working on bugs and features +---------------------------- + +Having prepared your development environment as explained above you can now start working on the feature or bugfix. + +### 1. Make sure there is an issue created for the thing you are working on if it requires significant effort to fix + +All new features and bug fixes should have an associated issue to provide a single point of reference for discussion +and documentation. Take a few minutes to look through the existing issue list for one that matches the contribution you +intend to make. If you find one already on the issue list, then please leave a comment on that issue indicating you +intend to work on that item. If you do not find an existing issue matching what you intend to work on, please +open a new issue or create a pull request directly if it is straightforward fix. This will allow the team to +review your suggestion, and provide appropriate feedback along the way. + +> For small changes or documentation issues or straightforward fixes, you don't need to create an issue, a pull request is enough in this case. + +### 2. Fetch the latest code from the main yii2-dialog branch + +``` +git fetch upstream +``` + +You should start at this point for every new contribution to make sure you are working on the latest code. + +### 3. Create a new branch for your feature based on the current yii2-dialog master branch + +> That's very important since you will not be able to submit more than one pull request from your account if you'll + use master. + +Each separate bug fix or change should go in its own branch. Branch names should be descriptive and start with +the number of the issue that your code relates to. If you aren't fixing any particular issue, just skip number. +For example: + +``` +git checkout upstream/master +git checkout -b 999-name-of-your-branch-goes-here +``` + +### 4. Do your magic, write your code + +Make sure you have first updated the testing environment as mentioned in [prepare-the-testing-environment][prepare-the-testing-environment]. + +Then make sure you have the updated code with your change and it works :). + +Unit tests are always welcome. Tested and well covered code greatly simplifies the task of checking your contributions. +Failing unit tests as issue description are also accepted. + +### 5. Update the CHANGE log + +Edit the `CHANGE.md` file to include your change, you should insert this at the top of the file under the +first heading (the version that is currently under development), the line in the change log should look like one of the following: + +``` +Bug #999: a description of the bug fix (Your Name) +Enh #999: a description of the enhancement (Your Name) +``` + +`#999` is the issue number that the `Bug` or `Enh` is referring to. +The changelog should be grouped by type (`Bug`,`Enh`) and ordered by issue number. + +For very small fixes, e.g. typos and documentation changes, there is no need to update the `CHANGE.md`. + +### 6. Commit your changes + +add the files/changes you want to commit to the [staging area](http://gitref.org/basic/#add) with + +``` +git add path/to/my/file.php +``` + +You can use the `-p` option to select the changes you want to have in your commit. + +Commit your changes with a descriptive commit message. Make sure to mention the ticket number with `#XXX` so GitHub will +automatically link your commit with the ticket: + +``` +git commit -m "A brief description of this change which fixes #999 goes here" +``` + +### 7. Pull the latest yii2-dialog code from upstream into your branch + +``` +git pull upstream master +``` + +This ensures you have the latest code in your branch before you open your pull request. If there are any merge conflicts, +you should fix them now and commit the changes again. This ensures that it's easy for the yii2-dialog team to merge your changes +with one click. + +### 8. Having resolved any conflicts, push your code to GitHub + +``` +git push -u origin 999-name-of-your-branch-goes-here +``` + +The `-u` parameter ensures that your branch will now automatically push and pull from the GitHub branch. That means +if you type `git push` the next time it will know where to push to. This is useful if you want to later add more commits +to the pull request. + +### 9. Open a [pull request](http://help.github.com/send-pull-requests/) against upstream. + +Go to your repository on GitHub and click "Pull Request", choose your branch on the right and enter some more details +in the comment box. To link the pull request to the issue put anywhere in the pull comment `#999` where 999 is the +issue number. + +> Note that each pull-request should fix a single change. For multiple, unrelated changes, please open multiple pull requests. + +### 10. Someone will review your code + +Someone will review your code, and you might be asked to make some changes, if so go to step #6 (you don't need to open +another pull request if your current one is still open). If your code is accepted it will be merged into the main branch +and become part of the next yii2-dialog release. If not, don't be disheartened, different people need different features and yii2-dialog +can't be everything to everyone, your code will still be available on GitHub as a reference for people who need it. + +### 11. Cleaning it up + +After your code was either accepted or declined you can delete branches you've worked with from your local repository +and `origin`. + +``` +git checkout master +git branch -D 999-name-of-your-branch-goes-here +git push origin --delete 999-name-of-your-branch-goes-here +``` + +### Command overview (for advanced contributors) + +``` +git clone git@github.com:YOUR-GITHUB-USERNAME/yii2-dialog.git +git remote add upstream git://github.com/kartik-v/yii2-dialog.git +``` + +``` +git fetch upstream +git checkout upstream/master +git checkout -b 999-name-of-your-branch-goes-here + +/* do your magic, update changelog if needed */ + +git add path/to/my/file.php +git commit -m "A brief description of this change which fixes #999 goes here" +git pull upstream master +git push -u origin 999-name-of-your-branch-goes-here +``` + +[prepare-the-testing-environment]: #3-prepare-the-testing-environment \ No newline at end of file diff --git a/CHANGE.md b/CHANGE.md index 4d43ff3..f8a0564 100755 --- a/CHANGE.md +++ b/CHANGE.md @@ -1,6 +1,14 @@ Change Log: `yii2-dialog` =================================== +## Version 1.0.3 + +**Date:** 06-Nov-2017 + +- Update contribution templates +- (enh #30): Enhance and fix dialog JS options initialization +- (enh #29): Add Hungarian translations + ## Version 1.0.2 **Date:** 20-Oct-2017 diff --git a/Dialog.php b/Dialog.php index 821dd33..d77bc93 100755 --- a/Dialog.php +++ b/Dialog.php @@ -4,7 +4,7 @@ * @package yii2-dialog * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 1.0.2 + * @version 1.0.3 */ namespace kartik\dialog; @@ -255,12 +255,9 @@ public function registerAssets() $defaults = Json::encode($this->dialogDefaults); $defaultsVar = self::LIBRARY . 'Defaults_' . hash('crc32', $defaults); $pos = $this->jsPosition; - $script = <<< JS - window.{$optsVar}={$opts}; - window.{$defaultsVar}={$defaults}; - window.{$this->libName}=new KrajeeDialog({$flag},{$optsVar},{$defaultsVar}); -JS; - $view->registerJs($script, $pos); + $view->registerJs("var {$defaultsVar} = {$defaults};", $pos); + $view->registerJs("var {$optsVar} = {$opts};", $pos); + $view->registerJs("var {$this->libName}=new KrajeeDialog({$flag},{$optsVar},{$defaultsVar});", $pos); if ($this->overrideYiiConfirm) { DialogYiiAsset::register($view); $view->registerJs("krajeeYiiConfirm('{$this->libName}');"); diff --git a/DialogAsset.php b/DialogAsset.php index b2bad6c..13479d6 100755 --- a/DialogAsset.php +++ b/DialogAsset.php @@ -4,7 +4,7 @@ * @package yii2-dialog * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 - * @version 1.0.2 + * @version 1.0.3 */ namespace kartik\dialog; diff --git a/DialogBootstrapAsset.php b/DialogBootstrapAsset.php index 2efd074..7da6973 100755 --- a/DialogBootstrapAsset.php +++ b/DialogBootstrapAsset.php @@ -4,7 +4,7 @@ * @package yii2-dialog * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 - * @version 1.0.2 + * @version 1.0.3 */ namespace kartik\dialog; diff --git a/DialogYiiAsset.php b/DialogYiiAsset.php index ecc8998..f4df89c 100755 --- a/DialogYiiAsset.php +++ b/DialogYiiAsset.php @@ -4,7 +4,7 @@ * @package yii2-dialog * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 - 2016 - * @version 1.0.2 + * @version 1.0.3 */ namespace kartik\dialog; diff --git a/README.md b/README.md index e6698c6..a1572d6 100755 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ A widget component for Yii Framework 2.0 to easily configure and initialize popu - 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. +How to contribute via a pull request? +------------------------------------- +Refer this [git workflow for contributors](.github/GIT-WORKFLOW.md). + ## Installation The preferred way to install this extension is through [composer](http://getcomposer.org/download/). diff --git a/assets/js/dialog-yii.js b/assets/js/dialog-yii.js index b0908f6..89452c9 100755 --- a/assets/js/dialog-yii.js +++ b/assets/js/dialog-yii.js @@ -2,7 +2,7 @@ * @package yii2-dialog * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 1.0.2 + * @version 1.0.3 * * Override Yii confirmation dialog with Krajee Dialog. * diff --git a/assets/js/dialog-yii.min.js b/assets/js/dialog-yii.min.js index 8948439..7a85626 100755 --- a/assets/js/dialog-yii.min.js +++ b/assets/js/dialog-yii.min.js @@ -2,7 +2,7 @@ * @package yii2-dialog * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 1.0.2 + * @version 1.0.3 * * Override Yii confirmation dialog with Krajee Dialog. * diff --git a/assets/js/dialog.js b/assets/js/dialog.js index b129cc6..bd53d77 100755 --- a/assets/js/dialog.js +++ b/assets/js/dialog.js @@ -2,7 +2,7 @@ * @package yii2-dialog * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 1.0.2 + * @version 1.0.3 * * 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. @@ -27,7 +27,7 @@ var KrajeeDialog; }; parseOptions = function (options) { - return options && options.length !== 0 ? options : {}; + return typeof(options) === 'object' ? options : {}; }; KrajeeDialog = function (useBsDialog, options, defaults) { @@ -45,7 +45,7 @@ var KrajeeDialog; }, getOpts: function (type) { var self = this; - return window.jQuery.extend({}, self.defaults[type], self.options[type]); + return window.jQuery.extend(true, {}, self.defaults[type], self.options); }, _dialog: function (type, message, callback) { var self = this, opts, out; diff --git a/assets/js/dialog.min.js b/assets/js/dialog.min.js index 50825d0..bcbebfb 100755 --- a/assets/js/dialog.min.js +++ b/assets/js/dialog.min.js @@ -2,7 +2,7 @@ * @package yii2-dialog * @author Kartik Visweswaran * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017 - * @version 1.0.2 + * @version 1.0.3 * * 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. @@ -11,4 +11,4 @@ * 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 KrajeeDialog;!function(){"use strict";var t,o;t=function(t,o){try{return window[t](o)}catch(e){return"confirm"===t?!0:null}},o=function(t){return t&&0!==t.length?t:{}},KrajeeDialog=function(t,e,n){var a=this;n=n||{},a.useBsDialog=t,a.options=o(e),a.defaults=o(n)},KrajeeDialog.prototype={constructor:KrajeeDialog,usePlugin:function(){return this.useBsDialog&&!!window.BootstrapDialog},getOpts:function(t){var o=this;return window.jQuery.extend({},o.defaults[t],o.options[t])},_dialog:function(o,e,n){var a,i,l=this;if("function"!=typeof n)throw"Invalid callback passed for KrajeeDialog."+o;return l.usePlugin()?"prompt"===o?void l.bdPrompt(e,n):(a=l.getOpts(o),a.message=e,void("confirm"===o?(a.callback=n,window.BootstrapDialog.confirm(a)):window.BootstrapDialog.show(a))):(i=t(o,e),void(i&&n(i)))},alert:function(t,o){var e=this,n=e.getOpts("alert");e.usePlugin()?(n.message=t,n.callback=o,window.BootstrapDialog.alert(n)):window.alert(t)},confirm:function(t,o){this._dialog("confirm",t,o)},prompt:function(t,o){this._dialog("prompt",t,o)},dialog:function(t,o){this._dialog("dialog",t,o)},bdPrompt:function(t,o){var e,n,a,i,l,r,s,c=this,u="",d=c.getOpts("prompt");for(e=function(t){var e,n=t.getModalBody();e=n.find("input")[0].value||"",o(e),t.close()},n=function(t){t.close(),o(null)},a=[{id:"btn-cancel",label:"Cancel",cssClass:"btn btn-default",action:n},{id:"btn-ok",label:"Ok",cssClass:"btn btn-primary",action:e}],i=d.buttons||[],"object"==typeof t?(l=$(document.createElement("div")),r=$(document.createElement("input")),void 0===t.name&&r.attr("name","krajee-dialog-prompt"),void 0===t.type&&r.attr("type","text"),void 0===t["class"]&&r.addClass("form-control"),$.each(t,function(t,o){"label"!==t&&r.attr(t,o)}),void 0!==t.label&&(u='"),l.append(r),u+=l.html(),r.remove(),l.remove()):u=t,d.message=u,s=0;s'+t.label+""),l.append(r),u+=l.html(),r.remove(),l.remove()):u=t,d.message=u,s=0;s