-
Notifications
You must be signed in to change notification settings - Fork 0
/
htmlInputFile.go
101 lines (86 loc) · 4.36 KB
/
htmlInputFile.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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package telerik
import (
"bytes"
"reflect"
)
// <input> elements with type="file" let the user choose one or more files from their device storage. Once chosen, the
// files can be uploaded to a server using form submission, or manipulated using JavaScript code and the File API.
//
// <input name="myFile" type="file">
type HtmlInputFile struct {
/*
The name of the control, which is submitted with the form data.
@see typeNamesForAutocomplete.go
Ex.: const NAMES_FOR_AUTOCOMPLETE_NAME
*/
Name string `htmlAttr:"name" jsonSchema_description:"" jsonSchema_enum:"['name', 'honorific-prefix', 'given-name', 'additional-name', 'family-name', 'honorific-suffix', 'nickname', 'email', 'username', 'new-password', 'current-password', 'organization-title', 'organization', 'street-address', 'address-line1', 'address-line2', 'address-line3', 'address-level4', 'address-level3', 'address-level2', 'address-level1', 'country', 'country-name', 'postal-code', 'cc-name', 'cc-given-name', 'cc-additional-name', 'cc-family-name', 'cc-number', 'cc-exp', 'cc-exp-month', 'cc-exp-year', 'cc-csc', 'cc-type', 'transaction-currency', 'transaction-amount', 'language', 'bday', 'bday-day', 'bday-month', 'bday-year', 'sex', 'tel', 'tel-country-code', 'tel-national', 'tel-area-code', 'tel-local', 'tel-local-prefix', 'tel-local-suffix', 'tel-extension', 'url', 'photo']"`
/*
The initial value of the control. This attribute is optional except when the value of the type attribute is radio or
checkbox.
Note that when reloading the page, Gecko and IE will ignore the value specified in the HTML source, if the value was
changed before the reload.
*/
Value string `htmlAttr:"value"`
/*
The form element that the input element is associated with (its form owner). The value of the attribute must be an id
of a <form> element in the same document. If this attribute is not specified, this <input> element must be a
descendant of a <form> element. This attribute enables you to place <input> elements anywhere within a document, not
just as descendants of their form elements. An input can only be associated with one form.
*/
Form string `htmlAttr:"form"`
/*
This Boolean attribute indicates that the form control is not available for interaction. In particular, the click
event will not be dispatched on disabled controls. Also, a disabled control's value isn't submitted with the form.
Unlike other browsers, Firefox will by default persist the dynamic disabled state of an <input> across page loads. Use
the autocomplete attribute to control this feature.
*/
Disabled Boolean `htmlAttrSet:"disabled"`
/*
This Boolean attribute indicates whether the user can enter more than one value. This attribute applies when the type
attribute is set to email or file, otherwise it is ignored.
*/
Multiple Boolean `htmlAttrSet:"multiple"`
/*
This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type
attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS
pseudo-classes will be applied to the field as appropriate.
*/
Required Boolean `htmlAttrSet:"required"`
/*
If the value of the type attribute is file, then this attribute will indicate the types of files that the server
accepts, otherwise it will be ignored. The value must be a comma-separated list of unique content type specifiers:
A file extension starting with the STOP character (U+002E). (e.g. .jpg, .png, .doc).
A valid MIME type with no extensions.
audio/* representing sound files.
video/* representing video files.
image/* representing image files.
*/
Accept []string `htmlAttr:"accept"`
Global HtmlGlobalAttributes `htmlAttr:"-"`
*ToJavaScriptConverter `htmlAttr:"-"`
}
func (el *HtmlInputFile) ToHtml() []byte {
var buffer bytes.Buffer
if el.Global.DoNotUseThisFieldOmitHtml == TRUE {
return []byte{}
}
element := reflect.ValueOf(el).Elem()
data := el.ToJavaScriptConverter.ToTelerikHtml(element)
buffer.Write([]byte(`<input type="file"`))
buffer.Write(el.Global.ToHtml())
buffer.Write(data)
buffer.Write([]byte(`>`))
return buffer.Bytes()
}
func (el *HtmlInputFile) GetId() []byte {
if el.Global.Id == "" {
el.Global.Id = GetAutoId()
}
return []byte(el.Global.Id)
}
func (el *HtmlInputFile) GetName() []byte {
if el.Name == "" {
el.Name = GetAutoId()
}
return []byte(el.Name)
}