mui_app_rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/mui_app_rails/mui.js +6013 -1
  3. data/app/assets/javascripts/mui_app_rails/mui.min.js +8 -0
  4. data/app/assets/javascripts/mui_app_rails.js +1 -1
  5. data/app/assets/stylesheets/mui_app_rails/mui.css +3742 -0
  6. data/app/assets/stylesheets/mui_app_rails/mui.min.css +5 -0
  7. data/lib/mui_app_rails/engine.rb +12 -0
  8. data/lib/mui_app_rails/version.rb +1 -1
  9. data/lib/mui_app_rails.rb +1 -1
  10. metadata +17 -99
  11. data/app/assets/javascripts/mui_app_rails/actions.js +0 -26
  12. data/app/assets/javascripts/mui_app_rails/ajax.plugin.js +0 -3
  13. data/app/assets/javascripts/mui_app_rails/input.plugin.js +0 -232
  14. data/app/assets/javascripts/mui_app_rails/modals.js +0 -37
  15. data/app/assets/javascripts/mui_app_rails/mui.active.js +0 -30
  16. data/app/assets/javascripts/mui_app_rails/mui.ajax.5+.js +0 -27
  17. data/app/assets/javascripts/mui_app_rails/mui.ajax.js +0 -277
  18. data/app/assets/javascripts/mui_app_rails/mui.animation.js +0 -39
  19. data/app/assets/javascripts/mui_app_rails/mui.animationframe.js +0 -72
  20. data/app/assets/javascripts/mui_app_rails/mui.back.5+.js +0 -108
  21. data/app/assets/javascripts/mui_app_rails/mui.back.js +0 -56
  22. data/app/assets/javascripts/mui_app_rails/mui.class.js +0 -40
  23. data/app/assets/javascripts/mui_app_rails/mui.class.scroll.js +0 -894
  24. data/app/assets/javascripts/mui_app_rails/mui.class.scroll.pullrefresh.js +0 -150
  25. data/app/assets/javascripts/mui_app_rails/mui.class.scroll.slider.js +0 -361
  26. data/app/assets/javascripts/mui_app_rails/mui.class.scroll.slider.old.js +0 -332
  27. data/app/assets/javascripts/mui_app_rails/mui.detect.5+.js +0 -18
  28. data/app/assets/javascripts/mui_app_rails/mui.detect.js +0 -50
  29. data/app/assets/javascripts/mui_app_rails/mui.dialog.alert.js +0 -27
  30. data/app/assets/javascripts/mui_app_rails/mui.dialog.confirm.js +0 -27
  31. data/app/assets/javascripts/mui_app_rails/mui.dialog.prompt.js +0 -33
  32. data/app/assets/javascripts/mui_app_rails/mui.dialog.toast.js +0 -20
  33. data/app/assets/javascripts/mui_app_rails/mui.event.js +0 -160
  34. data/app/assets/javascripts/mui_app_rails/mui.fixed.animation.js +0 -22
  35. data/app/assets/javascripts/mui_app_rails/mui.fixed.classlist.js +0 -50
  36. data/app/assets/javascripts/mui_app_rails/mui.fixed.fastclick.js +0 -64
  37. data/app/assets/javascripts/mui_app_rails/mui.fixed.js +0 -40
  38. data/app/assets/javascripts/mui_app_rails/mui.fixed.keyboard.js +0 -56
  39. data/app/assets/javascripts/mui_app_rails/mui.gestures.drag.js +0 -48
  40. data/app/assets/javascripts/mui_app_rails/mui.gestures.flick.js +0 -30
  41. data/app/assets/javascripts/mui_app_rails/mui.gestures.hold.js +0 -41
  42. data/app/assets/javascripts/mui_app_rails/mui.gestures.js +0 -207
  43. data/app/assets/javascripts/mui_app_rails/mui.gestures.longtap.js +0 -43
  44. data/app/assets/javascripts/mui_app_rails/mui.gestures.swipe.js +0 -29
  45. data/app/assets/javascripts/mui_app_rails/mui.gestures.tap.js +0 -40
  46. data/app/assets/javascripts/mui_app_rails/mui.init.5+.js +0 -441
  47. data/app/assets/javascripts/mui_app_rails/mui.init.js +0 -100
  48. data/app/assets/javascripts/mui_app_rails/mui.init.pullrefresh.js +0 -57
  49. data/app/assets/javascripts/mui_app_rails/mui.jsonp.js +0 -108
  50. data/app/assets/javascripts/mui_app_rails/mui.layout.js +0 -22
  51. data/app/assets/javascripts/mui_app_rails/mui.namespace.js +0 -35
  52. data/app/assets/javascripts/mui_app_rails/mui.number.js +0 -93
  53. data/app/assets/javascripts/mui_app_rails/mui.offcanvas.js +0 -497
  54. data/app/assets/javascripts/mui_app_rails/mui.pullrefresh.js +0 -157
  55. data/app/assets/javascripts/mui_app_rails/mui.target.js +0 -58
  56. data/app/assets/javascripts/mui_app_rails/mui.view.js +0 -172
  57. data/app/assets/javascripts/mui_app_rails/popovers.js +0 -278
  58. data/app/assets/javascripts/mui_app_rails/pullrefresh.5+.js +0 -238
  59. data/app/assets/javascripts/mui_app_rails/push.js +0 -479
  60. data/app/assets/javascripts/mui_app_rails/segmented-controllers.js +0 -99
  61. data/app/assets/javascripts/mui_app_rails/sliders.js +0 -362
  62. data/app/assets/javascripts/mui_app_rails/switches.js +0 -165
  63. data/app/assets/javascripts/mui_app_rails/tableviews.js +0 -512
  64. data/app/assets/stylesheets/mui_app_rails/badges.scss +0 -88
  65. data/app/assets/stylesheets/mui_app_rails/bars.scss +0 -312
  66. data/app/assets/stylesheets/mui_app_rails/base.scss +0 -196
  67. data/app/assets/stylesheets/mui_app_rails/buttons.scss +0 -205
  68. data/app/assets/stylesheets/mui_app_rails/cards.scss +0 -62
  69. data/app/assets/stylesheets/mui_app_rails/forms.scss +0 -452
  70. data/app/assets/stylesheets/mui_app_rails/fullscreen.scss +0 -35
  71. data/app/assets/stylesheets/mui_app_rails/grid.scss +0 -75
  72. data/app/assets/stylesheets/mui_app_rails/hack.scss +0 -14
  73. data/app/assets/stylesheets/mui_app_rails/icon.scss +0 -170
  74. data/app/assets/stylesheets/mui_app_rails/iscroll.scss +0 -43
  75. data/app/assets/stylesheets/mui_app_rails/loadings.scss +0 -111
  76. data/app/assets/stylesheets/mui_app_rails/mixins.scss +0 -212
  77. data/app/assets/stylesheets/mui_app_rails/modals.scss +0 -34
  78. data/app/assets/stylesheets/mui_app_rails/mui.scss +0 -46
  79. data/app/assets/stylesheets/mui_app_rails/normalize.scss +0 -425
  80. data/app/assets/stylesheets/mui_app_rails/number.scss +0 -70
  81. data/app/assets/stylesheets/mui_app_rails/off-canvas.scss +0 -84
  82. data/app/assets/stylesheets/mui_app_rails/os.scss +0 -12
  83. data/app/assets/stylesheets/mui_app_rails/pagination.scss +0 -155
  84. data/app/assets/stylesheets/mui_app_rails/popovers.scss +0 -198
  85. data/app/assets/stylesheets/mui_app_rails/pullrefreshs.scss +0 -98
  86. data/app/assets/stylesheets/mui_app_rails/push.scss +0 -63
  87. data/app/assets/stylesheets/mui_app_rails/scroll.scss +0 -95
  88. data/app/assets/stylesheets/mui_app_rails/segmented-controls.scss +0 -150
  89. data/app/assets/stylesheets/mui_app_rails/slider-cell.scss +0 -20
  90. data/app/assets/stylesheets/mui_app_rails/sliders.scss +0 -133
  91. data/app/assets/stylesheets/mui_app_rails/switches.scss +0 -115
  92. data/app/assets/stylesheets/mui_app_rails/table-views.scss +0 -482
  93. data/app/assets/stylesheets/mui_app_rails/toast.scss +0 -16
  94. data/app/assets/stylesheets/mui_app_rails/type.scss +0 -23
  95. data/app/assets/stylesheets/mui_app_rails/variables.scss +0 -64
