forked from GoAdminGroup/go-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qrcode.go
40 lines (32 loc) · 894 Bytes
/
qrcode.go
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
package display
import (
"html/template"
"github.com/kotovmak/go-admin/template/types"
)
type Qrcode struct {
types.BaseDisplayFnGenerator
}
func init() {
types.RegisterDisplayFnGenerator("qrcode", new(Qrcode))
}
func (q *Qrcode) Get(args ...interface{}) types.FieldFilterFn {
return func(value types.FieldModel) interface{} {
src := `https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=` + value.Value
return template.HTML(`
<a href="javascript:void(0);" class="grid-column-qrcode text-muted"
data-content="<img src='` + src + `'
style='height:150px;width:150px;'/>" data-toggle="popover" tabindex="0" data-original-title="" title="">
<i class="fa fa-qrcode"></i>
</a> ` + value.Value + `
`)
}
}
func (q *Qrcode) JS() template.HTML {
return template.HTML(`
$('.grid-column-qrcode').popover({
html: true,
container: 'body',
trigger: 'focus'
});
`)
}