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,512 +0,0 @@
1
- /**
2
- * Tableviews
3
- * @param {type} $
4
- * @param {type} window
5
- * @param {type} document
6
- * @returns {undefined}
7
- */
8
- (function($, window, document) {
9
-
10
- var CLASS_ACTIVE = $.className('active');
11
- var CLASS_SELECTED = $.className('selected');
12
- var CLASS_GRID_VIEW = $.className('grid-view');
13
- var CLASS_RADIO_VIEW = $.className('table-view-radio');
14
- var CLASS_TABLE_VIEW_CELL = $.className('table-view-cell');
15
- var CLASS_COLLAPSE_CONTENT = $.className('collapse-content');
16
- var CLASS_DISABLED = $.className('disabled');
17
- var CLASS_TOGGLE = $.className('switch');
18
- var CLASS_BTN = $.className('btn');
19
-
20
- var CLASS_SLIDER_HANDLE = $.className('slider-handle');
21
- var CLASS_SLIDER_LEFT = $.className('slider-left');
22
- var CLASS_SLIDER_RIGHT = $.className('slider-right');
23
- var CLASS_TRANSITIONING = $.className('transitioning');
24
-
25
-
26
- var SELECTOR_SLIDER_HANDLE = '.' + CLASS_SLIDER_HANDLE;
27
- var SELECTOR_SLIDER_LEFT = '.' + CLASS_SLIDER_LEFT;
28
- var SELECTOR_SLIDER_RIGHT = '.' + CLASS_SLIDER_RIGHT;
29
- var SELECTOR_SELECTED = '.' + CLASS_SELECTED;
30
- var SELECTOR_BUTTON = '.' + CLASS_BTN;
31
- var overFactor = 0.8;
32
- var cell, a;
33
-
34
- var isMoved = isOpened = openedActions = progress = false;
35
- var sliderHandle = sliderActionLeft = sliderActionRight = buttonsLeft = buttonsRight = sliderDirection = sliderRequestAnimationFrame = false;
36
- var timer = translateX = lastTranslateX = sliderActionLeftWidth = sliderActionRightWidth = 0;
37
-
38
-
39
-
40
- var toggleActive = function(isActive) {
41
- if (isActive) {
42
- if (a) {
43
- a.classList.add(CLASS_ACTIVE);
44
- } else if (cell) {
45
- cell.classList.add(CLASS_ACTIVE);
46
- }
47
- } else {
48
- timer && timer.cancel();
49
- if (a) {
50
- a.classList.remove(CLASS_ACTIVE);
51
- } else if (cell) {
52
- cell.classList.remove(CLASS_ACTIVE);
53
- }
54
- }
55
- };
56
-
57
- var updateTranslate = function() {
58
- if (translateX !== lastTranslateX) {
59
- if (buttonsRight && buttonsRight.length > 0) {
60
- progress = translateX / sliderActionRightWidth;
61
- if (translateX < -sliderActionRightWidth) {
62
- translateX = -sliderActionRightWidth - Math.pow(-translateX - sliderActionRightWidth, overFactor);
63
- }
64
- for (var i = 0, len = buttonsRight.length; i < len; i++) {
65
- var buttonRight = buttonsRight[i];
66
- if (typeof buttonRight._buttonOffset === 'undefined') {
67
- buttonRight._buttonOffset = buttonRight.offsetLeft;
68
- }
69
- buttonOffset = buttonRight._buttonOffset;
70
- setTranslate(buttonRight, (translateX - buttonOffset * (1 + Math.max(progress, -1))));
71
- }
72
- }
73
- if (buttonsLeft && buttonsLeft.length > 0) {
74
- progress = translateX / sliderActionLeftWidth;
75
- if (translateX > sliderActionLeftWidth) {
76
- translateX = sliderActionLeftWidth + Math.pow(translateX - sliderActionLeftWidth, overFactor);
77
- }
78
- for (var i = 0, len = buttonsLeft.length; i < len; i++) {
79
- var buttonLeft = buttonsLeft[i];
80
- if (typeof buttonLeft._buttonOffset === 'undefined') {
81
- buttonLeft._buttonOffset = sliderActionLeftWidth - buttonLeft.offsetLeft - buttonLeft.offsetWidth;
82
- }
83
- buttonOffset = buttonLeft._buttonOffset;
84
- if (buttonsLeft.length > 1) {
85
- buttonLeft.style.zIndex = buttonsLeft.length - i;
86
- }
87
- setTranslate(buttonLeft, (translateX + buttonOffset * (1 - Math.min(progress, 1))));
88
- }
89
- }
90
- setTranslate(sliderHandle, translateX);
91
- lastTranslateX = translateX;
92
- }
93
- sliderRequestAnimationFrame = requestAnimationFrame(function() {
94
- updateTranslate();
95
- });
96
- };
97
- var setTranslate = function(element, x) {
98
- if (element) {
99
- element.style.webkitTransform = 'translate3d(' + x + 'px,0,0)';
100
- }
101
- };
102
-
103
- window.addEventListener('touchstart', function(event) {
104
- if (cell) {
105
- toggleActive(false);
106
- }
107
- cell = a = false;
108
- isMoved = isOpened = openedActions = false;
109
- var target = event.target;
110
- var isDisabled = false;
111
- for (; target && target !== document; target = target.parentNode) {
112
- if (target.classList) {
113
- var classList = target.classList;
114
- if ((target.tagName === 'INPUT' && target.type !== 'radio' && target.type !== 'checkbox') || target.tagName === 'BUTTON' || classList.contains(CLASS_TOGGLE) || classList.contains(CLASS_BTN) || classList.contains(CLASS_DISABLED)) {
115
- isDisabled = true;
116
- }
117
- if (classList.contains(CLASS_COLLAPSE_CONTENT)) { //collapse content
118
- break;
119
- }
120
- if (classList.contains(CLASS_TABLE_VIEW_CELL)) {
121
- cell = target;
122
- //TODO swipe to delete close
123
- var selected = cell.parentNode.querySelector(SELECTOR_SELECTED);
124
- if (!cell.parentNode.classList.contains(CLASS_RADIO_VIEW) && selected && selected !== cell) {
125
- $.swipeoutClose(selected);
126
- cell = isDisabled = false;
127
- return;
128
- }
129
- if (!cell.parentNode.classList.contains(CLASS_GRID_VIEW)) {
130
- var link = cell.querySelector('a');
131
- if (link && link.parentNode === cell) { //li>a
132
- a = link;
133
- }
134
- }
135
- var handle = cell.querySelector(SELECTOR_SLIDER_HANDLE);
136
- if (handle) {
137
- toggleEvents(cell);
138
- event.stopPropagation();
139
- }
140
- if (!isDisabled) {
141
- if (handle) {
142
- if (timer) {
143
- timer.cancel();
144
- }
145
- timer = $.later(function() {
146
- toggleActive(true);
147
- }, 100);
148
- } else if (!(cell.querySelector('input') || cell.querySelector(SELECTOR_BUTTON) || cell.querySelector('.' + CLASS_TOGGLE))) {
149
- toggleActive(true);
150
- }
151
- }
152
- break;
153
- }
154
- }
155
- }
156
- });
157
- window.addEventListener('touchmove', function(event) {
158
- toggleActive(false);
159
- });
160
-
161
- var handleEvent = {
162
- handleEvent: function(event) {
163
- switch (event.type) {
164
- case 'drag':
165
- this.drag(event);
166
- break;
167
- case 'dragend':
168
- this.dragend(event);
169
- break;
170
- case 'flick':
171
- this.flick(event);
172
- break;
173
- case 'swiperight':
174
- this.swiperight(event);
175
- break;
176
- case 'swipeleft':
177
- this.swipeleft(event);
178
- break;
179
- }
180
- },
181
- drag: function(event) {
182
- if (!cell) {
183
- return;
184
- }
185
- if (!isMoved) { //init
186
- sliderHandle = sliderActionLeft = sliderActionRight = buttonsLeft = buttonsRight = sliderDirection = sliderRequestAnimationFrame = false;
187
- sliderHandle = cell.querySelector(SELECTOR_SLIDER_HANDLE);
188
- if (sliderHandle) {
189
- sliderActionLeft = cell.querySelector(SELECTOR_SLIDER_LEFT);
190
- sliderActionRight = cell.querySelector(SELECTOR_SLIDER_RIGHT);
191
- if (sliderActionLeft) {
192
- sliderActionLeftWidth = sliderActionLeft.offsetWidth;
193
- buttonsLeft = sliderActionLeft.querySelectorAll(SELECTOR_BUTTON);
194
- }
195
- if (sliderActionRight) {
196
- sliderActionRightWidth = sliderActionRight.offsetWidth;
197
- buttonsRight = sliderActionRight.querySelectorAll(SELECTOR_BUTTON);
198
- }
199
- cell.classList.remove(CLASS_TRANSITIONING);
200
- isOpened = cell.classList.contains(CLASS_SELECTED);
201
- if (isOpened) {
202
- openedActions = cell.querySelector(SELECTOR_SLIDER_LEFT + SELECTOR_SELECTED) ? 'left' : 'right';
203
- }
204
- }
205
- }
206
- var detail = event.detail;
207
- var direction = detail.direction;
208
- var angle = detail.angle;
209
- if (direction === 'left' && (angle > 150 || angle < -150)) {
210
- if (buttonsRight || (buttonsLeft && isOpened)) { //存在右侧按钮或存在左侧按钮且是已打开状态
211
- isMoved = true;
212
- }
213
- } else if (direction === 'right' && (angle > -30 && angle < 30)) {
214
- if (buttonsLeft || (buttonsRight && isOpened)) { //存在左侧按钮或存在右侧按钮且是已打开状态
215
- isMoved = true;
216
- }
217
- }
218
- if (isMoved) {
219
- event.stopPropagation();
220
- event.detail.gesture.preventDefault();
221
- var translate = event.detail.deltaX;
222
- if (isOpened) {
223
- if (openedActions === 'right') {
224
- translate = translate - sliderActionRightWidth;
225
- } else {
226
- translate = translate + sliderActionLeftWidth;
227
- }
228
- }
229
- if ((translate > 0 && !buttonsLeft) || (translate < 0 && !buttonsRight)) {
230
- if (!isOpened) {
231
- return;
232
- }
233
- translate = 0;
234
- }
235
- if (translate < 0) {
236
- sliderDirection = 'toLeft';
237
- } else if (translate > 0) {
238
- sliderDirection = 'toRight';
239
- } else {
240
- if (!sliderDirection) {
241
- sliderDirection = 'toLeft';
242
- }
243
- }
244
- if (!sliderRequestAnimationFrame) {
245
- updateTranslate();
246
- }
247
- translateX = translate;
248
- }
249
- },
250
- flick: function(event) {
251
- if (isMoved) {
252
- event.stopPropagation();
253
- }
254
- },
255
- swipeleft: function(event) {
256
- if (isMoved) {
257
- event.stopPropagation();
258
- }
259
- },
260
- swiperight: function(event) {
261
- if (isMoved) {
262
- event.stopPropagation();
263
- }
264
- },
265
- dragend: function(event) {
266
- if (!isMoved) {
267
- return;
268
- }
269
- event.stopPropagation();
270
- if (sliderRequestAnimationFrame) {
271
- cancelAnimationFrame(sliderRequestAnimationFrame);
272
- sliderRequestAnimationFrame = null;
273
- }
274
- var detail = event.detail;
275
- isMoved = false;
276
- var action = 'close';
277
- var actionsWidth = sliderDirection === 'toLeft' ? sliderActionRightWidth : sliderActionLeftWidth;
278
- var isToggle = detail.swipe || (Math.abs(translateX) > actionsWidth / 2);
279
- if (isToggle) {
280
- if (!isOpened) {
281
- action = 'open';
282
- } else if (detail.direction === 'left' && openedActions === 'right') {
283
- action = 'open';
284
- } else if (detail.direction === 'right' && openedActions === 'left') {
285
- action = 'open';
286
- }
287
-
288
- }
289
- cell.classList.add(CLASS_TRANSITIONING);
290
- var buttons;
291
- if (action === 'open') {
292
- var newTranslate = sliderDirection === 'toLeft' ? -actionsWidth : actionsWidth;
293
- setTranslate(sliderHandle, newTranslate);
294
- buttons = sliderDirection === 'toLeft' ? buttonsRight : buttonsLeft;
295
- if (typeof buttons !== 'undefined') {
296
- var button = null;
297
- for (var i = 0; i < buttons.length; i++) {
298
- button = buttons[i];
299
- setTranslate(button, newTranslate);
300
- }
301
- button.parentNode.classList.add(CLASS_SELECTED);
302
- cell.classList.add(CLASS_SELECTED);
303
- if (!isOpened) {
304
- $.trigger(cell, sliderDirection === 'toLeft' ? 'slideleft' : 'slideright');
305
- }
306
- }
307
- } else {
308
- setTranslate(sliderHandle, 0);
309
- sliderActionLeft && sliderActionLeft.classList.remove(CLASS_SELECTED);
310
- sliderActionRight && sliderActionRight.classList.remove(CLASS_SELECTED);
311
- cell.classList.remove(CLASS_SELECTED);
312
- }
313
- var buttonOffset;
314
- if (buttonsLeft && buttonsLeft.length > 0 && buttonsLeft !== buttons) {
315
- for (var i = 0, len = buttonsLeft.length; i < len; i++) {
316
- var buttonLeft = buttonsLeft[i];
317
- buttonOffset = buttonLeft._buttonOffset;
318
- if (typeof buttonOffset === 'undefined') {
319
- buttonLeft._buttonOffset = sliderActionLeftWidth - buttonLeft.offsetLeft - buttonLeft.offsetWidth;
320
- }
321
- setTranslate(buttonLeft, buttonOffset);
322
- }
323
- }
324
- if (buttonsRight && buttonsRight.length > 0 && buttonsRight !== buttons) {
325
- for (var i = 0, len = buttonsRight.length; i < len; i++) {
326
- var buttonRight = buttonsRight[i];
327
- buttonOffset = buttonRight._buttonOffset;
328
- if (typeof buttonOffset === 'undefined') {
329
- buttonRight._buttonOffset = buttonRight.offsetLeft;
330
- }
331
- setTranslate(buttonRight, -buttonOffset);
332
- }
333
- }
334
- }
335
- };
336
-
337
- function toggleEvents(element, isRemove) {
338
- var method = !!isRemove ? 'removeEventListener' : 'addEventListener';
339
- element[method]('drag', handleEvent);
340
- element[method]('dragend', handleEvent);
341
- element[method]('swiperight', handleEvent);
342
- element[method]('swipeleft', handleEvent);
343
- element[method]('flick', handleEvent);
344
- };
345
- /**
346
- * 打开滑动菜单
347
- * @param {Object} el
348
- * @param {Object} direction
349
- */
350
- $.swipeoutOpen = function(el, direction) {
351
- if (!el) return;
352
- var classList = el.classList;
353
- if (classList.contains(CLASS_SELECTED)) return;
354
- if (!direction) {
355
- if (el.querySelector(SELECTOR_SLIDER_RIGHT)) {
356
- direction = 'right';
357
- } else {
358
- direction = 'left';
359
- }
360
- }
361
- var swipeoutAction = el.querySelector($.classSelector(".slider-" + direction));
362
- if (!swipeoutAction) return;
363
- swipeoutAction.classList.add(CLASS_SELECTED);
364
- classList.add(CLASS_SELECTED);
365
- classList.remove(CLASS_TRANSITIONING);
366
- var buttons = swipeoutAction.querySelectorAll(SELECTOR_BUTTON);
367
- var swipeoutWidth = swipeoutAction.offsetWidth;
368
- var translate = (direction === 'right') ? -swipeoutWidth : swipeoutWidth;
369
- var length = buttons.length;
370
- var button;
371
- for (var i = 0; i < length; i++) {
372
- button = buttons[i];
373
- if (direction === 'right') {
374
- setTranslate(button, -button.offsetLeft);
375
- } else {
376
- setTranslate(button, (swipeoutWidth - button.offsetWidth - button.offsetLeft));
377
- }
378
- }
379
- classList.add(CLASS_TRANSITIONING);
380
- for (var i = 0; i < length; i++) {
381
- setTranslate(buttons[i], translate);
382
- }
383
- setTranslate(el.querySelector(SELECTOR_SLIDER_HANDLE), translate);
384
- };
385
- /**
386
- * 关闭滑动菜单
387
- * @param {Object} el
388
- */
389
- $.swipeoutClose = function(el) {
390
- if (!el) return;
391
- var classList = el.classList;
392
- if (!classList.contains(CLASS_SELECTED)) return;
393
- var direction = el.querySelector(SELECTOR_SLIDER_RIGHT + SELECTOR_SELECTED) ? 'right' : 'left';
394
- var swipeoutAction = el.querySelector($.classSelector(".slider-" + direction));
395
- if (!swipeoutAction) return;
396
- swipeoutAction.classList.remove(CLASS_SELECTED);
397
- classList.remove(CLASS_SELECTED);
398
- classList.add(CLASS_TRANSITIONING);
399
- var buttons = swipeoutAction.querySelectorAll(SELECTOR_BUTTON);
400
- var swipeoutWidth = swipeoutAction.offsetWidth;
401
- var length = buttons.length;
402
- var button;
403
- setTranslate(el.querySelector(SELECTOR_SLIDER_HANDLE), 0);
404
- for (var i = 0; i < length; i++) {
405
- button = buttons[i];
406
- if (direction === 'right') {
407
- setTranslate(button, (-button.offsetLeft));
408
- } else {
409
- setTranslate(button, (swipeoutWidth - button.offsetWidth - button.offsetLeft));
410
- }
411
- }
412
- };
413
-
414
- window.addEventListener('touchend', function(event) { //使用touchend来取消高亮,避免一次点击既不触发tap,doubletap,longtap的事件
415
- if (!cell) {
416
- return;
417
- }
418
- toggleActive(false);
419
- sliderHandle && toggleEvents(cell, true);
420
- });
421
- window.addEventListener('touchcancel', function(event) { //使用touchcancel来取消高亮,避免一次点击既不触发tap,doubletap,longtap的事件
422
- if (!cell) {
423
- return;
424
- }
425
- toggleActive(false);
426
- sliderHandle && toggleEvents(cell, true);
427
- });
428
- var radioOrCheckboxClick = function() {
429
- var classList = cell.classList;
430
- if (classList.contains($.className('radio'))) {
431
- var input = cell.querySelector('input[type=radio]');
432
- if (input) {
433
- // input.click();
434
- input.checked = !input.checked;
435
- }
436
- } else if (classList.contains($.className('checkbox'))) {
437
- var input = cell.querySelector('input[type=checkbox]');
438
- if (input) {
439
- // input.click();
440
- input.checked = !input.checked;
441
- }
442
- }
443
- };
444
- //fixed hashchange(android)
445
- window.addEventListener($.EVENT_CLICK, function(e) {
446
- if (cell && cell.classList.contains($.className('collapse'))) {
447
- e.preventDefault();
448
- }
449
- });
450
- window.addEventListener('doubletap', function(event) {
451
- if (cell) {
452
- radioOrCheckboxClick();
453
- }
454
- });
455
- window.addEventListener('tap', function(event) {
456
- if (!cell) {
457
- return;
458
- }
459
- var type = event.target && event.target.type;
460
- if (type === 'radio' || type === 'checkbox') {
461
- radioOrCheckboxClick();
462
- return;
463
- }
464
- var isExpand = false;
465
- var classList = cell.classList;
466
- var ul = cell.parentNode;
467
- if (ul && ul.classList.contains(CLASS_RADIO_VIEW)) {
468
- if (classList.contains(CLASS_SELECTED)) {
469
- return;
470
- }
471
- var selected = ul.querySelector('li' + SELECTOR_SELECTED);
472
- if (selected) {
473
- selected.classList.remove(CLASS_SELECTED);
474
- }
475
- classList.add(CLASS_SELECTED);
476
- $.trigger(cell, 'selected', {
477
- el: cell
478
- });
479
- return;
480
- }
481
- if (classList.contains($.className('collapse')) && !cell.parentNode.classList.contains($.className('unfold'))) {
482
- event.detail.gesture.preventDefault();
483
- if (!classList.contains(CLASS_ACTIVE)) { //展开时,需要收缩其他同类
484
- var collapse = cell.parentNode.querySelector($.classSelector('.collapse.active'));
485
- if (collapse) {
486
- collapse.classList.remove(CLASS_ACTIVE);
487
- }
488
- isExpand = true;
489
- }
490
- classList.toggle(CLASS_ACTIVE);
491
- if (isExpand) {
492
- //触发展开事件
493
- $.trigger(cell, 'expand');
494
-
495
- //scroll
496
- //暂不滚动
497
- // var offsetTop = $.offset(cell).top;
498
- // var scrollTop = document.body.scrollTop;
499
- // var height = window.innerHeight;
500
- // var offsetHeight = cell.offsetHeight;
501
- // var cellHeight = (offsetTop - scrollTop + offsetHeight);
502
- // if (offsetHeight > height) {
503
- // $.scrollTo(offsetTop, 300);
504
- // } else if (cellHeight > height) {
505
- // $.scrollTo(cellHeight - height + scrollTop, 300);
506
- // }
507
- }
508
- } else {
509
- radioOrCheckboxClick();
510
- }
511
- });
512
- })(mui, window, document);
@@ -1,88 +0,0 @@
1
- //
2
- // Badges
3
- // --------------------------------------------------
4
- .#{$namespace}badge {
5
- display: inline-block;
6
- padding: 3px 6px;
7
- font-size: 12px;
8
- line-height: 1;
9
- color: #333;
10
- background-color: rgba(0,0,0,.15);
11
- border-radius: 100px;
12
-
13
- // Inverted badges have no background.
14
- &.#{$namespace}badge-inverted {
15
- padding: 0 5px 0 0;
16
- color: $default-color;
17
- background-color: transparent;
18
- }
19
- }
20
-
21
-
22
- // Badge modifiers
23
- // --------------------------------------------------
24
-
25
- // Main badge
26
- .#{$namespace}badge-primary,.#{$namespace}badge-blue {
27
- color: #fff;
28
- background-color: $primary-color;
29
-
30
- &.#{$namespace}badge-inverted {
31
- color: $primary-color;
32
- background-color: transparent;
33
- }
34
- }
35
-
36
- // success badge
37
- .#{$namespace}badge-success,.#{$namespace}badge-green {
38
- color: #fff;
39
- background-color: $positive-color;
40
-
41
- &.#{$namespace}badge-inverted {
42
- color: $positive-color;
43
- background-color: transparent;
44
- }
45
- }
46
- //waring
47
- .#{$namespace}badge-warning,.#{$namespace}badge-yellow {
48
- color: #fff;
49
- background-color: $warning-color;
50
-
51
- &.#{$namespace}badge-inverted {
52
- color: $warning-color;
53
- background-color: transparent;
54
- }
55
- }
56
-
57
- // Negative badge
58
- .#{$namespace}badge-danger,.#{$namespace}badge-red {
59
- color: #fff;
60
- background-color: $negative-color;
61
-
62
- &.#{$namespace}badge-inverted {
63
- color: $negative-color;
64
- background-color: transparent;
65
- }
66
- }
67
-
68
- .#{$namespace}badge-royal,.#{$namespace}badge-purple {
69
- color: #fff;
70
- background-color: $royal-color;
71
-
72
- &.#{$namespace}badge-inverted {
73
- color: $royal-color;
74
- background-color: transparent;
75
- }
76
- }
77
-
78
- .#{$namespace}icon .#{$namespace}badge{
79
- position: absolute;
80
- left: 100%;
81
- margin-left: -10px;
82
- top: -2px;
83
- font-size: 10px;
84
- line-height: 1.4;
85
- padding: 1px 5px;
86
- background: red;
87
- color: white;
88
- }