{"id":15502536,"url":"https://github.com/itmammoth/with_popup","last_synced_at":"2025-07-31T06:03:00.806Z","repository":{"id":56898325,"uuid":"44475721","full_name":"itmammoth/with_popup","owner":"itmammoth","description":"A rubygem for rails application to open and manage a popup window","archived":false,"fork":false,"pushed_at":"2016-03-24T07:58:45.000Z","size":4652,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-24T03:13:01.036Z","etag":null,"topics":["gem","javascript","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itmammoth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-18T11:35:10.000Z","updated_at":"2018-11-05T13:56:15.000Z","dependencies_parsed_at":"2022-08-21T02:20:19.544Z","dependency_job_id":null,"html_url":"https://github.com/itmammoth/with_popup","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fwith_popup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fwith_popup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fwith_popup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fwith_popup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itmammoth","download_url":"https://codeload.github.com/itmammoth/with_popup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231996576,"owners_count":18457773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gem","javascript","rails","ruby"],"created_at":"2024-10-02T09:10:11.553Z","updated_at":"2024-12-31T14:37:21.762Z","avatar_url":"https://github.com/itmammoth.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"WithPopup\n====\n\nWithPopup makes it easy to open and manage a popup window in your rails application, and which is NOT controlled by popup blocker.\n\n## Demo\n\n![Demo](https://raw.githubusercontent.com/itmammoth/with_popup/master/demo.gif \"Demo\")\n\n## Requirement\n\n* rails ~\u003e 4.0\n* jquery-rails \u003e= 3.0, \u003c 5.0\n\n## Installation\n\nAdd this in your ```Gemfile```, and run the ```bundle install``` command.\n\n```ruby\ngem 'with_popup'\n```\n\nAdd this in your ```app/assets/javascripts/application.js``` below jquery.\n\n```Javascript\n//= require jquery\n//= require jquery_ujs\n//= require with_popup\n//= require_tree .\n```\n\n## Usage\n\nWithPopup provides some helper methods managing a popup window in view and controller contexts, which are wrapping form helper methods that create clickable DOM (like ```link_to```, ```submit_tag```) with ```*_with_popup``` naming.\n\nTypical usage is like this.\n\n```HTML+ERB\n# In your erb file\n\u003c%= form_for @post do |f| %\u003e\n  ...\n  # Submit while opening a popup window\n  \u003c%= f.submit_with_popup %\u003e\n\u003c% end %\u003e\n```\n\n```Ruby\n# In your controller\ndef create\n  @post = Post.new(params[:post].permit(...))\n  if @post.save\n    # Show print preview in the popup window you've opened\n    reload_popup print_post_path(@post)\n    redirect_to @post\n  else\n    # Close the popup window\n    close_popup\n    render :new\n  end\nend\n```\n\n#### Note:\nThese ```*_with_popup``` methods never interrupt the original click actions, just open popup windows simultaneously.\n\n### Form helper methods\n\nAll helper methods are defined to deledate the processing to the original methods they are wrapping, so you can invoke them as you do with the original methods.\n\n#### FormTagHelper (ActionView::Base)\n\n| Methods                           | Wrapped method         |\n|-----------------------------------|------------------------|\n| submit_with_popup_tag             | submit_tag             |\n| image_submit_with_popup_tag       | image_submit_tag       |\n| button_with_popup_tag             | button_tag             |\n| button_with_popup_to              | button_to              |\n| link_with_popup_to                | link_to                |\n| link_with_popup_to_if             | link_to_if             |\n| link_with_popup_to_unless         | link_to_unless         |\n| link_with_popup_to_unless_current | link_to_unless_current |\n\n#### FormHelper (ActionView::Helpers::FormBuilder)\n\n| Methods           | Wrapped method |\n|-------------------|----------------|\n| submit_with_popup | submit         |\n| button_with_popup | button         |\n\n### Option\n\nYou can give a particular option for the javascript ```window.open``` function.\n\n```HTML+ERB\n# In your erb file\n\u003c%= submit_with_popup_tag 'Create and Print',\n      with_popup: { src: '/loading', features: 'width=300,height=200' } %\u003e\n```\n\nIts popup window will be opened like this\n\n```Javascript\nwindow.open('', '/loading', 'width=300,height=200');\n```\n\n### Controller methods\n\n| Methods            | Description                                             |\n|--------------------|---------------------------------------------------------|\n| realod_popup(path) | Reload the popup window you opened with indicated path. |\n| close_popup        | Close the popup window you opened.                      |\n\n## Test helpers\nWithPopup provides some test helper methods.\n```ruby\n# In your rails_helper.rb\n\nrequire 'with_popup/test_helpers'\n\n...\n\nRSpec.configure do |config|\n...\n  config.include WithPopup::TestHelpers::Controller, type: :controller\n...\nend\n```\n\nThen, you can invoke the methods below in controller test context.\n```ruby\nit { expect(with_popup_reloading_path).to match '/reload/path' }\nit { expect(with_popup_is_closing?).to be_truthy }\n```\n\n## Contribution\n* Fork the master branch, and clone it.\n* Run the ```bundle install``` command to start developing.\n* Test it with the ```bundle exec rspec``` command.\n* Shoot a pull-request, thank you.\n\n## Licence\n\nMIT\n\n## Author\n\n[itmammoth](https://github.com/itmammoth)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitmammoth%2Fwith_popup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitmammoth%2Fwith_popup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitmammoth%2Fwith_popup/lists"}