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
|
/*
* Copyright (c) 2012-2014 Kaarle Ritvanen
* See LICENSE file for license details
*/
define(
["acf2/statusbar", "acf2/widget/link", "jquery", "underscore"],
function(statusBar, Base, $, _) {
var Class = Base.extend({
init: function(
data, name, meta, level, editable, removable
) {
this.txnMgr = data.txnMgr;
return this.super(
Class,
"init",
data,
name,
meta,
Math.min(6, level + 1),
editable,
removable
);
},
staticRender: function(value, meta) { return null; },
createEl: function() { return $("<div>"); },
showStatus: false,
requestData: function(value, meta) {
this.path = value;
return this.refreshData();
},
refreshData: function() {
var def = $.Deferred();
this.txnMgr.query(this.path).done(function(data) {
def.resolve(data, data.meta);
});
return def;
},
showHeading: true,
render: function(data, meta) {
if (this.showHeading)
this.el.html(
$("<h" + this.level + ">").text(meta["ui-name"])
);
},
wrap: function() { return this.el; },
validate: function(data) {
this.super(Class, "validate", data);
if (this.data.match(this.meta.condition)) {
var valid = data.validate();
this.setStatus(data.status());
statusBar.validationReady(valid);
}
if (this.fields)
_.each(this.fields, function(field) {
field.trigger("updated");
});
}
});
return Class;
}
);
|