예제 #1
0
func tplNavTabList(conf NavTabList) string {
	var _buf bytes.Buffer
	if conf.CustomClass == "" {
		conf.CustomClass = "nav-pills"
	}
	_buf.WriteString(`    <ul class="nav `)
	_buf.WriteString(kmgXss.H(conf.CustomClass))
	_buf.WriteString(`">
   `)
	for _, opt := range conf.OptionList {
		_buf.WriteString(`    <li
        `)
		if opt.Name == conf.ActiveName {
			_buf.WriteString(`           class="active")
        `)
		}
		_buf.WriteString(`            >
        <a href="`)
		_buf.WriteString(kmgXss.H(opt.Url))
		_buf.WriteString(`">`)
		_buf.WriteString(kmgXss.H(opt.Name))
		_buf.WriteString(`</a>
    </li>
    `)
	}
	_buf.WriteString(`</ul>`)
	return _buf.String()
}
예제 #2
0
파일: tplChart.go 프로젝트: keysonZZZ/kmg
func tplChart(chartData Chart) string {
	var _buf bytes.Buffer
	if chartData.Option.Title.Text != "" {
		_buf.WriteString(`<h6>`)
		_buf.WriteString(kmgXss.H(chartData.Option.Title.Text))
		_buf.WriteString(`</h6>`)
	}
	_buf.WriteString(`<div>
    <div id="`)
	_buf.WriteString(kmgXss.H(chartData.domId))
	_buf.WriteString(`" style="margin-top: -50px;margin-bottom: -35px;width: `)
	_buf.WriteString(kmgXss.H(chartData.Width))
	_buf.WriteString(`;height: `)
	_buf.WriteString(kmgXss.H(chartData.Height))
	_buf.WriteString(`;">
    </div>
    <script>
        (function () {
            var chart = echarts.init(document.getElementById(`)
	_buf.WriteString(kmgXss.Jsonv(chartData.domId))
	_buf.WriteString(`));
            var option = `)
	_buf.WriteString(chartData.GetOptionString())
	_buf.WriteString(`;
            `)
	_buf.WriteString(chartData.JS)
	_buf.WriteString(`            chart.setOption(option);
        })();
    </script>
</div>`)
	return _buf.String()
}
예제 #3
0
파일: tplButton.go 프로젝트: keysonZZZ/kmg
func tplButton(button Button) string {
	var _buf bytes.Buffer
	_buf.WriteString(`<`)
	_buf.WriteString(kmgXss.H(string(button.Type)))
	_buf.WriteString(` `)
	if button.FormId != "" {
		_buf.WriteString(` form="`)
		_buf.WriteString(kmgXss.H(button.FormId))
		_buf.WriteString(`" `)
	}
	if button.Type == ButtonTypeA {
		_buf.WriteString(`    `)
		if button.Url == "" {
			_buf.WriteString(`    href="javascript:void(0);"
    `)
		} else {
			_buf.WriteString(`    href="`)
			_buf.WriteString(kmgXss.H(button.Url))
			_buf.WriteString(`"
    `)
		}
	}
	if button.Name != "" {
		_buf.WriteString(`    name="`)
		_buf.WriteString(kmgXss.H(button.Name))
		_buf.WriteString(`"`)
	}
	if button.Value != "" {
		_buf.WriteString(`    value="`)
		_buf.WriteString(kmgXss.H(button.Value))
		_buf.WriteString(`"`)
	}
	if button.Type == ButtonTypeButton {
		_buf.WriteString(`    type="submit"`)
	}
	if button.AttributeNode != nil {
		_buf.WriteString(`    `)
		_buf.WriteString(button.AttributeNode.HtmlRender())
	}
	_buf.WriteString(`class="btn `)
	_buf.WriteString(kmgXss.H(string(button.Color)))
	_buf.WriteString(` `)
	_buf.WriteString(kmgXss.H(string(button.Size)))
	_buf.WriteString(` `)
	_buf.WriteString(kmgXss.H(button.ClassName))
	_buf.WriteString(`"
id="`)
	_buf.WriteString(kmgXss.H(button.Id))
	_buf.WriteString(`"
>
    `)
	_buf.WriteString(button.Content.HtmlRender())
	_buf.WriteString(`</`)
	_buf.WriteString(kmgXss.H(string(button.Type)))
	_buf.WriteString(`>`)
	return _buf.String()
}
예제 #4
0
func (a A) HtmlRender() string {
	s := `<a href="` + kmgXss.H(a.Href) + `" class="` + kmgXss.H(a.ClassName) + `"`
	if a.IsNewWindow {
		s += ` target="_blank" `
	}
	if a.Id != "" {
		s += ` id="` + kmgXss.H(a.Id) + `" `
	}
	return s + `>` + kmgXss.H(a.Title) + `</a>`
}
예제 #5
0
func tplTextArea(config TextArea) string {
	var _buf bytes.Buffer
	_buf.WriteString(`        <textarea autocomplete="off" class="form-control"
                    `)
	if config.ReadOnly {
		_buf.WriteString(` readonly `)
	}
	_buf.WriteString(`                name="`)
	_buf.WriteString(kmgXss.H(config.Name))
	_buf.WriteString(`" cols="30" rows="10" >`)
	_buf.WriteString(kmgXss.H(config.Value))
	_buf.WriteString(`</textarea>`)
	return _buf.String()
}
예제 #6
0
파일: tplIcon.go 프로젝트: keysonZZZ/kmg
func tplIcon(icon Icon) string {
	var _buf bytes.Buffer
	_buf.WriteString(`<i class="`)
	_buf.WriteString(kmgXss.H(string(icon.IconColor)))
	_buf.WriteString(` fa fa-`)
	_buf.WriteString(kmgXss.H(icon.IconName))
	_buf.WriteString(`"
    `)
	if icon.AttributeNode != nil {
		_buf.WriteString(`        `)
		_buf.WriteString(icon.AttributeNode.HtmlRender())
		_buf.WriteString(`    `)
	}
	_buf.WriteString(`></i>`)
	return _buf.String()
}
예제 #7
0
파일: tplPopover.go 프로젝트: keysonZZZ/kmg
func tplPopover(popover Popover) string {
	var _buf bytes.Buffer
	_buf.WriteString(`data-toggle="`)
	_buf.WriteString(kmgXss.H(string(popover.Type)))
	_buf.WriteString(`"
data-placement="`)
	_buf.WriteString(kmgXss.H(string(popover.Placement)))
	_buf.WriteString(`"
title="`)
	_buf.WriteString(popover.Title)
	_buf.WriteString(`"
data-content="`)
	_buf.WriteString(popover.Content)
	_buf.WriteString(`"
data-html="true"`)
	return _buf.String()
}
예제 #8
0
func (l Label) HtmlRender() string {
	if l.Color == "" {
		l.Color = LabelColorDefault
	}
	if l.Content == nil {
		return ""
	}
	return `<span class="label ` + kmgXss.H(string(l.Color)) + `">` + l.Content.HtmlRender() + `</span>`
}
예제 #9
0
func tplNavBarNode(node NavBarNode, level int) string {
	var _buf bytes.Buffer
	_buf.WriteString(`    `)
	if len(node.ChildList) == 0 {
		_buf.WriteString(`        <li><a href="`)
		_buf.WriteString(kmgXss.H(node.Url))
		_buf.WriteString(`">`)
		_buf.WriteString(kmgXss.H(node.Name))
		_buf.WriteString(`</a></li>
    `)
	} else if level == 0 {
		_buf.WriteString(`        <li class="dropdown">
            <a href="javascript:" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">`)
		_buf.WriteString(kmgXss.H(node.Name))
		_buf.WriteString(` <span class="caret"></span></a>
            <ul class="dropdown-menu">
                `)
		for _, subNode := range node.ChildList {
			_buf.WriteString(`                    `)
			_buf.WriteString(tplNavBarNode(subNode, level+1))
			_buf.WriteString(`                `)
		}
		_buf.WriteString(`            </ul>
        </li>
    `)
	} else {
		_buf.WriteString(`        <li class="dropdown-submenu">
            <a href="javascript:">`)
		_buf.WriteString(kmgXss.H(node.Name))
		_buf.WriteString(`</a>
            <ul class="dropdown-menu">
                `)
		for _, subNode := range node.ChildList {
			_buf.WriteString(`                `)
			_buf.WriteString(tplNavBarNode(subNode, level+1))
			_buf.WriteString(`                `)
		}
		_buf.WriteString(`            </ul>
        </li>`)
	}
	return _buf.String()
}
예제 #10
0
파일: tplSelect.go 프로젝트: keysonZZZ/kmg
func tplSelect(config Select) string {
	var _buf bytes.Buffer
	_buf.WriteString(`    <select class="form-control" `)
	if config.ReadOnly {
		_buf.WriteString(` disabled="true" `)
	} else {
		_buf.WriteString(` name="`)
		_buf.WriteString(kmgXss.H(config.Name))
		_buf.WriteString(`" `)
	}
	_buf.WriteString(` >
        `)
	for _, opt := range config.OptionList {
		_buf.WriteString(`        <option value="`)
		_buf.WriteString(kmgXss.H(opt.Value))
		_buf.WriteString(`" `)
		if opt.Value == config.Value {
			_buf.WriteString(` selected `)
		}
		_buf.WriteString(` `)
		if opt.Disable {
			_buf.WriteString(` disabled style="color:#ccc;background: #fff" `)
		}
		_buf.WriteString(` >
        `)
		_buf.WriteString(kmgXss.H(opt.ShowName))
		_buf.WriteString(`        </option>
        `)
	}
	_buf.WriteString(`    </select>
    `)
	if config.ReadOnly {
		_buf.WriteString(`    <input type="hidden" name="`)
		_buf.WriteString(kmgXss.H(config.Name))
		_buf.WriteString(`" value="`)
		_buf.WriteString(kmgXss.H(config.Value))
		_buf.WriteString(`">
    `)
	}
	return _buf.String()
}
예제 #11
0
파일: tplForm.go 프로젝트: keysonZZZ/kmg
func tplForm(config Form) string {
	method := "post"
	if config.IsGet {
		method = "get"
	}
	var _buf bytes.Buffer
	_buf.WriteString(`    <form `)
	if config.IsHidden {
		_buf.WriteString(`style="display: none;"`)
	}
	_buf.WriteString(` id="`)
	_buf.WriteString(kmgXss.H(config.Id))
	_buf.WriteString(`" class="form-horizontal" autocomplete="off" role="form" action="`)
	_buf.WriteString(kmgXss.H(config.Url))
	_buf.WriteString(`" method="`)
	_buf.WriteString(kmgXss.H(method))
	_buf.WriteString(`">
        <div class="panel-body">
            `)
	for _, input := range config.InputList {
		_buf.WriteString(`                `)
		_buf.WriteString(input.HtmlRender())
		_buf.WriteString(`            `)
	}
	_buf.WriteString(`        </div>

    `)
	if !config.NoSubmit {
		_buf.WriteString(`        <div class="panel-footer">
            <center>
                <button type="submit" class="btn btn-primary" style="width: 170px;">
                    <span class="fa fa-check"></span>
                    提交
                </button>
            </center>
        </div>
    `)
	}
	_buf.WriteString(`    </form>`)
	return _buf.String()
}
예제 #12
0
func tplDropDown(d DropDown) string {
	var _buf bytes.Buffer
	_buf.WriteString(`<div style="display: inline-block" class="dropdown">
    <span id="d-`)
	_buf.WriteString(kmgXss.H(d.id))
	_buf.WriteString(`" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
        `)
	_buf.WriteString(d.Title.HtmlRender())
	_buf.WriteString(`    </span>
    <ul class="dropdown-menu" aria-labelledby="d-`)
	_buf.WriteString(kmgXss.H(d.id))
	_buf.WriteString(`">
        `)
	for _, o := range d.OptionList {
		_buf.WriteString(`        `)
		_buf.WriteString(tplNavBarNode(o, 1))
		_buf.WriteString(`        `)
	}
	_buf.WriteString(`    </ul>
</div>`)
	return _buf.String()
}
예제 #13
0
func tplInputWrapVertical(config InputWrapVertical) string {
	var _buf bytes.Buffer
	_buf.WriteString(`<div class="form-group has-feedback">
    <label class="col-sm-2 control-label">`)
	_buf.WriteString(kmgXss.H(config.ShowName))
	_buf.WriteString(`        `)
	if config.Need {
		_buf.WriteString(`            <span style="color:red">*</span>
        `)
	}
	_buf.WriteString(`    </label>

    <div class="col-sm-8 `)
	if config.AppendTpl != nil {
		_buf.WriteString(` form-inline `)
	}
	_buf.WriteString(`">
        `)
	_buf.WriteString(config.Body.HtmlRender())
	_buf.WriteString(`        <span style="font-size:12px;color:red">
            `)
	if config.Comment != "" {
		_buf.WriteString(` 提示: `)
		_buf.WriteString(kmgXss.H(config.Comment))
		_buf.WriteString(` `)
	}
	_buf.WriteString(`        </span>
        `)
	if config.AppendTpl != nil {
		_buf.WriteString(`            `)
		_buf.WriteString(config.AppendTpl.HtmlRender())
		_buf.WriteString(`        `)
	}
	_buf.WriteString(`    </div>
</div>`)
	return _buf.String()
}
예제 #14
0
파일: Dialog.go 프로젝트: keysonZZZ/kmg
func (config DialogOpenWithButton) HtmlRender() string {
	targetId := "dialog_" + kmgRand.MustCryptoRandToReadableAlphaNum(10)
	return `<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#` + targetId + `">
` + kmgXss.H(config.ButtonTitle) + `
</button>
<div class="modal fade" id="` + targetId + `" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      </div>
      <div class="modal-body">
        ` + config.DialogContent.HtmlRender() + `
      </div>
    </div>
  </div>
</div>
`
}
예제 #15
0
파일: tplWrap.go 프로젝트: keysonZZZ/kmg
func tplWrap(w Wrap) string {
	var _buf bytes.Buffer
	_buf.WriteString(`<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>`)
	_buf.WriteString(kmgXss.H(w.Title))
	_buf.WriteString(`</title>
    `)
	_buf.WriteString(w.Head.HtmlRender())
	_buf.WriteString(`</head>
<body style="padding: 20px;">`)
	_buf.WriteString(w.Body.HtmlRender())
	_buf.WriteString(`</body>
</html>`)
	return _buf.String()
}
예제 #16
0
func HString(index int, content string) kmgView.HtmlRenderer {
	if index == 0 {
		index = 1
	}
	return kmgView.Html(`<h` + strconv.Itoa(index) + `>` + kmgXss.H(content) + `</h` + strconv.Itoa(index) + `>`)
}
예제 #17
0
func Pre(content string) kmgView.HtmlRenderer {
	return kmgView.Html(`<pre>` + kmgXss.H(content) + `</pre>`)
}
예제 #18
0
파일: wrap.go 프로젝트: keysonZZZ/kmg
func IncludeJsFile(url string) kmgView.HtmlRenderer {
	return kmgView.Html(`
	<script src="` + kmgXss.H(url) + `"></script>
	`)
}
예제 #19
0
파일: kmgView.go 프로젝트: keysonZZZ/kmg
func (s String) HtmlRender() string {
	return kmgXss.H(string(s))
}
예제 #20
0
파일: wrap.go 프로젝트: keysonZZZ/kmg
func IncludeCssFile(url string) kmgView.HtmlRenderer {
	return kmgView.Html(`
	<link rel="stylesheet" href="` + kmgXss.H(url) + `">
	`)
}