active_frontend 15.0.4 → 15.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 748cb998fb711985e57ab9a9a2922c866c8a0cf8
4
- data.tar.gz: 2c7699b0a10ade9ac7cf728bc7c5c399df3a28a3
3
+ metadata.gz: 260d3d1b317cf4e1512d4a1026c39de7c48c9e18
4
+ data.tar.gz: 43d3c96c7505ad5b3a1272013397342627bbb14f
5
5
  SHA512:
6
- metadata.gz: a35a7b297e2840b7fc5bdbc9c089ec5a6f3c1d89e5f1f883fe9b9dc3d9dd84471d4840a1a9e6fe9ec2b61e5d5b97c52951862d495721f545148b5a1be133841c
7
- data.tar.gz: 6f8f234ce680578c1257aa2dc4b9f07473bf49fc2f57217d85249af66db865e953765f3066cd4829da8498b163ec3e053fbeea09f4cefb7fc68a2ce8900f85a2
6
+ metadata.gz: 7630ea9d42a33d2dd4fa274e5b888357097fb0065b1835c520b049c604f4e59d8ede4e517494f94c172e1bf5425a7e4b0a2f40fe09e7351f2fc301f1f4cb174f
7
+ data.tar.gz: 529dea79fca3177a852c145b910b5e31d411560b068d431278d21f4a32bdad1dabc3d800b3f4b35fa9d736f73d3bb30eee218ca63a080c3b1ed7c3c7201becf9
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveFrontend
4
- VERSION ||= '15.0.4'
4
+ VERSION ||= '15.0.5'
5
5
  end
@@ -46,6 +46,7 @@
46
46
  //= require extensions/_copy
47
47
  //= require extensions/_funnel
48
48
  //= require extensions/_map
49
+ //= require extensions/_mobile_events
49
50
  //= require extensions/_push
50
51
  //= require extensions/_wysiwyg
51
52
  //= require extensions/_xpull
@@ -46,6 +46,7 @@
46
46
  //= require extensions/_copy
47
47
  //= require extensions/_funnel
48
48
  //= require extensions/_map
49
+ //= require extensions/_mobile_events
49
50
  //= require extensions/_push
50
51
  //= require extensions/_wysiwyg
51
52
  //= require extensions/_xpull
