Commit 827a0beb authored by MoGaven's avatar MoGaven

Merge pull request #2 from dcloudio/master

更新11-10
parents 6e5c5c45 a31a2740
...@@ -49,6 +49,7 @@ module.exports = function(grunt) { ...@@ -49,6 +49,7 @@ module.exports = function(grunt) {
'js/mui.detect.5+.js', 'js/mui.detect.5+.js',
'js/mui.target.js', 'js/mui.target.js',
'js/mui.fixed.js', 'js/mui.fixed.js',
'js/mui.fixed.bind.js',
'js/mui.fixed.classlist.js', 'js/mui.fixed.classlist.js',
'js/mui.fixed.animation.js', 'js/mui.fixed.animation.js',
'js/mui.fixed.fastclick.js', 'js/mui.fixed.fastclick.js',
...@@ -150,7 +151,7 @@ module.exports = function(grunt) { ...@@ -150,7 +151,7 @@ module.exports = function(grunt) {
uglify: { uglify: {
options: { options: {
banner: '<%= banner %>', banner: '<%= banner %>',
compress: true, compress: {},
mangle: true, mangle: true,
preserveComments: false preserveComments: false
}, },
......
...@@ -7,7 +7,7 @@ mui框架有效的解决了这些问题,这是一个可以方便开发出高 ...@@ -7,7 +7,7 @@ mui框架有效的解决了这些问题,这是一个可以方便开发出高
参考文档 参考文档
------ ------
[mui官网](http://dcloudio.github.io/mui/)文档使用[Jekyll](http://jekyllrb.com) 构建,发布在GitHub Pages上,[立即查看](http://dcloudio.github.io/mui/) [mui官网](http://dev.dcloud.net.cn/mui/)文档使用[Jekyll](http://jekyllrb.com) 构建,[立即查看](http://dev.dcloud.net.cn/mui/)
快速体验 快速体验
-------- --------
......
/*! /*!
* ===================================================== * =====================================================
* Mui v2.4.0 (https://github.com/dcloudio/mui) * Mui v2.6.0 (http://dev.dcloud.net.cn/mui)
* ===================================================== * =====================================================
*/ */
...@@ -4341,8 +4341,8 @@ select:focus ...@@ -4341,8 +4341,8 @@ select:focus
font-size: 14px; font-size: 14px;
width: 270px; width: 270px;
margin: 5px auto 5px auto; margin: 5px auto;
padding: 5px 5px 5px 5px; padding: 5px;
text-align: center; text-align: center;
......
This diff is collapsed.
/*! /*!
* ===================================================== * =====================================================
* Mui v2.4.0 (https://github.com/dcloudio/mui) * Mui v2.6.0 (http://dev.dcloud.net.cn/mui)
* ===================================================== * =====================================================
*/ */
/** /**
...@@ -190,25 +190,6 @@ var mui = (function(document, undefined) { ...@@ -190,25 +190,6 @@ var mui = (function(document, undefined) {
} }
return this; return this;
}; };
/**
* map
*/
$.map = function(elements, callback) {
var value, values = [],
i, key;
if (typeof elements.length === 'number') { //TODO 此处逻辑不严谨,可能会有Object:{a:'b',length:1}的情况未处理
for (i = 0, len = elements.length; i < len; i++) {
value = callback(elements[i], i);
if (value != null) values.push(value);
}
} else {
for (key in elements) {
value = callback(elements[key], key);
if (value != null) values.push(value);
}
}
return values.length > 0 ? [].concat.apply([], values) : values;
};
/** /**
* each * each
* @param {type} elements * @param {type} elements
...@@ -587,6 +568,32 @@ var mui = (function(document, undefined) { ...@@ -587,6 +568,32 @@ var mui = (function(document, undefined) {
window.CustomEvent = CustomEvent; window.CustomEvent = CustomEvent;
} }
})(); })();
/*
A shim for non ES5 supporting browsers.
Adds function bind to Function prototype, so that you can do partial application.
Works even with the nasty thing, where the first word is the opposite of extranet, the second one is the profession of Columbus, and the version number is 9, flipped 180 degrees.
*/
Function.prototype.bind = Function.prototype.bind || function(to) {
// Make an array of our arguments, starting from second argument
var partial = Array.prototype.splice.call(arguments, 1),
// We'll need the original function.
fn = this;
var bound = function() {
// Join the already applied arguments to the now called ones (after converting to an array again).
var args = partial.concat(Array.prototype.splice.call(arguments, 0));
// If not being called as a constructor
if (!(this instanceof bound)) {
// return the result of the function called bound to target and partially applied.
return fn.apply(to, args);
}
// If being called as a constructor, apply the function bound to self.
fn.apply(this, args);
}
// Attach the prototype of the function to our newly created function.
bound.prototype = fn.prototype;
return bound;
};
/** /**
* mui fixed classList * mui fixed classList
* @param {type} document * @param {type} document
...@@ -921,7 +928,7 @@ var mui = (function(document, undefined) { ...@@ -921,7 +928,7 @@ var mui = (function(document, undefined) {
}; };
var findDelegateFn = function(element, event) { var findDelegateFn = function(element, event) {
var delegateCallbacks = delegateFns[mid(element)]; var delegateCallbacks = delegateFns[mid(element)];
var result = false; var result = [];
if (delegateCallbacks) { if (delegateCallbacks) {
result = []; result = [];
if (event) { if (event) {
...@@ -2389,6 +2396,7 @@ var mui = (function(document, undefined) { ...@@ -2389,6 +2396,7 @@ var mui = (function(document, undefined) {
var action = $.targets.action; var action = $.targets.action;
if (action && action.classList.contains('mui-action-back')) { if (action && action.classList.contains('mui-action-back')) {
$.back(); $.back();
$.targets.action = false;
} }
}); });
window.addEventListener('swiperight', function(e) { window.addEventListener('swiperight', function(e) {
...@@ -2739,7 +2747,8 @@ var mui = (function(document, undefined) { ...@@ -2739,7 +2747,8 @@ var mui = (function(document, undefined) {
xhr.onreadystatechange = $.noop; xhr.onreadystatechange = $.noop;
clearTimeout(abortTimeout); clearTimeout(abortTimeout);
var result, error = false; var result, error = false;
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || (xhr.status === 0 && protocol === 'file:')) { var isLocal = protocol === 'file:';
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || (xhr.status === 0 && isLocal && xhr.responseText)) {
dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type')); dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type'));
result = xhr.responseText; result = xhr.responseText;
try { try {
...@@ -2761,7 +2770,13 @@ var mui = (function(document, undefined) { ...@@ -2761,7 +2770,13 @@ var mui = (function(document, undefined) {
ajaxSuccess(result, xhr, settings); ajaxSuccess(result, xhr, settings);
} }
} else { } else {
ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings); var status = xhr.status ? 'error' : 'abort';
var statusText = xhr.statusText || null;
if (isLocal) {
status = 'error';
statusText = '404';
}
ajaxError(statusText, status, xhr, settings);
} }
} }
}; };
...@@ -3418,6 +3433,7 @@ var mui = (function(document, undefined) { ...@@ -3418,6 +3433,7 @@ var mui = (function(document, undefined) {
this._end(e); this._end(e);
break; break;
case 'webkitTransitionEnd': case 'webkitTransitionEnd':
this.transitionTimer && this.transitionTimer.cancel();
this._transitionEnd(e); this._transitionEnd(e);
break; break;
case 'scrollend': case 'scrollend':
...@@ -3666,6 +3682,12 @@ var mui = (function(document, undefined) { ...@@ -3666,6 +3682,12 @@ var mui = (function(document, undefined) {
this.indicators[i].transitionTime(time); this.indicators[i].transitionTime(time);
} }
} }
if (time) { //自定义timer,保证webkitTransitionEnd始终触发
this.transitionTimer && this.transitionTimer.cancel();
this.transitionTimer = $.later(function() {
$.trigger(this.scroller, 'webkitTransitionEnd');
}, time + 100, this);
}
}, },
_transitionTimingFunction: function(easing) { _transitionTimingFunction: function(easing) {
this.scrollerStyle['webkitTransitionTimingFunction'] = easing; this.scrollerStyle['webkitTransitionTimingFunction'] = easing;
...@@ -3862,7 +3884,9 @@ var mui = (function(document, undefined) { ...@@ -3862,7 +3884,9 @@ var mui = (function(document, undefined) {
}, },
scrollTo: function(x, y, time, easing) { scrollTo: function(x, y, time, easing) {
var easing = easing || ease.circular; var easing = easing || ease.circular;
this.isInTransition = time > 0 && (this.lastX != x || this.lastY != y); // this.isInTransition = time > 0 && (this.lastX != x || this.lastY != y);
//暂不严格判断x,y,否则会导致部分版本上不正常触发轮播
this.isInTransition = time > 0;
if (this.isInTransition) { if (this.isInTransition) {
this._clearRequestAnimationFrame(); this._clearRequestAnimationFrame();
this._transitionTimingFunction(easing.style); this._transitionTimingFunction(easing.style);
...@@ -4253,6 +4277,7 @@ var mui = (function(document, undefined) { ...@@ -4253,6 +4277,7 @@ var mui = (function(document, undefined) {
indicators: false, indicators: false,
bounceTime: 200, bounceTime: 200,
startX: false, startX: false,
slideTime: 0, //滑动动画时间
snap: SELECTOR_SLIDER_ITEM snap: SELECTOR_SLIDER_ITEM
}, options)); }, options));
if (this.options.startX) { if (this.options.startX) {
...@@ -4313,7 +4338,14 @@ var mui = (function(document, undefined) { ...@@ -4313,7 +4338,14 @@ var mui = (function(document, undefined) {
} }
var detail = e.detail; var detail = e.detail;
detail.slideNumber = detail.slideNumber || 0; detail.slideNumber = detail.slideNumber || 0;
var items = self.scroller.querySelectorAll(SELECTOR_SLIDER_ITEM); var temps = self.scroller.querySelectorAll(SELECTOR_SLIDER_ITEM);
var items = [];
for (var i = 0, len = temps.length; i < len; i++) {
var item = temps[i];
if (item.parentNode === self.scroller) {
items.push(item);
}
}
var _slideNumber = detail.slideNumber; var _slideNumber = detail.slideNumber;
if (self.loop) { if (self.loop) {
_slideNumber += 1; _slideNumber += 1;
...@@ -4356,7 +4388,7 @@ var mui = (function(document, undefined) { ...@@ -4356,7 +4388,7 @@ var mui = (function(document, undefined) {
}, },
_handleTabShow: function(e) { _handleTabShow: function(e) {
var self = this; var self = this;
self.gotoItem((e.detail.tabNumber || 0), self.options.bounceTime); self.gotoItem((e.detail.tabNumber || 0), self.options.slideTime);
}, },
_handleIndicatorTap: function(event) { _handleIndicatorTap: function(event) {
var self = this; var self = this;
...@@ -7012,10 +7044,14 @@ var mui = (function(document, undefined) { ...@@ -7012,10 +7044,14 @@ var mui = (function(document, undefined) {
self.input.value = val.toString(); self.input.value = val.toString();
$.trigger(self.input, changeEventName, null); $.trigger(self.input, changeEventName, null);
}); });
// self.input.addEventListener(changeEventName, function(event) { self.input.addEventListener(changeEventName, function(event) {
// self.checkValue(); self.checkValue();
// $.trigger(self, changeEventName, self.getValue()); var val = parseInt(self.input.value);
// }); //触发顶层容器
$.trigger(self.holder, changeEventName, {
value: val
});
});
}, },
/** /**
* 获取当前值 * 获取当前值
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
/*! /*!
* ===================================================== * =====================================================
* Mui v2.4.0 (https://github.com/dcloudio/mui) * Mui v2.6.0 (http://dev.dcloud.net.cn/mui)
* ===================================================== * =====================================================
*/ */
...@@ -4341,8 +4341,8 @@ select:focus ...@@ -4341,8 +4341,8 @@ select:focus
font-size: 14px; font-size: 14px;
width: 270px; width: 270px;
margin: 5px auto 5px auto; margin: 5px auto;
padding: 5px 5px 5px 5px; padding: 5px;
text-align: center; text-align: center;
......
This diff is collapsed.
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
</p> </p>
<p>更多详细介绍,请到<a href="http://dcloudio.github.io/mui">mui官网</a>查看;</p> <p>更多详细介绍,请到<a href="http://dcloudio.github.io/mui">mui官网</a>查看;</p>
<h4>版本介绍</h4> <h4>版本介绍</h4>
<p>当前版本为2.4.0,可到<a href="https://github.com/dcloudio/mui">Github</a>上获取最新版本。</p> <p>当前版本为2.6.0,可到<a href="https://github.com/dcloudio/mui">Github</a>上获取最新版本。</p>
<h4>License</h4> <h4>License</h4>
<p> <p>
mui遵循MIT License,源码已提交至Github,<a href="https://github.com/dcloudio/mui">点击查看</a>; mui遵循MIT License,源码已提交至Github,<a href="https://github.com/dcloudio/mui">点击查看</a>;
......
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
</ul> </ul>
<ul class="mui-table-view mui-table-view-chevron"> <ul class="mui-table-view mui-table-view-chevron">
<li class="mui-table-view-cell"> <li class="mui-table-view-cell">
<a href="#about" class="mui-navigate-right">关于MUI <i class="mui-pull-right update">V2.4.0</i></a> <a href="#about" class="mui-navigate-right">关于MUI <i class="mui-pull-right update">V2.6.0</i></a>
</li> </li>
</ul> </ul>
<ul class="mui-table-view"> <ul class="mui-table-view">
......
/*! /*!
* ===================================================== * =====================================================
* Mui v2.4.0 (https://github.com/dcloudio/mui) * Mui v2.6.0 (http://dev.dcloud.net.cn/mui)
* ===================================================== * =====================================================
*/ */
/** /**
...@@ -190,25 +190,6 @@ var mui = (function(document, undefined) { ...@@ -190,25 +190,6 @@ var mui = (function(document, undefined) {
} }
return this; return this;
}; };
/**
* map
*/
$.map = function(elements, callback) {
var value, values = [],
i, key;
if (typeof elements.length === 'number') { //TODO 此处逻辑不严谨,可能会有Object:{a:'b',length:1}的情况未处理
for (i = 0, len = elements.length; i < len; i++) {
value = callback(elements[i], i);
if (value != null) values.push(value);
}
} else {
for (key in elements) {
value = callback(elements[key], key);
if (value != null) values.push(value);
}
}
return values.length > 0 ? [].concat.apply([], values) : values;
};
/** /**
* each * each
* @param {type} elements * @param {type} elements
...@@ -587,6 +568,32 @@ var mui = (function(document, undefined) { ...@@ -587,6 +568,32 @@ var mui = (function(document, undefined) {
window.CustomEvent = CustomEvent; window.CustomEvent = CustomEvent;
} }
})(); })();
/*
A shim for non ES5 supporting browsers.
Adds function bind to Function prototype, so that you can do partial application.
Works even with the nasty thing, where the first word is the opposite of extranet, the second one is the profession of Columbus, and the version number is 9, flipped 180 degrees.
*/
Function.prototype.bind = Function.prototype.bind || function(to) {
// Make an array of our arguments, starting from second argument
var partial = Array.prototype.splice.call(arguments, 1),
// We'll need the original function.
fn = this;
var bound = function() {
// Join the already applied arguments to the now called ones (after converting to an array again).
var args = partial.concat(Array.prototype.splice.call(arguments, 0));
// If not being called as a constructor
if (!(this instanceof bound)) {
// return the result of the function called bound to target and partially applied.
return fn.apply(to, args);
}
// If being called as a constructor, apply the function bound to self.
fn.apply(this, args);
}
// Attach the prototype of the function to our newly created function.
bound.prototype = fn.prototype;
return bound;
};
/** /**
* mui fixed classList * mui fixed classList
* @param {type} document * @param {type} document
...@@ -921,7 +928,7 @@ var mui = (function(document, undefined) { ...@@ -921,7 +928,7 @@ var mui = (function(document, undefined) {
}; };
var findDelegateFn = function(element, event) { var findDelegateFn = function(element, event) {
var delegateCallbacks = delegateFns[mid(element)]; var delegateCallbacks = delegateFns[mid(element)];
var result = false; var result = [];
if (delegateCallbacks) { if (delegateCallbacks) {
result = []; result = [];
if (event) { if (event) {
...@@ -2389,6 +2396,7 @@ var mui = (function(document, undefined) { ...@@ -2389,6 +2396,7 @@ var mui = (function(document, undefined) {
var action = $.targets.action; var action = $.targets.action;
if (action && action.classList.contains('mui-action-back')) { if (action && action.classList.contains('mui-action-back')) {
$.back(); $.back();
$.targets.action = false;
} }
}); });
window.addEventListener('swiperight', function(e) { window.addEventListener('swiperight', function(e) {
...@@ -2739,7 +2747,8 @@ var mui = (function(document, undefined) { ...@@ -2739,7 +2747,8 @@ var mui = (function(document, undefined) {
xhr.onreadystatechange = $.noop; xhr.onreadystatechange = $.noop;
clearTimeout(abortTimeout); clearTimeout(abortTimeout);
var result, error = false; var result, error = false;
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || (xhr.status === 0 && protocol === 'file:')) { var isLocal = protocol === 'file:';
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || (xhr.status === 0 && isLocal && xhr.responseText)) {
dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type')); dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type'));
result = xhr.responseText; result = xhr.responseText;
try { try {
...@@ -2761,7 +2770,13 @@ var mui = (function(document, undefined) { ...@@ -2761,7 +2770,13 @@ var mui = (function(document, undefined) {
ajaxSuccess(result, xhr, settings); ajaxSuccess(result, xhr, settings);
} }
} else { } else {
ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings); var status = xhr.status ? 'error' : 'abort';
var statusText = xhr.statusText || null;
if (isLocal) {
status = 'error';
statusText = '404';
}
ajaxError(statusText, status, xhr, settings);
} }
} }
}; };
...@@ -3418,6 +3433,7 @@ var mui = (function(document, undefined) { ...@@ -3418,6 +3433,7 @@ var mui = (function(document, undefined) {
this._end(e); this._end(e);
break; break;
case 'webkitTransitionEnd': case 'webkitTransitionEnd':
this.transitionTimer && this.transitionTimer.cancel();
this._transitionEnd(e); this._transitionEnd(e);
break; break;
case 'scrollend': case 'scrollend':
...@@ -3666,6 +3682,12 @@ var mui = (function(document, undefined) { ...@@ -3666,6 +3682,12 @@ var mui = (function(document, undefined) {
this.indicators[i].transitionTime(time); this.indicators[i].transitionTime(time);
} }
} }
if (time) { //自定义timer,保证webkitTransitionEnd始终触发
this.transitionTimer && this.transitionTimer.cancel();
this.transitionTimer = $.later(function() {
$.trigger(this.scroller, 'webkitTransitionEnd');
}, time + 100, this);
}
}, },
_transitionTimingFunction: function(easing) { _transitionTimingFunction: function(easing) {
this.scrollerStyle['webkitTransitionTimingFunction'] = easing; this.scrollerStyle['webkitTransitionTimingFunction'] = easing;
...@@ -3862,7 +3884,9 @@ var mui = (function(document, undefined) { ...@@ -3862,7 +3884,9 @@ var mui = (function(document, undefined) {
}, },
scrollTo: function(x, y, time, easing) { scrollTo: function(x, y, time, easing) {
var easing = easing || ease.circular; var easing = easing || ease.circular;
this.isInTransition = time > 0 && (this.lastX != x || this.lastY != y); // this.isInTransition = time > 0 && (this.lastX != x || this.lastY != y);
//暂不严格判断x,y,否则会导致部分版本上不正常触发轮播
this.isInTransition = time > 0;
if (this.isInTransition) { if (this.isInTransition) {
this._clearRequestAnimationFrame(); this._clearRequestAnimationFrame();
this._transitionTimingFunction(easing.style); this._transitionTimingFunction(easing.style);
...@@ -4253,6 +4277,7 @@ var mui = (function(document, undefined) { ...@@ -4253,6 +4277,7 @@ var mui = (function(document, undefined) {
indicators: false, indicators: false,
bounceTime: 200, bounceTime: 200,
startX: false, startX: false,
slideTime: 0, //滑动动画时间
snap: SELECTOR_SLIDER_ITEM snap: SELECTOR_SLIDER_ITEM
}, options)); }, options));
if (this.options.startX) { if (this.options.startX) {
...@@ -4313,7 +4338,14 @@ var mui = (function(document, undefined) { ...@@ -4313,7 +4338,14 @@ var mui = (function(document, undefined) {
} }
var detail = e.detail; var detail = e.detail;
detail.slideNumber = detail.slideNumber || 0; detail.slideNumber = detail.slideNumber || 0;
var items = self.scroller.querySelectorAll(SELECTOR_SLIDER_ITEM); var temps = self.scroller.querySelectorAll(SELECTOR_SLIDER_ITEM);
var items = [];
for (var i = 0, len = temps.length; i < len; i++) {
var item = temps[i];
if (item.parentNode === self.scroller) {
items.push(item);
}
}
var _slideNumber = detail.slideNumber; var _slideNumber = detail.slideNumber;
if (self.loop) { if (self.loop) {
_slideNumber += 1; _slideNumber += 1;
...@@ -4356,7 +4388,7 @@ var mui = (function(document, undefined) { ...@@ -4356,7 +4388,7 @@ var mui = (function(document, undefined) {
}, },
_handleTabShow: function(e) { _handleTabShow: function(e) {
var self = this; var self = this;
self.gotoItem((e.detail.tabNumber || 0), self.options.bounceTime); self.gotoItem((e.detail.tabNumber || 0), self.options.slideTime);
}, },
_handleIndicatorTap: function(event) { _handleIndicatorTap: function(event) {
var self = this; var self = this;
...@@ -7012,10 +7044,14 @@ var mui = (function(document, undefined) { ...@@ -7012,10 +7044,14 @@ var mui = (function(document, undefined) {
self.input.value = val.toString(); self.input.value = val.toString();
$.trigger(self.input, changeEventName, null); $.trigger(self.input, changeEventName, null);
}); });
// self.input.addEventListener(changeEventName, function(event) { self.input.addEventListener(changeEventName, function(event) {
// self.checkValue(); self.checkValue();
// $.trigger(self, changeEventName, self.getValue()); var val = parseInt(self.input.value);
// }); //触发顶层容器
$.trigger(self.holder, changeEventName, {
value: val
});
});
}, },
/** /**
* 获取当前值 * 获取当前值
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -22,8 +22,12 @@ ...@@ -22,8 +22,12 @@
var platform = navigator.platform.toLowerCase(); var platform = navigator.platform.toLowerCase();
var userAgent = navigator.userAgent.toLowerCase(); var userAgent = navigator.userAgent.toLowerCase();
var isIos = (userAgent.indexOf('iphone') > -1 || userAgent.indexOf('ipad') > -1) && var isIos = (userAgent.indexOf('iphone') > -1 ||
(platform.indexOf('iphone') > -1 || platform.indexOf('ipad') > -1); userAgent.indexOf('ipad') > -1 ||
userAgent.indexOf('ipod') > -1) &&
(platform.indexOf('iphone') > -1 ||
platform.indexOf('ipad') > -1 ||
platform.indexOf('ipod') > -1);
//alert(isIos); //alert(isIos);
var Picker = $.Picker = function(holder, options) { var Picker = $.Picker = function(holder, options) {
......
...@@ -22,8 +22,12 @@ ...@@ -22,8 +22,12 @@
var platform = navigator.platform.toLowerCase(); var platform = navigator.platform.toLowerCase();
var userAgent = navigator.userAgent.toLowerCase(); var userAgent = navigator.userAgent.toLowerCase();
var isIos = (userAgent.indexOf('iphone') > -1 || userAgent.indexOf('ipad') > -1) && var isIos = (userAgent.indexOf('iphone') > -1 ||
(platform.indexOf('iphone') > -1 || platform.indexOf('ipad') > -1); userAgent.indexOf('ipad') > -1 ||
userAgent.indexOf('ipod') > -1) &&
(platform.indexOf('iphone') > -1 ||
platform.indexOf('ipad') > -1 ||
platform.indexOf('ipod') > -1);
//alert(isIos); //alert(isIos);
var Picker = $.Picker = function(holder, options) { var Picker = $.Picker = function(holder, options) {
......
This diff is collapsed.
...@@ -64,9 +64,10 @@ ...@@ -64,9 +64,10 @@
} }
if (this.pullUpTips) { if (this.pullUpTips) {
this.element.addEventListener('dragup', this); this.element.addEventListener('dragup', this);
window.addEventListener('scroll', this);
if (this.isInScroll) { if (this.isInScroll) {
this.element.addEventListener('scrollbottom', this); this.element.addEventListener('scrollbottom', this);
} else {
window.addEventListener('scroll', this);
} }
} }
}, },
......
...@@ -162,7 +162,8 @@ ...@@ -162,7 +162,8 @@
xhr.onreadystatechange = $.noop; xhr.onreadystatechange = $.noop;
clearTimeout(abortTimeout); clearTimeout(abortTimeout);
var result, error = false; var result, error = false;
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || (xhr.status === 0 && protocol === 'file:')) { var isLocal = protocol === 'file:';
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304 || (xhr.status === 0 && isLocal && xhr.responseText)) {
dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type')); dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type'));
result = xhr.responseText; result = xhr.responseText;
try { try {
...@@ -184,7 +185,13 @@ ...@@ -184,7 +185,13 @@
ajaxSuccess(result, xhr, settings); ajaxSuccess(result, xhr, settings);
} }
} else { } else {
ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings); var status = xhr.status ? 'error' : 'abort';
var statusText = xhr.statusText || null;
if (isLocal) {
status = 'error';
statusText = '404';
}
ajaxError(statusText, status, xhr, settings);
} }
} }
}; };
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
var action = $.targets.action; var action = $.targets.action;
if (action && action.classList.contains($.className('action-back'))) { if (action && action.classList.contains($.className('action-back'))) {
$.back(); $.back();
$.targets.action = false;
} }
}); });
window.addEventListener('swiperight', function(e) { window.addEventListener('swiperight', function(e) {
......
...@@ -258,6 +258,7 @@ ...@@ -258,6 +258,7 @@
this._end(e); this._end(e);
break; break;
case 'webkitTransitionEnd': case 'webkitTransitionEnd':
this.transitionTimer && this.transitionTimer.cancel();
this._transitionEnd(e); this._transitionEnd(e);
break; break;
case 'scrollend': case 'scrollend':
...@@ -506,6 +507,12 @@ ...@@ -506,6 +507,12 @@
this.indicators[i].transitionTime(time); this.indicators[i].transitionTime(time);
} }
} }
if (time) { //自定义timer,保证webkitTransitionEnd始终触发
this.transitionTimer && this.transitionTimer.cancel();
this.transitionTimer = $.later(function() {
$.trigger(this.scroller, 'webkitTransitionEnd');
}, time + 100, this);
}
}, },
_transitionTimingFunction: function(easing) { _transitionTimingFunction: function(easing) {
this.scrollerStyle['webkitTransitionTimingFunction'] = easing; this.scrollerStyle['webkitTransitionTimingFunction'] = easing;
...@@ -702,7 +709,9 @@ ...@@ -702,7 +709,9 @@
}, },
scrollTo: function(x, y, time, easing) { scrollTo: function(x, y, time, easing) {
var easing = easing || ease.circular; var easing = easing || ease.circular;
this.isInTransition = time > 0 && (this.lastX != x || this.lastY != y); // this.isInTransition = time > 0 && (this.lastX != x || this.lastY != y);
//暂不严格判断x,y,否则会导致部分版本上不正常触发轮播
this.isInTransition = time > 0;
if (this.isInTransition) { if (this.isInTransition) {
this._clearRequestAnimationFrame(); this._clearRequestAnimationFrame();
this._transitionTimingFunction(easing.style); this._transitionTimingFunction(easing.style);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
indicators: false, indicators: false,
bounceTime: 200, bounceTime: 200,
startX: false, startX: false,
slideTime: 0, //滑动动画时间
snap: SELECTOR_SLIDER_ITEM snap: SELECTOR_SLIDER_ITEM
}, options)); }, options));
if (this.options.startX) { if (this.options.startX) {
...@@ -88,7 +89,14 @@ ...@@ -88,7 +89,14 @@
} }
var detail = e.detail; var detail = e.detail;
detail.slideNumber = detail.slideNumber || 0; detail.slideNumber = detail.slideNumber || 0;
var items = self.scroller.querySelectorAll(SELECTOR_SLIDER_ITEM); var temps = self.scroller.querySelectorAll(SELECTOR_SLIDER_ITEM);
var items = [];
for (var i = 0, len = temps.length; i < len; i++) {
var item = temps[i];
if (item.parentNode === self.scroller) {
items.push(item);
}
}
var _slideNumber = detail.slideNumber; var _slideNumber = detail.slideNumber;
if (self.loop) { if (self.loop) {
_slideNumber += 1; _slideNumber += 1;
...@@ -131,7 +139,7 @@ ...@@ -131,7 +139,7 @@
}, },
_handleTabShow: function(e) { _handleTabShow: function(e) {
var self = this; var self = this;
self.gotoItem((e.detail.tabNumber || 0), self.options.bounceTime); self.gotoItem((e.detail.tabNumber || 0), self.options.slideTime);
}, },
_handleIndicatorTap: function(event) { _handleIndicatorTap: function(event) {
var self = this; var self = this;
......
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
}; };
var findDelegateFn = function(element, event) { var findDelegateFn = function(element, event) {
var delegateCallbacks = delegateFns[mid(element)]; var delegateCallbacks = delegateFns[mid(element)];
var result = false; var result = [];
if (delegateCallbacks) { if (delegateCallbacks) {
result = []; result = [];
if (event) { if (event) {
......
/*
A shim for non ES5 supporting browsers.
Adds function bind to Function prototype, so that you can do partial application.
Works even with the nasty thing, where the first word is the opposite of extranet, the second one is the profession of Columbus, and the version number is 9, flipped 180 degrees.
*/
Function.prototype.bind = Function.prototype.bind || function(to) {
// Make an array of our arguments, starting from second argument
var partial = Array.prototype.splice.call(arguments, 1),
// We'll need the original function.
fn = this;
var bound = function() {
// Join the already applied arguments to the now called ones (after converting to an array again).
var args = partial.concat(Array.prototype.splice.call(arguments, 0));
// If not being called as a constructor
if (!(this instanceof bound)) {
// return the result of the function called bound to target and partially applied.
return fn.apply(to, args);
}
// If being called as a constructor, apply the function bound to self.
fn.apply(this, args);
}
// Attach the prototype of the function to our newly created function.
bound.prototype = fn.prototype;
return bound;
};
\ No newline at end of file
...@@ -185,25 +185,6 @@ var mui = (function(document, undefined) { ...@@ -185,25 +185,6 @@ var mui = (function(document, undefined) {
} }
return this; return this;
}; };
/**
* map
*/
$.map = function(elements, callback) {
var value, values = [],
i, key;
if (typeof elements.length === 'number') { //TODO 此处逻辑不严谨,可能会有Object:{a:'b',length:1}的情况未处理
for (i = 0, len = elements.length; i < len; i++) {
value = callback(elements[i], i);
if (value != null) values.push(value);
}
} else {
for (key in elements) {
value = callback(elements[key], key);
if (value != null) values.push(value);
}
}
return values.length > 0 ? [].concat.apply([], values) : values;
};
/** /**
* each * each
* @param {type} elements * @param {type} elements
......
...@@ -49,10 +49,14 @@ ...@@ -49,10 +49,14 @@
self.input.value = val.toString(); self.input.value = val.toString();
$.trigger(self.input, changeEventName, null); $.trigger(self.input, changeEventName, null);
}); });
// self.input.addEventListener(changeEventName, function(event) { self.input.addEventListener(changeEventName, function(event) {
// self.checkValue(); self.checkValue();
// $.trigger(self, changeEventName, self.getValue()); var val = parseInt(self.input.value);
// }); //触发顶层容器
$.trigger(self.holder, changeEventName, {
value: val
});
});
}, },
/** /**
* 获取当前值 * 获取当前值
......
This diff is collapsed.
{ {
"name": "mui", "name": "mui",
"description": "Build mobile apps with simple HTML, CSS, and JS components.", "description": "Build mobile apps with simple HTML, CSS, and JS components.",
"version": "2.4.0", "version": "2.6.0",
"keywords": [ "keywords": [
"css", "css",
"fonts", "fonts",
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"mobile", "mobile",
"prototype" "prototype"
], ],
"homepage": "https://github.com/dcloudio/mui", "homepage": "http://dev.dcloud.net.cn/mui",
"author": "DCloud", "author": "DCloud",
"style": "dist/css/mui.css", "style": "dist/css/mui.css",
"sass": "sass/mui.scss", "sass": "sass/mui.scss",
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
} }
.#{$namespace}toast-message { .#{$namespace}toast-message {
width: 270px; width: 270px;
margin: 5px auto 5px auto; margin: 5px auto;
padding: 5px 5px 5px 5px; padding: 5px;
background-color: #D8D8D8; background-color: #D8D8D8;
text-align: center; text-align: center;
color: #000; color: #000;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment