Skip to content

Commit

Permalink
add searchbar
Browse files Browse the repository at this point in the history
  • Loading branch information
sklme committed Feb 25, 2016
1 parent fdf5c3f commit f081257
Show file tree
Hide file tree
Showing 12 changed files with 463 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/example/example.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions dist/example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,49 @@ $(function () {
}
}
};
var searchbar = {
name:"searchbar",
url:"#searchbar",
template: '#tpl_searchbar',
events:{
'#weui_search_input':{
focus:function(){
//searchBar
var $weuiSearchBar = $('.weui_search_bar');
$weuiSearchBar.addClass('with_cancel');
},
blur:function(){
var $weuiSearchBar = $('.weui_search_bar');
$weuiSearchBar.removeClass('with_cancel');
if($(this).val()){
$('.weui_search_text').hide();
}else{
$('.weui_search_text').show();
}
},
input:function(){
var $searchShow = $(".search_show");
if($(this).val()){
$searchShow.show();
}else{
$searchShow.hide();
}
}
},
"#weui_search_cancel":{
touchend:function(){
$(".search_show").hide();
$('#weui_search_input').val('');
}
},
"#weui_search_clear":{
touchend:function(){
$(".search_show").hide();
$('#weui_search_input').val('');
}
}
}
};
var icons = {
name: 'icons',
url: '#icons',
Expand All @@ -334,6 +377,7 @@ $(function () {
.push(card)
.push(actionSheet)
.push(icons)
.push(searchbar)
.default('home')
.init();
});
54 changes: 54 additions & 0 deletions dist/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ <h1 class="page_title">WeUI</h1>
Icons
</p>
</a>
<a href="javascript:;" class="weui_grid js_grid" data-id="searchbar">
<div class="weui_grid_icon">
<img src="./images/icon_nav_icons.png" alt="">
</div>
<p class="weui_grid_label">
SearchBar
</p>
</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -766,6 +774,52 @@ <h1 class="page_title">Icons</h1>
</div>
</div>
</div>
</script>
<script type="text/html" id="tpl_searchbar">
<div class="page">
<div class="hd">
<h1 class="page_title">searchBar</h1>
</div>
<div class="bd">
<!--<a href="javascript:;" class="weui_btn weui_btn_primary">点击展现searchBar</a>-->
<div class="weui_search_bar">
<form class="weui_search_outer">
<div class="weui_search_inner">
<i class="weui_icon_search"></i>
<input type="search" class="weui_search_input" id="weui_search_input" placeholder="搜索" required/>
<a href="javascript:" class="weui_icon_clear" id="weui_search_clear"></a>
</div>
<label for="weui_search_input" class="weui_search_text">
<i class="weui_icon_search"></i>
<span>搜索</span>
</label>
</form>
<a href="javascript:" class="weui_search_cancel" id="weui_search_cancel">取消</a>
</div>
<div class="weui_cells weui_cells_access search_show">
<div class="weui_cell">
<div class="weui_cell_bd weui_cell_primary">
<p>实时搜索文本</p>
</div>
</div>
<div class="weui_cell">
<div class="weui_cell_bd weui_cell_primary">
<p>实时搜索文本</p>
</div>
</div>
<div class="weui_cell">
<div class="weui_cell_bd weui_cell_primary">
<p>实时搜索文本</p>
</div>
</div>
<div class="weui_cell">
<div class="weui_cell_bd weui_cell_primary">
<p>实时搜索文本</p>
</div>
</div>
</div>
</div>
</div>
</script>
<script src="./zepto.min.js"></script>
<script src="./example.js"></script>
Expand Down
140 changes: 139 additions & 1 deletion dist/style/weui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/style/weui.min.css

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions src/example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,49 @@ $(function () {
}
}
};
var searchbar = {
name:"searchbar",
url:"#searchbar",
template: '#tpl_searchbar',
events:{
'#weui_search_input':{
focus:function(){
//searchBar
var $weuiSearchBar = $('.weui_search_bar');
$weuiSearchBar.addClass('with_cancel');
},
blur:function(){
var $weuiSearchBar = $('.weui_search_bar');
$weuiSearchBar.removeClass('with_cancel');
if($(this).val()){
$('.weui_search_text').hide();
}else{
$('.weui_search_text').show();
}
},
input:function(){
var $searchShow = $(".search_show");
if($(this).val()){
$searchShow.show();
}else{
$searchShow.hide();
}
}
},
"#weui_search_cancel":{
touchend:function(){
$(".search_show").hide();
$('#weui_search_input').val('');
}
},
"#weui_search_clear":{
touchend:function(){
$(".search_show").hide();
$('#weui_search_input').val('');
}
}
}
};
var icons = {
name: 'icons',
url: '#icons',
Expand All @@ -334,6 +377,7 @@ $(function () {
.push(card)
.push(actionSheet)
.push(icons)
.push(searchbar)
.default('home')
.init();
});
11 changes: 11 additions & 0 deletions src/example/example.less
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ body, .page {
}
}

//search bar
.search_show {
display: none;
margin-top: 0;
font-size: 14px;
.weui_cell_bd{
padding:2px 0 2px 20px;
color:#666;
}
}

@keyframes slideIn {
from {
transform: translate3d(100%, 0, 0);
Expand Down
8 changes: 8 additions & 0 deletions src/example/fragment/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ <h1 class="page_title">WeUI</h1>
Icons
</p>
</a>
<a href="javascript:;" class="weui_grid js_grid" data-id="searchbar">
<div class="weui_grid_icon">
<img src="./images/icon_nav_icons.png" alt="">
</div>
<p class="weui_grid_label">
SearchBar
</p>
</a>
</div>
</div>
</div>
44 changes: 44 additions & 0 deletions src/example/fragment/searchbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<div class="page">
<div class="hd">
<h1 class="page_title">searchBar</h1>
</div>
<div class="bd">
<!--<a href="javascript:;" class="weui_btn weui_btn_primary">点击展现searchBar</a>-->
<div class="weui_search_bar">
<form class="weui_search_outer">
<div class="weui_search_inner">
<i class="weui_icon_search"></i>
<input type="search" class="weui_search_input" id="weui_search_input" placeholder="搜索" required/>
<a href="javascript:" class="weui_icon_clear" id="weui_search_clear"></a>
</div>
<label for="weui_search_input" class="weui_search_text">
<i class="weui_icon_search"></i>
<span>搜索</span>
</label>
</form>
<a href="javascript:" class="weui_search_cancel" id="weui_search_cancel">取消</a>
</div>
<div class="weui_cells weui_cells_access search_show">
<div class="weui_cell">
<div class="weui_cell_bd weui_cell_primary">
<p>实时搜索文本</p>
</div>
</div>
<div class="weui_cell">
<div class="weui_cell_bd weui_cell_primary">
<p>实时搜索文本</p>
</div>
</div>
<div class="weui_cell">
<div class="weui_cell_bd weui_cell_primary">
<p>实时搜索文本</p>
</div>
</div>
<div class="weui_cell">
<div class="weui_cell_bd weui_cell_primary">
<p>实时搜索文本</p>
</div>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions src/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<link rel="import" href="./fragment/card.html">
<link rel="import" href="./fragment/actionsheet.html">
<link rel="import" href="./fragment/icons.html">
<link rel="import" href="./fragment/searchbar.html">
<script src="./zepto.min.js"></script>
<script src="./example.js"></script>
</body>
Expand Down
3 changes: 3 additions & 0 deletions src/style/weui.less
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@

//action sheet
@import "./widget/weui_tips/weui_actionsheet";

//searchbar
@import "./widget/weui_searchbar/weuui_searchbar";
Loading

0 comments on commit f081257

Please sign in to comment.