active_frontend 14.0.17 → 14.0.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 172b12bf5f617882455d02532dc3026ef2e38d4a
4
- data.tar.gz: 6d351cb2a3f005c22a585568a927b8cbe9ea9306
3
+ metadata.gz: 908fca1eee6f9052c96127456b8c558cc0db4ba4
4
+ data.tar.gz: 47b54d7cf89ca24622d1b45ea522719c50ed0692
5
5
  SHA512:
6
- metadata.gz: 10b8945f842e161d1e4aeb03e206c17546111d5692894ea33e9aacfb7b28806bc5bae30ad69c2b50ca86429b4206ce5a490073cc5a4387ec62722c1812b28e8b
7
- data.tar.gz: 6254c70bb0b8e61c45eb7237b8add53b004595d3c37b520f69ce67f86570cb45f686aa587902d6127a9577bab6a656a28a898f82465dd7af12ff6cb0639308dd
6
+ metadata.gz: 1ae1d482f796d7f8df937b8d00564329557cc4e244b55a94377a847a0e5642bc293bcb57c452c4cd73612f39c7463e1507bd62c2302fb7b4ebe264f19df59a43
7
+ data.tar.gz: 14a4bbe94ca225585a63d6f35ffd8cec8ed64c6642da731f95671bcc9674af71989f839d4dee021bb6fbad3aadc95aef0d1344a0a0fceb093f4e67f319b3f261
@@ -1,3 +1,3 @@
1
1
  module ActiveFrontend
2
- VERSION = '14.0.17'.freeze
2
+ VERSION = '14.0.18'.freeze
3
3
  end
@@ -7,16 +7,24 @@
7
7
  var Affirm = function (element, options) {
8
8
  this.$element = $(element);
9
9
  this.settings = {
10
- title: this.$element.data('title'),
11
- offset: this.$element.data('offset'),
12
- removeClass: this.$element.data('remove-class')
10
+ btnClass: {
11
+ cancel: this.$element.data('btn-class-cancel') || Affirm.DEFAULTS.btnClass.cancel,
12
+ confirm: this.$element.data('btn-class-confirm') || Affirm.DEFAULTS.btnClass.confirm
13
+ },
14
+ format: this.$element.data('format'),
15
+ text: {
16
+ cancel: this.$element.data('text-cancel') || Affirm.DEFAULTS.text.cancel,
17
+ confirm: this.$element.data('text-confirm') || Affirm.DEFAULTS.text.confirm
18
+ },
19
+ title: this.$element.data('title')
13
20
  };
14
- this.options = $.extend({}, Affirm.DEFAULTS, options);
21
+ this.options = $.extend({}, Affirm.DEFAULTS, this.settings, options);
15
22
 
16
23
  this.init();
17
24
  };
18
25
 
19
26
  if (!$.fn.modal) throw new Error('Affirm requires modal.js');
27
+ if (!$.fn.popover) throw new Error('Affirm requires popover.js');
20
28
 
21
29
  Affirm.VERSION = '1.0.0';
22
30
  Affirm.DEFAULTS = {
@@ -24,14 +32,12 @@
24
32
  cancel: 'btn margin-size-right-xs',
25
33
  confirm: 'btn btn-color-red'
26
34
  },
27
- modalClass: 'modal fade',
28
- modalId: 'bsAffirmModal',
29
35
  format: 'modal',
30
36
  text: {
31
37
  cancel: 'No, Cancel',
32
38
  confirm: 'Yes, Confirm'
33
39
  },
34
- title: 'Are you 100% sure about this?'
40
+ title: 'Are you sure about this?'
35
41
  };
36
42
 
37
43
  Affirm.prototype.constructor = Affirm;
