@base-framework/base 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/README.md +1 -0
  2. package/dist/base.js +1 -0
  3. package/package.json +30 -26
  4. package/.jshintrc +0 -3
  5. package/base.js +0 -41
  6. package/base.min.js +0 -1
  7. package/core.js +0 -1
  8. package/data-tracker.js +0 -351
  9. package/es5/base.js +0 -2968
  10. package/es5/modules/ajax.js +0 -663
  11. package/es5/modules/animation.js +0 -188
  12. package/es5/modules/animations.js +0 -1080
  13. package/es5/modules/atom.js +0 -65
  14. package/es5/modules/component.js +0 -1310
  15. package/es5/modules/data-binder.js +0 -1131
  16. package/es5/modules/data.js +0 -1808
  17. package/es5/modules/date.js +0 -525
  18. package/es5/modules/form-validator.js +0 -324
  19. package/es5/modules/history.js +0 -126
  20. package/es5/modules/html-builder.js +0 -461
  21. package/es5/modules/layout.js +0 -1679
  22. package/es5/modules/mouse.js +0 -124
  23. package/es5/modules/nav-link.js +0 -123
  24. package/es5/modules/olderversions/animations-ease.js +0 -1095
  25. package/es5/modules/olderversions/animations-update.js +0 -1048
  26. package/es5/modules/olderversions/base-animations.js +0 -636
  27. package/es5/modules/olderversions/base-component-class.js +0 -100
  28. package/es5/modules/olderversions/base-data-binder-1.js +0 -407
  29. package/es5/modules/olderversions/base-data-binder-class.js +0 -358
  30. package/es5/modules/olderversions/base-layout-parser-class.js +0 -172
  31. package/es5/modules/olderversions/base-mode-1.js +0 -777
  32. package/es5/modules/olderversions/base-model-class.js +0 -585
  33. package/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
  34. package/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
  35. package/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
  36. package/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
  37. package/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
  38. package/es5/modules/olderversions/data-tracker.js +0 -187
  39. package/es5/modules/olderversions/event-update.js +0 -666
  40. package/es5/modules/olderversions/nav-link.js +0 -119
  41. package/es5/modules/olderversions/router-with-templates-1.js +0 -785
  42. package/es5/modules/olderversions/router-with-templates.js +0 -701
  43. package/es5/modules/prototypes/ajax.js +0 -657
  44. package/es5/modules/prototypes/atom.js +0 -65
  45. package/es5/modules/prototypes/component.js +0 -972
  46. package/es5/modules/prototypes/data-binder.js +0 -1089
  47. package/es5/modules/prototypes/data.js +0 -1290
  48. package/es5/modules/prototypes/html-builder.js +0 -414
  49. package/es5/modules/prototypes/layout.js +0 -879
  50. package/es5/modules/router.js +0 -1680
  51. package/es5/modules/state.js +0 -274
  52. package/es6/.jshintrc +0 -3
  53. package/es6/base.js +0 -41
  54. package/es6/core.js +0 -1
  55. package/es6/data-tracker.js +0 -351
  56. package/es6/events.js +0 -602
  57. package/es6/legacy/es5/base.js +0 -2968
  58. package/es6/legacy/es5/modules/ajax.js +0 -663
  59. package/es6/legacy/es5/modules/animation.js +0 -188
  60. package/es6/legacy/es5/modules/animations.js +0 -1080
  61. package/es6/legacy/es5/modules/atom.js +0 -65
  62. package/es6/legacy/es5/modules/component.js +0 -1310
  63. package/es6/legacy/es5/modules/data-binder.js +0 -1131
  64. package/es6/legacy/es5/modules/data.js +0 -1808
  65. package/es6/legacy/es5/modules/date.js +0 -525
  66. package/es6/legacy/es5/modules/form-validator.js +0 -324
  67. package/es6/legacy/es5/modules/history.js +0 -126
  68. package/es6/legacy/es5/modules/html-builder.js +0 -461
  69. package/es6/legacy/es5/modules/layout.js +0 -1679
  70. package/es6/legacy/es5/modules/mouse.js +0 -124
  71. package/es6/legacy/es5/modules/nav-link.js +0 -123
  72. package/es6/legacy/es5/modules/olderversions/animations-ease.js +0 -1095
  73. package/es6/legacy/es5/modules/olderversions/animations-update.js +0 -1048
  74. package/es6/legacy/es5/modules/olderversions/base-animations.js +0 -636
  75. package/es6/legacy/es5/modules/olderversions/base-component-class.js +0 -100
  76. package/es6/legacy/es5/modules/olderversions/base-data-binder-1.js +0 -407
  77. package/es6/legacy/es5/modules/olderversions/base-data-binder-class.js +0 -358
  78. package/es6/legacy/es5/modules/olderversions/base-layout-parser-class.js +0 -172
  79. package/es6/legacy/es5/modules/olderversions/base-mode-1.js +0 -777
  80. package/es6/legacy/es5/modules/olderversions/base-model-class.js +0 -585
  81. package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
  82. package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
  83. package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
  84. package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
  85. package/es6/legacy/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
  86. package/es6/legacy/es5/modules/olderversions/data-tracker.js +0 -187
  87. package/es6/legacy/es5/modules/olderversions/event-update.js +0 -666
  88. package/es6/legacy/es5/modules/olderversions/nav-link.js +0 -119
  89. package/es6/legacy/es5/modules/olderversions/router-with-templates-1.js +0 -785
  90. package/es6/legacy/es5/modules/olderversions/router-with-templates.js +0 -701
  91. package/es6/legacy/es5/modules/prototypes/ajax.js +0 -657
  92. package/es6/legacy/es5/modules/prototypes/atom.js +0 -65
  93. package/es6/legacy/es5/modules/prototypes/component.js +0 -972
  94. package/es6/legacy/es5/modules/prototypes/data-binder.js +0 -1089
  95. package/es6/legacy/es5/modules/prototypes/data.js +0 -1290
  96. package/es6/legacy/es5/modules/prototypes/html-builder.js +0 -414
  97. package/es6/legacy/es5/modules/prototypes/layout.js +0 -879
  98. package/es6/legacy/es5/modules/router.js +0 -1680
  99. package/es6/legacy/es5/modules/state.js +0 -274
  100. package/es6/main.js +0 -1331
  101. package/es6/modules/ajax/ajax.js +0 -514
  102. package/es6/modules/animation/animation.js +0 -236
  103. package/es6/modules/animations/animation-controller.js +0 -231
  104. package/es6/modules/animations/animation.js +0 -64
  105. package/es6/modules/animations/attr-movement.js +0 -66
  106. package/es6/modules/animations/css-movement.js +0 -170
  107. package/es6/modules/animations/movement.js +0 -131
  108. package/es6/modules/animations/value.js +0 -187
  109. package/es6/modules/atom/atom.js +0 -54
  110. package/es6/modules/component/component.js +0 -230
  111. package/es6/modules/component/event-helper.js +0 -119
  112. package/es6/modules/component/jot.js +0 -144
  113. package/es6/modules/component/state-helper.js +0 -262
  114. package/es6/modules/component/unit.js +0 -551
  115. package/es6/modules/data/attrs.js +0 -40
  116. package/es6/modules/data/basic-data.js +0 -500
  117. package/es6/modules/data/data-utils.js +0 -29
  118. package/es6/modules/data/data.js +0 -3
  119. package/es6/modules/data/deep-data.js +0 -541
  120. package/es6/modules/data/model-service.js +0 -528
  121. package/es6/modules/data/model.js +0 -133
  122. package/es6/modules/data/simple-data.js +0 -33
  123. package/es6/modules/data-binder/connection-tracker.js +0 -113
  124. package/es6/modules/data-binder/connection.js +0 -16
  125. package/es6/modules/data-binder/data-binder.js +0 -352
  126. package/es6/modules/data-binder/data-pub-sub.js +0 -141
  127. package/es6/modules/data-binder/data-source.js +0 -56
  128. package/es6/modules/data-binder/element-source.js +0 -219
  129. package/es6/modules/data-binder/one-way-connection.js +0 -46
  130. package/es6/modules/data-binder/one-way-source.js +0 -43
  131. package/es6/modules/data-binder/source.js +0 -36
  132. package/es6/modules/data-binder/two-way-connection.js +0 -75
  133. package/es6/modules/data-binder/two-way-source.js +0 -41
  134. package/es6/modules/date/date.js +0 -544
  135. package/es6/modules/history/history.js +0 -89
  136. package/es6/modules/html-builder/html-builder.js +0 -434
  137. package/es6/modules/import/import.js +0 -390
  138. package/es6/modules/layout/layout-builder.js +0 -1269
  139. package/es6/modules/layout/layout-parser.js +0 -134
  140. package/es6/modules/layout/watcher-helper.js +0 -282
  141. package/es6/modules/mouse/mouse.js +0 -114
  142. package/es6/modules/router/component-helper.js +0 -163
  143. package/es6/modules/router/history-controller.js +0 -216
  144. package/es6/modules/router/nav-link.js +0 -124
  145. package/es6/modules/router/route.js +0 -401
  146. package/es6/modules/router/router.js +0 -789
  147. package/es6/modules/router/utils.js +0 -31
  148. package/es6/modules/state/state-target.js +0 -91
  149. package/es6/modules/state/state.js +0 -171
  150. package/es6/package-lock.json +0 -13
  151. package/es6/package.json +0 -28
  152. package/es6/shared/objects.js +0 -99
  153. package/events.js +0 -602
  154. package/legacy/es5/base.js +0 -2968
  155. package/legacy/es5/modules/ajax.js +0 -663
  156. package/legacy/es5/modules/animation.js +0 -188
  157. package/legacy/es5/modules/animations.js +0 -1080
  158. package/legacy/es5/modules/atom.js +0 -65
  159. package/legacy/es5/modules/component.js +0 -1310
  160. package/legacy/es5/modules/data-binder.js +0 -1131
  161. package/legacy/es5/modules/data.js +0 -1808
  162. package/legacy/es5/modules/date.js +0 -525
  163. package/legacy/es5/modules/form-validator.js +0 -324
  164. package/legacy/es5/modules/history.js +0 -126
  165. package/legacy/es5/modules/html-builder.js +0 -461
  166. package/legacy/es5/modules/layout.js +0 -1679
  167. package/legacy/es5/modules/mouse.js +0 -124
  168. package/legacy/es5/modules/nav-link.js +0 -123
  169. package/legacy/es5/modules/olderversions/animations-ease.js +0 -1095
  170. package/legacy/es5/modules/olderversions/animations-update.js +0 -1048
  171. package/legacy/es5/modules/olderversions/base-animations.js +0 -636
  172. package/legacy/es5/modules/olderversions/base-component-class.js +0 -100
  173. package/legacy/es5/modules/olderversions/base-data-binder-1.js +0 -407
  174. package/legacy/es5/modules/olderversions/base-data-binder-class.js +0 -358
  175. package/legacy/es5/modules/olderversions/base-layout-parser-class.js +0 -172
  176. package/legacy/es5/modules/olderversions/base-mode-1.js +0 -777
  177. package/legacy/es5/modules/olderversions/base-model-class.js +0 -585
  178. package/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
  179. package/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
  180. package/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
  181. package/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
  182. package/legacy/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
  183. package/legacy/es5/modules/olderversions/data-tracker.js +0 -187
  184. package/legacy/es5/modules/olderversions/event-update.js +0 -666
  185. package/legacy/es5/modules/olderversions/nav-link.js +0 -119
  186. package/legacy/es5/modules/olderversions/router-with-templates-1.js +0 -785
  187. package/legacy/es5/modules/olderversions/router-with-templates.js +0 -701
  188. package/legacy/es5/modules/prototypes/ajax.js +0 -657
  189. package/legacy/es5/modules/prototypes/atom.js +0 -65
  190. package/legacy/es5/modules/prototypes/component.js +0 -972
  191. package/legacy/es5/modules/prototypes/data-binder.js +0 -1089
  192. package/legacy/es5/modules/prototypes/data.js +0 -1290
  193. package/legacy/es5/modules/prototypes/html-builder.js +0 -414
  194. package/legacy/es5/modules/prototypes/layout.js +0 -879
  195. package/legacy/es5/modules/router.js +0 -1680
  196. package/legacy/es5/modules/state.js +0 -274
  197. package/main.js +0 -1331
  198. package/modules/ajax/ajax.js +0 -514
  199. package/modules/animation/animation.js +0 -236
  200. package/modules/animations/animation-controller.js +0 -231
  201. package/modules/animations/animation.js +0 -64
  202. package/modules/animations/attr-movement.js +0 -66
  203. package/modules/animations/css-movement.js +0 -170
  204. package/modules/animations/movement.js +0 -131
  205. package/modules/animations/value.js +0 -187
  206. package/modules/atom/atom.js +0 -54
  207. package/modules/component/component.js +0 -230
  208. package/modules/component/event-helper.js +0 -119
  209. package/modules/component/jot.js +0 -144
  210. package/modules/component/state-helper.js +0 -262
  211. package/modules/component/unit.js +0 -551
  212. package/modules/data/attrs.js +0 -40
  213. package/modules/data/basic-data.js +0 -500
  214. package/modules/data/data-utils.js +0 -29
  215. package/modules/data/data.js +0 -3
  216. package/modules/data/deep-data.js +0 -541
  217. package/modules/data/model-service.js +0 -528
  218. package/modules/data/model.js +0 -133
  219. package/modules/data/simple-data.js +0 -33
  220. package/modules/data-binder/connection-tracker.js +0 -113
  221. package/modules/data-binder/connection.js +0 -16
  222. package/modules/data-binder/data-binder.js +0 -352
  223. package/modules/data-binder/data-pub-sub.js +0 -141
  224. package/modules/data-binder/data-source.js +0 -56
  225. package/modules/data-binder/element-source.js +0 -219
  226. package/modules/data-binder/one-way-connection.js +0 -46
  227. package/modules/data-binder/one-way-source.js +0 -43
  228. package/modules/data-binder/source.js +0 -36
  229. package/modules/data-binder/two-way-connection.js +0 -75
  230. package/modules/data-binder/two-way-source.js +0 -41
  231. package/modules/date/date.js +0 -544
  232. package/modules/history/history.js +0 -89
  233. package/modules/html-builder/html-builder.js +0 -434
  234. package/modules/import/import.js +0 -390
  235. package/modules/layout/layout-builder.js +0 -1269
  236. package/modules/layout/layout-parser.js +0 -134
  237. package/modules/layout/watcher-helper.js +0 -282
  238. package/modules/mouse/mouse.js +0 -114
  239. package/modules/router/component-helper.js +0 -163
  240. package/modules/router/history-controller.js +0 -216
  241. package/modules/router/nav-link.js +0 -124
  242. package/modules/router/route.js +0 -401
  243. package/modules/router/router.js +0 -789
  244. package/modules/router/utils.js +0 -31
  245. package/modules/state/state-target.js +0 -91
  246. package/modules/state/state.js +0 -171
  247. package/shared/objects.js +0 -99
  248. package/update +0 -16
