Skip to content

Commit

Permalink
mui编译至v 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hbcui1984 committed Apr 22, 2016
1 parent 08acba4 commit b103b03
Show file tree
Hide file tree
Showing 28 changed files with 518 additions and 7,920 deletions.
18 changes: 10 additions & 8 deletions dist/css/mui.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* =====================================================
* Mui v2.9.0 (http://dev.dcloud.net.cn/mui)
* Mui v3.0.0 (http://dev.dcloud.net.cn/mui)
* =====================================================
*/

Expand Down Expand Up @@ -3692,7 +3692,7 @@ select:focus

.mui-popup
{
position: absolute;
position: fixed;
z-index: 10000;
top: 50%;
left: 50%;
Expand Down Expand Up @@ -3775,9 +3775,10 @@ select:focus

.mui-popup-title + .mui-popup-text
{
font-family: inherit;
font-size: 14px;

margin-top: 5px;
margin: 5px 0 0;
}

.mui-popup-buttons
Expand Down Expand Up @@ -3869,8 +3870,7 @@ select:focus

width: 100%;
height: 26px;
margin: 0;
margin-top: 15px;
margin: 15px 0 0;
padding: 0 5px;

border: 1px solid rgba(0, 0, 0, .3);
Expand Down Expand Up @@ -5299,9 +5299,6 @@ body > .mui-progressbar
right: 0;
bottom: 0;
left: 0;

width: 100%;
height: 100%;
}
.mui-fullscreen.mui-slider .mui-slider-group
{
Expand Down Expand Up @@ -5331,6 +5328,11 @@ body > .mui-progressbar
transform: none;
}

.mui-bar-nav ~ .mui-content .mui-slider.mui-fullscreen
{
top: 44px;
}

.mui-bar-tab ~ .mui-content .mui-slider.mui-fullscreen .mui-segmented-control ~ .mui-slider-group
{
bottom: 50px;
Expand Down
4 changes: 2 additions & 2 deletions dist/css/mui.min.css

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions dist/js/mui.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* =====================================================
* Mui v2.9.0 (http://dev.dcloud.net.cn/mui)
* Mui v3.0.0 (http://dev.dcloud.net.cn/mui)
* =====================================================
*/
/**
Expand Down Expand Up @@ -3396,7 +3396,6 @@ Function.prototype.bind = Function.prototype.bind || function(to) {
scrollTime: 500,
scrollEasing: ease.outCubic, //轮播动画曲线


directionLockThreshold: 5,

parallaxElement: false, //视差元素
Expand Down Expand Up @@ -3837,7 +3836,7 @@ Function.prototype.bind = Function.prototype.bind || function(to) {
}
},
_scrollend: function(e) {
if (Math.abs(this.y) > 0 && this.y <= this.maxScrollY) {
if ((this.y === 0 && this.maxScrollY === 0) || (Math.abs(this.y) > 0 && this.y <= this.maxScrollY)) {
$.trigger(this.scroller, 'scrollbottom', this);
}
},
Expand Down Expand Up @@ -4120,7 +4119,6 @@ Function.prototype.bind = Function.prototype.bind || function(to) {
speedRatioY: 0
}, options);


this.sizeRatioX = 1;
this.sizeRatioY = 1;
this.maxPosX = 0;
Expand Down Expand Up @@ -6999,6 +6997,7 @@ Function.prototype.bind = Function.prototype.bind || function(to) {
var backdrop = (function() {
var element = document.createElement('div');
element.classList.add(CLASS_POPUP_BACKDROP);
element.addEventListener($.EVENT_MOVE, $.preventDefault);
element.addEventListener('webkitTransitionEnd', function() {
if (!this.classList.contains(CLASS_ACTIVE)) {
element.parentNode && element.parentNode.removeChild(element);
Expand All @@ -7011,7 +7010,7 @@ Function.prototype.bind = Function.prototype.bind || function(to) {
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>';
return '<div class="' + CLASS_POPUP_INNER + '"><div class="' + CLASS_POPUP_TITLE + '">' + title + '</div><pre class="' + CLASS_POPUP_TEXT + '">' + message + '</pre>' + (extra || '') + '</div>';
};
var createButtons = function(btnArray) {
var length = btnArray.length;
Expand All @@ -7030,7 +7029,7 @@ Function.prototype.bind = Function.prototype.bind || function(to) {
popupElement.parentNode && popupElement.parentNode.removeChild(popupElement);
popupElement = null;
};

popupElement.addEventListener($.EVENT_MOVE, $.preventDefault);
popupElement.addEventListener('webkitTransitionEnd', function(e) {
if (popupElement && e.target === popupElement && popupElement.classList.contains(CLASS_POPUP_OUT)) {
removePopupElement();
Expand Down Expand Up @@ -7241,6 +7240,8 @@ Function.prototype.bind = Function.prototype.bind || function(to) {
progressbar.innerHTML = '<span></span>';
}
container.appendChild(progressbar);
} else {
progressbar.classList.add(CLASS_PROGRESSBAR_IN);
}
}
if (progress) setProgressbar(container, progress);
Expand Down
6 changes: 3 additions & 3 deletions dist/js/mui.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/hello-mui/css/mui.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/hello-mui/examples/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h1 class="mui-title">关于</h1>
<p>mui是一款小巧高能的前端UI框架,其UI控件富有原生UI样式;
通过封装多webview、启动原生动画,使得mui成为目前最接近原生体验的前端框架,
更多详细介绍,请到<a href="http://dev.dcloud.net.cn/mui">mui官网</a>查看</p>
<p style="text-align: center;color: #ccc;text-indent: 0;">当前版本:<span id="version">2.9.0</span></p>
<p style="text-align: center;color: #ccc;text-indent: 0;">当前版本:<span id="version">3.0.0</span></p>
</div>
</div>
<script src="../js/mui.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-mui/examples/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ <h1 class="mui-center mui-title">设置</h1>
</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.9.0</i></a>
<a href="#about" class="mui-navigate-right">关于MUI <i class="mui-pull-right update">V3.0.0</i></a>
</li>
</ul>
<ul class="mui-table-view">
Expand Down
170 changes: 170 additions & 0 deletions examples/hello-mui/examples/tab-vertical-scroll.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Hello MUI</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<!--标准mui.css-->
<link rel="stylesheet" href="../css/mui.min.css">
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="../css/app.css" />
<style>
.mui-row.mui-fullscreen>[class*="mui-col-"] {
height: 100%;
}

.mui-col-xs-3,
.mui-col-xs-9 {
overflow-y: auto;
height: 100%;
}

.mui-segmented-control .mui-control-item {
line-height: 50px;
width: 100%;
}

.mui-control-content {
display: block;
}

.mui-segmented-control.mui-segmented-control-inverted .mui-control-item.mui-active {
background-color: #fff;
}
</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">侧面选项卡-div模式</h1>
</header>
<div class="mui-content mui-row mui-fullscreen">
<div class="mui-col-xs-3">
<div id="segmentedControls" class="mui-segmented-control mui-segmented-control-inverted mui-segmented-control-vertical">
</div>
</div>
<div id="segmentedControlContents" class="mui-col-xs-9" style="border-left: 1px solid #c8c7cc;">
</div>
</div>
<script src="../js/mui.min.js"></script>
<script>
mui.init({
swipeBack: true //启用右滑关闭功能
});
var controls = document.getElementById("segmentedControls");
var contents = document.getElementById("segmentedControlContents");
var html = [];
var i = 1,
j = 1,
m = 16, //左侧选项卡数量+1
n = 21; //每个选项卡列表数量+1
for (; i < m; i++) {
html.push('<a class="mui-control-item" data-index="' + (i - 1) + '" href="#content' + i + '">选项' + i + '</a>');
}
controls.innerHTML = html.join('');
html = [];
for (i = 1; i < m; i++) {
html.push('<div id="content' + i + '" class="mui-control-content"><ul class="mui-table-view">');
for (j = 1; j < n; j++) {
html.push('<li class="mui-table-view-cell">第' + i + '个选项卡子项-' + j + '</li>');
}
html.push('</ul></div>');
}
contents.innerHTML = html.join('');
//默认选中第一个
controls.querySelector('.mui-control-item').classList.add('mui-active');
// contents.querySelector('.mui-control-content').classList.add('mui-active');
(function() {
var controlsElem = document.getElementById("segmentedControls");
var contentsElem = document.getElementById("segmentedControlContents");
var controlListElem = controlsElem.querySelectorAll('.mui-control-item');
var contentListElem = contentsElem.querySelectorAll('.mui-control-content');
var controlWrapperElem = controlsElem.parentNode;
var controlWrapperHeight = controlWrapperElem.offsetHeight;
var controlMaxScroll = controlWrapperElem.scrollHeight - controlWrapperHeight;//左侧类别最大可滚动高度
var maxScroll = contentsElem.scrollHeight - contentsElem.offsetHeight;//右侧内容最大可滚动高度
var controlHeight = controlListElem[0].offsetHeight;//左侧类别每一项的高度
var controlTops = []; //存储control的scrollTop值
var contentTops = [0]; //存储content的scrollTop值
var length = contentListElem.length;
for (var i = 0; i < length; i++) {
controlTops.push(controlListElem[i].offsetTop + controlHeight);
}
for (var i = 1; i < length; i++) {
var offsetTop = contentListElem[i].offsetTop;
if (offsetTop + 100 >= maxScroll) {
var height = Math.max(offsetTop + 100 - maxScroll, 100);
var totalHeight = 0;
var heights = [];
for (var j = i; j < length; j++) {
var offsetHeight = contentListElem[j].offsetHeight;
totalHeight += offsetHeight;
heights.push(totalHeight);
}
for (var m = 0, len = heights.length; m < len; m++) {
contentTops.push(parseInt(maxScroll - (height - heights[m] / totalHeight * height)));
}
break;
} else {
contentTops.push(parseInt(offsetTop));
}
}
contentsElem.addEventListener('scroll', function() {
var scrollTop = contentsElem.scrollTop;
for (var i = 0; i < length; i++) {
var offsetTop = contentTops[i];
var offset = Math.abs(offsetTop - scrollTop);
// console.log("i:"+i+",scrollTop:"+scrollTop+",offsetTop:"+offsetTop+",offset:"+offset);
if (scrollTop < offsetTop) {
if (scrollTop >= maxScroll) {
onScroll(length - 1);
} else {
onScroll(i - 1);
}
break;
} else if (offset < 20) {
onScroll(i);
break;
}else if(scrollTop >= maxScroll){
onScroll(length - 1);
break;
}
}
});
var lastIndex = 0;
//监听content滚动
var onScroll = function(index) {
if (lastIndex !== index) {
lastIndex = index;
var lastActiveElem = controlsElem.querySelector('.mui-active');
lastActiveElem && (lastActiveElem.classList.remove('mui-active'));
var currentElem = controlsElem.querySelector('.mui-control-item:nth-child(' + (index + 1) + ')');
currentElem.classList.add('mui-active');
//简单处理左侧分类滚动,要么滚动到底,要么滚动到顶
var controlScrollTop = controlWrapperElem.scrollTop;
if (controlScrollTop + controlWrapperHeight < controlTops[index]) {
controlWrapperElem.scrollTop = controlMaxScroll;
} else if (controlScrollTop > controlTops[index] - controlHeight) {
controlWrapperElem.scrollTop = 0;
}
}
};
//滚动到指定content
var scrollTo = function(index) {
contentsElem.scrollTop = contentTops[index];
};
mui(controlsElem).on('tap', '.mui-control-item', function(e) {
scrollTo(this.getAttribute('data-index'));
return false;
});
})();
</script>

</body>

</html>
Loading

0 comments on commit b103b03

Please sign in to comment.