forked from jfquestiaux/consent-fabrik-form-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
consent.js
41 lines (35 loc) · 1.07 KB
/
consent.js
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
/**
* Consent
*
* @copyright: Copyright (C) 2005-2018 Media A-Team, Inc. - All rights reserved.
* @license: GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
define(['jquery', 'fab/fabrik'], function (jQuery, Fabrik) {
'use strict';
var Consent = new Class({
options: {
'renderOrder': ''
},
/**
* Initialize
* @param {object} options
*/
initialize: function (options) {
var self = this;
this.options = jQuery.extend(this.options, options);
this.form = Fabrik.getBlock('form_' + this.options.formid);
Fabrik.addEvent('fabrik.form.submit.failed', function (form, event, btn) {
if (form === this.form) {
jQuery('.consentError').removeClass('fabrikHide');
this.form.showMainError(this.form.options.error);
}
}.bind(this));
Fabrik.addEvent('fabrik.form.submitted', function (form, event, btn) {
if (form === this.form) {
jQuery('.consentError').addClass('fabrikHide');
}
}.bind(this));
}
});
return Consent;
});