Commit e0ac9c10 authored by hbcui1984's avatar hbcui1984

编译至mui v2.8.0

parent ba066596
......@@ -47,6 +47,7 @@ module.exports = function(grunt) {
'js/mui.js',
'js/mui.detect.js',
'js/mui.detect.5+.js',
'js/mui.event.js',
'js/mui.target.js',
'js/mui.fixed.js',
'js/mui.fixed.bind.js',
......@@ -55,7 +56,6 @@ module.exports = function(grunt) {
'js/mui.fixed.fastclick.js',
'js/mui.fixed.keyboard.js',
'js/mui.namespace.js',
'js/mui.event.js',
'js/mui.gestures.js',
'js/mui.gestures.flick.js',
'js/mui.gestures.swipe.js',
......@@ -90,6 +90,7 @@ module.exports = function(grunt) {
'js/mui.dialog.confirm.js',
'js/mui.dialog.prompt.js',
'js/mui.dialog.toast.js',
'js/mui.popup.js',
'js/input.plugin.js',
'js/mui.number.js'
......
/*!
* =====================================================
* Mui v2.7.0 (http://dev.dcloud.net.cn/mui)
* Mui v2.8.0 (http://dev.dcloud.net.cn/mui)
* =====================================================
*/
......@@ -722,7 +722,7 @@ p
.mui-scroll-wrapper
{
position: absolute;
z-index: 1;
z-index: 2;
top: 0;
bottom: 0;
left: 0;
......@@ -2852,7 +2852,7 @@ select:focus
float: left;
width: 35%;
padding: 10px 15px;
padding: 11px 15px;
}
.mui-input-row label ~ input, .mui-input-row label ~ select, .mui-input-row label ~ textarea
......@@ -3670,6 +3670,228 @@ select:focus
margin: -11px -15px -11px -15px;
}
.mui-popup-backdrop
{
position: fixed;
z-index: 998;
top: 0;
right: 0;
bottom: 0;
left: 0;
-webkit-transition-duration: 400ms;
transition-duration: 400ms;
opacity: 0;
background: rgba(0, 0, 0, .4);
}
.mui-popup-backdrop.mui-active
{
opacity: 1;
}
.mui-popup
{
position: absolute;
z-index: 10000;
top: 50%;
left: 50%;
display: none;
overflow: hidden;
width: 270px;
-webkit-transition-property: -webkit-transform,opacity;
transition-property: transform,opacity;
-webkit-transform: translate3d(-50%, -50%, 0) scale(1.185);
transform: translate3d(-50%, -50%, 0) scale(1.185);
text-align: center;
opacity: 0;
color: #000;
border-radius: 13px;
}
.mui-popup.mui-popup-in
{
display: block;
-webkit-transition-duration: 400ms;
transition-duration: 400ms;
-webkit-transform: translate3d(-50%, -50%, 0) scale(1);
transform: translate3d(-50%, -50%, 0) scale(1);
opacity: 1;
}
.mui-popup.mui-popup-out
{
-webkit-transition-duration: 400ms;
transition-duration: 400ms;
-webkit-transform: translate3d(-50%, -50%, 0) scale(1);
transform: translate3d(-50%, -50%, 0) scale(1);
opacity: 0;
}
.mui-popup-inner
{
position: relative;
padding: 15px;
border-radius: 13px 13px 0 0;
background: rgba(255, 255, 255, .95);
}
.mui-popup-inner:after
{
position: absolute;
z-index: 15;
top: auto;
right: auto;
bottom: 0;
left: 0;
display: block;
width: 100%;
height: 1px;
content: '';
-webkit-transform: scaleY(.5);
transform: scaleY(.5);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
background-color: rgba(0, 0, 0, .2);
}
.mui-popup-title
{
font-size: 18px;
font-weight: 500;
text-align: center;
}
.mui-popup-title + .mui-popup-text
{
font-size: 14px;
margin-top: 5px;
}
.mui-popup-buttons
{
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: flex;
height: 44px;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
.mui-popup-button
{
font-size: 17px;
line-height: 44px;
position: relative;
display: block;
overflow: hidden;
box-sizing: border-box;
width: 100%;
height: 44px;
padding: 0 5px;
cursor: pointer;
text-align: center;
white-space: nowrap;
text-overflow: ellipsis;
color: #007aff;
background: rgba(255, 255, 255, .95);
-webkit-box-flex: 1;
}
.mui-popup-button:after
{
position: absolute;
z-index: 15;
top: 0;
right: 0;
bottom: auto;
left: auto;
display: block;
width: 1px;
height: 100%;
content: '';
-webkit-transform: scaleX(.5);
transform: scaleX(.5);
-webkit-transform-origin: 100% 50%;
transform-origin: 100% 50%;
background-color: rgba(0, 0, 0, .2);
}
.mui-popup-button:first-child
{
border-radius: 0 0 0 13px;
}
.mui-popup-button:first-child:last-child
{
border-radius: 0 0 13px 13px;
}
.mui-popup-button:last-child
{
border-radius: 0 0 13px 0;
}
.mui-popup-button:last-child:after
{
display: none;
}
.mui-popup-button.mui-popup-button-bold
{
font-weight: 600;
}
.mui-popup-input input
{
font-size: 14px;
width: 100%;
height: 26px;
margin: 0;
margin-top: 15px;
padding: 0 5px;
border: 1px solid rgba(0, 0, 0, .3);
border-radius: 0;
background: #fff;
}
.mui-plus.mui-android .mui-popup-backdrop
{
-webkit-transition-duration: 1ms;
transition-duration: 1ms;
}
.mui-plus.mui-android .mui-popup
{
-webkit-transition-duration: 1ms;
transition-duration: 1ms;
-webkit-transform: translate3d(-50%, -50%, 0) scale(1);
transform: translate3d(-50%, -50%, 0) scale(1);
}
.mui-pagination
{
display: inline-block;
......@@ -3872,6 +4094,7 @@ select:focus
.mui-slider
{
position: relative;
z-index: 1;
overflow: hidden;
......@@ -4322,6 +4545,15 @@ select:focus
bottom: 50px;
width: 100%;
-webkit-transition: opacity .8s;
transition: opacity .8s;
opacity: 0;
}
.mui-toast-container.mui-active
{
opacity: 1;
}
.mui-toast-message
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -35,7 +35,7 @@
<input type="text" class="mui-input-clear" placeholder="带清除按钮的输入框">
</div>
<div class="mui-input-row mui-plus-hidden">
<div class="mui-input-row mui-plus-visible">
<label>Input</label>
<input type="text" class="mui-input-speech mui-input-clear" placeholder="语音输入">
</div>
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="../js/mui.min.js"></script>
<script type="text/javascript" charset="utf-8">
mui.init();
</script>
<!--标准mui.css-->
<link rel="stylesheet" href="../css/mui.min.css">
<style>
.mui-content-padded {
padding: 10px;
}
body,
body .mui-content {
background-color: #fff !important;
}
#total {
-webkit-user-select: text;
text-align: right;
padding: 0 1em;
border: 0px;
border-bottom: 1px solid #007aff;
border-radius: 0;
font-size: 16px;
width: 30%;
outline: none;
}
textarea{
margin-top: 10px;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">cloud Pay(云端支付)</h1>
</header>
<div id="dcontent" class="mui-content">
<div class="mui-content-padded">
<p style="text-indent: 22px;">
这是mui无后端开发示例,集成BeeCloud云支付服务,通过js连接云端支付服务器,实现支付功能的全流程开发。
如下为一个支付示例,为DCloud提供的免费、开源软件进行捐赠吧
</p>
<div style="padding: 0 1em;text-align:center">
捐赠金额:
<input id="total" type="number" value="0.1" style="text-align:center" />
</div>
<div id='WX_APP' class="mui-btn mui-btn-blue mui-btn-block pay">
微信支付
</div>
<div id='ALI_APP' class="mui-btn mui-btn-blue mui-btn-block pay">
支付宝钱包
</div>
<ul class="mui-table-view">
<li class="mui-table-view-cell">
支付方式: <span id="channel"></span>
</li>
<li class="mui-table-view-cell">
订单号: <span id="bill_no"></span>
</li>
<li class="mui-table-view-cell">
支付金额: <span id="total_fee"></span>
</li>
<li class="mui-table-view-cell">
支付状态:<span id="status"></span>
</li>
<textarea name="" id="status_msg" cols="20" rows="5"></textarea>
</ul>
</div>
</div>
</body>
<script src="../js/beecloud.js">
</script>
<script type="text/javascript">
mui('.mui-content-padded').on('tap','.pay',function () {
beecloudPay(this.id);
document.getElementById("channel").innerHTML = this.id
document.getElementById("total_fee").innerHTML = document.getElementById('total').value;
document.getElementById("bill_no").innerHTML = beecloud.genBillNo();
})
function beecloudPay(bcChannel) {
/*
* 构建支付参数
*
* app_id: BeeCloud控制台上创建的APP的appid,必填
* title: 订单标题,32个字节,最长支持16个汉字;必填
* total_fee: 支付金额,以分为单位,大于0的整数,必填
* bill_no: 订单号,8~32位数字和/或字母组合,确保在商户系统中唯一,必填
* optional: 扩展参数,可以传入任意数量的key/value对来补充对业务逻辑的需求;此参数会在webhook回调中返回; 选填
* bill_timeout: 订单失效时间,必须为非零正整数,单位为秒,必须大于360。选填
*/
var payData = {
app_id: "44f01a13-965f-4b27-ba9f-da678b47f3f5",
channel: bcChannel,
title: "DCloud项目捐赠",
total_fee: document.getElementById('total').value * 100,
bill_no: beecloud.genBillNo(),
optional: {'uerId':'beecloud','phone':'4006280728'},
bill_timeout: 360
};
/*
* 发起支付
* payData: 支付参数
* cbsuccess: 支付成功回调
* cberror: 支付失败回调
*/
beecloud.payReq(payData, function(result) {
document.getElementById("status").innerHTML = 'success';
document.getElementById("status").style.color = 'green'
document.getElementById("status_msg").innerHTML = "-------- 支付成功 --------" +"\n感谢您的支持,我们会继续努力完善产品";
console.log(result);
}, function(e) {
document.getElementById("status").innerHTML = 'failed';
document.getElementById("status").style.color = 'red'
document.getElementById("status_msg").innerHTML = "-------- 支付失败 --------\n" +"错误码:"+ e.code + '\n' + e.message;
});
}
</script>
</html>
\ No newline at end of file
......@@ -18,6 +18,7 @@
width: 120px;
margin: 10px auto;
}
#info {
padding: 20px 10px;
}
......@@ -43,7 +44,7 @@
</div>
<script src="../js/mui.min.js"></script>
<script type="text/javascript" charset="utf-8">
//mui初始化
//mui初始化
mui.init({
swipeBack: true //启用右滑关闭功能
});
......@@ -54,9 +55,9 @@
});
});
document.getElementById("confirmBtn").addEventListener('tap', function() {
var btnArray = ['', ''];
var btnArray = ['', ''];
mui.confirm('MUI是个好框架,确认?', 'Hello MUI', btnArray, function(e) {
if (e.index == 0) {
if (e.index == 1) {
info.innerText = '你刚确认MUI是个好框架';
} else {
info.innerText = 'MUI没有得到你的认可,继续加油'
......@@ -65,9 +66,9 @@
});
document.getElementById("promptBtn").addEventListener('tap', function(e) {
e.detail.gesture.preventDefault(); //修复iOS 8.x平台存在的bug,使用plus.nativeUI.prompt会造成输入法闪一下又没了
var btnArray = ['确定', '取消'];
var btnArray = ['取消', '确定'];
mui.prompt('请输入你对MUI的评语:', '性能好', 'Hello MUI', btnArray, function(e) {
if (e.index == 0) {
if (e.index == 1) {
info.innerText = '谢谢你的评语:' + e.value;
} else {
info.innerText = '你点了取消按钮';
......
......@@ -61,7 +61,7 @@
</p>
<p>更多详细介绍,请到<a href="http://dcloudio.github.io/mui">mui官网</a>查看;</p>
<h4>版本介绍</h4>
<p>当前版本为2.7.0,可到<a href="https://github.com/dcloudio/mui">Github</a>上获取最新版本。</p>
<p>当前版本为2.8.0,可到<a href="https://github.com/dcloudio/mui">Github</a>上获取最新版本。</p>
<h4>License</h4>
<p>
mui遵循MIT License,源码已提交至Github,<a href="https://github.com/dcloudio/mui">点击查看</a>;
......
......@@ -26,6 +26,7 @@
width: 40px;
height: 40px;
border-radius: 100%;
z-index: 1;
}
.mui-bar~.mui-pull-top-tips {
top: 24px;
......
......@@ -213,7 +213,7 @@
</ul>
<ul class="mui-table-view mui-table-view-chevron">
<li class="mui-table-view-cell">
<a href="#about" class="mui-navigate-right">关于MUI <i class="mui-pull-right update">V2.7.0</i></a>
<a href="#about" class="mui-navigate-right">关于MUI <i class="mui-pull-right update">V2.8.0</i></a>
</li>
</ul>
<ul class="mui-table-view">
......
var beecloud = {};
var channels = null;
var w = null;
beecloud.payReq = function(data, cbsuccess, cberror) {
doPay(data, cbsuccess, cberror);
};
beecloud.genBillNo = function() {
var d = new Date();
var vYear = d.getFullYear();
var vMon = d.getMonth() + 1;
var vDay = d.getDate();
var h = d.getHours();
var m = d.getMinutes();
var se = d.getSeconds();
var ms = d.getMilliseconds();
billno = "" + vYear + (vMon < 10 ? "0" + vMon : vMon) + (vDay < 10 ? "0" + vDay : vDay) + (h < 10 ? "0" + h : h) + (m < 10 ? "0" + m : m) + (se < 10 ? "0" + se : se) + ms;
return billno;
};
function plusReady() {
plus.payment.getChannels(function(s) {
channels = s;
}, function(e) {
alert("获取支付渠道信权限失败:" + e.message);
});
}
document.addEventListener("plusready", plusReady, false);
function checkServices(pc) {
if (!pc.serviceReady) {
var txt = null;
switch (pc.id) {
case "alipay":
txt = "检测到系统未安装“支付宝快捷支付服务”,无法完成支付操作,是否立即安装?";
break;
default:
txt = "系统未安装“" + pc.description + "”服务,无法完成支付,是否立即安装?";
break;
}
plus.nativeUI.confirm(txt, function(e) {
if (e.index == 0) {
pc.installService();
}
}, pc.description);
return false;
}
return true;
}
function getRandomHost() {
var hosts = ['https://apibj.beecloud.cn',
'https://apihz.beecloud.cn',
'https://apisz.beecloud.cn',
'https://apiqd.beecloud.cn'
];
return "" + hosts[parseInt(3 * Math.random())] + "/2/rest/app/bill";
}
function getPayChannel(bc_channel) {
var dc_channel_id = '';
switch (bc_channel) {
case 'ALI_APP':
dc_channel_id = 'alipay';
break;
case 'WX_APP':
dc_channel_id = 'wxpay';
break;
default:
break;
}
for (var i in channels) {
if (channels[i].id == dc_channel_id && checkServices(channels[i])) {
return channels[i];
}
}
return null;
}
function doPay(payData, cbsuccess, cberror) {
if (w) return;
console.log('doPay: ' + JSON.stringify(payData));
w = plus.nativeUI.showWaiting();
mui.ajax(getRandomHost(), {
data: JSON.stringify(payData),
type: 'post',
dataType: 'json',
contentType: "application/json",
success: function(data) {
console.log(JSON.stringify(data));
w.close();
w = null;
var paySrc = '';
if (data.result_code == 0) {
var payChannel = getPayChannel(payData.channel);
if (payChannel) {
if (payChannel.id === 'alipay') {
paySrc = data.order_string;
} else if (payChannel.id === 'wxpay') {
var statement = {};
statement.appid = data.app_id;
statement.noncestr = data.nonce_str;
statement.package = data.package;
statement.partnerid = data.partner_id;
statement.prepayid = data.prepay_id;
statement.timestamp = parseInt(data.timestamp);
statement.sign = data.pay_sign;
paySrc = JSON.stringify(statement);
}
plus.payment.request(payChannel, paySrc, cbsuccess, cberror);
}
} else {
var bcError = {};
bcError.code = data.result_code;
bcError.message = data.result_msg + ":" + data.err_detail;
cberror(bcError);
}
},
error: function(xhr, errorType, error) {
w.close();
w = null;
cberror(error);
}
});
}
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -360,14 +360,19 @@
chart(EChart 图表)
</a>
</li>
<li class="mui-table-view-cell mui-plus-visible">
<a class="mui-navigate-right" href="examples/im-chat.html">
chat(聊天窗口)
</a>
</li>
<li class="mui-table-view-cell mui-plus-visible">
<a class="mui-navigate-right" open-type="common" href="examples/clouddb_wilddog.html">
cloud DB(云端数据库)
</a>
</li>
<li class="mui-table-view-cell mui-plus-visible">
<a class="mui-navigate-right" href="examples/im-chat.html">
chat(聊天窗口)
<a class="mui-navigate-right" open-type="common" href="examples/beecloud.html">
cloud Pay(云端支付)
</a>
</li>
<li class="mui-table-view-cell">
......
......@@ -142,7 +142,7 @@
};
element.addEventListener('input', showTip);
element.addEventListener('tap', showTip);
element.addEventListener('touchmove', function(e) {
element.addEventListener($.EVENT_MOVE, function(e) {
e.stopPropagation();
});
} else {
......
......@@ -3,7 +3,7 @@
*/
(function(window) {
var active;
window.addEventListener('touchstart', function(event) {
window.addEventListener($.EVENT_START, function(event) {
var target = event.target;
var isCellDisabled = false;
for (; target && target !== document; target = target.parentNode) {
......
......@@ -130,7 +130,7 @@
if (settings.cache === false || ((!options || options.cache !== true) && ('script' === dataType))) {
settings.url = appendQuery(settings.url, '_=' + $.now());
}
var mime = settings.accepts[dataType.toLowerCase()];
var mime = settings.accepts[dataType && dataType.toLowerCase()];
var headers = {};
var setHeader = function(name, value) {
headers[name.toLowerCase()] = [name, value];
......
......@@ -10,6 +10,7 @@
name: 'mui',
index: 5,
handle: function() {
//后续重新设计此处,将back放到各个空间内部实现
//popover
if ($.targets._popover && $.targets._popover.classList.contains($.className('active'))) {
$($.targets._popover).popover('hide');
......@@ -26,6 +27,8 @@
previewImage.close();
return true;
}
//popup
return $.closePopup();
}
});
}
......@@ -73,7 +76,7 @@
$.menu = function() {
var menu = document.querySelector($.classSelector('.action-menu'));
if (menu) {
$.trigger(menu, 'touchstart'); //临时处理menu无touchstart的话,找不到当前targets的问题
$.trigger(menu, $.EVENT_START); //临时处理menu无touchstart的话,找不到当前targets的问题
$.trigger(menu, 'tap');
} else { //执行父窗口的menu
if (window.plus) {
......
......@@ -214,9 +214,9 @@
this.scroller[action]('webkitTransitionEnd', this);
this.wrapper[action]('touchstart', this);
this.wrapper[action]('touchcancel', this);
this.wrapper[action]('touchend', this);
this.wrapper[action]($.EVENT_START, this);
this.wrapper[action]($.EVENT_CANCEL, this);
this.wrapper[action]($.EVENT_END, this);
this.wrapper[action]('drag', this);
this.wrapper[action]('dragend', this);
this.wrapper[action]('flick', this);
......@@ -229,11 +229,8 @@
mui(segmentedControl)[detach ? 'off' : 'on']('click', 'a', $.preventDefault);
}
this.wrapper[action]('scrollend', this._handleIndicatorScrollend.bind(this));
this.wrapper[action]('scrollstart', this._handleIndicatorScrollstart.bind(this));
this.wrapper[action]('refresh', this._handleIndicatorRefresh.bind(this));
this.wrapper[action]('scrollstart', this);
this.wrapper[action]('refresh', this);
},
_handleIndicatorScrollend: function() {
this.indicators.map(function(indicator) {
......@@ -257,7 +254,7 @@
}
switch (e.type) {
case 'touchstart':
case $.EVENT_START:
this._start(e);
break;
case 'drag':
......@@ -269,15 +266,19 @@
this.options.stopPropagation && e.stopPropagation();
this._flick(e);
break;
case 'touchcancel':
case 'touchend':
case $.EVENT_CANCEL:
case $.EVENT_END:
this._end(e);
break;
case 'webkitTransitionEnd':
this.transitionTimer && this.transitionTimer.cancel();
this._transitionEnd(e);
break;
case 'scrollstart':
this._handleIndicatorScrollstart(e);
break;
case 'scrollend':
this._handleIndicatorScrollend(e);
this._scrollend(e);
e.stopPropagation();
break;
......@@ -288,6 +289,9 @@
case 'swiperight':
e.stopPropagation();
break;
case 'refresh':
this._handleIndicatorRefresh(e);
break;
}
},
......@@ -480,7 +484,7 @@
},
_end: function(e) {
this.needReset = false;
if ((!this.moved && this.needReset) || e.type === 'touchcancel') {
if ((!this.moved && this.needReset) || e.type === $.EVENT_CANCEL) {
this.resetPosition();
}
},
......@@ -745,7 +749,7 @@
gotoPage: function(index) {
this._gotoPage(index);
},
destory: function() {
destroy: function() {
this._initEvent(true); //detach
delete $.data[this.wrapper.getAttribute('data-scroll')];
this.wrapper.setAttribute('data-scroll', '');
......
......@@ -153,18 +153,24 @@
var self = this;
self._super(detach);
var action = detach ? 'removeEventListener' : 'addEventListener';
self.wrapper[action]('swiperight', $.stopPropagation);
self.wrapper[action]('scrollend', self._triggerSlide.bind(this));
self.wrapper[action]('slide', self._handleSlide.bind(this));
self.wrapper[action]($.eventName('shown', 'tab'), self._handleTabShow.bind(this));
//indicator
var indicator = self.wrapper.querySelector(SELECTOR_SLIDER_INDICATOR);
if (indicator) {
indicator[action]('tap', self._handleIndicatorTap.bind(this));
self.wrapper[action]('slide', this);
self.wrapper[action]($.eventName('shown', 'tab'), this);
},
handleEvent: function(e) {
this._super(e);
switch (e.type) {
case 'slide':
this._handleSlide(e);
break;
case $.eventName('shown', 'tab'):
this._handleTabShow(e);
break;
}
},
_scrollend: function(e) {
this._super(e);
this._triggerSlide(e);
},
_drag: function(e) {
this._super(e);
var direction = e.detail.direction;
......@@ -341,12 +347,12 @@
if (options) {
$.extend(this.options, options);
this._super();
this.nextItem();
this._initTimer();
} else {
this._super();
}
},
destory: function() {
destroy: function() {
this._initEvent(true); //detach
delete $.data[this.wrapper.getAttribute('data-slider')];
this.wrapper.setAttribute('data-slider', '');
......
......@@ -4,7 +4,7 @@
*/
$.alert = function(message, title, btnValue, callback) {
if ($.os.plus) {
if (typeof message === undefined) {
if (typeof message === 'undefined') {
return;
} else {
if (typeof title === 'function') {
......
......@@ -4,7 +4,7 @@
*/
$.confirm = function(message, title, btnArray, callback) {
if ($.os.plus) {
if (typeof message === undefined) {
if (typeof message === 'undefined') {
return;
} else {
if (typeof title === 'function') {
......
......@@ -4,7 +4,7 @@
*/
$.prompt = function(text, defaultText, title, btnArray, callback) {
if ($.os.plus) {
if (typeof message === undefined) {
if (typeof message === 'undefined') {
return;
} else {
......
(function($, window) {
var CLASS_ACTIVE = $.className('active');
/**
* 自动消失提示框
*/
......@@ -14,9 +15,16 @@
var toast = document.createElement('div');
toast.classList.add($.className('toast-container'));
toast.innerHTML = '<div class="' + $.className('toast-message') + '">' + message + '</div>';
toast.addEventListener('webkitTransitionEnd', function() {
if (!toast.classList.contains(CLASS_ACTIVE)) {
toast.parentNode.removeChild(toast);
}
});
document.body.appendChild(toast);
toast.offsetHeight;
toast.classList.add(CLASS_ACTIVE);
setTimeout(function() {
document.body.removeChild(toast);
toast.classList.remove(CLASS_ACTIVE);
}, 2000);
}
};
......
......@@ -3,6 +3,19 @@
* @param {Object} $
*/
(function($) {
if ('ontouchstart' in window) {
$.isTouchable = true;
$.EVENT_START = 'touchstart';
$.EVENT_MOVE = 'touchmove';
$.EVENT_END = 'touchend';
} else {
$.isTouchable = false;
$.EVENT_START = 'mousedown';
$.EVENT_MOVE = 'mousemove';
$.EVENT_END = 'mouseup';
}
$.EVENT_CANCEL = 'touchcancel';
$.EVENT_CLICK = 'click';
var _mid = 1;
var delegates = {};
......
......@@ -2,6 +2,9 @@
* fastclick(only for radio,checkbox)
*/
(function($, window, name) {
if (!$.os.android && !$.os.ios) { //目前仅识别android和ios
return;
}
if (window.FastClick) {
return;
}
......
......@@ -11,7 +11,7 @@
case $.EVENT_START:
break;
case $.EVENT_MOVE:
if (!touch.direction) {
if (!touch.direction || !session.target) {
return;
}
//修正direction,可在session期间自行锁定拖拽方向,方便开发scroll类不同方向拖拽插件嵌套
......
......@@ -5,11 +5,6 @@
* @returns {undefined}
*/
(function($, window) {
$.EVENT_START = 'touchstart';
$.EVENT_MOVE = 'touchmove';
$.EVENT_END = 'touchend';
$.EVENT_CANCEL = 'touchcancel';
$.EVENT_CLICK = 'click';
$.gestures = {
session: {}
};
......@@ -316,8 +311,14 @@
touch.direction = direction;
};
var targetIds = {};
var convertTouches = function(touches) {
for (var i = 0; i < touches.length; i++) {
!touches['identifier'] && (touches['identifier'] = 0);
}
return touches;
};
var getTouches = function(event, touch) {
var allTouches = $.slice.call(event.touches || event);
var allTouches = convertTouches($.slice.call(event.touches || [event]));
var type = event.type;
......@@ -334,7 +335,7 @@
var i = 0;
var targetTouches = [];
var changedTargetTouches = [];
var changedTouches = $.slice.call(event.changedTouches || event);
var changedTouches = convertTouches($.slice.call(event.changedTouches || [event]));
touch.target = event.target;
var sessionTarget = $.gestures.session.target || event.target;
......@@ -368,7 +369,6 @@
targetTouches = uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true);
var touchesLength = targetTouches.length;
var changedTouchesLength = changedTargetTouches.length;
if (type === $.EVENT_START && touchesLength - changedTouchesLength === 0) { //first
touch.isFirst = true;
$.gestures.touch = $.gestures.session = {
......@@ -393,6 +393,9 @@
calTouchData(touch);
detect(event, touch);
$.gestures.session.prevTouch = touch;
if (event.type === $.EVENT_END && !$.isTouchable) {
$.gestures.touch = $.gestures.session = {};
}
};
window.addEventListener($.EVENT_START, handleTouchEvent);
window.addEventListener($.EVENT_MOVE, handleTouchEvent);
......
......@@ -160,7 +160,12 @@
}
}
if (!$.os.plus) {
window.top.location.href = url;
//TODO 先临时这么处理:手机上顶层跳,PC上parent跳
if ($.os.ios || $.os.android) {
window.top.location.href = url;
} else {
window.parent.location.href = url;
}
return;
}
if (!window.plus) {
......@@ -198,7 +203,7 @@
webview = plus.webview.getWebviewById(id);
if (webview) { //如果已存在
nShow = $.showOptions(options.show);
webview.show(nShow.aniShow, nShow.duration, function() {
nShow.autoShow && webview.show(nShow.aniShow, nShow.duration, function() {
triggerPreload(webview);
trigger(webview, 'pagebeforeshow', false);
});
......
......@@ -11,9 +11,9 @@
var tapEventName = touchSupport ? 'tap' : 'click';
var changeEventName = 'change';
var holderClassName = $.className('numbox');
var plusClassName = $.className('btn-numbox-plus') + "," + $.className("numbox-btn-plus");
var minusClassName = $.className('btn-numbox-minus') + "," + $.className("numbox-btn-minus");
var inputClassName = $.className('input-numbox') + "," + $.className("numbox-input");
var plusClassSelector = $.classSelector('.btn-numbox-plus,.numbox-btn-plus');
var minusClassSelector = $.classSelector('.btn-numbox-minus,.numbox-btn-minus');
var inputClassSelector = $.classSelector('.input-numbox,.numbox-input');
var Numbox = $.Numbox = $.Class.extend({
/**
......@@ -28,9 +28,9 @@
options = options || {};
options.step = parseInt(options.step || 1);
self.options = options;
self.input = $.qsa('.' + inputClassName, self.holder)[0];
self.plus = $.qsa('.' + plusClassName, self.holder)[0];
self.minus = $.qsa('.' + minusClassName, self.holder)[0];
self.input = $.qsa(inputClassSelector, self.holder)[0];
self.plus = $.qsa(plusClassSelector, self.holder)[0];
self.minus = $.qsa(minusClassSelector, self.holder)[0];
self.checkValue();
self.initEvent();
},
......
......@@ -95,7 +95,7 @@
},
handleEvent: function(e) {
switch (e.type) {
case 'touchstart':
case $.EVENT_START:
e.target && !this._preventDefaultException(e.target, this.options.preventDefaultException) && e.preventDefault();
break;
case 'webkitTransitionEnd': //有个bug需要处理,需要考虑假设没有触发webkitTransitionEnd的情况
......@@ -275,7 +275,7 @@
});
}
if (this.classList.contains($.className('draggable'))) {
this.wrapper.addEventListener('touchstart', this); //临时处理
this.wrapper.addEventListener($.EVENT_START, this); //临时处理
this.wrapper.addEventListener('drag', this);
this.wrapper.addEventListener('dragend', this);
}
......
/**
* Popup(alert,confirm,prompt)
* @param {Object} $
* @param {Object} window
* @param {Object} document
*/
(function($, window, document) {
var CLASS_POPUP = $.className('popup');
var CLASS_POPUP_BACKDROP = $.className('popup-backdrop');
var CLASS_POPUP_IN = $.className('popup-in');
var CLASS_POPUP_OUT = $.className('popup-out');
var CLASS_POPUP_INNER = $.className('popup-inner');
var CLASS_POPUP_TITLE = $.className('popup-title');
var CLASS_POPUP_TEXT = $.className('popup-text');
var CLASS_POPUP_INPUT = $.className('popup-input');
var CLASS_POPUP_BUTTONS = $.className('popup-buttons');
var CLASS_POPUP_BUTTON = $.className('popup-button');
var CLASS_POPUP_BUTTON_BOLD = $.className('popup-button-bold');
var CLASS_POPUP_BACKDROP = $.className('popup-backdrop');
var CLASS_ACTIVE = $.className('active');
var popupStack = [];
var backdrop = (function() {
var element = document.createElement('div');
element.classList.add(CLASS_POPUP_BACKDROP);
element.addEventListener('webkitTransitionEnd', function() {
if (!this.classList.contains(CLASS_ACTIVE)) {
element.parentNode && element.parentNode.removeChild(element);
}
});
return element;
}());
var createInput = function(placeholder) {
return '<div class="' + CLASS_POPUP_INPUT + '"><input type="text" autofocus placeholder="' + (placeholder || '') + '"/></div>';
};
var createInner = function(message, title, extra) {
return '<div class="' + CLASS_POPUP_INNER + '"><div class="' + CLASS_POPUP_TITLE + '">' + title + '</div><div class="' + CLASS_POPUP_TEXT + '">' + message + '</div>' + (extra || '') + '</div>';
};
var createButtons = function(btnArray) {
var length = btnArray.length;
var btns = [];
for (var i = 0; i < length; i++) {
btns.push('<span class="' + CLASS_POPUP_BUTTON + (i === length - 1 ? (' ' + CLASS_POPUP_BUTTON_BOLD) : '') + '">' + btnArray[i] + '</span>');
}
return '<div class="' + CLASS_POPUP_BUTTONS + '">' + btns.join('') + '</div>';
};
var createPopup = function(html, callback) {
var popupElement = document.createElement('div');
popupElement.className = CLASS_POPUP;
popupElement.innerHTML = html;
var removePopupElement = function() {
popupElement.parentNode && popupElement.parentNode.removeChild(popupElement);
popupElement = null;
};
popupElement.addEventListener('webkitTransitionEnd', function(e) {
if (popupElement && e.target === popupElement && popupElement.classList.contains(CLASS_POPUP_OUT)) {
removePopupElement();
}
});
popupElement.style.display = 'block';
document.body.appendChild(popupElement);
popupElement.offsetHeight;
popupElement.classList.add(CLASS_POPUP_IN);
if (!backdrop.classList.contains(CLASS_ACTIVE)) {
backdrop.style.display = 'block';
document.body.appendChild(backdrop);
backdrop.offsetHeight;
backdrop.classList.add(CLASS_ACTIVE);
}
var btns = $.qsa('.' + CLASS_POPUP_BUTTON, popupElement);
var input = popupElement.querySelector('.' + CLASS_POPUP_INPUT + ' input');
var popup = {
element: popupElement,
close: function(index, animate) {
if (popupElement) {
callback && callback({
index: index || 0,
value: input && input.value || ''
});
if (animate !== false) {
popupElement.classList.remove(CLASS_POPUP_IN);
popupElement.classList.add(CLASS_POPUP_OUT);
} else {
removePopupElement();
}
popupStack.pop();
//如果还有其他popup,则不remove backdrop
if (popupStack.length) {
popupStack[popupStack.length - 1]['show'](animate);
} else {
backdrop.classList.remove(CLASS_ACTIVE);
}
}
}
};
var handleEvent = function(e) {
popup.close(btns.indexOf(e.target));
};
$(popupElement).on('tap', '.' + CLASS_POPUP_BUTTON, handleEvent);
if (popupStack.length) {
popupStack[popupStack.length - 1]['hide']();
}
popupStack.push({
close: popup.close,
show: function(animate) {
popupElement.style.display = 'block';
popupElement.offsetHeight;
popupElement.classList.add(CLASS_POPUP_IN);
},
hide: function() {
popupElement.style.display = 'none';
popupElement.classList.remove(CLASS_POPUP_IN);
}
});
return popup;
};
var createAlert = function(message, title, btnValue, callback, type) {
if (typeof message === 'undefined') {
return;
} else {
if (typeof title === 'function') {
callback = title;
title = null;
btnValue = null;
} else if (typeof btnValue === 'function') {
callback = btnValue;
btnValue = null;
}
}
if (!$.os.plus || type === 'div') {
return createPopup(createInner(message, title || '提示') + createButtons([btnValue || '确定']), callback);
}
return plus.nativeUI.alert(message, callback, title || '提示', btnValue || '确定');
};
var createConfirm = function(message, title, btnArray, callback, type) {
if (typeof message === 'undefined') {
return;
} else {
if (typeof title === 'function') {
callback = title;
title = null;
btnArray = null;
} else if (typeof btnArray === 'function') {
callback = btnArray;
btnArray = null;
}
}
if (!$.os.plus || type === 'div') {
return createPopup(createInner(message, title || '提示') + createButtons(btnArray || ['取消', '确认']), callback);
}
return plus.nativeUI.confirm(message, callback, title, btnArray || ['取消', '确认']);
};
var createPrompt = function(message, placeholder, title, btnArray, callback, type) {
if (typeof message === 'undefined') {
return;
} else {
if (typeof placeholder === 'function') {
callback = placeholder;
placeholder = null;
title = null;
btnArray = null;
} else if (typeof title === 'function') {
callback = title;
title = null;
btnArray = null;
} else if (typeof btnArray === 'function') {
callback = btnArray;
btnArray = null;
}
}
if (!$.os.plus || type === 'div') {
return createPopup(createInner(message, title || '提示', createInput(placeholder)) + createButtons(btnArray || ['取消', '确认']), callback);
}
return plus.nativeUI.prompt(message, callback, title || '提示', placeholder, btnArray || ['取消', '确认']);
};
var closePopup = function() {
if (popupStack.length) {
popupStack[popupStack.length - 1]['close']();
return true;
} else {
return false;
}
};
var closePopups = function() {
while (popupStack.length) {
popupStack[popupStack.length - 1]['close']();
}
};
$.closePopup = closePopup;
$.closePopups = closePopups;
$.alert = createAlert;
$.confirm = createConfirm;
$.prompt = createPrompt;
})(mui, window, document);
\ No newline at end of file
......@@ -27,7 +27,7 @@
return $.targetHandles;
};
window.addEventListener('touchstart', function(event) {
window.addEventListener($.EVENT_START, function(event) {
var target = event.target;
var founds = {};
for (; target && target !== document; target = target.parentNode) {
......
......@@ -51,13 +51,13 @@
};
var onPopoverShown = function(e) {
this.removeEventListener('webkitTransitionEnd', onPopoverShown);
this.addEventListener('touchmove', $.preventDefault);
this.addEventListener($.EVENT_MOVE, $.preventDefault);
$.trigger(this, 'shown', this);
}
var onPopoverHidden = function(e) {
setStyle(this, 'none');
this.removeEventListener('webkitTransitionEnd', onPopoverHidden);
this.removeEventListener('touchmove', $.preventDefault);
this.removeEventListener($.EVENT_MOVE, $.preventDefault);
fixedPopoverScroll(false);
$.trigger(this, 'hidden', this);
};
......@@ -65,7 +65,7 @@
var backdrop = (function() {
var element = document.createElement('div');
element.classList.add(CLASS_BACKDROP);
element.addEventListener('touchmove', $.preventDefault);
element.addEventListener($.EVENT_MOVE, $.preventDefault);
element.addEventListener('tap', function(e) {
var popover = $.targets._popover;
if (popover) {
......@@ -240,7 +240,7 @@
$.createMask = function(callback) {
var element = document.createElement('div');
element.classList.add(CLASS_BACKDROP);
element.addEventListener('touchmove', $.preventDefault);
element.addEventListener($.EVENT_MOVE, $.preventDefault);
element.addEventListener('tap', function() {
mask.close();
});
......
This diff is collapsed.
......@@ -44,11 +44,11 @@
this.handleX = this.toggleWidth - this.handleWidth - 3;
};
Toggle.prototype.initEvent = function() {
this.element.addEventListener('touchstart', this);
this.element.addEventListener($.EVENT_START, this);
this.element.addEventListener('drag', this);
this.element.addEventListener('swiperight', this);
this.element.addEventListener('touchend', this);
this.element.addEventListener('touchcancel', this);
this.element.addEventListener($.EVENT_END, this);
this.element.addEventListener($.EVENT_CANCEL, this);
};
Toggle.prototype.handleEvent = function(e) {
......@@ -56,7 +56,7 @@
return;
}
switch (e.type) {
case 'touchstart':
case $.EVENT_START:
this.start(e);
break;
case 'drag':
......@@ -65,8 +65,8 @@
case 'swiperight':
this.swiperight();
break;
case 'touchend':
case 'touchcancel':
case $.EVENT_END:
case $.EVENT_CANCEL:
this.end(e);
break;
}
......
......@@ -100,7 +100,7 @@
}
};
window.addEventListener('touchstart', function(event) {
window.addEventListener($.EVENT_START, function(event) {
if (cell) {
toggleActive(false);
}
......@@ -154,7 +154,7 @@
}
}
});
window.addEventListener('touchmove', function(event) {
window.addEventListener($.EVENT_MOVE, function(event) {
toggleActive(false);
});
......@@ -411,14 +411,14 @@
}
};
window.addEventListener('touchend', function(event) { //使用touchend来取消高亮,避免一次点击既不触发tap,doubletap,longtap的事件
window.addEventListener($.EVENT_END, function(event) { //使用touchend来取消高亮,避免一次点击既不触发tap,doubletap,longtap的事件
if (!cell) {
return;
}
toggleActive(false);
sliderHandle && toggleEvents(cell, true);
});
window.addEventListener('touchcancel', function(event) { //使用touchcancel来取消高亮,避免一次点击既不触发tap,doubletap,longtap的事件
window.addEventListener($.EVENT_CANCEL, function(event) { //使用touchcancel来取消高亮,避免一次点击既不触发tap,doubletap,longtap的事件
if (!cell) {
return;
}
......
{
"name": "mui",
"description": "最接近原生体验的高性能前端框架.",
"version": "2.7.0",
"version": "2.8.0",
"keywords": [
"css",
"fonts",
......
......@@ -141,7 +141,7 @@ select {
.#{$namespace}input-row label {
float: left;
width: 35%;
padding: 10px 15px;
padding: 11px 15px;
font-family: $font-family-default;
line-height: 1.1; // Put the text on the baseline.
}
......
......@@ -25,6 +25,7 @@
@import "forms.scss";
@import "segmented-controls.scss";
@import "popovers.scss";
@import "popup.scss";
@import "pagination.scss";
// Javascript components
......
.#{$namespace}popup-backdrop{
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: z("backdrop");
background: rgba(0,0,0,.4);
opacity: 0;
@include transition-duration(400ms);
&.#{$namespace}active {
opacity: 1;
}
}
.#{$namespace}popup{
width: 270px;
position: absolute;
z-index: z("max");
left: 50%;
top: 50%;
text-align: center;
border-radius: 13px;
overflow: hidden;
opacity: 0;
@include transform(translate3d(-50%,-50%,0) scale(1.185));
-webkit-transition-property: -webkit-transform,opacity;
transition-property: transform,opacity;
color: #000;
display: none;
&.#{$namespace}popup-in{
opacity: 1;
@include transition-duration(400ms);
@include transform(translate3d(-50%,-50%,0) scale(1));
display: block;
}
&.#{$namespace}popup-out{
opacity: 0;
//z-index:max-1
@include transition-duration(400ms);
@include transform(translate3d(-50%,-50%,0) scale(1));
}
}
.#{$namespace}popup-inner {
padding: 15px;
border-radius: 13px 13px 0 0;
position: relative;
background: rgba(255,255,255,.95);
&:after {
content: '';
position: absolute;
left: 0;
bottom: 0;
right: auto;
top: auto;
height: 1px;
width: 100%;
background-color: rgba(0,0,0,.2);
display: block;
z-index: 15;
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
-webkit-transform: scaleY(.5);
transform: scaleY(.5);
}
}
.#{$namespace}popup-title {
font-weight: 500;
font-size: 18px;
text-align: center;
}
.#{$namespace}popup-title+.#{$namespace}popup-text {
margin-top: 5px;
font-size: 14px;
}
.#{$namespace}popup-buttons {
height: 44px;
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center
}
.#{$namespace}popup-button {
width: 100%;
padding: 0 5px;
height: 44px;
font-size: 17px;
line-height: 44px;
text-align: center;
color: #007aff;
display: block;
position: relative;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
cursor: pointer;
box-sizing: border-box;
-webkit-box-flex: 1;
background: rgba(255,255,255,.95);
&:after {
content: '';
position: absolute;
right: 0;
top: 0;
left: auto;
bottom: auto;
width: 1px;
height: 100%;
background-color: rgba(0,0,0,.2);
display: block;
z-index: 15;
-webkit-transform-origin: 100% 50%;
transform-origin: 100% 50%;
-webkit-transform: scaleX(.5);
transform: scaleX(.5)
}
&:first-child {
border-radius: 0 0 0 13px;
&:last-child {
border-radius: 0 0 13px 13px
}
}
&:last-child {
border-radius: 0 0 13px 0;
&:after {
display: none
}
}
&.#{$namespace}popup-button-bold {
font-weight: 600
}
}
.#{$namespace}popup-input input{
height: 26px;
background: #fff;
margin: 0;
margin-top: 15px;
padding: 0 5px;
border: 1px solid rgba(0,0,0,.3);
border-radius: 0;
width: 100%;
font-size: 14px;
}
.#{$namespace}plus.#{$namespace}android .#{$namespace}popup-backdrop{
@include transition-duration(1ms);
}
.#{$namespace}plus.#{$namespace}android .#{$namespace}popup{
@include transition-duration(1ms);
@include transform(translate3d(-50%,-50%,0) scale(1));
}
......@@ -2,7 +2,7 @@
.#{$namespace}scroll-wrapper {
// -webkit-backface-visibility: hidden;
position: absolute;
z-index: z("default");
z-index: 2;
top: 0px;
bottom: 0px;
left: 0;
......
......@@ -8,6 +8,7 @@
overflow: hidden;
width: 100%;
position:relative;
z-index:z("default");
.#{$namespace}segmented-control.#{$namespace}segmented-control-inverted{
.#{$namespace}control-item {
&.#{$namespace}active {
......
......@@ -3,6 +3,12 @@
width: 100%;
bottom: 50px;
z-index: z("toast");
opacity: 0;
-webkit-transition: opacity .8s;
transition: opacity .8s;
&.#{$namespace}active{
opacity: 1;
}
}
.#{$namespace}toast-message {
width: 270px;
......
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