Newer
Older
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/**
* QUIQQER Contact Control
*
* @author www.pcsg.de (Henning Leutz)
* @module Bricks\Controls\SimpleContact
*/
define('Controls/SimpleContact', [
'qui/QUI',
'qui/controls/Control',
'qui/controls/buttons/Button',
'qui/controls/loader/Loader',
'Ajax',
'Locale'
], function(QUI, QUIControl, QUIButton, QUILoader, Ajax, Locale)
{
"use strict";
return new Class({
Extends : QUIControl,
Type : 'Controls/SimpleContact',
Binds : ['$onImport'],
initialize : function(options)
{
this.parent( options );
this.Loader = new QUILoader();
this.$Text = null;
this.$Email = null;
this.$Name = null;
this.addEvents({
onImport : this.$onImport
});
},
/**
* event : on import
*/
$onImport : function()
{
var self = this;
this.Loader.inject( this.$Elm );
this.Loader.show();
/*
var Send = new QUIButton({
text : 'senden',
textimage : 'fa fa-envelope-o icon-envelope-alt',
events :
{
onClick : function() {
self.$Elm.getElement('form').fireEvent('submit');
}
}
}).inject( this.$Elm );
*/
new Element('button', {
html : 'sendenNNnN',
'class' : 'button qui-button',
events : {
click : function() {
self.$Elm.getElement('form').fireEvent('submit');
}
}
}).inject(this.$Elm);
this.$Elm.getElement('form').addEvent('submit', function(event)
{
var sendViaAjax = self.getElm().get('data-ajax').toInt();
if ( sendViaAjax === 0 )
{
self.getElm().getElement('form').submit();
return;
}
if ( typeof event !== 'undefined' ) {
event.stop();
}
self.send();
});
this.$Text = this.$Elm.getElement( '[name="message"]' );
this.$Email = this.$Elm.getElement( '[name="email"]' );
this.$Name = this.$Elm.getElement( '[name="name"]' );
this.Loader.hide();
},
/**
* Send contact message
*/
send : function()
{
if ( this.$Text.value === '' )
{
this.$Text.focus();
return;
}
if ( this.$Email.value === '' )
{
this.$Email.focus();
return;
}
if ( this.$Name.value === '' )
{
this.$Name.focus();
return;
}
var self = this;
this.Loader.show();
Ajax.post('ajax_contact', function(result)
{
if ( result ) {
self.$Elm.set( 'html', Locale.get( 'quiqqer/system', 'message.contact.successful' ) );
}
self.Loader.hide();
}, {
message : this.$Text.value,
email : this.$Email.value,
name : this.$Name.value,
showError : false,
onError : function(Exception)
{
self.Loader.hide();
QUI.getMessageHandler(function(MH) {
MH.addError( Exception.getMessage(), self.$Elm );
});
}
});
}
});
});