Skip to content

Commit

Permalink
update timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
cnyet committed Mar 1, 2019
1 parent 34d1577 commit e5a9dc9
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 23 deletions.
16 changes: 16 additions & 0 deletions demos/中文排序/sort.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
body {
margin: 0;
padding: 0
}

.arrange {
padding: 0 2%;
list-style-type: none
}

.arrange li {
border: 1px solid #dfdfdf;
height: 2em;
line-height: 2em;
padding-left: 2%
}
29 changes: 29 additions & 0 deletions demos/中文排序/sort.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>

<head>
<title>排序</title>
<meta charset="UTF-8">
</meta>
<meta author="alex">
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>

<body>
<ul class="arrange">
<li class="arrangeLi">你好</li>
<li class="arrangeLi">我是</li>
<li class="arrangeLi">安妮</li>
<li class="arrangeLi">可以</li>
<li class="arrangeLi">做个</li>
<li class="arrangeLi">一友</li>
</ul>
<script src="../../js/jquery.min.js" type="text/javascript"></script>
<script src="sortUnicode.js" type="text/javascript"></script>
<script src="sort.js" type="text/javascript"></script>
<script>
$(".arrange").sort();
</script>
</body>

</html>
109 changes: 109 additions & 0 deletions demos/中文排序/sort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
;(function($) {
var Arrange = function(ele, options) {
var list = ele.find("li.arrangeLi"); //获取容器下的li集合

this.dft = { //缺省值
"titleFontColor": "#fff",
"titleBgColor": "#adadad",
"conFontColor": "#000",
"conBgColor": "#fff",
"conBgColorHover": "#c2c2c2"
};
this.obj = $.extend("", this.dft, options);
this.obj.str = this.getStr(list);

//判断首字母数组
var pinYin = this.executive(this.obj.str); // 得到一串首字母数组
var arry = [];
for (var i = 0; i < pinYin.length; i++) {
arry[i] = pinYin[i];
}
var temp;
var arrangeLi = "";
for (var i = 0; i < pinYin.length - 1; i++) { //将出现的字符按ascii顺序由小到大存进数组
for (var j = 0; j < pinYin.length - 1 - i; j++) {
if (pinYin[j] > pinYin[j + 1]) {
temp = pinYin[j];
pinYin[j] = pinYin[j + 1];
pinYin[j + 1] = temp;
}
}
};
for (var i = 0; i < pinYin.length; i++) { //生成拥有的字符
if (pinYin[i] != pinYin[i - 1]) {
arrangeLi += "<li class='arrangeTitle " + pinYin[i] + "'><b>" + pinYin[i] + "</b></li>";
}
};
ele.html(arrangeLi);
for (var i = 0; i < this.obj.str.length; i++) { //将各字段放进相应的字符区间
var li = "<li class='arrangeCon'>" + this.obj.str[i] + "</li>";
ele.find("." + arry[i] + "").after(li);
};

this.setCss(this.obj);
}
Arrange.prototype = {
setCss: function(obj) { //设置样式
$(".arrangeTitle").css({
"color": obj.titleFontColor,
"backgroundColor": obj.titleBgColor
});
$(".arrangeCon").css({
"color": obj.conFontColor,
"backgroundColor": obj.conBgColor
});
$(".arrangeCon").hover(
function() {
$(this).css({
"backgroundColor": obj.conBgColorHover
});
},
function() {
$(this).css({
"backgroundColor": obj.conBgColor
});
}
);
},
executive: function(str) { //得到一串首字母数组
var isEnglishOrNum = /^[A-Za-z0-9]+$/; //正则验算是否英文字母或数字
var arr = []; //存储各字符串首字母
var j = 0;
for (var i = 0; i < str.length; i++) {
if (Object.prototype.toString.call(str[i]) === "[object String]") { //判断是否为字符串
var sing = str[i].substring(0, 1); //截取字符串首个字符
var ch = str[i].charCodeAt(0); //获取字符对应Unicode编码值
if (isEnglishOrNum.test(sing)) { //判断是否为英文字母或数字
arr[j++] = sing.toUpperCase(); //是则将字符赋值给数组
} else {

if (ch < 40869 && ch >= 19968) { //判断字符编码值在19968到40869之间
arr[j++] = strChineseFirstPY.charAt(ch - 19968); //获取对应表中的字母并赋值到数组
} else {
alert("字符串首字母仅支持字母和数字");
return false;
}
}
} else {
alert("请检查您输入的字符串数组是否有误");
return false;
}
}
return arr;
},
getStr: function(obj) { //获取当前对象下数组串
var str = [];
obj.each(function() {
str.push($(this).text());
})
return str;
}

}
$.fn.sort = function(options) {
this.each(function() {
var arr = new Arrange($(this), options);
})

}
})(jQuery);
6 changes: 6 additions & 0 deletions demos/中文排序/sortUnicode.js

