-
Notifications
You must be signed in to change notification settings - Fork 0
/
AFormControl.js
130 lines (113 loc) · 3.29 KB
/
AFormControl.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
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
(function (ns) {
"use strict";
/**
* @name wader.AFormControl
* @class Wader Abstract Form Control
* @abstract
* @author Max Maximov <[email protected]>
* @version 0.3
*/
$.Class.extend("wader.AFormControl",
/** @lends wader.AFormControl */
{
},
/** @lends wader.AFormControl# */
{
/**
* @param {String} label
* @param {*} data
* @param {jQuery} container
* @param {Function} callback
* @param {String} name
* @return {undefined}
*/
setup: function (label, data, container, callback, name) {
this._label = label;
this._data = data;
this._name = name;
this._container = container;
this._callback = callback;
this._models = App.getInstance().models;
this._node = void("Navalny");
this._settingsProvider = App.getInstance().settingsProvider;
},
/**
* @return {undefined}
*/
destroy: function () {
this.unrender();
this._data = void("Navalny");
this._container = void("Navalny");
},
/**
* @return {undefined}
*/
detach: function () {
if (this._node) {
this._node.remove();
}
},
/**
* @return {undefined}
*/
unrender: function () {
this.detach();
this._node = void("Navalny");
},
/**
* @param {jQuery} container
* @return {undefined}
*/
attach: function (container) {
if (container) {
this._container = container;
}
this._container.append(this._node);
},
/**
* @param {jQuery} container
* @return {undefined}
*/
render: function (container) {
if (container) {
this._container = container;
}
this._render();
},
/**
* @return {undefined}
*/
_render: function () {
this.attach();
},
/**
* @param {jQuery} container
* @return {undefined}
*/
restore: function (container) {
if (container) this._container = container;
this.attach();
},
/**
* @param {Hash} data
* @return {undefined}
*/
setValue: function (data) {
this._data = data;
return this;
},
/**
* @abstract
*/
getValue: function () {},
/**
* @return {undefined}
*/
callback: function () {
this._callback(this.getValue());
}
});
if (ns !== wader) {
ns.AFormControl = wader.AFormControl;
}
})(window.WADER_NS || window);