suggest.js
1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* 个人中心--意见反馈
* @author: chenglong<chenglong.wang@yoho.cn>
* @date: 2015/11/12
*/
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
Handlebars = require('yoho.handlebars');
var $uploadImgList = $('.upload-img-list'),
headerNavHammer,
imgTpl,
template;
require('./jquery.uploadifive');
$('#upload-img').uploadifive({
auto: true,
fileType: 'image*/*',
uploadScript: '/home/suggestimgUpload',
fileObjName: 'fileData',
fileSizeLimit: 1024,
height: '100%',
width: '100%',
onAddQueueItem: function (files) {
//TODO
},
onUploadComplete: function (file, data) {
$uploadImgList.html(template(data));
}
});
imgTpl = '{{# imgList}}' +
'<li><img src="{{imgUrl}}" /></li>' +
'{{/ imgList}}';
template = Handlebars.compile(imgTpl);
headerNavHammer = new Hammer(document.getElementById('yoho-header'));
headerNavHammer.on('tap', function (e) {
var suggestText = $('#suggest-textarea').val();
if ($(e.target).hasClass('nav-btn')) {
$.ajax({
method: 'post',
url: '/home/savesuggest',
data: {
content: suggestText
}
}).then(function (data) {
//TODO
}).fail(function () {
//TODO
});
}
});