Large diffs are not rendered by default.

36 changes: 28 additions & 8 deletions demos/补间动画/timeline.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ i{
width: 51px;
height: 51px;
margin: 18px auto 0;
background: transparent url("../../images/icon_01.png") no-repeat;
background-position: center;
background-size: 30px 26px;
}
.timeline_icon svg {
width: 51px;
Expand All @@ -57,8 +60,8 @@ i{
.timeline_list {
position: relative;
bottom: 0;
width: 450px;
height: 612px;
width: 500px;
height: 720px;
margin: 0 auto;
padding: 30px 0;
display: flex;
Expand All @@ -83,12 +86,12 @@ i{
}
.timeline_item b {
position: absolute;
width: 8px;
height: 8px;
width: 10px;
height: 10px;
border-radius: 50%;
left: 50%;
top: 50%;
margin: -4px 0 0 -4px;
margin: -5px 0 0 -5px;
z-index: 1;
background: #fff;
box-shadow: 0 0 0 8px #0084ff;
Expand All @@ -100,6 +103,8 @@ i{
.timeline_item_cnt {
flex: 1;
padding: 0 50px;
height: 32px;
line-height: 32px;
}
.timeline_item_cnt:nth-child(1){
text-align:right;
Expand All @@ -110,18 +115,24 @@ i{
.timeline_item_cnt.flag{
width: 55px;
height: 36px;

vertical-align: middle;
}
.timeline_item_cnt.time{
font-size: 20px;
}
.timeline_item_cnt.flag i{
display: inline-block;
width: 55px;
height: 36px;
height: 32px;
background-size: 100%;
}
.timeline_item_cnt.country{
font-size: 12px;
font-size: 20px;
color: #66b5ff;
}
.timeline_item_cnt.city{
font-size: 26px;
}
.timeline_line {
position: absolute;
width: 1px;
Expand All @@ -130,4 +141,13 @@ i{
top: 0;
left: 50%;
}
.flag_sin{
background: transparent url("../../images/icon_02.png") no-repeat;
}
.flag_us{
background: transparent url("../../images/icon_03.png") no-repeat;
}
.flag_uk{
background: transparent url("../../images/icon_04.png") no-repeat;
}

44 changes: 29 additions & 15 deletions demos/补间动画/timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,51 @@
<span class="timeline_item_cnt flag">
<i class="flag_sin"></i>
</span>
<span class="timeline_item_cnt country">
<i>Singapore</i>
</span>
<span class="timeline_item_cnt country">Singapore</span>
<b></b>
</li>
<li class="timeline_item">
<span class="timeline_item_cnt flag">
<i class="flag_sin"></i>
</span>
<span class="timeline_item_cnt country"></span>
<span class="timeline_item_cnt time">09/20</span>
<span class="timeline_item_cnt city">INSEAD</span>
<b></b>
</li>
<li class="timeline_item">
<span class="timeline_item_cnt flag">
<i class="flag_sin"></i>
</span>
<span class="timeline_item_cnt country"></span>
<span class="timeline_item_cnt time">09/21</span>
<span class="timeline_item_cnt city">NTU</span>
<b></b>
</li>
<li class="timeline_item timeline_item_sp">
<span class="timeline_item_cnt flag">
<i class="flag_sin"></i>
<i class="flag_us"></i>
</span>
<span class="timeline_item_cnt country"></span>
<span class="timeline_item_cnt country">U.S</span>
<b></b>
</li>
<li class="timeline_item">
<span class="timeline_item_cnt time">09/26</span>
<span class="timeline_item_cnt city">UCLA</span>
<b></b>
</li>
<li class="timeline_item">
<span class="timeline_item_cnt time">09/28</span>
<span class="timeline_item_cnt city">UC Berkely</span>
<b></b>
</li>
<li class="timeline_item">
<span class="timeline_item_cnt time">10/05</span>
<span class="timeline_item_cnt city">Wharton</span>
<b></b>
</li>
<li class="timeline_item timeline_item_sp">
<span class="timeline_item_cnt flag">
<i class="flag_sin"></i>
<i class="flag_uk"></i>
</span>
<span class="timeline_item_cnt country"></span>
<span class="timeline_item_cnt country">U.K</span>
<b></b>
</li>
<li class="timeline_item">
<span class="timeline_item_cnt time">10/05</span>
<span class="timeline_item_cnt city">Wharton</span>
<b></b>
</li>
<li class="timeline_line"></li>
Expand Down
Binary file added images/icon_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e5a9dc9

Please sign in to comment.