@@ -0,0 +1,778 @@
1
+ 'use strict';
2
+
3
+ (function ($) {
4
+ $.attrFn = $.attrFn || {};
5
+
6
+ var touchCapable = ('ontouchstart' in window);
7
+ var settings = {
8
+ tap_pixel_range: 5,
9
+ swipe_h_threshold: 50,
10
+ swipe_v_threshold: 50,
11
+ taphold_threshold: 750,
12
+ doubletap_int: 500,
13
+ touch_capable: touchCapable,
14
+ orientation_support: ('orientation' in window && 'onorientationchange' in window),
15
+ startevent: (touchCapable) ? 'touchstart' : 'mousedown',
16
+ endevent: (touchCapable) ? 'touchend' : 'mouseup',
17
+ moveevent: (touchCapable) ? 'touchmove' : 'mousemove',
18
+ tapevent: (touchCapable) ? 'tap' : 'click',
19
+ scrollevent: (touchCapable) ? 'touchmove' : 'scroll',
20
+ hold_timer: null,
21
+ tap_timer: null
22
+ };
23
+
24
+ $.isTouchCapable = function() { return settings.touch_capable; };
25
+ $.getStartEvent = function() { return settings.startevent; };
26
+ $.getEndEvent = function() { return settings.endevent; };
27
+ $.getMoveEvent = function() { return settings.moveevent; };
28
+ $.getTapEvent = function() { return settings.tapevent; };
29
+ $.getScrollEvent = function() { return settings.scrollevent; };
30
+
31
+ $.each([
32
+ 'tapstart', 'tapend', 'tapmove', 'tap', 'tap2', 'tap3', 'tap4', 'singletap', 'doubletap',
33
+ 'taphold', 'swipe', 'swipeup', 'swiperight', 'swipedown', 'swipeleft', 'swipeend',
34
+ 'scrollstart', 'scrollend', 'orientationchange'
35
+ ], function (i, name) {
36
+ $.fn[name] = function (fn) {
37
+ return fn ? this.on(name, fn) : this.trigger(name);
38
+ };
39
+
40
+ $.attrFn[name] = true;
41
+ });
42
+
43
+ $.event.special.tapstart = {
44
+ setup: function () {
45
+ var thisObject = this;
46
+ var $this = $(thisObject);
47
+
48
+ $this.on(settings.startevent, function tapStartFunc(e) {
49
+ $this.data('callee', tapStartFunc);
50
+ if (e.which && e.which !== 1) return false;
51
+
52
+ var origEvent = e.originalEvent;
53
+ var touchData = {
54
+ 'position': {
55
+ 'x': ((settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX),
56
+ 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY
57
+ },
58
+ 'offset': {
59
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
60
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
61
+ },
62
+ 'time': Date.now(),
63
+ 'target': e.target
64
+ };
65
+
66
+ triggerCustomEvent(thisObject, 'tapstart', e, touchData);
67
+ return true;
68
+ });
69
+ },
70
+ remove: function () {
71
+ $(this).off(settings.startevent, $(this).data.callee);
72
+ }
73
+ };
74
+
75
+ $.event.special.tapmove = {
76
+ setup: function() {
77
+ var thisObject = this;
78
+ var $this = $(thisObject);
79
+
80
+ $this.on(settings.moveevent, function tapMoveFunc(e) {
81
+ $this.data('callee', tapMoveFunc);
82
+
83
+ var origEvent = e.originalEvent;
84
+ var touchData = {
85
+ 'position': {
86
+ 'x': ((settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX),
87
+ 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY
88
+ },
89
+ 'offset': {
90
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
91
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
92
+ },
93
+ 'time': Date.now(),
94
+ 'target': e.target
95
+ };
96
+
97
+ triggerCustomEvent(thisObject, 'tapmove', e, touchData);
98
+ return true;
99
+ });
100
+ },
101
+ remove: function() {
102
+ $(this).off(settings.moveevent, $(this).data.callee);
103
+ }
104
+ };
105
+
106
+ $.event.special.tapend = {
107
+ setup: function () {
108
+ var thisObject = this;
109
+ var $this = $(thisObject);
110
+
111
+ $this.on(settings.endevent, function tapEndFunc(e) {
112
+ $this.data('callee', tapEndFunc);
113
+
114
+ var origEvent = e.originalEvent;
115
+ var touchData = {
116
+ 'position': {
117
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[0].screenX : e.screenX,
118
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[0].screenY : e.screenY
119
+ },
120
+ 'offset': {
121
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
122
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
123
+ },
124
+ 'time': Date.now(),
125
+ 'target': e.target
126
+ };
127
+ triggerCustomEvent(thisObject, 'tapend', e, touchData);
128
+ return true;
129
+ });
130
+ },
131
+ remove: function () {
132
+ $(this).off(settings.endevent, $(this).data.callee);
133
+ }
134
+ };
135
+
136
+ $.event.special.taphold = {
137
+ setup: function () {
138
+ var thisObject = this;
139
+ var $this = $(thisObject);
140
+ var origTarget;
141
+ var start_pos = {
142
+ x: 0,
143
+ y: 0
144
+ };
145
+ var end_x = 0;
146
+ var end_y = 0;
147
+
148
+ $this.on(settings.startevent, function tapHoldFunc1(e) {
149
+ if (e.which && e.which !== 1) {
150
+ return false;
151
+ } else {
152
+ $this.data('tapheld', false);
153
+ origTarget = e.target;
154
+
155
+ var origEvent = e.originalEvent;
156
+ var start_time = Date.now();
157
+ var startPosition = {
158
+ 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX,
159
+ 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY
160
+ };
161
+ var startOffset = {
162
+ 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX,
163
+ 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY
164
+ };
165
+
166
+ start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
167
+ start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
168
+
169
+ end_x = start_pos.x;
170
+ end_y = start_pos.y;
171
+
172
+ var ele_threshold = ($this.parent().data('threshold')) ? $this.parent().data('threshold') : $this.data('threshold');
173
+ var threshold = (typeof ele_threshold !== 'undefined' && ele_threshold !== false && parseInt(ele_threshold)) ? parseInt(ele_threshold) : settings.taphold_threshold;
174
+
175
+ settings.hold_timer = window.setTimeout(function () {
176
+ var diff_x = (start_pos.x - end_x);
177
+ var diff_y = (start_pos.y - end_y);
178
+
179
+ if (e.target == origTarget && ((start_pos.x == end_x && start_pos.y == end_y) || (diff_x >= -(settings.tap_pixel_range) && diff_x <= settings.tap_pixel_range && diff_y >= -(settings.tap_pixel_range) && diff_y <= settings.tap_pixel_range))) {
180
+ $this.data('tapheld', true);
181
+
182
+ var end_time = Date.now();
183
+ var endPosition = {
184
+ 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX,
185
+ 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY
186
+ };
187
+ var endOffset = {
188
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
189
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
190
+ };
191
+ var duration = end_time - start_time;
192
+ var touchData = {
193
+ 'startTime': start_time,
194
+ 'endTime': end_time,
195
+ 'startPosition': startPosition,
196
+ 'startOffset': startOffset,
197
+ 'endPosition': endPosition,
198
+ 'endOffset': endOffset,
199
+ 'duration': duration,
200
+ 'target': e.target
201
+ };
202
+
203
+ $this.data('callee1', tapHoldFunc1);
204
+ triggerCustomEvent(thisObject, 'taphold', e, touchData);
205
+ }
206
+ }, threshold);
207
+
208
+ return true;
209
+ }
210
+ }).on(settings.endevent, function tapHoldFunc2() {
211
+ $this.data('callee2', tapHoldFunc2);
212
+ $this.data('tapheld', false);
213
+ window.clearTimeout(settings.hold_timer);
214
+ })
215
+ .on(settings.moveevent, function tapHoldFunc3(e) {
216
+ $this.data('callee3', tapHoldFunc3);
217
+
218
+ end_x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
219
+ end_y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
220
+ });
221
+ },
222
+ remove: function () {
223
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2).off(settings.moveevent, $(this).data.callee3);
224
+ }
225
+ };
226
+
227
+ $.event.special.doubletap = {
228
+ setup: function () {
229
+ var thisObject = this;
230
+ var $this = $(thisObject);
231
+ var origTarget;
232
+ var action;
233
+ var firstTap = null;
234
+ var origEvent;
235
+ var cooloff;
236
+ var cooling = false;
237
+
238
+ $this.on(settings.startevent, function doubleTapFunc1(e) {
239
+ if (e.which && e.which !== 1) return false;
240
+
241
+ $this.data('doubletapped', false);
242
+ origTarget = e.target;
243
+
244
+ $this.data('callee1', doubleTapFunc1);
245
+ origEvent = e.originalEvent;
246
+
247
+ if (!firstTap) {
248
+ firstTap = {
249
+ 'position': {
250
+ 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX,
251
+ 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY
252
+ },
253
+ 'offset': {
254
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
255
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
256
+ },
257
+ 'time': Date.now(),
258
+ 'target': e.target,
259
+ 'element': e.originalEvent.srcElement,
260
+ 'index': $(e.target).index()
261
+ };
262
+ }
263
+
264
+ return true;
265
+ }).on(settings.endevent, function doubleTapFunc2(e) {
266
+ var now = Date.now();
267
+ var lastTouch = $this.data('lastTouch') || now + 1;
268
+ var delta = now - lastTouch;
269
+
270
+ window.clearTimeout(action);
271
+ $this.data('callee2', doubleTapFunc2);
272
+
273
+ if (delta < settings.doubletap_int && ($(e.target).index() == firstTap.index) && delta > 100) {
274
+ $this.data('doubletapped', true);
275
+ window.clearTimeout(settings.tap_timer);
276
+
277
+ var lastTap = {
278
+ 'position': {
279
+ 'x': (settings.touch_capable) ? e.originalEvent.changedTouches[0].screenX : e.screenX,
280
+ 'y': (settings.touch_capable) ? e.originalEvent.changedTouches[0].screenY : e.screenY
281
+ },
282
+ 'offset': {
283
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
284
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
285
+ },
286
+ 'time': Date.now(),
287
+ 'target': e.target,
288
+ 'element': e.originalEvent.srcElement,
289
+ 'index': $(e.target).index()
290
+ };
291
+
292
+ var touchData = {
293
+ 'firstTap': firstTap,
294
+ 'secondTap': lastTap,
295
+ 'interval': lastTap.time - firstTap.time
296
+ };
297
+
298
+ if (!cooling) {
299
+ triggerCustomEvent(thisObject, 'doubletap', e, touchData);
300
+ firstTap = null;
301
+ }
302
+
303
+ cooling = true;
304
+ cooloff = window.setTimeout(function () {
305
+ cooling = false;
306
+ }, settings.doubletap_int);
307
+ } else {
308
+ $this.data('lastTouch', now);
309
+ action = window.setTimeout(function () {
310
+ firstTap = null;
311
+ window.clearTimeout(action);
312
+ }, settings.doubletap_int, [e]);
313
+ }
314
+
315
+ $this.data('lastTouch', now);
316
+ });
317
+ },
318
+ remove: function () {
319
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
320
+ }
321
+ };
322
+
323
+ $.event.special.singletap = {
324
+ setup: function () {
325
+ var thisObject = this;
326
+ var $this = $(thisObject);
327
+ var origTarget = null;
328
+ var startTime = null;
329
+ var start_pos = {
330
+ x: 0,
331
+ y: 0
332
+ };
333
+
334
+ $this.on(settings.startevent, function singleTapFunc1(e) {
335
+ if (e.which && e.which !== 1) {
336
+ return false;
337
+ } else {
338
+ startTime = Date.now();
339
+ origTarget = e.target;
340
+ $this.data('callee1', singleTapFunc1);
341
+
342
+ start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
343
+ start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
344
+
345
+ return true;
346
+ }
347
+ }).on(settings.endevent, function singleTapFunc2(e) {
348
+ $this.data('callee2', singleTapFunc2);
349
+
350
+ if (e.target == origTarget) {
351
+ var end_pos_x = (e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageX : e.pageX;
352
+ var end_pos_y = (e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageY : e.pageY;
353
+
354
+ settings.tap_timer = window.setTimeout(function () {
355
+ var diff_x = (start_pos.x - end_pos_x);
356
+ var diff_y = (start_pos.y - end_pos_y);
357
+
358
+ if (!$this.data('doubletapped') && !$this.data('tapheld') && (((start_pos.x == end_pos_x) && (start_pos.y == end_pos_y)) || (diff_x >= -(settings.tap_pixel_range) && diff_x <= settings.tap_pixel_range && diff_y >= -(settings.tap_pixel_range) && diff_y <= settings.tap_pixel_range))) {
359
+ var origEvent = e.originalEvent;
360
+ var touchData = {
361
+ 'position': {
362
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[0].screenX : e.screenX,
363
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[0].screenY : e.screenY
364
+ },
365
+ 'offset': {
366
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
367
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
368
+ },
369
+ 'time': Date.now(),
370
+ 'target': e.target
371
+ };
372
+
373
+ if ((touchData.time - startTime) < settings.taphold_threshold) {
374
+ triggerCustomEvent(thisObject, 'singletap', e, touchData);
375
+ }
376
+ }
377
+ }, settings.doubletap_int);
378
+ }
379
+ });
380
+ },
381
+ remove: function () {
382
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
383
+ }
384
+ };
385
+
386
+ $.event.special.tap = {
387
+ setup: function () {
388
+ var thisObject = this;
389
+ var $this = $(thisObject);
390
+ var started = false;
391
+ var origTarget = null;
392
+ var start_time;
393
+ var start_pos = {
394
+ x: 0,
395
+ y: 0
396
+ };
397
+ var touches;
398
+
399
+ $this.on(settings.startevent, function tapFunc1(e) {
400
+ $this.data('callee1', tapFunc1);
401
+
402
+ if ( e.which && e.which !== 1 ) {
403
+ return false;
404
+ } else {
405
+ started = true;
406
+ start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
407
+ start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
408
+ start_time = Date.now();
409
+ origTarget = e.target;
410
+
411
+ touches = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches : [ e ];
412
+ return true;
413
+ }
414
+ }).on(settings.endevent, function tapFunc2(e) {
415
+ $this.data('callee2', tapFunc2);
416
+
417
+ var end_x = (e.originalEvent.targetTouches) ? e.originalEvent.changedTouches[0].pageX : e.pageX;
418
+ var end_y = (e.originalEvent.targetTouches) ? e.originalEvent.changedTouches[0].pageY : e.pageY;
419
+ var diff_x = (start_pos.x - end_x);
420
+ var diff_y = (start_pos.y - end_y);
421
+ var eventName;
422
+
423
+ if (origTarget == e.target && started && ((Date.now() - start_time) < settings.taphold_threshold) && ((start_pos.x == end_x && start_pos.y == end_y) || (diff_x >= -(settings.tap_pixel_range) && diff_x <= settings.tap_pixel_range && diff_y >= -(settings.tap_pixel_range) && diff_y <= settings.tap_pixel_range))) {
424
+ var origEvent = e.originalEvent;
425
+ var touchData = [];
426
+
427
+ for ( var i = 0; i < touches.length; i++) {
428
+ if (settings.touch_capable && !origEvent.changedTouches[i]) continue;
429
+
430
+ var touch = {
431
+ 'position': {
432
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[i].screenX : e.screenX,
433
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[i].screenY : e.screenY
434
+ },
435
+ 'offset': {
436
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
437
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[i].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
438
+ },
439
+ 'time': Date.now(),
440
+ 'target': e.target
441
+ };
442
+
443
+ touchData.push( touch );
444
+ }
445
+
446
+ triggerCustomEvent(thisObject, 'tap', e, touchData);
447
+ }
448
+ });
449
+ },
450
+ remove: function () {
451
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2);
452
+ }
453
+ };
454
+
455
+ $.event.special.swipe = {
456
+ setup: function () {
457
+ var thisObject = this;
458
+ var $this = $(thisObject);
459
+ var started = false;
460
+ var hasSwiped = false;
461
+ var originalCoord = {
462
+ x: 0,
463
+ y: 0
464
+ };
465
+ var finalCoord = {
466
+ x: 0,
467
+ y: 0
468
+ };
469
+ var startEvnt;
470
+
471
+ function touchStart(e) {
472
+ $this = $(e.currentTarget);
473
+ $this.data('callee1', touchStart);
474
+ originalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
475
+ originalCoord.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
476
+ finalCoord.x = originalCoord.x;
477
+ finalCoord.y = originalCoord.y;
478
+
479
+ started = true;
480
+ var origEvent = e.originalEvent;
481
+ startEvnt = {
482
+ 'position': {
483
+ 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX,
484
+ 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY
485
+ },
486
+ 'offset': {
487
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
488
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
489
+ },
490
+ 'time': Date.now(),
491
+ 'target': e.target
492
+ };
493
+ }
494
+
495
+ function touchMove(e) {
496
+ $this = $(e.currentTarget);
497
+ $this.data('callee2', touchMove);
498
+ finalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX;
499
+ finalCoord.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY;
500
+
501
+ var swipedir;
502
+
503
+ var ele_x_threshold = ($this.parent().data('xthreshold')) ? $this.parent().data('xthreshold') : $this.data('xthreshold');
504
+ var ele_y_threshold = ($this.parent().data('ythreshold')) ? $this.parent().data('ythreshold') : $this.data('ythreshold');
505
+ var h_threshold = (typeof ele_x_threshold !== 'undefined' && ele_x_threshold !== false && parseInt(ele_x_threshold)) ? parseInt(ele_x_threshold) : settings.swipe_h_threshold;
506
+ var v_threshold = (typeof ele_y_threshold !== 'undefined' && ele_y_threshold !== false && parseInt(ele_y_threshold)) ? parseInt(ele_y_threshold) : settings.swipe_v_threshold;
507
+
508
+ if (originalCoord.y > finalCoord.y && (originalCoord.y - finalCoord.y > v_threshold)) {
509
+ swipedir = 'swipeup';
510
+ }
511
+ if (originalCoord.x < finalCoord.x && (finalCoord.x - originalCoord.x > h_threshold)) {
512
+ swipedir = 'swiperight';
513
+ }
514
+ if (originalCoord.y < finalCoord.y && (finalCoord.y - originalCoord.y > v_threshold)) {
515
+ swipedir = 'swipedown';
516
+ }
517
+ if (originalCoord.x > finalCoord.x && (originalCoord.x - finalCoord.x > h_threshold)) {
518
+ swipedir = 'swipeleft';
519
+ }
520
+ if (swipedir != undefined && started) {
521
+ originalCoord.x = 0;
522
+ originalCoord.y = 0;
523
+ finalCoord.x = 0;
524
+ finalCoord.y = 0;
525
+ started = false;
526
+
527
+ var origEvent = e.originalEvent;
528
+ var endEvnt = {
529
+ 'position': {
530
+ 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX,
531
+ 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY
532
+ },
533
+ 'offset': {
534
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
535
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
536
+ },
537
+ 'time': Date.now(),
538
+ 'target': e.target
539
+ };
540
+
541
+ var xAmount = Math.abs(startEvnt.position.x - endEvnt.position.x);
542
+ var yAmount = Math.abs(startEvnt.position.y - endEvnt.position.y);
543
+
544
+ var touchData = {
545
+ 'startEvnt': startEvnt,
546
+ 'endEvnt': endEvnt,
547
+ 'direction': swipedir.replace('swipe', ''),
548
+ 'xAmount': xAmount,
549
+ 'yAmount': yAmount,
550
+ 'duration': endEvnt.time - startEvnt.time
551
+ };
552
+
553
+ hasSwiped = true;
554
+ $this.trigger('swipe', touchData).trigger(swipedir, touchData);
555
+ }
556
+ }
557
+
558
+ function touchEnd(e) {
559
+ $this = $(e.currentTarget);
560
+ var swipedir = '';
561
+
562
+ $this.data('callee3', touchEnd);
563
+
564
+ if (hasSwiped) {
565
+ var ele_x_threshold = $this.data('xthreshold');
566
+ var ele_y_threshold = $this.data('ythreshold');
567
+ var h_threshold = (typeof ele_x_threshold !== 'undefined' && ele_x_threshold !== false && parseInt(ele_x_threshold)) ? parseInt(ele_x_threshold) : settings.swipe_h_threshold;
568
+ var v_threshold = (typeof ele_y_threshold !== 'undefined' && ele_y_threshold !== false && parseInt(ele_y_threshold)) ? parseInt(ele_y_threshold) : settings.swipe_v_threshold;
569
+ var origEvent = e.originalEvent;
570
+ var endEvnt = {
571
+ 'position': {
572
+ 'x': (settings.touch_capable) ? origEvent.changedTouches[0].screenX : e.screenX,
573
+ 'y': (settings.touch_capable) ? origEvent.changedTouches[0].screenY : e.screenY
574
+ },
575
+ 'offset': {
576
+ 'x': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageX - ($this.offset() ? $this.offset().left : 0)) : Math.round(e.pageX - ($this.offset() ? $this.offset().left : 0)),
577
+ 'y': (settings.touch_capable) ? Math.round(origEvent.changedTouches[0].pageY - ($this.offset() ? $this.offset().top : 0)) : Math.round(e.pageY - ($this.offset() ? $this.offset().top : 0))
578
+ },
579
+ 'time': Date.now(),
580
+ 'target': e.target
581
+ };
582
+
583
+ if (startEvnt.position.y > endEvnt.position.y && (startEvnt.position.y - endEvnt.position.y > v_threshold)) {
584
+ swipedir = 'swipeup';
585
+ }
586
+ if (startEvnt.position.x < endEvnt.position.x && (endEvnt.position.x - startEvnt.position.x > h_threshold)) {
587
+ swipedir = 'swiperight';
588
+ }
589
+ if (startEvnt.position.y < endEvnt.position.y && (endEvnt.position.y - startEvnt.position.y > v_threshold)) {
590
+ swipedir = 'swipedown';
591
+ }
592
+ if (startEvnt.position.x > endEvnt.position.x && (startEvnt.position.x - endEvnt.position.x > h_threshold)) {
593
+ swipedir = 'swipeleft';
594
+ }
595
+
596
+ var xAmount = Math.abs(startEvnt.position.x - endEvnt.position.x);
597
+ var yAmount = Math.abs(startEvnt.position.y - endEvnt.position.y);
598
+
599
+ var touchData = {
600
+ 'startEvnt': startEvnt,
601
+ 'endEvnt': endEvnt,
602
+ 'direction': swipedir.replace('swipe', ''),
603
+ 'xAmount': xAmount,
604
+ 'yAmount': yAmount,
605
+ 'duration': endEvnt.time - startEvnt.time
606
+ };
607
+
608
+ $this.trigger('swipeend', touchData);
609
+ }
610
+
611
+ started = false;
612
+ hasSwiped = false;
613
+ }
614
+
615
+ $this.on(settings.startevent, touchStart);
616
+ $this.on(settings.moveevent, touchMove);
617
+ $this.on(settings.endevent, touchEnd);
618
+ },
619
+ remove: function () {
620
+ $(this).off(settings.startevent, $(this).data.callee1).off(settings.moveevent, $(this).data.callee2).off(settings.endevent, $(this).data.callee3);
621
+ }
622
+ };
623
+
624
+ $.event.special.scrollstart = {
625
+ setup: function () {
626
+ var thisObject = this;
627
+ var $this = $(thisObject);
628
+ var scrolling;
629
+ var timer;
630
+
631
+ function trigger(event, state) {
632
+ scrolling = state;
633
+ triggerCustomEvent(thisObject, scrolling ? 'scrollstart' : 'scrollend', event);
634
+ }
635
+
636
+ $this.on(settings.scrollevent, function scrollFunc(event) {
637
+ $this.data('callee', scrollFunc);
638
+
639
+ if (!scrolling) trigger(event, true);
640
+
641
+ clearTimeout(timer);
642
+ timer = setTimeout(function () {
643
+ trigger(event, false);
644
+ }, 50);
645
+ });
646
+ },
647
+ remove: function () {
648
+ $(this).off(settings.scrollevent, $(this).data.callee);
649
+ }
650
+ };
651
+
652
+ var win = $(window);
653
+ var special_event;
654
+ var get_orientation;
655
+ var last_orientation;
656
+ var initial_orientation_is_landscape;
657
+ var initial_orientation_is_default;
658
+ var portrait_map = {
659
+ '0': true,
660
+ '180': true
661
+ };
662
+
663
+ if (settings.orientation_support) {
664
+ var ww = window.innerWidth || win.width();
665
+ var wh = window.innerHeight || win.height();
666
+ var landscape_threshold = 50;
667
+
668
+ initial_orientation_is_landscape = ww > wh && (ww - wh) > landscape_threshold;
669
+ initial_orientation_is_default = portrait_map[window.orientation];
670
+
671
+ if ((initial_orientation_is_landscape && initial_orientation_is_default) || (!initial_orientation_is_landscape && !initial_orientation_is_default)) {
672
+ portrait_map = {
673
+ '-90': true,
674
+ '90': true
675
+ };
676
+ }
677
+ }
678
+
679
+ $.event.special.orientationchange = special_event = {
680
+ setup: function () {
681
+ if (settings.orientation_support) return false;
682
+
683
+ last_orientation = get_orientation();
684
+
685
+ win.on('throttledresize', handler);
686
+ return true;
687
+ },
688
+ teardown: function () {
689
+ if (settings.orientation_support) return false;
690
+
691
+ win.off('throttledresize', handler);
692
+ return true;
693
+ },
694
+ add: function (handleObj) {
695
+ var old_handler = handleObj.handler;
696
+
697
+ handleObj.handler = function (event) {
698
+ event.orientation = get_orientation();
699
+ return old_handler.apply(this, arguments);
700
+ };
701
+ }
702
+ };
703
+
704
+ function handler() {
705
+ var orientation = get_orientation();
706
+
707
+ if (orientation !== last_orientation) {
708
+ last_orientation = orientation;
709
+ win.trigger('orientationchange');
710
+ }
711
+ }
712
+
713
+ $.event.special.orientationchange.orientation = get_orientation = function () {
714
+ var isPortrait = true;
715
+ var elem = document.documentElement;
716
+
717
+ if (settings.orientation_support) {
718
+ isPortrait = portrait_map[window.orientation];
719
+ } else {
720
+ isPortrait = elem && elem.clientWidth / elem.clientHeight < 1.1;
721
+ }
722
+
723
+ return isPortrait ? 'portrait' : 'landscape';
724
+ };
725
+
726
+ $.event.special.throttledresize = {
727
+ setup: function () {
728
+ $(this).on('resize', throttle_handler);
729
+ },
730
+ teardown: function () {
731
+ $(this).off('resize', throttle_handler);
732
+ }
733
+ };
734
+
735
+ var throttle = 250;
736
+ var throttle_handler = function () {
737
+ curr = Date.now();
738
+ diff = curr - lastCall;
739
+
740
+ if (diff >= throttle) {
741
+ lastCall = curr;
742
+ $(this).trigger('throttledresize');
743
+ } else {
744
+ if (heldCall) window.clearTimeout(heldCall);
745
+
746
+ heldCall = window.setTimeout(handler, throttle - diff);
747
+ }
748
+ };
749
+ var lastCall = 0;
750
+ var heldCall;
751
+ var curr;
752
+ var diff;
753
+
754
+ function triggerCustomEvent(obj, eventType, event, touchData) {
755
+ var originalType = event.type;
756
+ event.type = eventType;
757
+
758
+ $.event.dispatch.call(obj, event, touchData);
759
+ event.type = originalType;
760
+ }
761
+
762
+ $.each({
763
+ scrollend: 'scrollstart',
764
+ swipeup: 'swipe',
765
+ swiperight: 'swipe',
766
+ swipedown: 'swipe',
767
+ swipeleft: 'swipe',
768
+ swipeend: 'swipe',
769
+ tap2: 'tap'
770
+ }, function (e, srcE) {
771
+ $.event.special[e] = {
772
+ setup: function () {
773
+ $(this).on(srcE, $.noop);
774
+ }
775
+ };
776
+ });
777
+
778
+ }(jQuery));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_frontend
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.0.4
4
+ version: 15.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-21 00:00:00.000000000 Z
11
+ date: 2017-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -496,6 +496,7 @@ files:
496
496
  - vendor/assets/javascripts/extensions/_copy.js
497
497
  - vendor/assets/javascripts/extensions/_funnel.js
498
498
  - vendor/assets/javascripts/extensions/_map.js
499
+ - vendor/assets/javascripts/extensions/_mobile_events.js
499
500
  - vendor/assets/javascripts/extensions/_push.js
500
501
  - vendor/assets/javascripts/extensions/_wysiwyg.js
501
502
  - vendor/assets/javascripts/extensions/_xpull.js