{"id":14955960,"url":"https://github.com/igorakaamigo/maac","last_synced_at":"2026-01-19T03:01:23.705Z","repository":{"id":56882433,"uuid":"118901911","full_name":"igorakaamigo/maac","owner":"igorakaamigo","description":"Replaces confirm() call with Twitter Bootstrap modal","archived":false,"fork":false,"pushed_at":"2019-01-21T11:20:45.000Z","size":63,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-06T13:40:49.890Z","etag":null,"topics":["bdd","bdd-kata","bootstrap","modal","modal-plugin","rails","rails5","rails51","ujs"],"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/igorakaamigo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-25T10:59:29.000Z","updated_at":"2018-02-06T16:12:51.000Z","dependencies_parsed_at":"2022-08-20T13:10:43.334Z","dependency_job_id":null,"html_url":"https://github.com/igorakaamigo/maac","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/igorakaamigo/maac","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorakaamigo%2Fmaac","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorakaamigo%2Fmaac/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorakaamigo%2Fmaac/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorakaamigo%2Fmaac/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igorakaamigo","download_url":"https://codeload.github.com/igorakaamigo/maac/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorakaamigo%2Fmaac/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28559347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T00:46:33.223Z","status":"online","status_checked_at":"2026-01-19T02:00:08.049Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bdd","bdd-kata","bootstrap","modal","modal-plugin","rails","rails5","rails51","ujs"],"created_at":"2024-09-24T13:12:05.478Z","updated_at":"2026-01-19T03:01:23.678Z","avatar_url":"https://github.com/igorakaamigo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Modal As A Confirm (MAAC)\n\n[![License](https://img.shields.io/github/license/igorakaamigo/maac.svg)](https://github.com/igorakaamigo/maac/blob/master/MIT-LICENSE)\n[![Build Status](https://img.shields.io/travis/igorakaamigo/maac/master.svg)](https://travis-ci.org/igorakaamigo/maac)\n[![Gem](https://img.shields.io/gem/v/maac.svg)](https://rubygems.org/gems/maac)\n\nThis gem allows you to replace standard confirm() call for data-confirm'ed page elements,\nwith a html modal (Bootstrap modal or a custom markup). I.e. instead of calling confirm(\"Are you sure?\") this code will draw\na yes-no popup after clicking the link.\n\n```rhtml\n\u003c%= link_to 'A very dangerous action',\n        dangerous_action_path,\n        data: {\n            method: :delete,\n            confirm: 'Are you sure?'\n        } %\u003e\n```\n\n```rhtml\n\u003c%= link_to 'A very dangerous action',\n        dangerous_action_path,\n        data: {\n            method: :delete,\n            'confirm-title': 'Oh, no!',\n            confirm: 'Are you sure?'\n        } %\u003e\n``` \n\nThere are lots of gems for the similar purposes, but I found nothing appropriate for Rails 5.1\nSo I've made it for my own purposes. I'll be happy if you find it useful.\n\n## Run-time configuration\nYou can simply customize titles via link attributes:\n\n- **data-confirm-title** - *dialog title text: default value is \"Confirm\"*\n\n- **data-confirm-yes** - *yes-button text: default value is \"Yes\"*\n\n- **data-confirm-no** - *no-button text: default value is \"No\"*\n\n- **data-confirm-close** - *close cross title: default value is \"Close\"*\n\n```rhtml\n\u003c%= link_to 'A very dangerous action',\n        dangerous_action_path,\n        data: {\n            method: :delete,\n            confirm: 'Are you sure?',\n            'confirm-title': 'Important!',\n            'confirm-yes': 'Proceed',\n            'confirm-no': 'Dismiss',\n            'confirm-close': 'Never mind'\n        } %\u003e\n```\n\n## Initialization\nIf your gemfile includes a gem, which is named with something containing \"bootstrap\",\nthe bootstrap modal'll be used by default. Otherwise it will use the following template code:\n\n```html\n\u003cdiv class=\"maac-popup\"\u003e\n    \u003cdiv class=\"maac-popup_inner\"\u003e\n        \u003cdiv class=\"maac-popup_header\"\u003e\n            \u003cdiv class=\"maac-popup_header_title\"\u003e%{title}\u003c/div\u003e\n            \u003cdiv class=\"maac-popup_header_buttons\"\u003e\n                \u003ca id=\"js-maac-close\" href=\"javascript:void(0)\" class=\"maac-popup_header_buttons_button maac-popup_header_buttons_button__close\"\u003e%{close}\u003c/a\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n        \u003cdiv class=\"maac-popup_body\"\u003e%{text}\u003c/div\u003e\n        \u003cdiv class=\"maac-popup_footer\"\u003e\n            \u003cdiv class=\"maac-popup_footer_buttons\"\u003e\n                \u003ca id=\"js-maac-yes\" href=\"javascript:void(0)\" class=\"maac-popup_footer_buttons_button maac-popup_footer_buttons_button__yes\"\u003e%{yes}\u003c/a\u003e\n                \u003ca id=\"js-maac-no\" href=\"javascript:void(0)\" class=\"maac-popup_footer_buttons_button maac-popup_footer_buttons_button__no\"\u003e%{no}\u003c/a\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n```\n\nYou can add an initializer, i.e.:\n*/config/initializers/maac.rb*:\n```ruby\nMaac.configure do |config|\n  # Strings to be substituted into template\n  # (using %{key}). You can define your own set of keys\n  config.strings = {\n    title: 'A default title value',\n    yes:   'A default Yes button text',\n    no:    'A default No button text',\n    close: 'A default Close button text'\n  }\n\n  # A modal' template code\n  config.template      = '\u003cdiv class=\"my-modal\"\u003e\u003cspan id=\"js-yes\"\u003e%{yes}\u003c/span\u003e\u003cspan id=\"js-no\"\u003e%{no}\u003c/span\u003e\u003c/div\u003e'\n\n  # A modal' selector – used to remove the modal code and\n  # for event bindings \n  config.selector      = '.my-modal'\n\n  # Selector of a yes button \n  config.selector_y    = '#js-yes'\n\n  # Selector of a no button\n  config.selector_n    = '#js-no'\n  \n  # Callback, which is called just after the modal code\n  # appended to a page\n  config.after_append  = 'function () {}'\n\n  # Async handler, called before code removement.\n  # After your code completes the execution call cb()\n  config.before_remove = 'function (cb) { cb(); }'\nend\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'maac'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install maac\n\n## Usage\n\n/app/assets/javascripts/application.js:\n```javascript\n//= require rails-ujs\n//= require bootstrap/modal\n//= require maac\n```\n\nSomewhere in views:\n```rhtml\n\u003c%= link_to 'A very dangerous action',\n        dangerous_action_path,\n        data: {\n            method: :delete,\n            confirm: 'Are you sure?'\n        } %\u003e\n```\n\nOr:\n```rhtml\n\u003c%= link_to 'A very dangerous action',\n        dangerous_action_path,\n        data: {\n            method: :delete,\n            confirm: 'Are you sure?'\n            'confirm-title': 'Danger!',\n            'confirm-yes': 'Proceed',\n            'confirm-no': 'Cancel',\n            'confirm-close': 'Never mind'\n        } %\u003e\n```\n\n## Development\n\nMost important steps are described below. You can also look at defined rake tasks by typing:\n\n    $ rake -T\n\n### Setup\n\nSimply run:\n\n    $ bundle install\n    $ rake dummy:dep\n    $ rake\n\nAnd rake will compile the .coffee.erb code and run all tests for you.\n\n### Testing\n\nThe project uses automated testing. The RSpec is used.\nThe /spec directory contents:\n\n- **/spec/features/client_spec.rb** - the main behaviour testing\n- **/spec/features/config_spec.rb** - the gem' configuration testing\n- **/spec/features/host_application_spec.rb** - dummy application, which uses the maac, testing\n \n- **/spec/support/dummy** - dummy applications\n- **/spec/support/dummy/vanilla** - a dummy app, which uses neither jQuery nor Bpptstrap\n- **/spec/support/dummy/bs3** - a dummy app, which uses both jQuery and Bpptstrap\n\nTo start automated testing just type:\n\n    $ rake\n\n### Building\n\nTo build a gem, type:\n\n    $ rake build\n\n### Releasing\n\nTo create a tag, build and push gem to rubygems.org, type:\n\n    $ rake release\n\n### Versioning\n\nA current version is defined in **lib/maac/version.rb** file.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/igorakaamigo/maac.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorakaamigo%2Fmaac","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figorakaamigo%2Fmaac","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorakaamigo%2Fmaac/lists"}