@@ -1,50 +0,0 @@
1
- /**
2
- * mui fixed classList
3
- * @param {type} document
4
- * @returns {undefined}
5
- */
6
- (function(document) {
7
- if (!("classList" in document.documentElement) && Object.defineProperty && typeof HTMLElement !== 'undefined') {
8
-
9
- Object.defineProperty(HTMLElement.prototype, 'classList', {
10
- get: function() {
11
- var self = this;
12
- function update(fn) {
13
- return function(value) {
14
- var classes = self.className.split(/\s+/),
15
- index = classes.indexOf(value);
16
-
17
- fn(classes, index, value);
18
- self.className = classes.join(" ");
19
- };
20
- }
21
-
22
- var ret = {
23
- add: update(function(classes, index, value) {
24
- ~index || classes.push(value);
25
- }),
26
- remove: update(function(classes, index) {
27
- ~index && classes.splice(index, 1);
28
- }),
29
- toggle: update(function(classes, index, value) {
30
- ~index ? classes.splice(index, 1) : classes.push(value);
31
- }),
32
- contains: function(value) {
33
- return !!~self.className.split(/\s+/).indexOf(value);
34
- },
35
- item: function(i) {
36
- return self.className.split(/\s+/)[i] || null;
37
- }
38
- };
39
-
40
- Object.defineProperty(ret, 'length', {
41
- get: function() {
42
- return self.className.split(/\s+/).length;
43
- }
44
- });
45
-
46
- return ret;
47
- }
48
- });
49
- }
50
- })(document);
@@ -1,64 +0,0 @@
1
- /**
2
- * fastclick(only for radio,checkbox)
3
- */
4
- (function($, window, name) {
5
- if (window.FastClick) {
6
- return;
7
- }
8
-
9
- var handle = function(event, target) {
10
- if (target.tagName === 'LABEL') {
11
- if (target.parentNode) {
12
- target = target.parentNode.querySelector('input');
13
- }
14
- }
15
- if (target && (target.type === 'radio' || target.type === 'checkbox')) {
16
- if (!target.disabled) { //disabled
17
- return target;
18
- }
19
- }
20
- return false;
21
- };
22
-
23
- $.registerTarget({
24
- name: name,
25
- index: 40,
26
- handle: handle,
27
- target: false
28
- });
29
- var dispatchEvent = function(event) {
30
- var targetElement = $.targets.click;
31
- if (targetElement) {
32
- var clickEvent, touch;
33
- // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect
34
- if (document.activeElement && document.activeElement !== targetElement) {
35
- document.activeElement.blur();
36
- }
37
- touch = event.detail.gesture.changedTouches[0];
38
- // Synthesise a click event, with an extra attribute so it can be tracked
39
- clickEvent = document.createEvent('MouseEvents');
40
- clickEvent.initMouseEvent('click', true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
41
- clickEvent.forwardedTouchEvent = true;
42
- targetElement.dispatchEvent(clickEvent);
43
- }
44
- };
45
- window.addEventListener('tap', dispatchEvent);
46
- window.addEventListener('doubletap', dispatchEvent);
47
- //捕获
48
- window.addEventListener('click', function(event) {
49
- if ($.targets.click) {
50
- if (!event.forwardedTouchEvent) { //stop click
51
- if (event.stopImmediatePropagation) {
52
- event.stopImmediatePropagation();
53
- } else {
54
- // Part of the hack for browsers that don't support Event#stopImmediatePropagation
55
- event.propagationStopped = true;
56
- }
57
- event.stopPropagation();
58
- event.preventDefault();
59
- return false;
60
- }
61
- }
62
- }, true);
63
-
64
- })(mui, window, 'click');
@@ -1,40 +0,0 @@
1
- /**
2
- * fixed trim
3
- * @param {type} undefined
4
- * @returns {undefined}
5
- */
6
- (function(undefined) {
7
- if (String.prototype.trim === undefined) { // fix for iOS 3.2
8
- String.prototype.trim = function() {
9
- return this.replace(/^\s+|\s+$/g, '');
10
- };
11
- }
12
- Object.setPrototypeOf = Object.setPrototypeOf || function(obj, proto) {
13
- obj['__proto__'] = proto;
14
- return obj;
15
- };
16
-
17
- })();
18
- /**
19
- * fixed CustomEvent
20
- */
21
- (function() {
22
- if (typeof window.CustomEvent === 'undefined') {
23
- function CustomEvent(event, params) {
24
- params = params || {
25
- bubbles: false,
26
- cancelable: false,
27
- detail: undefined
28
- };
29
- var evt = document.createEvent('Events');
30
- var bubbles = true;
31
- for (var name in params) {
32
- (name === 'bubbles') ? (bubbles = !!params[name]) : (evt[name] = params[name]);
33
- }
34
- evt.initEvent(event, bubbles, true);
35
- return evt;
36
- };
37
- CustomEvent.prototype = window.Event.prototype;
38
- window.CustomEvent = CustomEvent;
39
- }
40
- })();
@@ -1,56 +0,0 @@
1
- (function($, document) {
2
- $(function() {
3
- if (!$.os.ios) {
4
- return;
5
- }
6
- var CLASS_FOCUSIN = $.className('focusin');
7
- var CLASS_BAR_TAB = $.className('bar-tab');
8
- var CLASS_BAR_FOOTER = $.className('bar-footer');
9
- var CLASS_BAR_FOOTER_SECONDARY = $.className('bar-footer-secondary');
10
- var CLASS_BAR_FOOTER_SECONDARY_TAB = $.className('bar-footer-secondary-tab');
11
- // var content = document.querySelector('.' + CLASS_CONTENT);
12
- // if (content) {
13
- // document.body.insertBefore(content, document.body.firstElementChild);
14
- // }
15
- document.addEventListener('focusin', function(e) {
16
- if ($.os.plus) { //在父webview里边不fix
17
- if (window.plus) {
18
- if (plus.webview.currentWebview().children().length > 0) {
19
- return;
20
- }
21
- }
22
- }
23
- var target = e.target;
24
- if (target.tagName && target.tagName === 'INPUT' && target.type === 'text') {
25
- if (target.disabled || target.readOnly) {
26
- return;
27
- }
28
- document.body.classList.add(CLASS_FOCUSIN);
29
- var isFooter = false;
30
- for (; target && target !== document; target = target.parentNode) {
31
- var classList = target.classList;
32
- if (classList && classList.contains(CLASS_BAR_TAB) || classList.contains(CLASS_BAR_FOOTER) || classList.contains(CLASS_BAR_FOOTER_SECONDARY) || classList.contains(CLASS_BAR_FOOTER_SECONDARY_TAB)) {
33
- isFooter = true;
34
- break;
35
- }
36
- }
37
- if (isFooter) {
38
- var scrollTop = document.body.scrollHeight;
39
- var scrollLeft = document.body.scrollLeft;
40
- setTimeout(function() {
41
- window.scrollTo(scrollLeft, scrollTop);
42
- }, 20);
43
- }
44
- }
45
- });
46
- document.addEventListener('focusout', function(e) {
47
- var classList = document.body.classList;
48
- if (classList.contains(CLASS_FOCUSIN)) {
49
- classList.remove(CLASS_FOCUSIN);
50
- setTimeout(function() {
51
- window.scrollTo(document.body.scrollLeft, document.body.scrollTop);
52
- }, 20);
53
- }
54
- });
55
- });
56
- })(mui, document);
@@ -1,48 +0,0 @@
1
- /**
2
- * mui gesture drag[start|left|right|up|down|end]
3
- * @param {type} $
4
- * @param {type} name
5
- * @returns {undefined}
6
- */
7
- (function($, name) {
8
- var handle = function(event, touch) {
9
- switch (event.type) {
10
- case $.EVENT_MOVE:
11
- if (touch.direction) { //drag
12
- //修正direction
13
- //默认锁定单向drag(后续可能需要额外配置支持)
14
- if (touch.lockDirection && touch.startDirection) {
15
- if (touch.startDirection && touch.startDirection !== touch.direction) {
16
- if (touch.startDirection === 'up' || touch.startDirection === 'down') {
17
- touch.direction = touch.deltaY < 0 ? 'up' : 'down';
18
- } else {
19
- touch.direction = touch.deltaX < 0 ? 'left' : 'right';
20
- }
21
- }
22
- }
23
- if (!touch.drag) {
24
- touch.drag = true;
25
- $.trigger(event.target, name + 'start', touch);
26
- }
27
- $.trigger(event.target, name, touch);
28
- $.trigger(event.target, name + touch.direction, touch);
29
- }
30
- break;
31
- case $.EVENT_END:
32
- case $.EVENT_CANCEL:
33
- if (touch.drag) {
34
- $.trigger(event.target, name + 'end', touch);
35
- }
36
- break;
37
- }
38
- };
39
- /**
40
- * mui gesture drag
41
- */
42
- $.registerGesture({
43
- name: name,
44
- index: 20,
45
- handle: handle,
46
- options: {}
47
- });
48
- })(mui, 'drag');
@@ -1,30 +0,0 @@
1
- /**
2
- * mui gesture flick[left|right|up|down]
3
- * @param {type} $
4
- * @param {type} name
5
- * @returns {undefined}
6
- */
7
- (function($, name) {
8
- var handle = function(event, touch) {
9
- if (event.type === $.EVENT_END || event.type === $.EVENT_CANCEL) {
10
- var options = this.options;
11
- if (touch.direction && options.flickMaxTime > touch.flickTime && touch.distance > options.flickMinDistince) {
12
- touch.flick = true;
13
- $.trigger(event.target, name, touch);
14
- $.trigger(event.target, name + touch.direction, touch);
15
- }
16
- }
17
- };
18
- /**
19
- * mui gesture flick
20
- */
21
- $.registerGesture({
22
- name: name,
23
- index: 5,
24
- handle: handle,
25
- options: {
26
- flickMaxTime: 200,
27
- flickMinDistince: 10
28
- }
29
- });
30
- })(mui, 'flick');
@@ -1,41 +0,0 @@
1
- /**
2
- * mui gesture hold
3
- * @param {type} $
4
- * @param {type} name
5
- * @returns {undefined}
6
- */
7
- (function($, name) {
8
- var timer;
9
- var handle = function(event, touch) {
10
- var options = this.options;
11
- switch (event.type) {
12
- case $.EVENT_START:
13
- clearTimeout(timer);
14
- timer = setTimeout(function() {
15
- touch.hold = true;
16
- $.trigger(event.target, name, touch);
17
- }, options.holdTimeout);
18
- break;
19
- case $.EVENT_MOVE:
20
- break;
21
- case $.EVENT_END:
22
- case $.EVENT_CANCEL:
23
- clearTimeout(timer);
24
- if ($.options.gestureConfig.hold && touch.hold) {
25
- $.trigger(event.target, 'release', touch);
26
- }
27
- break;
28
- }
29
- };
30
- /**
31
- * mui gesture hold
32
- */
33
- $.registerGesture({
34
- name: name,
35
- index: 10,
36
- handle: handle,
37
- options: {
38
- holdTimeout: 0
39
- }
40
- });
41
- })(mui, 'hold');
@@ -1,207 +0,0 @@
1
- /**
2
- * mui gestures
3
- * @param {type} $
4
- * @param {type} window
5
- * @returns {undefined}
6
- */
7
- (function($, window) {
8
- $.EVENT_START = 'touchstart';
9
- $.EVENT_MOVE = 'touchmove';
10
- $.EVENT_END = 'touchend';
11
- $.EVENT_CANCEL = 'touchcancel';
12
- $.EVENT_CLICK = 'click';
13
- /**
14
- * Gesture preventDefault
15
- * @param {type} e
16
- * @returns {undefined}
17
- */
18
- $.preventDefault = function(e) {
19
- e.preventDefault();
20
- };
21
- /**
22
- * Gesture stopPropagation
23
- * @param {type} e
24
- * @returns {undefined}
25
- */
26
- $.stopPropagation = function(e) {
27
- e.stopPropagation();
28
- };
29
-
30
- /**
31
- * register gesture
32
- * @param {type} gesture
33
- * @returns {$.gestures}
34
- */
35
- $.registerGesture = function(gesture) {
36
- return $.registerHandler('gestures', gesture);
37
-
38
- };
39
- /**
40
- * distance
41
- * @param {type} p1
42
- * @param {type} p2
43
- * @returns {Number}
44
- */
45
- var getDistance = function(p1, p2) {
46
- var x = p2.x - p1.x;
47
- var y = p2.y - p1.y;
48
- return Math.sqrt((x * x) + (y * y));
49
- };
50
- /**
51
- * angle
52
- * @param {type} p1
53
- * @param {type} p2
54
- * @returns {Number}
55
- */
56
- var getAngle = function(p1, p2) {
57
- return Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
58
- };
59
- /**
60
- * direction
61
- * @param {type} angle
62
- * @returns {unresolved}
63
- */
64
- var getDirectionByAngle = function(angle) {
65
- if (angle < -45 && angle > -135) {
66
- return 'up';
67
- } else if (angle >= 45 && angle < 135) {
68
- return 'down';
69
- } else if (angle >= 135 || angle <= -135) {
70
- return 'left';
71
- } else if (angle >= -45 && angle <= 45) {
72
- return 'right';
73
- }
74
- return null;
75
- };
76
- /**
77
- * detect gestures
78
- * @param {type} event
79
- * @param {type} touch
80
- * @returns {undefined}
81
- */
82
- var detect = function(event, touch) {
83
- if ($.gestures.stoped) {
84
- return;
85
- }
86
- $.each($.gestures, function(index, gesture) {
87
- if (!$.gestures.stoped) {
88
- if ($.options.gestureConfig[gesture.name] !== false) {
89
- gesture.handle(event, touch);
90
- }
91
- }
92
- });
93
- };
94
- var detectTouchStart = function(event) {
95
- $.gestures.stoped = false;
96
- var now = $.now();
97
- var point = event.touches ? event.touches[0] : event;
98
- $.gestures.touch = {
99
- target: event.target,
100
- lastTarget: ($.gestures.touch && $.gestures.touch.lastTarget ? $.gestures.touch.lastTarget : null),
101
- startTime: now,
102
- touchTime: 0,
103
- flickStartTime: now,
104
- lastTapTime: ($.gestures.touch && $.gestures.touch.lastTapTime ? $.gestures.touch.lastTapTime : 0),
105
- start: {
106
- x: point.pageX,
107
- y: point.pageY
108
- },
109
- flickStart: {
110
- x: point.pageX,
111
- y: point.pageY
112
- },
113
- flickDistanceX: 0,
114
- flickDistanceY: 0,
115
- move: {
116
- x: 0,
117
- y: 0
118
- },
119
- deltaX: 0,
120
- deltaY: 0,
121
- lastDeltaX: 0,
122
- lastDeltaY: 0,
123
- angle: '',
124
- direction: '',
125
- lockDirection: false,
126
- startDirection: '',
127
- distance: 0,
128
- drag: false,
129
- swipe: false,
130
- hold: false,
131
- gesture: event
132
- };
133
-
134
- detect(event, $.gestures.touch);
135
- };
136
- var detectTouchMove = function(event) {
137
- if ($.gestures.stoped) {
138
- return;
139
- }
140
- var touch = $.gestures.touch;
141
- if (event.target != touch.target) {
142
- return;
143
- }
144
- var now = $.now();
145
- var point = event.touches ? event.touches[0] : event;
146
- touch.touchTime = now - touch.startTime;
147
- touch.move = {
148
- x: point.pageX,
149
- y: point.pageY
150
- };
151
- if (now - touch.flickStartTime > 300) {
152
- touch.flickStartTime = now;
153
- touch.flickStart = touch.move;
154
- }
155
- touch.distance = getDistance(touch.start, touch.move);
156
- touch.angle = getAngle(touch.start, touch.move);
157
- touch.direction = getDirectionByAngle(touch.angle);
158
- touch.lastDeltaX = touch.deltaX;
159
- touch.lastDeltaY = touch.deltaY;
160
- touch.deltaX = touch.move.x - touch.start.x;
161
- touch.deltaY = touch.move.y - touch.start.y;
162
- touch.gesture = event;
163
-
164
- detect(event, touch);
165
- };
166
- var detectTouchEnd = function(event) {
167
- if ($.gestures.stoped) {
168
- return;
169
- }
170
- var touch = $.gestures.touch;
171
- if (event.target != touch.target) {
172
- return;
173
- }
174
- var now = $.now();
175
- touch.touchTime = now - touch.startTime;
176
- touch.flickTime = now - touch.flickStartTime;
177
- touch.flickDistanceX = touch.move.x - touch.flickStart.x;
178
- touch.flickDistanceY = touch.move.y - touch.flickStart.y;
179
- touch.gesture = event;
180
-
181
- detect(event, touch);
182
- };
183
-
184
- window.addEventListener($.EVENT_START, detectTouchStart);
185
- window.addEventListener($.EVENT_MOVE, detectTouchMove);
186
- window.addEventListener($.EVENT_END, detectTouchEnd);
187
- window.addEventListener($.EVENT_CANCEL, detectTouchEnd);
188
- //fixed hashchange(android)
189
- window.addEventListener($.EVENT_CLICK, function(e) {
190
- //TODO 应该判断当前target是不是在targets.popover内部,而不是非要相等
191
- if (($.targets.popover && e.target === $.targets.popover) || ($.targets.tab) || $.targets.offcanvas || $.targets.modal) {
192
- e.preventDefault();
193
- }
194
- }, true);
195
-
196
-
197
- //增加原生滚动识别
198
- $.isScrolling = false;
199
- var scrollingTimeout = null;
200
- window.addEventListener('scroll', function() {
201
- $.isScrolling = true;
202
- scrollingTimeout && clearTimeout(scrollingTimeout);
203
- scrollingTimeout = setTimeout(function() {
204
- $.isScrolling = false;
205
- }, 250);
206
- });
207
- })(mui, window);
@@ -1,43 +0,0 @@
1
- /**
2
- * mui gesture longtap
3
- * @param {type} $
4
- * @param {type} name
5
- * @returns {undefined}
6
- */
7
- (function($, name) {
8
- var timer;
9
- var handle = function(event, touch) {
10
- var options = this.options;
11
- switch (event.type) {
12
- case $.EVENT_START:
13
- clearTimeout(timer);
14
- timer = setTimeout(function() {
15
- if (!touch.drag) {
16
- $.trigger(event.target, name, touch);
17
- }
18
- }, options.holdTimeout);
19
- break;
20
- case $.EVENT_MOVE:
21
- if (touch.distance > options.holdThreshold) {
22
- clearTimeout(timer);
23
- }
24
- break;
25
- case $.EVENT_END:
26
- case $.EVENT_CANCEL:
27
- clearTimeout(timer);
28
- break;
29
- }
30
- };
31
- /**
32
- * mui gesture longtap
33
- */
34
- $.registerGesture({
35
- name: name,
36
- index: 10,
37
- handle: handle,
38
- options: {
39
- holdTimeout: 500,
40
- holdThreshold: 2
41
- }
42
- });
43
- })(mui, 'longtap');
@@ -1,29 +0,0 @@
1
- /**
2
- * mui gesture swipe[left|right|up|down]
3
- * @param {type} $
4
- * @param {type} name
5
- * @returns {undefined}
6
- */
7
- (function($, name) {
8
- var handle = function(event, touch) {
9
- if (event.type === $.EVENT_END || event.type === $.EVENT_CANCEL) {
10
- var options = this.options;
11
- if (touch.direction && options.swipeMaxTime > touch.touchTime && touch.distance > options.swipeMinDistince) {
12
- touch.swipe = true;
13
- $.trigger(event.target, name + touch.direction, touch);
14
- }
15
- }
16
- };
17
- /**
18
- * mui gesture swipe
19
- */
20
- $.registerGesture({
21
- name: name,
22
- index: 10,
23
- handle: handle,
24
- options: {
25
- swipeMaxTime: 300,
26
- swipeMinDistince: 18
27
- }
28
- });
29
- })(mui, 'swipe');
@@ -1,40 +0,0 @@
1
- /**
2
- * mui gesture tap and doubleTap
3
- * @param {type} $
4
- * @param {type} name
5
- * @returns {undefined}
6
- */
7
- (function($, name) {
8
- var handle = function(event, touch) {
9
- //if (event.type === $.EVENT_END || event.type === $.EVENT_CANCEL) {
10
- if (event.type === $.EVENT_END) { //ignore touchcancel
11
- var options = this.options;
12
- if (touch.distance < options.tapMaxDistance && touch.touchTime < options.tapMaxTime) {
13
- if ($.options.gestureConfig.doubletap && touch.lastTarget && (touch.lastTarget === event.target)) { //same target
14
- if (touch.lastTapTime && (touch.startTime - touch.lastTapTime) < options.tapMaxInterval) {
15
- $.trigger(event.target, 'doubletap', touch);
16
- touch.lastTapTime = $.now();
17
- touch.lastTarget = event.target;
18
- return;
19
- }
20
- }
21
- $.trigger(event.target, name, touch);
22
- touch.lastTapTime = $.now();
23
- touch.lastTarget = event.target;
24
- }
25
- }
26
- };
27
- /**
28
- * mui gesture tap
29
- */
30
- $.registerGesture({
31
- name: name,
32
- index: 30,
33
- handle: handle,
34
- options: {
35
- tapMaxInterval: 300,
36
- tapMaxDistance: 5,
37
- tapMaxTime: 250
38
- }
39
- });
40
- })(mui, 'tap');