active_element 0.0.20 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/active_element/active_element.js +1 -0
- data/app/assets/javascripts/active_element/ae-ujs.js +531 -0
- data/app/assets/javascripts/active_element/secret.js +3 -0
- data/app/views/active_element/components/button.html.erb +1 -1
- data/app/views/layouts/active_element.html.erb +0 -1
- data/example_app/Gemfile.lock +1 -1
- data/lib/active_element/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9d94959c19253efbd6ed4d945304d6397d4d1ad1a9aa0d8bd23ef5329559980
|
4
|
+
data.tar.gz: b3a0d8f7bc1d514c6cca342e7e8fadc37a818497c87ebf5e894c757186ae6b21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a019e911c0d376c2a12f44e5d37ef697cf00a9a11d889c016784a2a3b41df9b0deb17f93c545ee0e2563d5f8a132a9f2c49cb0f900ed4bd926fa361cf67f81b
|
7
|
+
data.tar.gz: f7e4b9a719611918516bb1d2601eb66eb77f87dc648dffe93cbdf1b5c7c96f829bf76098145e698b27b943fa8331128409ccb8fc089d32c0e8f4b91851afe514
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,531 @@
|
|
1
|
+
/*
|
2
|
+
Unobtrusive JavaScript
|
3
|
+
https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts
|
4
|
+
Released under the MIT license
|
5
|
+
*/;
|
6
|
+
|
7
|
+
/* Reduced and customized for ActiveElementUJS */
|
8
|
+
|
9
|
+
(function() {
|
10
|
+
var context = this;
|
11
|
+
|
12
|
+
(function() {
|
13
|
+
(function() {
|
14
|
+
this.ActiveElementUJS = { linkClickSelector: 'a[data-ae-method]' };
|
15
|
+
}).call(this);
|
16
|
+
}).call(context);
|
17
|
+
|
18
|
+
var ActiveElementUJS = context.ActiveElementUJS;
|
19
|
+
|
20
|
+
(function() {
|
21
|
+
(function() {
|
22
|
+
var nonce;
|
23
|
+
|
24
|
+
nonce = null;
|
25
|
+
|
26
|
+
ActiveElementUJS.loadCSPNonce = function() {
|
27
|
+
var ref;
|
28
|
+
return nonce = (ref = document.querySelector("meta[name=csp-nonce]")) != null ? ref.content : void 0;
|
29
|
+
};
|
30
|
+
|
31
|
+
ActiveElementUJS.cspNonce = function() {
|
32
|
+
return nonce != null ? nonce : ActiveElementUJS.loadCSPNonce();
|
33
|
+
};
|
34
|
+
|
35
|
+
}).call(this);
|
36
|
+
(function() {
|
37
|
+
var expando, m;
|
38
|
+
|
39
|
+
m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector;
|
40
|
+
|
41
|
+
ActiveElementUJS.matches = function(element, selector) {
|
42
|
+
if (selector.exclude != null) {
|
43
|
+
return m.call(element, selector.selector) && !m.call(element, selector.exclude);
|
44
|
+
} else {
|
45
|
+
return m.call(element, selector);
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
expando = '_ujsData';
|
50
|
+
|
51
|
+
ActiveElementUJS.getData = function(element, key) {
|
52
|
+
var ref;
|
53
|
+
return (ref = element[expando]) != null ? ref[key] : void 0;
|
54
|
+
};
|
55
|
+
|
56
|
+
ActiveElementUJS.setData = function(element, key, value) {
|
57
|
+
if (element[expando] == null) {
|
58
|
+
element[expando] = {};
|
59
|
+
}
|
60
|
+
return element[expando][key] = value;
|
61
|
+
};
|
62
|
+
|
63
|
+
ActiveElementUJS.$ = function(selector) {
|
64
|
+
return Array.prototype.slice.call(document.querySelectorAll(selector));
|
65
|
+
};
|
66
|
+
|
67
|
+
}).call(this);
|
68
|
+
(function() {
|
69
|
+
var $, csrfParam, csrfToken;
|
70
|
+
|
71
|
+
$ = ActiveElementUJS.$;
|
72
|
+
|
73
|
+
csrfToken = ActiveElementUJS.csrfToken = function() {
|
74
|
+
var meta;
|
75
|
+
meta = document.querySelector('meta[name=csrf-token]');
|
76
|
+
return meta && meta.content;
|
77
|
+
};
|
78
|
+
|
79
|
+
csrfParam = ActiveElementUJS.csrfParam = function() {
|
80
|
+
var meta;
|
81
|
+
meta = document.querySelector('meta[name=csrf-param]');
|
82
|
+
return meta && meta.content;
|
83
|
+
};
|
84
|
+
|
85
|
+
ActiveElementUJS.CSRFProtection = function(xhr) {
|
86
|
+
var token;
|
87
|
+
token = csrfToken();
|
88
|
+
if (token != null) {
|
89
|
+
return xhr.setRequestHeader('X-CSRF-Token', token);
|
90
|
+
}
|
91
|
+
};
|
92
|
+
|
93
|
+
ActiveElementUJS.refreshCSRFTokens = function() {
|
94
|
+
var param, token;
|
95
|
+
token = csrfToken();
|
96
|
+
param = csrfParam();
|
97
|
+
if ((token != null) && (param != null)) {
|
98
|
+
return $('form input[name="' + param + '"]').forEach(function(input) {
|
99
|
+
return input.value = token;
|
100
|
+
});
|
101
|
+
}
|
102
|
+
};
|
103
|
+
|
104
|
+
}).call(this);
|
105
|
+
(function() {
|
106
|
+
var CustomEvent, fire, matches, preventDefault;
|
107
|
+
|
108
|
+
matches = ActiveElementUJS.matches;
|
109
|
+
|
110
|
+
CustomEvent = window.CustomEvent;
|
111
|
+
|
112
|
+
if (typeof CustomEvent !== 'function') {
|
113
|
+
CustomEvent = function(event, params) {
|
114
|
+
var evt;
|
115
|
+
evt = document.createEvent('CustomEvent');
|
116
|
+
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
117
|
+
return evt;
|
118
|
+
};
|
119
|
+
CustomEvent.prototype = window.Event.prototype;
|
120
|
+
preventDefault = CustomEvent.prototype.preventDefault;
|
121
|
+
CustomEvent.prototype.preventDefault = function() {
|
122
|
+
var result;
|
123
|
+
result = preventDefault.call(this);
|
124
|
+
if (this.cancelable && !this.defaultPrevented) {
|
125
|
+
Object.defineProperty(this, 'defaultPrevented', {
|
126
|
+
get: function() {
|
127
|
+
return true;
|
128
|
+
}
|
129
|
+
});
|
130
|
+
}
|
131
|
+
return result;
|
132
|
+
};
|
133
|
+
}
|
134
|
+
|
135
|
+
fire = ActiveElementUJS.fire = function(obj, name, data) {
|
136
|
+
var event;
|
137
|
+
event = new CustomEvent(name, {
|
138
|
+
bubbles: true,
|
139
|
+
cancelable: true,
|
140
|
+
detail: data
|
141
|
+
});
|
142
|
+
obj.dispatchEvent(event);
|
143
|
+
return !event.defaultPrevented;
|
144
|
+
};
|
145
|
+
|
146
|
+
ActiveElementUJS.stopEverything = function(e) {
|
147
|
+
fire(e.target, 'ujs:everythingStopped');
|
148
|
+
e.preventDefault();
|
149
|
+
e.stopPropagation();
|
150
|
+
return e.stopImmediatePropagation();
|
151
|
+
};
|
152
|
+
|
153
|
+
ActiveElementUJS.delegate = function(element, selector, eventType, handler) {
|
154
|
+
return element.addEventListener(eventType, function(e) {
|
155
|
+
var target;
|
156
|
+
target = e.target;
|
157
|
+
while (!(!(target instanceof Element) || matches(target, selector))) {
|
158
|
+
target = target.parentNode;
|
159
|
+
}
|
160
|
+
if (target instanceof Element && handler.call(target, e) === false) {
|
161
|
+
e.preventDefault();
|
162
|
+
return e.stopPropagation();
|
163
|
+
}
|
164
|
+
});
|
165
|
+
};
|
166
|
+
|
167
|
+
}).call(this);
|
168
|
+
(function() {
|
169
|
+
var AcceptHeaders, CSRFProtection, createXHR, cspNonce, fire, prepareOptions, processResponse;
|
170
|
+
|
171
|
+
cspNonce = ActiveElementUJS.cspNonce, CSRFProtection = ActiveElementUJS.CSRFProtection, fire = ActiveElementUJS.fire;
|
172
|
+
|
173
|
+
AcceptHeaders = {
|
174
|
+
'*': '*/*',
|
175
|
+
text: 'text/plain',
|
176
|
+
html: 'text/html',
|
177
|
+
xml: 'application/xml, text/xml',
|
178
|
+
json: 'application/json, text/javascript',
|
179
|
+
script: 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript'
|
180
|
+
};
|
181
|
+
|
182
|
+
ActiveElementUJS.ajax = function(options) {
|
183
|
+
var xhr;
|
184
|
+
options = prepareOptions(options);
|
185
|
+
xhr = createXHR(options, function() {
|
186
|
+
var ref, response;
|
187
|
+
response = processResponse((ref = xhr.response) != null ? ref : xhr.responseText, xhr.getResponseHeader('Content-Type'));
|
188
|
+
if (Math.floor(xhr.status / 100) === 2) {
|
189
|
+
if (typeof options.success === "function") {
|
190
|
+
options.success(response, xhr.statusText, xhr);
|
191
|
+
}
|
192
|
+
} else {
|
193
|
+
if (typeof options.error === "function") {
|
194
|
+
options.error(response, xhr.statusText, xhr);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
return typeof options.complete === "function" ? options.complete(xhr, xhr.statusText) : void 0;
|
198
|
+
});
|
199
|
+
if ((options.beforeSend != null) && !options.beforeSend(xhr, options)) {
|
200
|
+
return false;
|
201
|
+
}
|
202
|
+
if (xhr.readyState === XMLHttpRequest.OPENED) {
|
203
|
+
return xhr.send(options.data);
|
204
|
+
}
|
205
|
+
};
|
206
|
+
|
207
|
+
prepareOptions = function(options) {
|
208
|
+
options.url = options.url || location.href;
|
209
|
+
options.type = options.type.toUpperCase();
|
210
|
+
if (options.type === 'GET' && options.data) {
|
211
|
+
if (options.url.indexOf('?') < 0) {
|
212
|
+
options.url += '?' + options.data;
|
213
|
+
} else {
|
214
|
+
options.url += '&' + options.data;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
if (AcceptHeaders[options.dataType] == null) {
|
218
|
+
options.dataType = '*';
|
219
|
+
}
|
220
|
+
options.accept = AcceptHeaders[options.dataType];
|
221
|
+
if (options.dataType !== '*') {
|
222
|
+
options.accept += ', */*; q=0.01';
|
223
|
+
}
|
224
|
+
return options;
|
225
|
+
};
|
226
|
+
|
227
|
+
createXHR = function(options, done) {
|
228
|
+
var xhr;
|
229
|
+
xhr = new XMLHttpRequest();
|
230
|
+
xhr.open(options.type, options.url, true);
|
231
|
+
xhr.setRequestHeader('Accept', options.accept);
|
232
|
+
if (typeof options.data === 'string') {
|
233
|
+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
234
|
+
}
|
235
|
+
if (!options.crossDomain) {
|
236
|
+
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
237
|
+
CSRFProtection(xhr);
|
238
|
+
}
|
239
|
+
xhr.withCredentials = !!options.withCredentials;
|
240
|
+
xhr.onreadystatechange = function() {
|
241
|
+
if (xhr.readyState === XMLHttpRequest.DONE) {
|
242
|
+
return done(xhr);
|
243
|
+
}
|
244
|
+
};
|
245
|
+
return xhr;
|
246
|
+
};
|
247
|
+
|
248
|
+
processResponse = function(response, type) {
|
249
|
+
var parser, script;
|
250
|
+
if (typeof response === 'string' && typeof type === 'string') {
|
251
|
+
if (type.match(/\bjson\b/)) {
|
252
|
+
try {
|
253
|
+
response = JSON.parse(response);
|
254
|
+
} catch (error) {}
|
255
|
+
} else if (type.match(/\b(?:java|ecma)script\b/)) {
|
256
|
+
script = document.createElement('script');
|
257
|
+
script.setAttribute('nonce', cspNonce());
|
258
|
+
script.text = response;
|
259
|
+
document.head.appendChild(script).parentNode.removeChild(script);
|
260
|
+
} else if (type.match(/\b(xml|html|svg)\b/)) {
|
261
|
+
parser = new DOMParser();
|
262
|
+
type = type.replace(/;.+/, '');
|
263
|
+
try {
|
264
|
+
response = parser.parseFromString(response, type);
|
265
|
+
} catch (error) {}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
return response;
|
269
|
+
};
|
270
|
+
|
271
|
+
ActiveElementUJS.href = function(element) {
|
272
|
+
return element.href;
|
273
|
+
};
|
274
|
+
|
275
|
+
ActiveElementUJS.isCrossDomain = function(url) {
|
276
|
+
var e, originAnchor, urlAnchor;
|
277
|
+
originAnchor = document.createElement('a');
|
278
|
+
originAnchor.href = location.href;
|
279
|
+
urlAnchor = document.createElement('a');
|
280
|
+
try {
|
281
|
+
urlAnchor.href = url;
|
282
|
+
return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) || (originAnchor.protocol + '//' + originAnchor.host === urlAnchor.protocol + '//' + urlAnchor.host));
|
283
|
+
} catch (error) {
|
284
|
+
e = error;
|
285
|
+
return true;
|
286
|
+
}
|
287
|
+
};
|
288
|
+
|
289
|
+
}).call(this);
|
290
|
+
(function() {
|
291
|
+
var matches, toArray;
|
292
|
+
|
293
|
+
matches = ActiveElementUJS.matches;
|
294
|
+
|
295
|
+
toArray = function(e) {
|
296
|
+
return Array.prototype.slice.call(e);
|
297
|
+
};
|
298
|
+
|
299
|
+
ActiveElementUJS.serializeElement = function(element, additionalParam) {
|
300
|
+
var inputs, params;
|
301
|
+
inputs = [element];
|
302
|
+
if (matches(element, 'form')) {
|
303
|
+
inputs = toArray(element.elements);
|
304
|
+
}
|
305
|
+
params = [];
|
306
|
+
inputs.forEach(function(input) {
|
307
|
+
if (!input.name || input.disabled) {
|
308
|
+
return;
|
309
|
+
}
|
310
|
+
if (matches(input, 'select')) {
|
311
|
+
return toArray(input.options).forEach(function(option) {
|
312
|
+
if (option.selected) {
|
313
|
+
return params.push({
|
314
|
+
name: input.name,
|
315
|
+
value: option.value
|
316
|
+
});
|
317
|
+
}
|
318
|
+
});
|
319
|
+
} else if (input.checked || ['radio', 'checkbox', 'submit'].indexOf(input.type) === -1) {
|
320
|
+
return params.push({
|
321
|
+
name: input.name,
|
322
|
+
value: input.value
|
323
|
+
});
|
324
|
+
}
|
325
|
+
});
|
326
|
+
if (additionalParam) {
|
327
|
+
params.push(additionalParam);
|
328
|
+
}
|
329
|
+
return params.map(function(param) {
|
330
|
+
if (param.name != null) {
|
331
|
+
return (encodeURIComponent(param.name)) + "=" + (encodeURIComponent(param.value));
|
332
|
+
} else {
|
333
|
+
return param;
|
334
|
+
}
|
335
|
+
}).join('&');
|
336
|
+
};
|
337
|
+
|
338
|
+
ActiveElementUJS.formElements = function(form, selector) {
|
339
|
+
if (matches(form, 'form')) {
|
340
|
+
return toArray(form.elements).filter(function(el) {
|
341
|
+
return matches(el, selector);
|
342
|
+
});
|
343
|
+
} else {
|
344
|
+
return toArray(form.querySelectorAll(selector));
|
345
|
+
}
|
346
|
+
};
|
347
|
+
|
348
|
+
}).call(this);
|
349
|
+
(function() {
|
350
|
+
var allowAction, fire, stopEverything;
|
351
|
+
|
352
|
+
fire = ActiveElementUJS.fire, stopEverything = ActiveElementUJS.stopEverything;
|
353
|
+
|
354
|
+
ActiveElementUJS.handleConfirm = function(e) {
|
355
|
+
if (!allowAction(this)) {
|
356
|
+
return stopEverything(e);
|
357
|
+
}
|
358
|
+
};
|
359
|
+
|
360
|
+
allowAction = function(element) {
|
361
|
+
var answer, callback, message;
|
362
|
+
message = element.getAttribute('data-confirm');
|
363
|
+
if (!message) {
|
364
|
+
return true;
|
365
|
+
}
|
366
|
+
answer = false;
|
367
|
+
if (fire(element, 'confirm')) {
|
368
|
+
try {
|
369
|
+
answer = confirm(message);
|
370
|
+
} catch (error) {}
|
371
|
+
callback = fire(element, 'confirm:complete', [answer]);
|
372
|
+
}
|
373
|
+
return answer && callback;
|
374
|
+
};
|
375
|
+
|
376
|
+
}).call(this);
|
377
|
+
|
378
|
+
(function() {
|
379
|
+
var stopEverything;
|
380
|
+
|
381
|
+
stopEverything = ActiveElementUJS.stopEverything;
|
382
|
+
|
383
|
+
ActiveElementUJS.handleMethod = function(e) {
|
384
|
+
var csrfParam, csrfToken, form, formContent, href, link, method;
|
385
|
+
link = this;
|
386
|
+
method = link.getAttribute('data-ae-method');
|
387
|
+
if (!method) {
|
388
|
+
return;
|
389
|
+
}
|
390
|
+
href = ActiveElementUJS.href(link);
|
391
|
+
csrfToken = ActiveElementUJS.csrfToken();
|
392
|
+
csrfParam = ActiveElementUJS.csrfParam();
|
393
|
+
form = document.createElement('form');
|
394
|
+
formContent = "<input name='_method' value='" + method + "' type='hidden' />";
|
395
|
+
if ((csrfParam != null) && (csrfToken != null) && !ActiveElementUJS.isCrossDomain(href)) {
|
396
|
+
formContent += "<input name='" + csrfParam + "' value='" + csrfToken + "' type='hidden' />";
|
397
|
+
}
|
398
|
+
formContent += '<input type="submit" />';
|
399
|
+
form.method = 'post';
|
400
|
+
form.action = href;
|
401
|
+
form.target = link.target;
|
402
|
+
form.innerHTML = formContent;
|
403
|
+
form.style.display = 'none';
|
404
|
+
document.body.appendChild(form);
|
405
|
+
form.querySelector('[type="submit"]').click();
|
406
|
+
return stopEverything(e);
|
407
|
+
};
|
408
|
+
|
409
|
+
}).call(this);
|
410
|
+
(function() {
|
411
|
+
var ajax, fire, getData, isCrossDomain, isRemote, matches, serializeElement, setData, stopEverything,
|
412
|
+
slice = [].slice;
|
413
|
+
|
414
|
+
matches = ActiveElementUJS.matches, getData = ActiveElementUJS.getData, setData = ActiveElementUJS.setData, fire = ActiveElementUJS.fire, stopEverything = ActiveElementUJS.stopEverything, ajax = ActiveElementUJS.ajax, isCrossDomain = ActiveElementUJS.isCrossDomain, serializeElement = ActiveElementUJS.serializeElement;
|
415
|
+
|
416
|
+
isRemote = function(element) {
|
417
|
+
var value;
|
418
|
+
value = element.getAttribute('data-remote');
|
419
|
+
return (value != null) && value !== 'false';
|
420
|
+
};
|
421
|
+
|
422
|
+
ActiveElementUJS.handleRemote = function(e) {
|
423
|
+
var button, data, dataType, element, method, url, withCredentials;
|
424
|
+
element = this;
|
425
|
+
if (!isRemote(element)) {
|
426
|
+
return true;
|
427
|
+
}
|
428
|
+
if (!fire(element, 'ajax:before')) {
|
429
|
+
fire(element, 'ajax:stopped');
|
430
|
+
return false;
|
431
|
+
}
|
432
|
+
withCredentials = element.getAttribute('data-with-credentials');
|
433
|
+
dataType = element.getAttribute('data-type') || 'script';
|
434
|
+
method = element.getAttribute('data-ae-method');
|
435
|
+
url = ActiveElementUJS.href(element);
|
436
|
+
data = element.getAttribute('data-params');
|
437
|
+
ajax({
|
438
|
+
type: method || 'GET',
|
439
|
+
url: url,
|
440
|
+
data: data,
|
441
|
+
dataType: dataType,
|
442
|
+
beforeSend: function(xhr, options) {
|
443
|
+
if (fire(element, 'ajax:beforeSend', [xhr, options])) {
|
444
|
+
return fire(element, 'ajax:send', [xhr]);
|
445
|
+
} else {
|
446
|
+
fire(element, 'ajax:stopped');
|
447
|
+
return false;
|
448
|
+
}
|
449
|
+
},
|
450
|
+
success: function() {
|
451
|
+
var args;
|
452
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
453
|
+
return fire(element, 'ajax:success', args);
|
454
|
+
},
|
455
|
+
error: function() {
|
456
|
+
var args;
|
457
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
458
|
+
return fire(element, 'ajax:error', args);
|
459
|
+
},
|
460
|
+
complete: function() {
|
461
|
+
var args;
|
462
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
463
|
+
return fire(element, 'ajax:complete', args);
|
464
|
+
},
|
465
|
+
crossDomain: isCrossDomain(url),
|
466
|
+
withCredentials: (withCredentials != null) && withCredentials !== 'false'
|
467
|
+
});
|
468
|
+
return stopEverything(e);
|
469
|
+
};
|
470
|
+
|
471
|
+
ActiveElementUJS.formSubmitButtonClick = function(e) {
|
472
|
+
var button, form;
|
473
|
+
button = this;
|
474
|
+
form = button.form;
|
475
|
+
if (!form) {
|
476
|
+
return;
|
477
|
+
}
|
478
|
+
if (button.name) {
|
479
|
+
setData(form, 'ujs:submit-button', {
|
480
|
+
name: button.name,
|
481
|
+
value: button.value
|
482
|
+
});
|
483
|
+
}
|
484
|
+
setData(form, 'ujs:formnovalidate-button', button.formNoValidate);
|
485
|
+
setData(form, 'ujs:submit-button-formaction', button.getAttribute('formaction'));
|
486
|
+
return setData(form, 'ujs:submit-button-formmethod', button.getAttribute('formmethod'));
|
487
|
+
};
|
488
|
+
|
489
|
+
ActiveElementUJS.preventInsignificantClick = function(e) {
|
490
|
+
var data, insignificantMetaClick, link, metaClick, method, nonPrimaryMouseClick;
|
491
|
+
link = this;
|
492
|
+
method = (link.getAttribute('data-ae-method') || 'GET').toUpperCase();
|
493
|
+
data = link.getAttribute('data-params');
|
494
|
+
metaClick = e.metaKey || e.ctrlKey;
|
495
|
+
insignificantMetaClick = metaClick && method === 'GET' && !data;
|
496
|
+
nonPrimaryMouseClick = (e.button != null) && e.button !== 0;
|
497
|
+
if (nonPrimaryMouseClick || insignificantMetaClick) {
|
498
|
+
return e.stopImmediatePropagation();
|
499
|
+
}
|
500
|
+
};
|
501
|
+
|
502
|
+
}).call(this);
|
503
|
+
(function() {
|
504
|
+
var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, handleConfirm, handleDisabledElement, handleMethod, handleRemote, loadCSPNonce, preventInsignificantClick, refreshCSRFTokens;
|
505
|
+
|
506
|
+
fire = ActiveElementUJS.fire, delegate = ActiveElementUJS.delegate, getData = ActiveElementUJS.getData, $ = ActiveElementUJS.$, refreshCSRFTokens = ActiveElementUJS.refreshCSRFTokens, CSRFProtection = ActiveElementUJS.CSRFProtection, loadCSPNonce = ActiveElementUJS.loadCSPNonce, enableElement = ActiveElementUJS.enableElement, disableElement = ActiveElementUJS.disableElement, handleDisabledElement = ActiveElementUJS.handleDisabledElement, handleConfirm = ActiveElementUJS.handleConfirm, preventInsignificantClick = ActiveElementUJS.preventInsignificantClick, handleRemote = ActiveElementUJS.handleRemote, formSubmitButtonClick = ActiveElementUJS.formSubmitButtonClick, handleMethod = ActiveElementUJS.handleMethod;
|
507
|
+
|
508
|
+
ActiveElementUJS.start = function() {
|
509
|
+
if (window._active_element_loaded) {
|
510
|
+
throw new Error('active_element-ujs has already been loaded!');
|
511
|
+
}
|
512
|
+
delegate(document, ActiveElementUJS.linkClickSelector, 'click', handleMethod);
|
513
|
+
document.addEventListener('DOMContentLoaded', refreshCSRFTokens);
|
514
|
+
document.addEventListener('DOMContentLoaded', loadCSPNonce);
|
515
|
+
console.log("ActiveElement-ujs loaded.");
|
516
|
+
return window._active_element_loaded = true;
|
517
|
+
};
|
518
|
+
|
519
|
+
if (window.ActiveElementUJS === ActiveElementUJS && fire(document, 'rails:attachBindings')) {
|
520
|
+
ActiveElementUJS.start();
|
521
|
+
}
|
522
|
+
|
523
|
+
}).call(this);
|
524
|
+
}).call(this);
|
525
|
+
|
526
|
+
if (typeof module === "object" && module.exports) {
|
527
|
+
module.exports = ActiveElementUJS;
|
528
|
+
} else if (typeof define === "function" && define.amd) {
|
529
|
+
define(ActiveElementUJS);
|
530
|
+
}
|
531
|
+
}).call(this);
|
@@ -1,6 +1,8 @@
|
|
1
1
|
(() => {
|
2
2
|
const cloneElement = (id) => ActiveElement.cloneElement('secret', id);
|
3
3
|
|
4
|
+
if (window._active_element_secrets_loaded) return;
|
5
|
+
|
4
6
|
window.addEventListener(ActiveElement.reloadEvent, () => {
|
5
7
|
document.querySelectorAll('span[data-field-type="secret"]').forEach((element) => {
|
6
8
|
const secret = element.dataset.secret;
|
@@ -36,5 +38,6 @@
|
|
36
38
|
element.append(showButton);
|
37
39
|
element.append(hideButton);
|
38
40
|
});
|
41
|
+
window._active_element_secrets_loaded = true;
|
39
42
|
});
|
40
43
|
})();
|
@@ -6,7 +6,7 @@
|
|
6
6
|
'bs-trigger': 'hover',
|
7
7
|
'bs-toggle': 'popover',
|
8
8
|
'bs-content': title,
|
9
|
-
} : {}).merge(method&.to_s == 'get' ? {} : { '
|
9
|
+
} : {}).merge(method&.to_s == 'get' ? {} : { 'ae-method' => method.to_s }),
|
10
10
|
class: "btn #{button_class} #{float_class} #{kwargs_class}",
|
11
11
|
**kwargs
|
12
12
|
) do %>
|
@@ -122,7 +122,6 @@
|
|
122
122
|
<%= render_active_element_hook 'active_element/after_content' %>
|
123
123
|
|
124
124
|
<% if !respond_to?(:javascript_importmap_tags) && Rails.application.assets&.find_asset('application.js').present? %>
|
125
|
-
<%= javascript_include_tag 'active_element/active_element', 'data-turbo-track': 'reload', 'data-turbolinks-track': 'reload' %>
|
126
125
|
<%= javascript_include_tag 'application', 'data-turbo-track': 'reload', 'data-turbolinks-track': 'reload' %>
|
127
126
|
<% end %>
|
128
127
|
</body>
|
data/example_app/Gemfile.lock
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_element
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootstrap
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- active_element.gemspec
|
115
115
|
- app/assets/config/active_element/manifest.js
|
116
116
|
- app/assets/javascripts/active_element/active_element.js
|
117
|
+
- app/assets/javascripts/active_element/ae-ujs.js
|
117
118
|
- app/assets/javascripts/active_element/confirm.js
|
118
119
|
- app/assets/javascripts/active_element/form.js
|
119
120
|
- app/assets/javascripts/active_element/highlight.js
|