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,150 +0,0 @@
1
- (function($, window, document, undefined) {
2
-
3
- var CLASS_VISIBILITY = $.className('visibility');
4
- var CLASS_HIDDEN = $.className('hidden');
5
-
6
- var PullRefresh = $.Scroll.extend($.extend({
7
- handleEvent: function(e) {
8
- this._super(e);
9
- if (e.type === 'scrollbottom') {
10
- if (e.target === this.scroller) {
11
- this._scrollbottom();
12
- }
13
- }
14
- },
15
- _scrollbottom: function() {
16
- if (!this.pulldown && !this.loading) {
17
- this.pulldown = false;
18
- this._initPullupRefresh();
19
- this.pullupLoading();
20
- }
21
- },
22
- _start: function(e) {
23
- if (!this.loading) {
24
- this.pulldown = this.pullPocket = this.pullCaption = this.pullLoading = false
25
- }
26
- this._super(e);
27
- },
28
- _drag: function(e) {
29
- this._super(e);
30
- if (!this.pulldown && !this.loading && this.topPocket && e.detail.direction === 'down' && this.y >= 0) {
31
- this._initPulldownRefresh();
32
- }
33
- if (this.pulldown) {
34
- this._setCaption(this.y > this.options.down.height ? this.options.down.contentover : this.options.down.contentdown);
35
- }
36
- },
37
-
38
- _reLayout: function() {
39
- this.hasVerticalScroll = true;
40
- this._super();
41
- },
42
- //API
43
- resetPosition: function(time) {
44
- if (this.pulldown && this.y >= this.options.down.height) {
45
- this.pulldownLoading(0, time || 0);
46
- return true;
47
- }
48
- return this._super(time);
49
- },
50
- pulldownLoading: function(x, time) {
51
- x = x || 0;
52
- this.scrollTo(x, this.options.down.height, time, this.options.bounceEasing);
53
- if (this.loading) {
54
- return;
55
- }
56
- // if (!this.pulldown) {
57
- this._initPulldownRefresh();
58
- // }
59
- this._setCaption(this.options.down.contentrefresh);
60
- this.loading = true;
61
- this.indicators.map(function(indicator) {
62
- indicator.fade(0);
63
- });
64
- var callback = this.options.down.callback;
65
- callback && callback.call(this);
66
- },
67
- endPulldownToRefresh: function() {
68
- var self = this;
69
- if (self.topPocket && self.loading && this.pulldown) {
70
- self.scrollTo(0, 0, self.options.bounceTime, self.options.bounceEasing);
71
- self.loading = false;
72
- self._setCaption(self.options.down.contentdown, true);
73
- setTimeout(function() {
74
- self.loading || self.topPocket.classList.remove(CLASS_VISIBILITY);
75
- }, 350);
76
- }
77
- },
78
- pullupLoading: function(callback, x, time) {
79
- x = x || 0;
80
- this.scrollTo(x, this.maxScrollY, time, this.options.bounceEasing);
81
- if (this.loading) {
82
- return;
83
- }
84
- this._initPullupRefresh();
85
- this._setCaption(this.options.up.contentrefresh);
86
- this.indicators.map(function(indicator) {
87
- indicator.fade(0);
88
- });
89
- this.loading = true;
90
- callback = callback || this.options.up.callback;
91
- callback && callback.call(this);
92
- },
93
- endPullupToRefresh: function(finished) {
94
- var self = this;
95
- if (self.bottomPocket && self.loading && !this.pulldown) {
96
- self.loading = false;
97
- if (finished) {
98
- this.finished = true;
99
- self._setCaption(self.options.up.contentnomore);
100
- // self.bottomPocket.classList.remove(CLASS_VISIBILITY);
101
- // self.bottomPocket.classList.add(CLASS_HIDDEN);
102
- self.wrapper.removeEventListener('scrollbottom', self);
103
- } else {
104
- self._setCaption(self.options.up.contentdown);
105
- setTimeout(function() {
106
- self.loading || self.bottomPocket.classList.remove(CLASS_VISIBILITY);
107
- }, 350);
108
- }
109
- }
110
- },
111
- refresh: function(isReset) {
112
- if (isReset && this.finished) {
113
- if (this.pulldown !== false) {
114
- this._initPullupRefresh();
115
- }
116
- this.bottomPocket.classList.remove(CLASS_HIDDEN);
117
- this._setCaption(this.options.up.contentdown);
118
- this.wrapper.addEventListener('scrollbottom', this);
119
- this.finished = false;
120
- }
121
- this._super();
122
- },
123
- }, $.PullRefresh));
124
- $.fn.pullRefresh = function(options) {
125
- if (this.length === 1) {
126
- var self = this[0];
127
- var pullRefreshApi = null;
128
- options = options || {};
129
- var id = self.getAttribute('data-pullrefresh');
130
- if (!id) {
131
- id = ++$.uuid;
132
- $.data[id] = pullRefreshApi = new PullRefresh(self, options);
133
- self.setAttribute('data-pullrefresh', id);
134
- } else {
135
- pullRefreshApi = $.data[id];
136
- }
137
- if (options.up && options.up.auto) { //如果设置了auto,则自动上拉一次
138
- pullRefreshApi.pullupLoading();
139
- }
140
- //暂不提供这种调用方式吧
141
- // if (typeof options === 'string') {
142
- // var methodValue = pullRefreshApi[options].apply(pullRefreshApi, $.slice.call(arguments, 1));
143
- // if (methodValue !== undefined) {
144
- // return methodValue;
145
- // }
146
- // }
147
- return pullRefreshApi;
148
- }
149
- };
150
- })(mui, window, document);
@@ -1,361 +0,0 @@
1
- /**
2
- * snap 重构
3
- * @param {Object} $
4
- * @param {Object} window
5
- */
6
- (function($, window) {
7
- var CLASS_SLIDER = $.className('slider');
8
- var CLASS_SLIDER_GROUP = $.className('slider-group');
9
- var CLASS_SLIDER_LOOP = $.className('slider-loop');
10
- var CLASS_SLIDER_INDICATOR = $.className('slider-indicator');
11
- var CLASS_ACTION_PREVIOUS = $.className('action-previous');
12
- var CLASS_ACTION_NEXT = $.className('action-next');
13
- var CLASS_SLIDER_ITEM = $.className('slider-item');
14
-
15
- var CLASS_ACTIVE = $.className('active');
16
-
17
- var SELECTOR_SLIDER_ITEM = '.' + CLASS_SLIDER_ITEM;
18
- var SELECTOR_SLIDER_INDICATOR = '.' + CLASS_SLIDER_INDICATOR;
19
- var SELECTOR_SLIDER_PROGRESS_BAR = $.classSelector('.slider-progress-bar');
20
-
21
-
22
- var Slider = $.Scroll.extend({
23
- init: function(element, options) {
24
- this._super(element, $.extend(true, {
25
- interval: 0, //设置为0,则不定时轮播
26
- scrollY: false,
27
- scrollX: true,
28
- indicators: false,
29
- bounceTime: 200,
30
- startX: false,
31
- snap: SELECTOR_SLIDER_ITEM
32
- }, options));
33
- if (this.options.startX) {
34
- // $.trigger(this.wrapper, 'scrollend', this);
35
- }
36
- },
37
- _init: function() {
38
- var groups = this.wrapper.querySelectorAll('.' + CLASS_SLIDER_GROUP);
39
- for (var i = 0, len = groups.length; i < len; i++) {
40
- if (groups[i].parentNode === this.wrapper) {
41
- this.scroller = groups[i];
42
- break;
43
- }
44
- }
45
- if (this.scroller) {
46
- this.scrollerStyle = this.scroller.style;
47
- this.progressBar = this.wrapper.querySelector(SELECTOR_SLIDER_PROGRESS_BAR);
48
- if (this.progressBar) {
49
- this.progressBarWidth = this.progressBar.offsetWidth;
50
- this.progressBarStyle = this.progressBar.style;
51
- }
52
- //忘记这个代码是干什么的了?
53
- // this.x = this._getScroll();
54
- // if (this.options.startX === false) {
55
- // this.options.startX = this.x;
56
- // }
57
- //根据active修正startX
58
-
59
- this._super();
60
- this._initTimer();
61
- }
62
- },
63
- _initEvent: function() {
64
- var self = this;
65
- self._super();
66
- self.wrapper.addEventListener('swiperight', $.stopPropagation);
67
- self.wrapper.addEventListener('scrollend', function() {
68
- self.isInTransition = false;
69
- var page = self.currentPage;
70
- var oldSlideNumber = self.slideNumber;
71
- self.slideNumber = self._fixedSlideNumber();
72
- if (self.loop) {
73
- if (self.slideNumber === 0) {
74
- self.setTranslate(self.pages[1][0].x, 0);
75
- } else if (self.slideNumber === self.itemLength - 3) {
76
- self.setTranslate(self.pages[self.itemLength - 2][0].x, 0);
77
- }
78
- }
79
- if (oldSlideNumber != self.slideNumber) {
80
- $.trigger(self.wrapper, 'slide', {
81
- slideNumber: self.slideNumber
82
- });
83
- }
84
- });
85
-
86
- self.wrapper.addEventListener('slide', function(e) {
87
- if (e.target !== self.wrapper) {
88
- return;
89
- }
90
- var detail = e.detail;
91
- detail.slideNumber = detail.slideNumber || 0;
92
- var items = self.scroller.querySelectorAll(SELECTOR_SLIDER_ITEM);
93
- var _slideNumber = detail.slideNumber;
94
- if (self.loop) {
95
- _slideNumber += 1;
96
- }
97
- if (!self.wrapper.classList.contains($.className('segmented-control'))) {
98
- for (var i = 0, len = items.length; i < len; i++) {
99
- var item = items[i];
100
- if (item.parentNode === self.scroller) {
101
- if (i === _slideNumber) {
102
- item.classList.add(CLASS_ACTIVE);
103
- } else {
104
- item.classList.remove(CLASS_ACTIVE);
105
- }
106
- }
107
- }
108
- }
109
- var indicatorWrap = self.wrapper.querySelector($.classSelector('.slider-indicator'));
110
- if (indicatorWrap) {
111
- if (indicatorWrap.getAttribute('data-scroll')) { //scroll
112
- $(indicatorWrap).scroll().gotoPage(detail.slideNumber);
113
- }
114
- var indicators = indicatorWrap.querySelectorAll($.classSelector('.indicator'));
115
- if (indicators.length > 0) { //图片轮播
116
- for (var i = 0, len = indicators.length; i < len; i++) {
117
- indicators[i].classList[i === detail.slideNumber ? 'add' : 'remove'](CLASS_ACTIVE);
118
- }
119
- } else {
120
- var number = indicatorWrap.querySelector($.classSelector('.number span'));
121
- if (number) { //图文表格
122
- number.innerText = (detail.slideNumber + 1);
123
- } else { //segmented controls
124
- var controlItems = self.wrapper.querySelectorAll($.classSelector('.control-item'));
125
- for (var i = 0, len = controlItems.length; i < len; i++) {
126
- controlItems[i].classList[i === detail.slideNumber ? 'add' : 'remove'](CLASS_ACTIVE);
127
- }
128
- }
129
- }
130
- }
131
- e.stopPropagation();
132
- });
133
-
134
- self.wrapper.addEventListener($.eventName('shown', 'tab'), function(e) { //tab
135
- self.gotoItem((e.detail.tabNumber || 0), self.options.bounceTime);
136
- });
137
- //indicator
138
- var indicator = self.wrapper.querySelector(SELECTOR_SLIDER_INDICATOR);
139
- if (indicator) {
140
- indicator.addEventListener('tap', function(event) {
141
- var target = event.target;
142
- if (target.classList.contains(CLASS_ACTION_PREVIOUS) || target.classList.contains(CLASS_ACTION_NEXT)) {
143
- self[target.classList.contains(CLASS_ACTION_PREVIOUS) ? 'prevItem' : 'nextItem']();
144
- event.stopPropagation();
145
- }
146
- });
147
- }
148
- },
149
- _drag: function(e) {
150
- this._super(e);
151
- var direction = e.detail.direction;
152
- if (direction === 'left' || direction === 'right') {
153
- e.stopPropagation();
154
- }
155
- },
156
- _initTimer: function() {
157
- var self = this;
158
- var slider = self.wrapper;
159
- var interval = self.options.interval;
160
- var slidershowTimer = slider.getAttribute('data-slidershowTimer');
161
- slidershowTimer && window.clearTimeout(slidershowTimer);
162
- if (interval) {
163
- slidershowTimer = window.setTimeout(function() {
164
- if (!slider) {
165
- return;
166
- }
167
- //仅slider显示状态进行自动轮播
168
- if (!!(slider.offsetWidth || slider.offsetHeight)) {
169
- self.nextItem(true);
170
- //下一个
171
- }
172
- self._initTimer();
173
- }, interval);
174
- slider.setAttribute('data-slidershowTimer', slidershowTimer);
175
- }
176
- },
177
-
178
- _fixedSlideNumber: function(page) {
179
- page = page || this.currentPage;
180
- var slideNumber = page.pageX;
181
- if (this.loop) {
182
- if (page.pageX === 0) {
183
- slideNumber = this.itemLength - 3;
184
- } else if (page.pageX === (this.itemLength - 1)) {
185
- slideNumber = 0;
186
- } else {
187
- slideNumber = page.pageX - 1;
188
- }
189
- }
190
- return slideNumber;
191
- },
192
- _reLayout: function() {
193
- this.hasHorizontalScroll = true;
194
- this.loop = this.scroller.classList.contains(CLASS_SLIDER_LOOP);
195
- this._super();
196
- },
197
- _getScroll: function() {
198
- var result = $.parseTranslateMatrix($.getStyles(this.scroller, 'webkitTransform'));
199
- return result ? result.x : 0;
200
- },
201
- _transitionEnd: function(e) {
202
- if (e.target !== this.scroller || !this.isInTransition) {
203
- return;
204
- }
205
- this._transitionTime();
206
- this.isInTransition = false;
207
- $.trigger(this.wrapper, 'scrollend', this);
208
- },
209
- _flick: function(e) {
210
- if (!this.moved) { //无moved
211
- return;
212
- }
213
- var detail = e.detail;
214
- var direction = detail.direction;
215
- this._clearRequestAnimationFrame();
216
- this.isInTransition = true;
217
- // if (direction === 'up' || direction === 'down') {
218
- // this.resetPosition(this.options.bounceTime);
219
- // return;
220
- // }
221
- if (e.type === 'flick') {
222
- if (detail.touchTime < 200) { //flick,太容易触发,额外校验一下touchtime
223
- this.x = this._getPage((this.slideNumber + (direction === 'right' ? -1 : 1)), true).x;
224
- }
225
- this.resetPosition(this.options.bounceTime);
226
- } else if (e.type === 'dragend' && !detail.flick) {
227
- this.resetPosition(this.options.bounceTime);
228
- }
229
- e.stopPropagation();
230
- },
231
- _initSnap: function() {
232
- this.scrollerWidth = this.itemLength * this.scrollerWidth;
233
- this.maxScrollX = Math.min(this.wrapperWidth - this.scrollerWidth, 0);
234
- this._super();
235
- if (!this.currentPage.x) {
236
- //当slider处于隐藏状态时,导致snap计算是错误的,临时先这么判断一下,后续要考虑解决所有scroll在隐藏状态下初始化属性不正确的问题
237
- var currentPage = this.pages[this.loop ? 1 : 0];
238
- currentPage = currentPage || this.pages[0];
239
- if (!currentPage) {
240
- return;
241
- }
242
- this.currentPage = currentPage[0];
243
- this.slideNumber = 0;
244
- } else {
245
- this.slideNumber = this._fixedSlideNumber();
246
- }
247
- this.options.startX = this.currentPage.x || 0;
248
- },
249
- _getSnapX: function(offsetLeft) {
250
- return Math.max(-offsetLeft, this.maxScrollX);
251
- },
252
- _getPage: function(slideNumber, isFlick) {
253
- if (this.loop) {
254
- if (slideNumber > (this.itemLength - (isFlick ? 2 : 3))) {
255
- slideNumber = 1;
256
- time = 0;
257
- } else if (slideNumber < (isFlick ? -1 : 0)) {
258
- slideNumber = this.itemLength - 2;
259
- time = 0;
260
- } else {
261
- slideNumber += 1;
262
- }
263
- } else {
264
- if (!isFlick) {
265
- if (slideNumber > (this.itemLength - 1)) {
266
- slideNumber = 0;
267
- time = 0;
268
- } else if (slideNumber < 0) {
269
- slideNumber = this.itemLength - 1;
270
- time = 0;
271
- }
272
- }
273
- slideNumber = Math.min(Math.max(0, slideNumber), this.itemLength - 1);
274
- }
275
- return this.pages[slideNumber][0];
276
- },
277
- _gotoItem: function(slideNumber, time) {
278
- this.currentPage = this._getPage(slideNumber, true); //此处传true。可保证程序切换时,动画与人手操作一致(第一张,最后一张的切换动画)
279
- this.scrollTo(this.currentPage.x, 0, time, this.options.bounceEasing);
280
- if (time === 0) {
281
- $.trigger(this.wrapper, 'scrollend', this);
282
- }
283
- this._initTimer();
284
- },
285
- //API
286
- setTranslate: function(x, y) {
287
- this._super(x, y);
288
- var progressBar = this.progressBar;
289
- if (progressBar) {
290
- this.progressBarStyle.webkitTransform = this._getTranslateStr((-x * (this.progressBarWidth / this.wrapperWidth)), 0);
291
- }
292
- },
293
- resetPosition: function(time) {
294
- time = time || 0;
295
- if (this.x > 0) {
296
- this.x = 0;
297
- } else if (this.x < this.maxScrollX) {
298
- this.x = this.maxScrollX;
299
- }
300
- this.currentPage = this._nearestSnap(this.x);
301
- this.scrollTo(this.currentPage.x, 0, time);
302
- return true;
303
- },
304
- gotoItem: function(slideNumber, time) {
305
- this._gotoItem(slideNumber, time || this.options.bounceTime);
306
- },
307
- nextItem: function() {
308
- this._gotoItem(this.slideNumber + 1, this.options.bounceTime);
309
- },
310
- prevItem: function() {
311
- this._gotoItem(this.slideNumber - 1, this.options.bounceTime);
312
- },
313
- getSlideNumber: function() {
314
- return this.slideNumber || 0;
315
- },
316
- refresh: function(options) {
317
- if (options) {
318
- $.extend(this.options, options);
319
- this._super();
320
- this.nextItem();
321
- } else {
322
- this._super();
323
- }
324
- }
325
- });
326
- $.fn.slider = function(options) {
327
- var slider = null;
328
- this.each(function() {
329
- var sliderElement = this;
330
- if (!this.classList.contains(CLASS_SLIDER)) {
331
- sliderElement = this.querySelector('.' + CLASS_SLIDER);
332
- }
333
- if (sliderElement && sliderElement.querySelector(SELECTOR_SLIDER_ITEM)) {
334
- var id = sliderElement.getAttribute('data-slider');
335
- if (!id) {
336
- id = ++$.uuid;
337
- $.data[id] = slider = new Slider(sliderElement, options);
338
- sliderElement.setAttribute('data-slider', id);
339
- } else {
340
- slider = $.data[id];
341
- if (slider && options) {
342
- slider.refresh(options);
343
- }
344
- }
345
- }
346
- });
347
- return slider;
348
- };
349
- $.ready(function() {
350
- // setTimeout(function() {
351
- $($.classSelector('.slider')).slider();
352
- $($.classSelector('.scroll-wrapper.slider-indicator.segmented-control')).scroll({
353
- scrollY: false,
354
- scrollX: true,
355
- indicators: false,
356
- snap: $.classSelector('.control-item')
357
- });
358
- // }, 500); //临时处理slider宽度计算不正确的问题(初步确认是scrollbar导致的)
359
-
360
- });
361
- })(mui, window);