search.js
1.14 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
/**
* 我的信息
* @author: yyqing<yanqing.yang@yoho.cn>
* @date: 2016/3/23
*/
var $ = require('yoho.jquery'),
Handlebars = require('yoho.handlebars');
var $searchMain = $('.search-content'),
$dialog = $('#help-dialog-widget'),
$dialogBg = $('#help-dialog-bg');
var docW = $(document).width(),
winH = $(window).height();
var tpl =
'<div class="dialog-titlebar">' +
'<span class="dialog-close-btn"></span>' +
'</div>' +
'<div class="dialog-content">' +
'<p class="ask">问:<br>{{ask}}</p>' +
'<p class="answer">答:<br>{{answer}}</p>' +
'</div>';
var tplFn = Handlebars.compile(tpl);
$searchMain.on('click', '.faqs', function() {
var data = $(this).data(),
top = $(document).scrollTop();
$dialog.html(tplFn(data)).removeClass('hide');
$dialogBg.removeClass('hide');
$dialog.html(tplFn(data)).css({
top: top + (winH - $dialog.outerHeight()) / 2,
left: (docW - $dialog.outerWidth()) / 2
});
});
$dialog.on('click', '.dialog-close-btn', function() {
$dialog.addClass('hide');
$dialogBg.addClass('hide');
});