Showing
5 changed files
with
121 additions
and
15 deletions
@@ -49,11 +49,9 @@ | @@ -49,11 +49,9 @@ | ||
49 | <button class="btn active radius" data-role="showCommentForm">评价商品</button> | 49 | <button class="btn active radius" data-role="showCommentForm">评价商品</button> |
50 | </td> | 50 | </td> |
51 | </tr> | 51 | </tr> |
52 | - <tr data-role="commentAddForm" class="hide"> | 52 | + <tr data-role="commentAddForm" class="m-hide"> |
53 | <td colspan="3" class="comment-add"> | 53 | <td colspan="3" class="comment-add"> |
54 | - <em class="arrow"> | ||
55 | - <em class="arrow-in"></em> | ||
56 | - </em> | 54 | + <div class="arrow"><i></i><em></em></div> |
57 | <div class="row"> | 55 | <div class="row"> |
58 | <label class="fl-left"><i class="color-warn require-sign">*</i> 商品满意度:</label> | 56 | <label class="fl-left"><i class="color-warn require-sign">*</i> 商品满意度:</label> |
59 | <span class="comment-star editable"> | 57 | <span class="comment-star editable"> |
@@ -87,10 +85,9 @@ | @@ -87,10 +85,9 @@ | ||
87 | <textarea name="goodsComment"></textarea> | 85 | <textarea name="goodsComment"></textarea> |
88 | </div> | 86 | </div> |
89 | <div class="row img-list clearfix"> | 87 | <div class="row img-list clearfix"> |
90 | - <div class="img-preview"> | ||
91 | - <img src="" /> | 88 | + <div class="img-preview selected"> |
92 | <img src="" alt=""> | 89 | <img src="" alt=""> |
93 | - <input type="file" /> | 90 | + <input type="file" id="upload-{{@index}}" /> |
94 | <i class="view">查看</i> | 91 | <i class="view">查看</i> |
95 | <i class="del">删除</i> | 92 | <i class="del">删除</i> |
96 | </div> | 93 | </div> |
@@ -120,6 +117,8 @@ | @@ -120,6 +117,8 @@ | ||
120 | <div class="clearfix"> | 117 | <div class="clearfix"> |
121 | <div class="img-preview selected"> | 118 | <div class="img-preview selected"> |
122 | <img src="{{img}}" /> | 119 | <img src="{{img}}" /> |
120 | + <i class="view">查看</i> | ||
121 | + <i class="del">删除</i> | ||
123 | </div> | 122 | </div> |
124 | </div> | 123 | </div> |
125 | <p class="color-gray">评论时间:2016-10-10 21:21:21</p> | 124 | <p class="color-gray">评论时间:2016-10-10 21:21:21</p> |
public/js/common/img-preview.js
0 → 100644
1 | +/** | ||
2 | + * 图片预览 | ||
3 | + * @author: liuchuanyang<chuanyang.liu@yoho.cn> | ||
4 | + * @date: 2016/10/27 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho-jquery'), | ||
8 | + Handlebars = require('yoho-handlebars'), | ||
9 | + Dialog = require('./dialog').Dialog; | ||
10 | + | ||
11 | +var tpl = '<div class="toolbar">' + | ||
12 | + '<span class="preview-route-left"><i class="iconfont"></i>向左转</span>' + | ||
13 | + '<span class="preview-route-right"><i class="iconfont"></i>向右转</span>' + | ||
14 | + '</div>' + | ||
15 | + '<div class="preview-body"><img /></div>'; | ||
16 | + | ||
17 | +var tplFn = Handlebars.compile(tpl); | ||
18 | + | ||
19 | +function ImgPreview(url, opt) { | ||
20 | + var that = this; | ||
21 | + | ||
22 | + var option = { | ||
23 | + content: tplFn(), | ||
24 | + className: 'img-preview-dialog' | ||
25 | + }; | ||
26 | + | ||
27 | + Dialog.call(this, $.extend({}, opt || {}, option)); | ||
28 | + | ||
29 | + this._data = { | ||
30 | + url: url, | ||
31 | + rotate: 0 | ||
32 | + }; | ||
33 | + | ||
34 | + this.$previewBody = this.$el.find('.preview-body'); | ||
35 | + this.$img = this.$previewBody.find('img'); | ||
36 | + this.$toolbar = this.$el.find('.toolbar'); | ||
37 | + | ||
38 | + this.$toolbar.on('click', '.preview-route-left', function() { | ||
39 | + that.rotateLeft(); | ||
40 | + }); | ||
41 | + | ||
42 | + this.$toolbar.on('click', '.preview-route-right', function() { | ||
43 | + that.rotateRight(); | ||
44 | + }); | ||
45 | +} | ||
46 | + | ||
47 | +ImgPreview.prototype = new Dialog({ | ||
48 | + inherit: true | ||
49 | +}); | ||
50 | + | ||
51 | +ImgPreview.prototype.preview = function(url) { | ||
52 | + | ||
53 | + if (url) { | ||
54 | + this._data.url = url; | ||
55 | + } | ||
56 | + | ||
57 | + this._data.rotate = 0; | ||
58 | + this.$img.attr('src', this._data.url); | ||
59 | + | ||
60 | + this.show(); | ||
61 | +}; | ||
62 | + | ||
63 | +ImgPreview.prototype.refresh = function() { | ||
64 | + this.$img.css('transform', 'rotate(' + this._data.rotate + 'deg)'); | ||
65 | +}; | ||
66 | + | ||
67 | +ImgPreview.prototype.rotateLeft = function() { | ||
68 | + this._data.rotate = this._data.rotate - 90; | ||
69 | + this.refresh(); | ||
70 | +}; | ||
71 | + | ||
72 | +ImgPreview.prototype.rotateRight = function() { | ||
73 | + this._data.rotate = this._data.rotate + 90; | ||
74 | + this.refresh(); | ||
75 | +}; | ||
76 | + | ||
77 | +ImgPreview.prototype.constructor = ImgPreview; | ||
78 | +module.exports = ImgPreview; |
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | * @date: 2016/3/1 | 4 | * @date: 2016/3/1 |
5 | */ | 5 | */ |
6 | var $ = require('yoho-jquery'); | 6 | var $ = require('yoho-jquery'); |
7 | +var ImgPreview = require('../common/img-preview'); | ||
7 | 8 | ||
8 | var $comment = $('.comment-table'), | 9 | var $comment = $('.comment-table'), |
9 | $remarkBtn = $comment.find('.remark-btn'); | 10 | $remarkBtn = $comment.find('.remark-btn'); |
@@ -14,7 +15,8 @@ var $dialog = $('#comment-dialog-widget'), | @@ -14,7 +15,8 @@ var $dialog = $('#comment-dialog-widget'), | ||
14 | 15 | ||
15 | var pageW = $(document).width(), | 16 | var pageW = $(document).width(), |
16 | pageH = $(document).height(), | 17 | pageH = $(document).height(), |
17 | - winH = $(window).height(); | 18 | + winH = $(window).height(), |
19 | + preview = new ImgPreview(); | ||
18 | 20 | ||
19 | var dialog = { | 21 | var dialog = { |
20 | canmove: false, | 22 | canmove: false, |
@@ -90,6 +92,13 @@ $(document).mousemove(function(e) { | @@ -90,6 +92,13 @@ $(document).mousemove(function(e) { | ||
90 | dialog.canmove = false; | 92 | dialog.canmove = false; |
91 | }); | 93 | }); |
92 | 94 | ||
95 | +$('.img-preview').on('click', 'i.view', function() { | ||
96 | + | ||
97 | + var url = $(this).closest('.img-preview').find('img').attr('src'); | ||
98 | + | ||
99 | + preview.preview(url); | ||
100 | +}); | ||
101 | + | ||
93 | $dialog.on('click', '.dialog-save-btn', function() { | 102 | $dialog.on('click', '.dialog-save-btn', function() { |
94 | var remark = $.trim($commentArea.val()), | 103 | var remark = $.trim($commentArea.val()), |
95 | param; | 104 | param; |
@@ -126,8 +135,8 @@ $dialog.on('click', '.dialog-close-btn', function() { | @@ -126,8 +135,8 @@ $dialog.on('click', '.dialog-close-btn', function() { | ||
126 | $dialog.addClass('hide'); | 135 | $dialog.addClass('hide'); |
127 | }); | 136 | }); |
128 | 137 | ||
129 | -$('.comment-add input:file').each(function(e) { | ||
130 | - var $this = $('#upload-img-' + e), | 138 | +$('.comment-add input[type="file"]').each(function(i, it) { |
139 | + var $this = $(it), | ||
131 | $par = $this.closest('.problem-description'); | 140 | $par = $this.closest('.problem-description'); |
132 | 141 | ||
133 | if (!window.location.origin) { | 142 | if (!window.location.origin) { |
@@ -140,8 +149,8 @@ $('.comment-add input:file').each(function(e) { | @@ -140,8 +149,8 @@ $('.comment-add input:file').each(function(e) { | ||
140 | file_post_name: 'fileData', | 149 | file_post_name: 'fileData', |
141 | button_text: '<span class="btn_upload_text">上传图片</span>', | 150 | button_text: '<span class="btn_upload_text">上传图片</span>', |
142 | button_text_style: '.btn_upload_text{color: #ffffff;}', | 151 | button_text_style: '.btn_upload_text{color: #ffffff;}', |
143 | - button_width: 116, | ||
144 | - button_height: 33, | 152 | + button_width: 60, |
153 | + button_height: 60, | ||
145 | button_text_left_padding: 32, | 154 | button_text_left_padding: 32, |
146 | button_text_top_padding: 8, | 155 | button_text_top_padding: 8, |
147 | button_action: window.SWFUpload.BUTTON_ACTION.SELECT_FILE, | 156 | button_action: window.SWFUpload.BUTTON_ACTION.SELECT_FILE, |
@@ -169,6 +178,11 @@ $('.comment-add input:file').each(function(e) { | @@ -169,6 +178,11 @@ $('.comment-add input:file').each(function(e) { | ||
169 | // comment form | 178 | // comment form |
170 | $('.comment-table').on('click', '[data-role="showCommentForm"]', function() { | 179 | $('.comment-table').on('click', '[data-role="showCommentForm"]', function() { |
171 | // $('[data-role="showCommentForm"]). | 180 | // $('[data-role="showCommentForm"]). |
181 | + var $ntr = $(this).closest('tr').next('tr'); | ||
182 | + | ||
183 | + if ($ntr.attr('data-role') === 'commentAddForm') { | ||
184 | + $ntr.toggle(); | ||
185 | + } | ||
172 | }); | 186 | }); |
173 | 187 | ||
174 | 188 |
public/scss/common/_img-preview.css
0 → 100644
@@ -33,6 +33,9 @@ | @@ -33,6 +33,9 @@ | ||
33 | .fl-left{ | 33 | .fl-left{ |
34 | float: left; | 34 | float: left; |
35 | } | 35 | } |
36 | + .m-hide{ | ||
37 | + display:none; | ||
38 | + } | ||
36 | .comment .title { | 39 | .comment .title { |
37 | background-image: resolve(img/home/comment.png); | 40 | background-image: resolve(img/home/comment.png); |
38 | } | 41 | } |
@@ -185,22 +188,31 @@ | @@ -185,22 +188,31 @@ | ||
185 | padding: 20px 50px; | 188 | padding: 20px 50px; |
186 | position:relative; | 189 | position:relative; |
187 | 190 | ||
188 | - .arrow,.arrow-in{ | 191 | + .arrow { |
189 | position: absolute; | 192 | position: absolute; |
193 | + width:40px; | ||
194 | + height:20px; | ||
190 | left:75%; | 195 | left:75%; |
191 | margin-left:-20px; | 196 | margin-left:-20px; |
192 | - top:-40px; | 197 | + top:-20px; |
198 | + overflow:hidden; | ||
199 | + | ||
200 | + i, em { | ||
201 | + position: absolute; | ||
193 | width:0; | 202 | width:0; |
194 | height:0; | 203 | height:0; |
204 | + left: 0; | ||
205 | + top:-20px; | ||
195 | border-color: transparent transparent #CCC transparent; | 206 | border-color: transparent transparent #CCC transparent; |
196 | border-width:20px; | 207 | border-width:20px; |
197 | border-style:dashed dashed solid dashed; | 208 | border-style:dashed dashed solid dashed; |
198 | } | 209 | } |
199 | - .arrow-in{ | 210 | + em { |
200 | border-color: transparent transparent #FFF transparent; | 211 | border-color: transparent transparent #FFF transparent; |
201 | top:-19px; | 212 | top:-19px; |
202 | left:0; | 213 | left:0; |
203 | } | 214 | } |
215 | + } | ||
204 | .row { | 216 | .row { |
205 | margin-bottom:16px; | 217 | margin-bottom:16px; |
206 | 218 |
-
Please register or login to post a comment