maac 0.1.0.pre.alpha → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +38 -4
- data/vendor/assets/javascripts/maac.js +26 -19
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20b29d045152f4bd689b235932aef38a7b9753b4
|
4
|
+
data.tar.gz: 5be8d79d74ac3bab6ee3d251a73320b304391fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c0786d9ba68ba7a01363a0f3ae3953893cb12a0734645894d61555756ad2f9d1a8a16bbb4018c2072824e6904d3574854014edda76e2e102f1c8111c9108d85
|
7
|
+
data.tar.gz: 21a775473428f5bca537998f092db00ea0e85cb04392de5df14ee08bfc3ffdf72167d2abfb6c5263f41043a53da13383f7dddd7603ae7c4210156b65c59ab7a2
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Modal As A Confirm (MAAC)
|
2
2
|
|
3
|
+
[](https://github.com/igorakaamigo/maac/blob/master/MIT-LICENSE)
|
4
|
+
[](https://travis-ci.org/igorakaamigo/maac)
|
5
|
+
[](https://rubygems.org/gems/maac)
|
6
|
+
|
3
7
|
This gem allows you to replace standard confirm() call for data-confirm'ed page elements,
|
4
8
|
with a bootstrap modal. I.e. instead of calling confirm("Are you sure?") this code will draw
|
5
9
|
a bootstrap yes-no modal after clicking the link.
|
@@ -75,21 +79,51 @@ Or:
|
|
75
79
|
|
76
80
|
## Development
|
77
81
|
|
78
|
-
|
82
|
+
Most important steps are described below. You can also look at defined rake tasks by typing:
|
83
|
+
|
84
|
+
$ rake -T
|
85
|
+
|
86
|
+
### Setup
|
87
|
+
|
88
|
+
You must perform a few simple steps to prepare the project for development:
|
79
89
|
|
80
90
|
$ bundle install
|
91
|
+
$ rake db:migrate
|
92
|
+
$ rake
|
81
93
|
|
82
94
|
### Testing
|
83
95
|
|
96
|
+
The project uses automated testing. The RSpec is used.
|
97
|
+
The /spec directory contents:
|
98
|
+
|
99
|
+
- **/spec/dummy** - *a simple rails app used for gem testing*
|
100
|
+
- **/spec/factories** - *factory_bot factory descriptions*
|
101
|
+
- **/spec/features/maac_features_spec.rb** - *gem specifications*
|
102
|
+
- **/spec/spec_helper.rb** - *a helper file*
|
103
|
+
|
104
|
+
To start automated testing just type:
|
105
|
+
|
84
106
|
$ rake
|
85
107
|
|
86
|
-
|
108
|
+
### Building
|
109
|
+
|
110
|
+
To build a gem, type:
|
111
|
+
|
112
|
+
$ rake build
|
113
|
+
|
114
|
+
### Releasing
|
115
|
+
|
116
|
+
To create a tag, build and push gem to rubygems.org, type:
|
117
|
+
|
118
|
+
$ rake release
|
119
|
+
|
120
|
+
### Versioning
|
87
121
|
|
88
|
-
|
122
|
+
A current version is defined in **lib/maac/version.rb** file.
|
89
123
|
|
90
124
|
## Contributing
|
91
125
|
|
92
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/igorakaamigo/
|
126
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/igorakaamigo/maac.
|
93
127
|
|
94
128
|
## License
|
95
129
|
|
@@ -1,22 +1,27 @@
|
|
1
|
+
|
2
|
+
/*!
|
3
|
+
Modal As A Confirm (MAAC) v1.0.0 (2018-01-26T02:19:14+03:00)
|
4
|
+
https://github.com/igorakaamigo/maac
|
5
|
+
Released under the MIT license:
|
6
|
+
https://github.com/igorakaamigo/maac/blob/master/MIT-LICENSE
|
7
|
+
*/
|
8
|
+
|
1
9
|
(function() {
|
2
|
-
var showAModal;
|
10
|
+
var safeBsModal, showAModal;
|
3
11
|
|
4
12
|
Rails.delegate(document, 'a[data-confirm]', 'confirm', function(event) {
|
5
|
-
|
6
|
-
link = this;
|
7
|
-
if (link.hasAttribute('data-confirmed')) {
|
8
|
-
link.removeAttribute('data-confirmed');
|
9
|
-
confirm = function() {
|
10
|
-
return true;
|
11
|
-
};
|
12
|
-
return true;
|
13
|
-
}
|
14
|
-
showAModal(link, 'Yes', 'No', 'Close', 'Confirm');
|
13
|
+
showAModal(this, 'Yes', 'No', 'Close', 'Confirm');
|
15
14
|
return false;
|
16
15
|
});
|
17
16
|
|
17
|
+
safeBsModal = function(arg) {
|
18
|
+
if (this.jQuery && this.jQuery.fn.modal) {
|
19
|
+
return this.jQuery('.modal').modal(arg);
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
18
23
|
showAModal = function(link, defaultYes, defaultNo, defaultClose, defaultTitle) {
|
19
|
-
var dialogClose, dialogNo, dialogTitle, dialogYes, modal;
|
24
|
+
var close, dialogClose, dialogNo, dialogTitle, dialogYes, modal;
|
20
25
|
modal = document.createElement('div');
|
21
26
|
modal.className = 'modal';
|
22
27
|
modal.setAttribute('tabindex', '-1');
|
@@ -25,23 +30,25 @@
|
|
25
30
|
dialogNo = link.getAttribute('data-confirm-no') || defaultNo;
|
26
31
|
dialogClose = link.getAttribute('data-confirm-close') || defaultClose;
|
27
32
|
dialogTitle = link.getAttribute('data-confirm-title') || defaultTitle;
|
28
|
-
modal.innerHTML = '<div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title"></h5> <button type="button" class="close"
|
33
|
+
modal.innerHTML = '<div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title"></h5> <button type="button" class="close" aria-label=""> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <p></p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary"></button> <button type="button" class="btn btn-primary"></button> </div> </div> </div>';
|
29
34
|
modal.querySelector('.modal-body > p').innerText = link.getAttribute('data-confirm');
|
30
35
|
modal.querySelector('.modal-footer > .btn-secondary').innerText = dialogYes;
|
31
36
|
modal.querySelector('.modal-footer > .btn-primary').innerText = dialogNo;
|
32
37
|
modal.querySelector('.modal-header > button').setAttribute('aria-label', dialogClose);
|
33
38
|
modal.querySelector('.modal-header > h5').innerText = dialogTitle;
|
34
|
-
|
39
|
+
close = function() {
|
35
40
|
Rails.stopEverything(event);
|
41
|
+
safeBsModal('hide');
|
36
42
|
return modal.remove();
|
37
|
-
}
|
43
|
+
};
|
44
|
+
Rails.delegate(modal, '.close,.btn-primary', 'click', close);
|
38
45
|
Rails.delegate(modal, '.btn-secondary', 'click', function(event) {
|
39
|
-
|
40
|
-
|
41
|
-
link.setAttribute('data-confirmed', true);
|
46
|
+
close();
|
47
|
+
link.removeAttribute('data-confirm');
|
42
48
|
return Rails.fire(link, 'click');
|
43
49
|
});
|
44
|
-
|
50
|
+
document.body.appendChild(modal);
|
51
|
+
return safeBsModal();
|
45
52
|
};
|
46
53
|
|
47
54
|
}).call(this);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor M Osipov
|
@@ -135,9 +135,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- - "
|
138
|
+
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
140
|
+
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
143
|
rubygems_version: 2.6.13
|