@@ -39,19 +45,23 @@
39
45
  Affirm.prototype.init = function () {
40
46
  var _self = this;
41
47
  var body = $('body');
42
- var modalId = '#' + this.options.modalId;
43
48
 
44
- this.$element.click(function () {
45
- $(modalId).remove();
46
- body.append(_self.modalTemplate());
47
- $(modalId).modal('show');
49
+ this.$element.click(function (e) {
50
+ e.stopPropagation();
51
+ e.preventDefault();
52
+
53
+ _self.displayFormat();
48
54
 
49
55
  return false;
50
56
  });
51
57
 
52
- body.on('click', '[data-affirm-toggle="confirm"]', function () {
53
- $(modalId).modal('hide');
54
- });
58
+ $('body')
59
+ .on('click', '[data-affirm-toggle="cancel"]', function () {
60
+ _self.cancelFormat();
61
+ })
62
+ .on('click', '[data-affirm-toggle="confirm"]', function () {
63
+ _self.confirmFormat();
64
+ });
55
65
  };
56
66
 
57
67
  Affirm.prototype.cancelBtn = function () {
@@ -85,9 +95,8 @@
85
95
  var footer = $('<div class="modal-footer text-align-right">')
86
96
  .append(this.cancelBtn())
87
97
  .append(this.confirmBtn());
88
- var modal = $('<div role="modal">')
89
- .addClass(this.options.modalClass)
90
- .attr('id', this.options.modalId)
98
+ var modal = $('<div class="modal fade" role="modal">')
99
+ .attr('id', 'bsAffirmModal')
91
100
  .append(header)
92
101
  .append(body)
93
102
  .append(footer);
@@ -95,6 +104,67 @@
95
104
  return modal;
96
105
  };
97
106
 
107
+ Affirm.prototype.displayModal = function () {
108
+ var modalId = '#bsAffirmModal';
109
+
110
+ $(modalId).remove();
111
+ $('body').append(this.modalTemplate());
112
+ $(modalId).modal('show');
113
+ };
114
+
115
+ Affirm.prototype.popoverTemplate = function () {
116
+ var cancelBtn = this.cancelBtn()
117
+ .addClass('btn-size-s');
118
+ var confirmBtn = this.confirmBtn()
119
+ .addClass('btn-size-s');
120
+ var navigation = $('<div class="popover-nav text-align-center row">')
121
+ .append(cancelBtn)
122
+ .append(confirmBtn);
123
+ var popover = $('<div class="popover" role="tooltip">')
124
+ .append('<div class="arrow"></div>')
125
+ .append('<strong class="popover-title"></strong>')
126
+ .append('<div class="popover-content"></div>')
127
+ .append(navigation);
128
+
129
+ return popover;
130
+ };
131
+
132
+ Affirm.prototype.displayPopover = function () {
133
+ $('.popover').remove();
134
+
135
+ this.$element.popover({
136
+ container: false,
137
+ content: this.$element.attr('data-affirm'),
138
+ html: true,
139
+ placement: 'top',
140
+ title: this.options.title,
141
+ template: this.popoverTemplate(),
142
+ trigger: 'manual'
143
+ });
144
+
145
+ this.$element.popover('show');
146
+ };
147
+
148
+ Affirm.prototype.displayFormat = function () {
149
+ if (this.options.format === 'popover') {
150
+ this.displayPopover();
151
+ } else {
152
+ this.displayModal();
153
+ }
154
+ };
155
+
156
+ Affirm.prototype.cancelFormat = function () {
157
+ if (this.options.format === 'popover') this.$element.popover('hide');
158
+ };
159
+
160
+ Affirm.prototype.confirmFormat = function () {
161
+ if (this.options.format === 'popover') {
162
+ this.$element.popover('hide');
163
+ } else {
164
+ $('#bsAffirmModal').modal('show');
165
+ }
166
+ };
167
+
98
168
  // AFFIRM PLUGIN DEFINITION
99
169
  // ========================
100
170
 
@@ -49,9 +49,9 @@
49
49
 
50
50
  element.removeClass(animation)
51
51
  .addClass(animation)
52
- .on(Animation.TRANSITION_END, function (event) {
53
- event.stopPropagation();
54
- event.preventDefault();
52
+ .on(Animation.TRANSITION_END, function (e) {
53
+ e.stopPropagation();
54
+ e.preventDefault();
55
55
 
56
56
  if (infinite !== true) element.removeClass(animation);
57
57
  if (hide === true) element.addClass('hidden');
@@ -197,7 +197,7 @@
197
197
 
198
198
  > a {
199
199
  border-bottom: 2px solid color(transparent);
200
- padding-bottom: 13px;
200
+ padding-bottom: 15px;
201
201
 
202
202
  &:hover,
203
203
  &:active,
@@ -217,6 +217,14 @@
217
217
  }
218
218
  }
219
219
  }
220
+
221
+ > .btn,
222
+ > .btn-group {
223
+ margin-top: -12px;
224
+
225
+ &.pull-left,
226
+ &.pull-right { margin-top: -7px; }
227
+ }
220
228
  }
221
229
  .nav-stacked > li {
222
230
  float: none;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_frontend
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.17
4
+ version: 14.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez