Authored by xuqi

good del opt

@@ -10,14 +10,29 @@ var $ = require('yoho.zepto'), @@ -10,14 +10,29 @@ var $ = require('yoho.zepto'),
10 10
11 var chosePanel = require('./chose-panel'); 11 var chosePanel = require('./chose-panel');
12 12
  13 +function docTouchEvt(e) {
  14 + var $tar = $(e.target);
  15 +
  16 + if ($tar.closest('.opt-panel').length === 0) {
  17 + $('.opt-panel:not(.hide)').addClass('hide');
  18 +
  19 + //
  20 + $(document).unbind('touchstart', docTouchEvt);
  21 + }
  22 +}
  23 +
  24 +// function unbindDocTouchEvt(e) {
  25 +// $(document).unbind('touchstart', docTouchEvt);
  26 +// }
  27 +
13 ellipsis.init(); 28 ellipsis.init();
14 29
15 lazyLoad($('.lazy')); 30 lazyLoad($('.lazy'));
16 31
17 $('.name')[0].mlellipsis(2); 32 $('.name')[0].mlellipsis(2);
18 33
19 -//checkbox toggle status  
20 -$('.checkbox').bind('touchstart', function() { 34 +//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
  35 +$('.cart-goods').delegate('.checkbox', 'touchstart', function() {
21 var $this = $(this); 36 var $this = $(this);
22 37
23 if ($this.hasClass('icon-cb-checked')) { 38 if ($this.hasClass('icon-cb-checked')) {
@@ -25,9 +40,7 @@ $('.checkbox').bind('touchstart', function() { @@ -25,9 +40,7 @@ $('.checkbox').bind('touchstart', function() {
25 } else { 40 } else {
26 $this.removeClass('icon-checkbox').addClass('icon-cb-checked'); 41 $this.removeClass('icon-checkbox').addClass('icon-cb-checked');
27 } 42 }
28 -});  
29 -  
30 -$('.icon-edit').bind('touchstart', function() { 43 +}).delegate('.icon-edit', 'touchstart', function() {
31 var id = $(this).closest('.shopping-cart-good').data('id'); 44 var id = $(this).closest('.shopping-cart-good').data('id');
32 45
33 $.ajax({ 46 $.ajax({
@@ -42,5 +55,9 @@ $('.icon-edit').bind('touchstart', function() { @@ -42,5 +55,9 @@ $('.icon-edit').bind('touchstart', function() {
42 } 55 }
43 } 56 }
44 }); 57 });
  58 +}).delegate('.icon-del', 'touchstart', function() {
  59 + $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
  60 +
  61 + $(document).bind('touchstart', docTouchEvt);
45 }); 62 });
46 63
@@ -105,19 +105,38 @@ @@ -105,19 +105,38 @@
105 } 105 }
106 106
107 .opt-panel { 107 .opt-panel {
108 - display: none;  
109 - 108 + position: absolute;
110 width: 220rem / $pxConvertRem; 109 width: 220rem / $pxConvertRem;
111 height: 190rem / $pxConvertRem; 110 height: 190rem / $pxConvertRem;
  111 + right: 0;
112 112
113 color: #fff; 113 color: #fff;
114 114
  115 + > div {
  116 + float: left;
  117 + box-sizing: border-box;
  118 + width: 110rem / $pxConvertRem;
  119 + height: 100%;
  120 + text-align: center;
  121 + padding: 40rem / $pxConvertRem 20rem / $pxConvertRem 0;
  122 + font-size: 15px;
  123 + }
  124 +
  125 + span {
  126 + display: block;
  127 + }
  128 +
115 .put-in-favorite { 129 .put-in-favorite {
116 background: #bbb; 130 background: #bbb;
  131 +
117 } 132 }
118 133
119 .del { 134 .del {
120 background: #999; 135 background: #999;
  136 +
  137 + .iconfont {
  138 + margin-bottom: 20rem / $pxConvertRem;
  139 + }
121 } 140 }
122 } 141 }
123 } 142 }
@@ -4,6 +4,10 @@ @@ -4,6 +4,10 @@
4 .icon-checkbox:before { content: "\e61c"; } 4 .icon-checkbox:before { content: "\e61c"; }
5 .icon-cb-checked:before { content: "\e61d"; } 5 .icon-cb-checked:before { content: "\e61d"; }
6 6
  7 +.shopping-cart-page {
  8 + padding-bottom: 120rem / $pxConvertRem;
  9 +}
  10 +
7 .cart-nav { 11 .cart-nav {
8 height: 30rem / $pxConvertRem; 12 height: 30rem / $pxConvertRem;
9 color: #c6c6c6; 13 color: #c6c6c6;
@@ -96,6 +100,7 @@ @@ -96,6 +100,7 @@
96 padding: 20rem / $pxConvertRem; 100 padding: 20rem / $pxConvertRem;
97 height: 120rem / $pxConvertRem; 101 height: 120rem / $pxConvertRem;
98 border-top: 1px solid #e0e0e0; 102 border-top: 1px solid #e0e0e0;
  103 + background: #fff;
99 104
100 .iconfont { 105 .iconfont {
101 position: absolute; 106 position: absolute;
@@ -47,13 +47,14 @@ @@ -47,13 +47,14 @@
47 </p> 47 </p>
48 </div> 48 </div>
49 </div> 49 </div>
50 - <div class="opt-panel"> 50 + <div class="opt-panel hide">
51 <div class="put-in-favorite"> 51 <div class="put-in-favorite">
52 <span class="iconfont">&#xe622;</span> 52 <span class="iconfont">&#xe622;</span>
53 - 移入收藏夹 53 + <span>移入</span>
  54 + 收藏夹
54 </div> 55 </div>
55 <div class="del"> 56 <div class="del">
56 - <span class="iconfont">&#xe61a;</span> 57 + <span class="iconfont">&#xe626;</span>
57 删除 58 删除
58 </div> 59 </div>
59 </div> 60 </div>