This module help site builder or developer to add "Custom JS confirm box" to form
used within site, when user fills form and without complete it want redirect from
that page, Shows the confirm box with warns to save form or leave the page.

Project home page : JS confirm Pop Up

Git clone command:
1. git clone --branch 7.x-1.x http://git.drupal.org/sandbox/sandipauti11/2680965.git js_confirm_pop_up
2. cd js_confirm_pop_up

Manual review of other projects:
1. https://www.drupal.org/node/2701911#comment-11085529
2. https://www.drupal.org/node/2686277#comment-10982283
3. https://www.drupal.org/node/2654016#comment-10982153
4. https://www.drupal.org/node/2668878#comment-10949585

CommentFileSizeAuthor
#30 drupalcs-js_confirm_pop_up.txt3.87 KBleanderl

Comments

sandipauti created an issue. See original summary.

PA robot’s picture

Status: Active » Needs work

Git clone command for the sandbox is missing in the issue summary, please add it.

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

sandipauti’s picture

Issue summary: View changes

Adding Git clone command and project home Page

sandipauti’s picture

Issue summary: View changes
sandipauti’s picture

Status: Needs work » Reviewed & tested by the community
sandipauti’s picture

Issue summary: View changes
sandipauti’s picture

Issue tags: +PAreview: review bonus
sandipauti’s picture

Issue summary: View changes
sandipauti’s picture

Status: Reviewed & tested by the community » Needs review
sandipauti’s picture

Issue summary: View changes
sourabhutani’s picture

Manual Review

Individual user account
[Yes] the guidelines for individual user accounts.
No duplication
[Yes] module duplication and/or fragmentation.
Master Branch
[Yes branch 7.x-1.x ] the guidelines for master branch.
Licensing
[Yes ] the licensing requirements.
3rd party assets/code
[Yes] the guidelines for 3rd party assets/code.
README.txt/README.md
[Yes] the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
[Yes] the guidelines for project length and complexity.
Secure code
[Yes: Meets the security requirements. / No: List of security issues identified.]
Coding style & Drupal API usage
  1. (*) On line 14,21 : All variables defined by your module must be prefixed with your module's name to avoid name collisions with others.
  2. (*) On line 44 in js_confirm_pop_up.js there should not be white space after an opening "(" .
  3. Expected 1 newline at end of file

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

sandipauti’s picture

@sourabhutani

Thanks for your review, I will look into it.

sandipauti’s picture

Done with all the required changes.

1. Format source code according to Drupal coding standard
2. Replace variable to avoid name collision.

Thanks,

abhiklpm’s picture

Status: Needs review » Needs work

Please add configuration link in the module listing page, otherwise we will not be able to navigate to the config page with out url.
eg: configure = admin/config/user-interface/jsconfirmpopup in your info file

sandipauti’s picture

Status: Needs work » Needs review

Hey abhiklpm,

Fix added configuration link to info file.

sandipauti’s picture

Status: Needs review » Active
sandipauti’s picture

Status: Active » Needs review
marabak’s picture

Hi,


1 - I don't understand why in your settings form you have two fields with two variables set :
js_confirm_pop_up_confirm_form_id and js_confirm_pop_up_actual_form_id
As i read your main function in your module :

function js_confirm_pop_up_form_alter(&$form, &$form_state, $form_id) {
  $form_ids = variable_get('js_confirm_pop_up_actual_form_id');
  $form_ids_arr = explode(',', $form_ids);
  if (!empty($form_ids_arr)) {
    foreach ($form_ids_arr as $value) {
      if ($form_id == $value) {
        drupal_add_js(drupal_get_path('module', 'js_confirm_pop_up') . '/js_confirm_pop_up.js');
        drupal_add_js(array('js_confirm' => array('form_ids' => variable_get('js_confirm_pop_up_confirm_form_id'))), 'setting');
      }
    }
  }
}

i think the first variable is for the php and the second for the javascript - but it is unnesessary. You should have only one variable js_confirm_pop_up_confirm_form_id and in your form_alter function you should for instance add a special class to your form tag in order to make it detectable by your script :

function js_confirm_pop_up_form_alter(&$form, &$form_state, $form_id) {
  $form_ids = variable_get('js_confirm_pop_up_actual_form_id');
  $form_ids_arr = explode(',', $form_ids);
  if (!empty($form_ids_arr)) {
    foreach ($form_ids_arr as $value) {
      if ($form_id == $value) {
        drupal_add_js(drupal_get_path('module', 'js_confirm_pop_up') . '/js_confirm_pop_up.js');
        if (!isset($form['#attributes']['class'])) {
          $form['#attributes'] = array('class' => array('js-confirm-pop-up'));
        }
        else {
          $form['#attributes']['class'][] = 'js-confirm-pop-up';
        }
      }
    }
  }
}

Then in your javascript you just need to detect any form with the ''js-confirm-pop-up' class.