@@ -1,972 +0,0 @@
1
- /* base framework module */
2
- (function()
3
- {
4
- "use strict";
5
-
6
- /**
7
- * EventHelper
8
- *
9
- * This will create an event object to make
10
- * adding and removing events easier.
11
- * @class
12
- */
13
- var EventHelper = base.Class.extend(
14
- {
15
- /**
16
- * @constructor
17
- */
18
- constructor: function()
19
- {
20
- this.events = [];
21
- },
22
-
23
- /**
24
- * This will add an array of events.
25
- *
26
- * @param {array} events
27
- */
28
- addEvents: function(events)
29
- {
30
- if(events.length < 1)
31
- {
32
- return false;
33
- }
34
-
35
- for(var i = 0, length = events.length; i < length; i++)
36
- {
37
- var event = events[i];
38
- this.on(event[0], event[1], event[2], event[3]);
39
- }
40
- },
41
-
42
- /**
43
- * This will add an event.
44
- *
45
- * @param {string} event
46
- * @param {object} obj
47
- * @param {function} callBack
48
- * @param {boolean} capture
49
- */
50
- on: function(event, obj, callBack, capture)
51
- {
52
- base.on(event, obj, callBack, capture);
53
-
54
- this.events.push({
55
- event: event,
56
- obj: obj,
57
- callBack: callBack,
58
- capture: capture
59
- });
60
- },
61
-
62
- /**
63
- * This will remove an event.
64
- *
65
- * @param {string} event
66
- * @param {object} obj
67
- * @param {function} callBack
68
- * @param {boolean} capture
69
- */
70
- off: function(event, obj, callBack, capture)
71
- {
72
- base.off(event, obj, callBack, capture);
73
-
74
- var option,
75
- events = this.events;
76
- for(var i = 0, length = events.length; i < length; i++)
77
- {
78
- option = events[i];
79
- if(option.event === event && option.obj === obj)
80
- {
81
- events.splice(i, 1);
82
- break;
83
- }
84
- }
85
- },
86
-
87
- /**
88
- * This will set all events.
89
- */
90
- set: function()
91
- {
92
- var event,
93
- events = this.events;
94
- for(var i = 0, length = events.length; i < length; i++)
95
- {
96
- event = events[i];
97
- base.on(event.event, event.obj, event.callBack, event.capture);
98
- }
99
- },
100
-
101
- unset: function()
102
- {
103
- var event,
104
- events = this.events;
105
- for(var i = 0, length = events.length; i < length; i++)
106
- {
107
- event = events[i];
108
- base.off(event.event, event.obj, event.callBack, event.capture);
109
- }
110
- },
111
-
112
- /**
113
- * This will reset the events.
114
- */
115
- reset: function()
116
- {
117
- this.unset();
118
- this.events = [];
119
- }
120
- });
121
-
122
- base.extend.EventHelper = EventHelper;
123
-
124
- /* this will register the component system to the
125
- data tracker to remove components that have been
126
- nested in layouts. */
127
- base.DataTracker.addType('components', function(data)
128
- {
129
- if(!data)
130
- {
131
- return false;
132
- }
133
-
134
- var component = data.component;
135
- if(component && component.rendered === true)
136
- {
137
- component.prepareDestroy();
138
- }
139
- });
140
-
141
- /**
142
- * StateHelper
143
- *
144
- * This is a helper to manage component states.
145
- */
146
- var StateHelper = base.Class.extend(
147
- {
148
- /**
149
- * @constructor
150
- * @param {object} state
151
- * @param {object} states
152
- */
153
- constructor: function(state, states)
154
- {
155
- this.remoteStates = [];
156
-
157
- var actions = this.convertStates(states);
158
- this.addStatesToTarget(state, actions);
159
- },
160
-
161
- /**
162
- * This will create a state object.
163
- *
164
- * @param {string} action
165
- * @param {*} state
166
- * @param {function} callBack
167
- * @param {string} [targetId]
168
- * @return {object}
169
- */
170
- createState: function(action, state, callBack, targetId)
171
- {
172
- return {
173
- action: action,
174
- state: state,
175
- callBack: callBack,
176
- targetId: targetId,
177
- token: null
178
- };
179
- },
180
-
181
- /**
182
- * This will convert an action object to a state array.
183
- *
184
- * @protected
185
- * @param {object} action
186
- * @return {array}
187
- */
188
- convertStates: function(action)
189
- {
190
- var actions = [];
191
- for(var prop in action)
192
- {
193
- if(action.hasOwnProperty(prop) === false)
194
- {
195
- continue;
196
- }
197
- else if(prop === 'remotes')
198
- {
199
- this.setupRemoteStates(action[prop], actions);
200
- continue;
201
- }
202
-
203
- var targetId = null,
204
- callBack = null,
205
- state = action[prop];
206
- if(state && typeof state === 'object')
207
- {
208
- callBack = state.callBack;
209
- targetId = state.id || state.targetId;
210
- state = state.state;
211
- }
212
-
213
- actions.push(this.createState(
214
- prop,
215
- state,
216
- callBack,
217
- targetId
218
- ));
219
- }
220
- return actions;
221
- },
222
-
223
- setupRemoteStates: function(remotes, actions)
224
- {
225
- var remote;
226
- for(var i = 0, length = remotes.length; i < length; i++)
227
- {
228
- remote = remotes[i];
229
- if(!remote)
230
- {
231
- continue;
232
- }
233
-
234
- for(var prop in remote)
235
- {
236
- if(remote.hasOwnProperty(prop) === false || prop === 'id')
237
- {
238
- continue;
239
- }
240
-
241
- var callBack = null,
242
- value = remote[prop],
243
- state = (value !== null)? value : undefined;
244
- if(state && typeof state === 'object')
245
- {
246
- callBack = state.callBack;
247
- state = state.state;
248
- }
249
-
250
- actions.push(this.createState(
251
- prop,
252
- state,
253
- callBack,
254
- remote.id
255
- ));
256
- }
257
- }
258
- },
259
-
260
- /**
261
- * This will remove remote states.
262
- */
263
- removeRemoteStates: function()
264
- {
265
- var remoteStates = this.remoteStates;
266
- if(remoteStates)
267
- {
268
- this.removeActions(remoteStates);
269
- }
270
- },
271
-
272
- /**
273
- * This will remove the actions.
274
- *
275
- * @param {array} actions
276
- */
277
- removeActions: function(actions)
278
- {
279
- if(actions.length < 1)
280
- {
281
- return false;
282
- }
283
-
284
- var states = base.state;
285
- for(var i = 0, length = actions.length; i < length; i++)
286
- {
287
- var action = actions[i];
288
- states.remove(action.targetId, action.action, action.token);
289
- }
290
- },
291
-
292
- /**
293
- * This will restore a state.
294
- *
295
- * @param {object} state
296
- */
297
- restore: function(state)
298
- {
299
- state.restore();
300
-
301
- var remotes = this.remoteStates;
302
- if(!remotes)
303
- {
304
- return;
305
- }
306
-
307
- for(var i = 0, length = remotes.length; i < length; i++)
308
- {
309
- var action = remotes[i];
310
- action.token = this.bindRemoteState(state, action.action, action.targetId);
311
- }
312
- },
313
-
314
- /**
315
- * This will setup a two way bind to a remote state.
316
- *
317
- * @param {object} target
318
- * @param {string} actionEvent
319
- * @param {string} remoteTargetId
320
- * @return {string}
321
- */
322
- bindRemoteState: function(target, actionEvent, remoteTargetId)
323
- {
324
- var token,
325
- remoteTarget = base.state.getTarget(remoteTargetId);
326
-
327
- var value = remoteTarget.get(actionEvent);
328
- if(typeof value !== 'undefined')
329
- {
330
- target.set(actionEvent, value);
331
- }
332
-
333
- token = remoteTarget.on(actionEvent, function(state, prevState, committer)
334
- {
335
- if(committer === target)
336
- {
337
- return false;
338
- }
339
-
340
- target.set(actionEvent, state, remoteTarget);
341
- });
342
-
343
- target.on(actionEvent, function(state, prevState, committer)
344
- {
345
- if(committer === remoteTarget)
346
- {
347
- return false;
348
- }
349
-
350
- remoteTarget.set(actionEvent, state, target);
351
- });
352
-
353
- return token;
354
- },
355
-
356
- /**
357
- * This will add the states to the target.
358
- *
359
- * @protected
360
- * @param {object} state
361
- * @param {array} actions
362
- */
363
- addStatesToTarget: function(state, actions)
364
- {
365
- var remotes = this.remoteStates;
366
-
367
- for(var i = 0, length = actions.length; i < length; i++)
368
- {
369
- var action = actions[i],
370
- token = this.addAction(state, action);
371
-
372
- if(action.targetId)
373
- {
374
- action.token = token;
375
- remotes.push(action);
376
- }
377
- }
378
-
379
- if(remotes.length < 1)
380
- {
381
- this.remoteStates = null;
382
- }
383
- },
384
-
385
- /**
386
- * This will add an action.
387
- *
388
- * @param {object} target
389
- * @param {object} action
390
- */
391
- addAction: function(target, action)
392
- {
393
- var token,
394
- actionEvent = action.action;
395
-
396
- /* this will check to select the remote target if set */
397
- var targetId = action.targetId;
398
- if(targetId)
399
- {
400
- token = this.bindRemoteState(target, actionEvent, targetId);
401
- }
402
-
403
- if(typeof action.state !== 'undefined')
404
- {
405
- target.addAction(actionEvent, action.state);
406
- }
407
-
408
- var callBack = action.callBack;
409
- if(typeof callBack === 'function')
410
- {
411
- target.on(actionEvent, callBack);
412
- }
413
-
414
- return token;
415
- }
416
- });
417
-
418
- var builder = base.builder;
419
-
420
- /**
421
- * Component
422
- *
423
- * @class
424
- *
425
- * This will allow components to be extended
426
- * from a single factory.
427
- *
428
- * @example
429
- * var QuickFlashPanel = base.Component.extend(
430
- * {
431
- * constructor: function(props)
432
- * {
433
- * // this will setup the component id
434
- * base.Component.call(this, props);
435
- * },
436
- *
437
- * render: function()
438
- * {
439
- * return {
440
- *
441
- * };
442
- * }
443
- * });
444
- */
445
- var Component = base.Class.extend(
446
- {
447
- /**
448
- * @constructor
449
- * @param {object} [props]
450
- */
451
- constructor: function(props)
452
- {
453
- this.init();
454
- this.setupProps(props);
455
- this.onCreated();
456
-
457
- this.rendered = false;
458
- this.container = null;
459
- },
460
-
461
- /**
462
- * @param {bool} isComponent
463
- */
464
- isComponent: true,
465
-
466
- /**
467
- * This will setup the component number and unique
468
- * instance id for the component elements.
469
- * @protected
470
- */
471
- init: function()
472
- {
473
- var constructor = this.constructor;
474
- this.number = (typeof constructor.number === 'undefined')? constructor.number = 0 : (++constructor.number);
475
-
476
- var name = this.overrideTypeId || this.componentTypeId;
477
- this.id = name + this.number;
478
- },
479
-
480
- /**
481
- * This will setup the component props.
482
- *
483
- * @param {object} [props]
484
- */
485
- setupProps: function(props)
486
- {
487
- if(!props || typeof props !== 'object')
488
- {
489
- return false;
490
- }
491
-
492
- for(var prop in props)
493
- {
494
- if(props.hasOwnProperty(prop))
495
- {
496
- this[prop] = props[prop];
497
- }
498
- }
499
- },
500
-
501
- /**
502
- * override this to do something when created.
503
- */
504
- onCreated: function()
505
- {
506
-
507
- },
508
-
509
- /**
510
- * This will render the component.
511
- *
512
- * @return {object}
513
- */
514
- render: function()
515
- {
516
- return {
517
-
518
- };
519
- },
520
-
521
- /**
522
- * This will cache the layout panel and set the main id.
523
- * @param {object} layout
524
- * @return {object}
525
- */
526
- _cacheRoot: function(layout)
527
- {
528
- if(!layout)
529
- {
530
- return layout;
531
- }
532
-
533
- if(!layout.id)
534
- {
535
- layout.id = this.getId();
536
- }
537
-
538
- layout.cache = 'panel';
539
- return layout;
540
- },
541
-
542
- /**
543
- * This will create the component layout.
544
- * @protected
545
- * @return {object}
546
- */
547
- _createLayout: function()
548
- {
549
- if(this.persist)
550
- {
551
- return this._layout || (this._layout = this.render());
552
- }
553
-
554
- return this.render();
555
- },
556
-
557
- /**
558
- * This will prepare the layout.
559
- *
560
- * @protected
561
- * @return {object}
562
- */
563
- prepareLayout: function()
564
- {
565
- var layout = this._createLayout();
566
- return this._cacheRoot(layout);
567
- },
568
-
569
- /**
570
- * This will build the layout.
571
- * @protected
572
- */
573
- buildLayout: function()
574
- {
575
- var layout = this.prepareLayout();
576
- this.build(layout, this.container);
577
-
578
- base.DataTracker.add(this.panel, 'components',
579
- {
580
- component: this
581
- });
582
-
583
- this.rendered = true;
584
- },
585
-
586
- /**
587
- * This will build a layout.
588
- *
589
- * @param {object} layout
590
- * @param {object} container
591
- * @return {object}
592
- */
593
- build: function(layout, container)
594
- {
595
- return builder.build(layout, container, this);
596
- },
597
-
598
- /**
599
- * This will rebuild a layout.
600
- *
601
- * @param {object} layout
602
- * @param {object} container
603
- * @return {object}
604
- */
605
- rebuild: function(layout, container)
606
- {
607
- return builder.rebuild(container, layout, this);
608
- },
609
-
610
- /**
611
- * This will remove children from an element.
612
- *
613
- * @param {object} layout
614
- * @param {object} container
615
- * @return {object}
616
- */
617
- removeAll: function(ele)
618
- {
619
- return builder.removeAll(ele);
620
- },
621
-
622
- /**
623
- * This will cache an element when its created by
624
- * saving a reference to it as a property on the
625
- * component.
626
- *
627
- * @param {string} propName The name to use as
628
- * the reference.
629
- * @param {object} layout
630
- * @param {function} [callBack]
631
- * @return {object}
632
- */
633
- cache: function(propName, layout, callBack)
634
- {
635
- if(!layout || typeof layout !== 'object')
636
- {
637
- return false;
638
- }
639
-
640
- if(layout.isUnit === true)
641
- {
642
- layout =
643
- {
644
- component: layout
645
- };
646
- }
647
-
648
- var self = this;
649
- layout.onCreated = function(element)
650
- {
651
- self[propName] = element;
652
-
653
- if(typeof callBack === 'function')
654
- {
655
- callBack(element);
656
- }
657
- };
658
- return layout;
659
- },
660
-
661
- /**
662
- * This will get an id of the component or the full
663
- * id that has the component id prepended to the
664
- * requested id.
665
- *
666
- * @param {string} [id]
667
- * @return {string}
668
- */
669
- getId: function(id)
670
- {
671
- var mainId = this.id;
672
- if(typeof id === 'string')
673
- {
674
- mainId += '-' + id;
675
- }
676
- return mainId;
677
- },
678
-
679
- /**
680
- * This will initialize the component.
681
- * @protected
682
- */
683
- initialize: function()
684
- {
685
- this.beforeSetup();
686
- this.addStates();
687
- this.buildLayout();
688
- this.addEvents();
689
- this.afterSetup();
690
- },
691
-
692
- /**
693
- * override this to do something before setup.
694
- */
695
- beforeSetup: function()
696
- {
697
-
698
- },
699
-
700
- /**
701
- * override this to do something after setup.
702
- */
703
- afterSetup: function()
704
- {
705
-
706
- },
707
-
708
- /**
709
- * This will setup and render the component.
710
- * @param {object} container
711
- */
712
- setup: function(container)
713
- {
714
- this.container = container;
715
- this.initialize();
716
- },
717
-
718
- /* this will allow the component to override the
719
- state target id to add a custom id */
720
- /**
721
- * @member {string} [stateTargetId] // optional override of state id
722
- */
723
- stateTargetId: null,
724
-
725
- /**
726
- * This will setup the state target.
727
- *
728
- * @protected
729
- * @param {string} [id]
730
- */
731
- setupStateTarget: function(id)
732
- {
733
- var targetId = id || this.stateTargetId || this.id;
734
- this.state = base.state.getTarget(targetId);
735
- },
736
-
737
- /**
738
- * Override this to setup the component states.
739
- * @return {object}
740
- */
741
- setupStates: function()
742
- {
743
- /*
744
- return {
745
- action: 'state'
746
- };
747
-
748
- or
749
-
750
- return {
751
- action:
752
- {
753
- state: 'state',
754
- callBack: function(state, prevState)
755
- {
756
-
757
- }
758
- }
759
- };*/
760
-
761
- return {
762
-
763
- };
764
- },
765
-
766
- /**
767
- * This will add the states.
768
- * @protected
769
- */
770
- addStates: function()
771
- {
772
- /* this will check to restore previous a previous state if the
773
- component has been preserved. */
774
- var state = this.state;
775
- if(state)
776
- {
777
- this.stateHelper.restore(state);
778
- return;
779
- }
780
-
781
- /* this will only setupa state manager if
782
- we have states */
783
- var states = this.setupStates();
784
- if(base.isEmpty(states))
785
- {
786
- return;
787
- }
788
-
789
- this.setupStateTarget();
790
- this.stateHelper = new StateHelper(this.state, states);
791
- },
792
-
793
- /**
794
- * This will remove the states.
795
- * @protected
796
- */
797
- removeStates: function()
798
- {
799
- var state = this.state;
800
- if(!state)
801
- {
802
- return false;
803
- }
804
-
805
- this.stateHelper.removeRemoteStates();
806
- state.remove();
807
- },
808
-
809
- /**
810
- * This will setup the event helper.
811
- *
812
- * @protected
813
- */
814
- setupEventHelper: function()
815
- {
816
- if(!this.events)
817
- {
818
- this.events = new EventHelper();
819
- }
820
- },
821
-
822
- /**
823
- * This will setup the events.
824
- *
825
- * @protected
826
- * @return {array}
827
- */
828
- setupEvents: function()
829
- {
830
- return [
831
- //['action', element, function(e){}, false]
832
- ];
833
- },
834
-
835
- /**
836
- * This will add the events.
837
- *
838
- * @protected
839
- */
840
- addEvents: function()
841
- {
842
- var events = this.setupEvents();
843
- if(events.length < 1)
844
- {
845
- return false;
846
- }
847
-
848
- this.setupEventHelper();
849
- this.events.addEvents(events);
850
- },
851
-
852
- /**
853
- * This will remove the events.
854
- * @protected
855
- */
856
- removeEvents: function()
857
- {
858
- var events = this.events;
859
- if(events)
860
- {
861
- events.reset();
862
- }
863
- },
864
-
865
- /**
866
- * This will remove the component.
867
- * @protected
868
- */
869
- remove: function()
870
- {
871
- this.prepareDestroy();
872
-
873
- var panel = this.panel || this.id;
874
- builder.removeElement(panel);
875
- },
876
-
877
- /**
878
- * This will prepare the component to be destroyed.
879
- */
880
- prepareDestroy: function()
881
- {
882
- this.rendered = false;
883
- this.beforeDestroy();
884
- this.removeEvents();
885
- this.removeStates();
886
- },
887
-
888
- /**
889
- * Override this to do something before destroy.
890
- */
891
- beforeDestroy: function()
892
- {
893
-
894
- },
895
-
896
- /**
897
- * This will destroy the component.
898
- */
899
- destroy: function()
900
- {
901
- this.remove();
902
- },
903
-
904
- /**
905
- * This will bind and element to data.
906
- *
907
- * @param {object} element
908
- * @param {object} data
909
- * @param {string} prop
910
- * @param {function} filter
911
- */
912
- bindElement: function(element, data, prop, filter)
913
- {
914
- if(element)
915
- {
916
- base.DataBinder.bind(element, data, prop, filter);
917
- }
918
- }
919
- });
920
-
921
- var componentTypeNumber = 0;
922
-
923
- /**
924
- * This will extend the parent component to a child
925
- * component.
926
- *
927
- * @static
928
- * @param {object} child
929
- * @return {function}
930
- */
931
- Component.extend = function(child)
932
- {
933
- if(!child)
934
- {
935
- return false;
936
- }
937
-
938
- var parent = this.prototype;
939
-
940
- /* the child constructor must be set to set
941
- the parent static methods on the child */
942
- var constructor = child && child.constructor? child.constructor : false;
943
- if(child.hasOwnProperty('constructor') === false)
944
- {
945
- constructor = function()
946
- {
947
- var args = base.listToArray(arguments);
948
- parent.constructor.apply(this, args);
949
- };
950
- }
951
-
952
- /* this will add the parent class to the
953
- child class */
954
- constructor.prototype = base.extendClass(parent, child);
955
-
956
- /* this will assign a unique id to the type of
957
- component */
958
- constructor.prototype.componentTypeId = 'bs-cp-' + (componentTypeNumber++) + '-';
959
-
960
- /* this will add the static methods from the parent to
961
- the child constructor. could use assign but ie doesn't
962
- support it */
963
- //Object.assign(constructor, this);
964
- base.extendObject(this, constructor);
965
- return constructor;
966
- };
967
-
968
- /* this will add a reference to the component
969
- object */
970
- base.extend.Component = Component;
971
-
972
- })();