2 - I think you should check if the form really changed. If i edit a field in the form and then cancel my changes by typing exactly the same i still have the popup displayed.
Maybe you should store in the attach function all the inputs state and then compare it to the form state when the user is leaving.

marabak’s picture

You have also an encoding problem in your README.txt file

harish b’s picture

Status: Needs review » Needs work

EDIT: removed long pareview.sh dump, see http://pareview.sh/

leanderl’s picture

This is a manual review...

Manual Review

Individual user account
[Yes: Follows] the guidelines for individual user accounts.
No duplication
[Yes: Does not cause] module duplication and/or fragmentation.
Master Branch
[Yes: Follows] the guidelines for master branch.
Licensing
[Yes: Follows / No: Does not follow] the licensing requirements.
3rd party assets/code
[Yes: Follows] the guidelines for 3rd party assets/code.
README.txt/README.md
[Yes: Follows] the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
[Yes: Follows] the guidelines for project length and complexity.
Secure code
[Yes: Meets the security requirements. / No: List of security issues identified.]
Coding style & Drupal API usage
[List of identified issues in no particular order. Use (*) and (+) to indicate an issue importance. Replace the text below by the issues themselves:

No particluar issues were found. Issues identified by @sourabhutani in comment #11 seem to have been solved.

This review uses the Project Application Review Template.

klausi’s picture

Status: Needs work » Needs review

Minor coding standard errors are not application blockers. Anything else that you found or should this be RTBC instead?

leanderl’s picture

@klausi – are you asking me? If so, I would have wished for slightly clearer instructions on how to try it out and how to find the form #ID's. Had to fiddle around for a while before I got it to "kick in". It also seems the comma separated list of form #ID's doesn't tolerate spaces like:
my_form_id1, my_form_id2

this has to be
my_form_id1,my_form_id2

Perhaps a trim function or similar could be added when grabbing the variables to allow for space after comma.

harish b’s picture

Status: Needs review » Needs work

EDIT: removed long pareview.sh dump, see http://pareview.sh/

klausi’s picture

Status: Needs work » Needs review

Minor coding standard errors are not application blockers, please do a real manual review.

sandipauti’s picture

@leanderl - You should add comma(,) separated form id's here.

leanderl’s picture

@sandipauti Yes, it works very well, but it may be even nicer if one could also have a blank space after the comma like this:
form_id2, form_id2, form_id3

when I tried the module it would only work if formated it like this:
form_id2,form_id2,form_id3

The reason is simply that I'm used to adding a blank space after a comma. So it is more an ease-of-use question and not a major thing...

sandipauti’s picture

@marabak,

Thanks for review, I have optimize js_confirm_pop_up_form_alter() function, So now only one field to add js_confirm_pop_up_actual_form_id

Added JS directory for JS file.

sandipauti’s picture

@marabak

Fix "README.txt" encoding problem, review.

Thanks

leanderl’s picture

Status: Needs review » Needs work
StatusFileSize
new3.87 KB

Automated review

See attached file for formatting errors drupalcs-js_confirm_pop_up.txt

Manual review

The js-file doesn't load correctly:
GET http://loc.drupal7.dev/sites/all/modules/js_confirm_pop_up/js_confirm_pop_up.js?o44kzr 404 (Not Found)

This is due to line 43 in js_confirm_pop_up.module not having the correct path.
drupal_add_js(drupal_get_path('module', 'js_confirm_pop_up') . '/js_confirm_pop_up.js');

Should be
drupal_add_js(drupal_get_path('module', 'js_confirm_pop_up') . '/js/js_confirm_pop_up.js');

Either that or the js-file should be moved into the module's root directory

sandipauti’s picture

Status: Needs work » Needs review

@leanderl,

Thanks for review, I have updated same for in my code.

abu-zakham’s picture

Hello sandipauti,

I didn't find any bug in your module, just you need to fix automated review report errors.
http://pareview.sh/pareview/httpgitdrupalorgsandboxsandipauti112680965git

Regards

sandipauti’s picture

@Abdulla Abu-Zakham

Thanks for your review, Done with all automated review fixes.

Regards,

sandipauti’s picture

Status: Needs review » Reviewed & tested by the community
klausi’s picture

Status: Reviewed & tested by the community » Needs review

Please don't RTBC your won issues, see the workflow: https://www.drupal.org/node/532400

sandipauti’s picture

@klausi,

Thanks for information, It is done by mistake.

Regards

sandipauti’s picture

sandipauti’s picture

th_tushar’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +PAreview: single application approval

Hi @sandipauti,

I have manually reviewed your code, Below are the findings,

  • In .info file, package= Custom can be removed as it would be a contrib module after promoting to full project.
  • The variable "js_confirm_pop_up_actual_form_id" is a configuration variable and should be removed/deleted on module un-installation.

There are a lot of examples available on https://www.drupal.org/node/1182224.

Removed the review bonus tag as you have not manually reviewed the modules.

Code too short
This project is too short to approve you as git vetted user. We are currently discussing how much code we need, but everything with less than 120 lines of code or less than 5 functions cannot be seriously reviewed. However, we can promote this single project manually to a full project for you.
sandipauti’s picture

Status: Needs work » Needs review

Hey th_tushar,

Thanks for your manual review, I had fixed all the stuff you mentioned above, Please review.

Thanks

sandipauti’s picture

th_tushar’s picture

Issue tags: -PAreview: review bonus +PAReview: Single project promote; PAReview: review bonus

Hi sandipauti,

As per comment #39, please don't remove the single project promote tag.

th_tushar’s picture

Issue tags: -PAReview: Single project promote; PAReview: review bonus +PAReview: Single project promote;

As you also not reviewed other project application, removing the review bonus tag. Please review three other projects in the issue queue and update them in your issue description.

th_tushar’s picture

Issue tags: -PAReview: Single project promote; +PAreview: single application approval

Adding the proper single project promotion tag.

sandipauti’s picture

Issue summary: View changes
braindrift’s picture

Hi sandipauti,

very nice module, thanks.

In your js_confirm_pop_up_form_alter() you check for the existance of $form['#attributes']['class'] and then you are setting $form['#attributes'] = array('class' => array('js-confirm-pop-up'));. What happens if only the class attribute is not set but other attributes? You are deleting all the other attributes that might exist.

Best regards

braindrift’s picture

Status: Needs review » Needs work
sandipauti’s picture

Hi @braindrift,

Thanks for review, I had updated my code as per your comment.

Thanks,

sandipauti’s picture

Status: Needs work » Needs review
sandipauti’s picture

Hi Team,

When i can promote this as single project

sandipauti’s picture

Hi Team,

When i can promote this as single project

sandipauti’s picture

Hey team what is actual status of this project, As per th_tushar comment when i can promote this as single project or not else need to close this issue ?

sandipauti’s picture

asiby’s picture

How is this module different from the following:

  • Node Edit Protection (either for D6 or D7).

    A very simple JavaScript based protection that will alert a user if they are navigating away from a modified Node Edit form without saving. It uses a standard JavaScript confirm dialog that allows the user to either continue what they were doing, or cancel the move allowing them the opportunity to save. It marks the form as dirty by using the blur event of the node fields.

  • SaveGuard (either for D6 or D7).

    ... adds javascript which detects if a form had been modified, and if it has, uses the onBeforeUnload event to pop up a warning to the user if they attempt to navigate away from the page without saving their changes. This works for Firefox, IE, and Safari, but not Opera.

  • Dirty Forms (only an official release for D6, though for D7 there seems to be a trustworthy patch available also).

    ... provides a javascript behavior that checks forms before users leave the page, warning them if they are about to loose changes and providing an option to remain on the page.

    ... The module provides a configuration form that allows setting up a list of forms that should be excluded from the dirtyForms behavior.

Source: http://drupal.stackexchange.com/a/160002/11723

th_tushar’s picture

@sandipauti, please don't remove the tags already added.

ashwinsh’s picture

Hello Sandip,

Your module looks good. But there are some minor errors reported by automated review tools, did you check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxsandipauti112680965git

Regards,

naveenvalecha’s picture

Assigned: Unassigned » klausi
Status: Needs review » Reviewed & tested by the community

Automated Review :

http://pareview.sh/pareview/httpgitdrupalorgsandboxsandipauti112680965gi...

Manual Review :

Nothing blocker found. Looks good to me.
Assigning to klausi to give it a second look when he will get time.

sandipauti’s picture

Hey @naveenvalecha, @ashwin.shaharkar

Thanks for reviewing my module, As you both mentioned i had fix all bugs

Automated preview here:

http://pareview.sh/pareview/httpgitdrupalorgsandboxsandipauti112680965gi...

Thanks

klausi’s picture

Assigned: klausi » Unassigned
Status: Reviewed & tested by the community » Fixed
Issue tags: -PAreview: single application approval

Thank you for your reviews. When finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no major flaws).

manual review:

  • project page is too short. what is the use case, why would I use the module? What are the differences to the other projects that asiby listed? See https://www.drupal.org/node/997024 . Can you add a screenshot?

Otherwise looks good to me. I think with the javascript this is just about our code limit, so I think we can approve you.

Thanks for your contribution, Sandip!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

sandipauti’s picture

Thank you klausi, All project reviewer for there guidence...thank you all

sandipauti’s picture

Hey @klausi,

I had promote my sandbox project to full project but it still not showing download packages on project home page.

It show following error

Packaging error messages

Git clone failed:
fatal: remote error: access denied or repository not exported: /project/2680965.git
Initialized empty Git repository in /tmp/drush_tmp_1464858840_574ff8d8255f7/clone/.git/

It will great if some one help me to solve out this git issue.

Thanks

klausi’s picture

sandipauti’s picture

@klausi,

Thanks for quick response.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.