@base-framework/base 2.6.0 → 2.6.1

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 (190) hide show
  1. package/base.min.js +1 -0
  2. package/es5/base.js +2968 -0
  3. package/es5/modules/ajax.js +663 -0
  4. package/es5/modules/animation.js +188 -0
  5. package/es5/modules/animations.js +1080 -0
  6. package/es5/modules/atom.js +65 -0
  7. package/es5/modules/component.js +1310 -0
  8. package/es5/modules/data-binder.js +1131 -0
  9. package/es5/modules/data.js +1808 -0
  10. package/es5/modules/date.js +525 -0
  11. package/es5/modules/form-validator.js +324 -0
  12. package/es5/modules/history.js +126 -0
  13. package/es5/modules/html-builder.js +461 -0
  14. package/es5/modules/layout.js +1679 -0
  15. package/es5/modules/mouse.js +124 -0
  16. package/es5/modules/nav-link.js +123 -0
  17. package/es5/modules/olderversions/animations-ease.js +1095 -0
  18. package/es5/modules/olderversions/animations-update.js +1048 -0
  19. package/es5/modules/olderversions/base-animations.js +636 -0
  20. package/es5/modules/olderversions/base-component-class.js +100 -0
  21. package/es5/modules/olderversions/base-data-binder-1.js +407 -0
  22. package/es5/modules/olderversions/base-data-binder-class.js +358 -0
  23. package/es5/modules/olderversions/base-layout-parser-class.js +172 -0
  24. package/es5/modules/olderversions/base-mode-1.js +777 -0
  25. package/es5/modules/olderversions/base-model-class.js +585 -0
  26. package/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +358 -0
  27. package/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +585 -0
  28. package/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +353 -0
  29. package/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +604 -0
  30. package/es5/modules/olderversions/data-binder-update-watcher.js +640 -0
  31. package/es5/modules/olderversions/data-tracker.js +187 -0
  32. package/es5/modules/olderversions/event-update.js +666 -0
  33. package/es5/modules/olderversions/nav-link.js +119 -0
  34. package/es5/modules/olderversions/router-with-templates-1.js +785 -0
  35. package/es5/modules/olderversions/router-with-templates.js +701 -0
  36. package/es5/modules/prototypes/ajax.js +657 -0
  37. package/es5/modules/prototypes/atom.js +65 -0
  38. package/es5/modules/prototypes/component.js +972 -0
  39. package/es5/modules/prototypes/data-binder.js +1089 -0
  40. package/es5/modules/prototypes/data.js +1290 -0
  41. package/es5/modules/prototypes/html-builder.js +414 -0
  42. package/es5/modules/prototypes/layout.js +879 -0
  43. package/es5/modules/router.js +1680 -0
  44. package/es5/modules/state.js +274 -0
  45. package/es6/.jshintrc +3 -0
  46. package/es6/base.js +41 -0
  47. package/es6/core.js +1 -0
  48. package/es6/data-tracker.js +351 -0
  49. package/es6/events.js +602 -0
  50. package/es6/legacy/es5/base.js +2968 -0
  51. package/es6/legacy/es5/modules/ajax.js +663 -0
  52. package/es6/legacy/es5/modules/animation.js +188 -0
  53. package/es6/legacy/es5/modules/animations.js +1080 -0
  54. package/es6/legacy/es5/modules/atom.js +65 -0
  55. package/es6/legacy/es5/modules/component.js +1310 -0
  56. package/es6/legacy/es5/modules/data-binder.js +1131 -0
  57. package/es6/legacy/es5/modules/data.js +1808 -0
  58. package/es6/legacy/es5/modules/date.js +525 -0
  59. package/es6/legacy/es5/modules/form-validator.js +324 -0
  60. package/es6/legacy/es5/modules/history.js +126 -0
  61. package/es6/legacy/es5/modules/html-builder.js +461 -0
  62. package/es6/legacy/es5/modules/layout.js +1679 -0
  63. package/es6/legacy/es5/modules/mouse.js +124 -0
  64. package/es6/legacy/es5/modules/nav-link.js +123 -0
  65. package/es6/legacy/es5/modules/olderversions/animations-ease.js +1095 -0
  66. package/es6/legacy/es5/modules/olderversions/animations-update.js +1048 -0
  67. package/es6/legacy/es5/modules/olderversions/base-animations.js +636 -0
  68. package/es6/legacy/es5/modules/olderversions/base-component-class.js +100 -0
  69. package/es6/legacy/es5/modules/olderversions/base-data-binder-1.js +407 -0
  70. package/es6/legacy/es5/modules/olderversions/base-data-binder-class.js +358 -0
  71. package/es6/legacy/es5/modules/olderversions/base-layout-parser-class.js +172 -0
  72. package/es6/legacy/es5/modules/olderversions/base-mode-1.js +777 -0
  73. package/es6/legacy/es5/modules/olderversions/base-model-class.js +585 -0
  74. package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +358 -0
  75. package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +585 -0
  76. package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +353 -0
  77. package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +604 -0
  78. package/es6/legacy/es5/modules/olderversions/data-binder-update-watcher.js +640 -0
  79. package/es6/legacy/es5/modules/olderversions/data-tracker.js +187 -0
  80. package/es6/legacy/es5/modules/olderversions/event-update.js +666 -0
  81. package/es6/legacy/es5/modules/olderversions/nav-link.js +119 -0
  82. package/es6/legacy/es5/modules/olderversions/router-with-templates-1.js +785 -0
  83. package/es6/legacy/es5/modules/olderversions/router-with-templates.js +701 -0
  84. package/es6/legacy/es5/modules/prototypes/ajax.js +657 -0
  85. package/es6/legacy/es5/modules/prototypes/atom.js +65 -0
  86. package/es6/legacy/es5/modules/prototypes/component.js +972 -0
  87. package/es6/legacy/es5/modules/prototypes/data-binder.js +1089 -0
  88. package/es6/legacy/es5/modules/prototypes/data.js +1290 -0
  89. package/es6/legacy/es5/modules/prototypes/html-builder.js +414 -0
  90. package/es6/legacy/es5/modules/prototypes/layout.js +879 -0
  91. package/es6/legacy/es5/modules/router.js +1680 -0
  92. package/es6/legacy/es5/modules/state.js +274 -0
  93. package/es6/main.js +1331 -0
  94. package/es6/modules/ajax/ajax.js +514 -0
  95. package/es6/modules/animation/animation.js +236 -0
  96. package/es6/modules/animations/animation-controller.js +231 -0
  97. package/es6/modules/animations/animation.js +64 -0
  98. package/es6/modules/animations/attr-movement.js +66 -0
  99. package/es6/modules/animations/css-movement.js +170 -0
  100. package/es6/modules/animations/movement.js +131 -0
  101. package/es6/modules/animations/value.js +187 -0
  102. package/es6/modules/atom/atom.js +54 -0
  103. package/es6/modules/component/component.js +230 -0
  104. package/es6/modules/component/event-helper.js +119 -0
  105. package/es6/modules/component/jot.js +144 -0
  106. package/es6/modules/component/state-helper.js +262 -0
  107. package/es6/modules/component/unit.js +551 -0
  108. package/es6/modules/data/attrs.js +40 -0
  109. package/es6/modules/data/basic-data.js +500 -0
  110. package/es6/modules/data/data-utils.js +29 -0
  111. package/es6/modules/data/data.js +3 -0
  112. package/es6/modules/data/deep-data.js +541 -0
  113. package/es6/modules/data/model-service.js +528 -0
  114. package/es6/modules/data/model.js +133 -0
  115. package/es6/modules/data/simple-data.js +33 -0
  116. package/es6/modules/data-binder/connection-tracker.js +113 -0
  117. package/es6/modules/data-binder/connection.js +16 -0
  118. package/es6/modules/data-binder/data-binder.js +352 -0
  119. package/es6/modules/data-binder/data-pub-sub.js +141 -0
  120. package/es6/modules/data-binder/data-source.js +56 -0
  121. package/es6/modules/data-binder/element-source.js +219 -0
  122. package/es6/modules/data-binder/one-way-connection.js +46 -0
  123. package/es6/modules/data-binder/one-way-source.js +43 -0
  124. package/es6/modules/data-binder/source.js +36 -0
  125. package/es6/modules/data-binder/two-way-connection.js +75 -0
  126. package/es6/modules/data-binder/two-way-source.js +41 -0
  127. package/es6/modules/date/date.js +544 -0
  128. package/es6/modules/history/history.js +89 -0
  129. package/es6/modules/html-builder/html-builder.js +434 -0
  130. package/es6/modules/import/import.js +390 -0
  131. package/es6/modules/layout/layout-builder.js +1269 -0
  132. package/es6/modules/layout/layout-parser.js +134 -0
  133. package/es6/modules/layout/watcher-helper.js +282 -0
  134. package/es6/modules/mouse/mouse.js +114 -0
  135. package/es6/modules/router/component-helper.js +163 -0
  136. package/es6/modules/router/history-controller.js +216 -0
  137. package/es6/modules/router/nav-link.js +124 -0
  138. package/es6/modules/router/route.js +401 -0
  139. package/es6/modules/router/router.js +789 -0
  140. package/es6/modules/router/utils.js +31 -0
  141. package/es6/modules/state/state-target.js +91 -0
  142. package/es6/modules/state/state.js +171 -0
  143. package/es6/package-lock.json +13 -0
  144. package/es6/package.json +28 -0
  145. package/es6/shared/objects.js +99 -0
  146. package/legacy/es5/base.js +2968 -0
  147. package/legacy/es5/modules/ajax.js +663 -0
  148. package/legacy/es5/modules/animation.js +188 -0
  149. package/legacy/es5/modules/animations.js +1080 -0
  150. package/legacy/es5/modules/atom.js +65 -0
  151. package/legacy/es5/modules/component.js +1310 -0
  152. package/legacy/es5/modules/data-binder.js +1131 -0
  153. package/legacy/es5/modules/data.js +1808 -0
  154. package/legacy/es5/modules/date.js +525 -0
  155. package/legacy/es5/modules/form-validator.js +324 -0
  156. package/legacy/es5/modules/history.js +126 -0
  157. package/legacy/es5/modules/html-builder.js +461 -0
  158. package/legacy/es5/modules/layout.js +1679 -0
  159. package/legacy/es5/modules/mouse.js +124 -0
  160. package/legacy/es5/modules/nav-link.js +123 -0
  161. package/legacy/es5/modules/olderversions/animations-ease.js +1095 -0
  162. package/legacy/es5/modules/olderversions/animations-update.js +1048 -0
  163. package/legacy/es5/modules/olderversions/base-animations.js +636 -0
  164. package/legacy/es5/modules/olderversions/base-component-class.js +100 -0
  165. package/legacy/es5/modules/olderversions/base-data-binder-1.js +407 -0
  166. package/legacy/es5/modules/olderversions/base-data-binder-class.js +358 -0
  167. package/legacy/es5/modules/olderversions/base-layout-parser-class.js +172 -0
  168. package/legacy/es5/modules/olderversions/base-mode-1.js +777 -0
  169. package/legacy/es5/modules/olderversions/base-model-class.js +585 -0
  170. package/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +358 -0
  171. package/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +585 -0
  172. package/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +353 -0
  173. package/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +604 -0
  174. package/legacy/es5/modules/olderversions/data-binder-update-watcher.js +640 -0
  175. package/legacy/es5/modules/olderversions/data-tracker.js +187 -0
  176. package/legacy/es5/modules/olderversions/event-update.js +666 -0
  177. package/legacy/es5/modules/olderversions/nav-link.js +119 -0
  178. package/legacy/es5/modules/olderversions/router-with-templates-1.js +785 -0
  179. package/legacy/es5/modules/olderversions/router-with-templates.js +701 -0
  180. package/legacy/es5/modules/prototypes/ajax.js +657 -0
  181. package/legacy/es5/modules/prototypes/atom.js +65 -0
  182. package/legacy/es5/modules/prototypes/component.js +972 -0
  183. package/legacy/es5/modules/prototypes/data-binder.js +1089 -0
  184. package/legacy/es5/modules/prototypes/data.js +1290 -0
  185. package/legacy/es5/modules/prototypes/html-builder.js +414 -0
  186. package/legacy/es5/modules/prototypes/layout.js +879 -0
  187. package/legacy/es5/modules/router.js +1680 -0
  188. package/legacy/es5/modules/state.js +274 -0
  189. package/package.json +8 -3
  190. package/update +16 -0
@@ -0,0 +1,100 @@
1
+ /* base framework module */
2
+ (function()
3
+ {
4
+ "use strict";
5
+
6
+ /*
7
+ Component
8
+
9
+ this will allow components to be extend
10
+ from a single factory.
11
+
12
+ example:
13
+
14
+ var QuickFlashPanel = function()
15
+ {
16
+ // call super
17
+ Component.call(this);
18
+ };
19
+
20
+ base.Component.extend(
21
+ {
22
+ constructor: QuickFlashPanel
23
+ });
24
+
25
+ // or
26
+
27
+ QuickFlashPanel.prototype = base.Component.extend(
28
+ {
29
+ constructor: QuickFlashPanel
30
+ });
31
+
32
+ */
33
+ var Component = function()
34
+ {
35
+ this.init();
36
+ };
37
+
38
+ /* this will extedn the html builder to allow the
39
+ components to build */
40
+ Component.prototype = base.extendClass( base.htmlBuilder,
41
+ {
42
+ constructor: Component,
43
+
44
+ /* this will setup the component number and unique
45
+ instance id for the component elements.
46
+ @param [(string)] overrideName = the component name to
47
+ override the constructor name */
48
+ init: function(overrideName)
49
+ {
50
+ var constructor = this.constructor;
51
+ this.number = (typeof constructor.number === 'undefined')? constructor.number = 0 : (++constructor.number);
52
+
53
+ var name = overrideName || constructor.name || this.componentTypeId;
54
+ this.id = name + this.number;
55
+ },
56
+
57
+ bind: function(element, model, prop)
58
+ {
59
+ if(element)
60
+ {
61
+ base.DataBinder.bind(element, model, value);
62
+ }
63
+ }
64
+ });
65
+
66
+ var componentTypeNumber = 0;
67
+
68
+ /* this will allow the components to be extened.
69
+ @param (object) child = the child object to extend
70
+ @return (mixed) the new child prototype or false */
71
+ Component.extend = function(child)
72
+ {
73
+ /* the child constructor must be set to set
74
+ the parent static methods on the child */
75
+ var constructor = child && child.constructor? child.constructor : false;
76
+ if(constructor)
77
+ {
78
+ /* this will add the parent class to the
79
+ child class */
80
+ constructor.prototype = base.extendClass(this.prototype, child);
81
+
82
+ /* this will assign a unique id to the type of
83
+ component */
84
+ constructor.prototype.componentTypeId = 'base-comp-' + (componentTypeNumber++);
85
+
86
+ /* this will add the static methods from the parent to
87
+ the child constructor. could use assign but ie doesn't
88
+ support it */
89
+ //Object.assign(constructor, this);
90
+ base.extendObject(this, constructor);
91
+ return constructor.prototype;
92
+ }
93
+ return false;
94
+ };
95
+
96
+ /* this will add a reference to the component
97
+ object */
98
+ base.extend.component = base.extend.Component = Component;
99
+
100
+ })();
@@ -0,0 +1,407 @@
1
+ /* base framework module */
2
+ (function()
3
+ {
4
+ "use strict";
5
+
6
+ /*
7
+ DataBinder
8
+
9
+ this create a data bind module to add
10
+ two way data binding to base models.
11
+
12
+ @param [(string)] attr
13
+
14
+ */
15
+ var DataBinder = function(attr)
16
+ {
17
+ this.attr = attr || 'data-bind';
18
+ /* this will create a new pub sub object
19
+ that will be used to propagate the changes */
20
+ this.pubSub = new DataPubSub();
21
+ this.idCount = 0;
22
+ this.setup();
23
+ };
24
+
25
+ DataBinder.prototype =
26
+ {
27
+ constructor: DataBinder,
28
+
29
+ setup: function()
30
+ {
31
+ this.setupEvents();
32
+
33
+ /* this will add a callback to our pubsub object
34
+ to check what has been changed even if the model
35
+ is not added to the pub sub. this will allow our
36
+ models to publish changes without being added
37
+ and requiring them to be removed when deleted */
38
+ this.pubSub.callBack = base.bind(this, this.messageChange);
39
+ },
40
+
41
+ /* this will add the data bind attr on an
42
+
43
+ element for a model property.
44
+ @param (object) element
45
+ @param (object) model
46
+ @param (string) prop
47
+ @return (object) the instance of the data binder */
48
+ bind: function(element, model, prop)
49
+ {
50
+ /* this will add the data binding
51
+ attr to out element so it will subscribe to
52
+ the two model changes */
53
+ var modelId = model.getModelId(),
54
+ attr = this.attr;
55
+ base.attr(element, attr, modelId + ':' + prop);
56
+
57
+ /* this will add a unique id to the element
58
+ so the model will know when the element has
59
+ been updated */
60
+ var id = 'bs-db-' + this.idCount++;
61
+ base.attr(element, attr + '-id', id);
62
+
63
+ /* this will setup the model to update
64
+ from the pubSub element changes */
65
+ this.pubSub.on( id, function(evt, prop, value, committer)
66
+ {
67
+ model.set(prop, value, committer);
68
+ });
69
+
70
+ /* we want to get the starting value of the
71
+ model and set it on our element */
72
+ var value = model.get(prop);
73
+ if(typeof value !== 'undefined')
74
+ {
75
+ this.set(element, value);
76
+ }
77
+ return this;
78
+ },
79
+
80
+ /* this will remove an element from the data binder
81
+ @param (object) element
82
+ @return (object) the instance of the data binder*/
83
+ unbind: function(element)
84
+ {
85
+ var bindId = base.data(element, this.attr + '-id');
86
+ this.pubSub.remove(bindId);
87
+ return this;
88
+ },
89
+
90
+ messageChange: function(message, prop, value, committer)
91
+ {
92
+ if(typeof message === 'string' && message.indexOf(':') > -1)
93
+ {
94
+ var parts = message.split(':');
95
+ var modelId = parts[0];
96
+
97
+ this.updateElements(modelId, prop, value, committer);
98
+
99
+ /*
100
+ var action = parts[1];
101
+ switch(action)
102
+ {
103
+ case 'change':
104
+ this.updateElements(modelId, prop, value, committer);
105
+ break;
106
+ case 'delete':
107
+ this.deleteElements(modelId, prop);
108
+ break;
109
+ }*/
110
+ }
111
+ return this;
112
+ },
113
+
114
+ /* this will update all elements with the model id
115
+ attr.
116
+ @param (string) modelId
117
+ @param (string) prop
118
+ @param (mixed) value
119
+ @param (object) committer */
120
+ updateElements: function(modelId, prop, value, committer)
121
+ {
122
+ var elements = document.querySelectorAll("[" + this.attr + "='" + modelId + ':' + prop + "']");
123
+ if(elements)
124
+ {
125
+ for(var i = 0, len = elements.length; i < len; i++ )
126
+ {
127
+ var element = elements[i];
128
+ if(committer !== element)
129
+ {
130
+ this.set(element, value);
131
+ }
132
+ }
133
+ }
134
+ },
135
+
136
+ /* this will update all elements with the model id
137
+ attr.
138
+ @param (string) modelId
139
+ @param (string) prop
140
+ @param (mixed) value
141
+ @param (object) committer */
142
+ deleteElements: function(modelId, prop)
143
+ {
144
+ var elements = document.querySelectorAll("[" + this.attr + "='" + modelId + ':' + prop + "']");
145
+ if(elements)
146
+ {
147
+ var builder = new base.htmlBuilder();
148
+ for(var i = 0, len = elements.length; i < len; i++ )
149
+ {
150
+ builder.removeElement(elements[i]);
151
+ }
152
+ }
153
+ },
154
+
155
+ /* this will set a value on an elememnt.
156
+ @param (object) element
157
+ @param (mixed) value */
158
+ set: function(element, value)
159
+ {
160
+ if(element && typeof element === 'object')
161
+ {
162
+ var tagName = element.tagName.toLowerCase();
163
+ if (tagName === "input" || tagName === "textarea" || tagName === "select" )
164
+ {
165
+ var type = element.type;
166
+ if(type && (type === 'checkbox' || type === 'radio'))
167
+ {
168
+ value = value == 0? false : true;
169
+ element.checked = value;
170
+ }
171
+ else
172
+ {
173
+ element.value = value;
174
+ }
175
+ }
176
+ else
177
+ {
178
+ element.textContent = value;
179
+ }
180
+ }
181
+ },
182
+
183
+ /* this will get a value on an elememnt.
184
+ @param (object) element
185
+ @param (mixed) value
186
+ @return (mixed) the element value */
187
+ get: function(element)
188
+ {
189
+ var value = '';
190
+ if(element && typeof element === 'object')
191
+ {
192
+ var tagName = element.tagName.toLowerCase();
193
+ if (tagName === "input" || tagName === "textarea" || tagName === "select" )
194
+ {
195
+ var type = element.type;
196
+ if(type && (type === 'checkbox' || type === 'radio'))
197
+ {
198
+ value = element.checked;
199
+ }
200
+ else
201
+ {
202
+ value = element.value;
203
+ }
204
+ }
205
+ else
206
+ {
207
+ value = element.textContent;
208
+ }
209
+ }
210
+ return value;
211
+ },
212
+
213
+ /* this will publish a change to the data binder.
214
+ @param (string) message e.g id:change
215
+ @param (string) attrName = the model prop name
216
+ @param (mixed) the prop value
217
+ @param (object) the object committing the change */
218
+ publish: function(message, attrName, value, committer)
219
+ {
220
+ this.pubSub.publish(message, attrName, value, committer);
221
+ return this;
222
+ },
223
+
224
+ onChange: function(message, callBack)
225
+ {
226
+ this.pubSub.on(message, callBack);
227
+ return this;
228
+ },
229
+
230
+ /* this will setup the on change handler and
231
+ add the events. this needs to be setup before adding
232
+ the events. */
233
+ changeHandler: null,
234
+ setupEvents: function()
235
+ {
236
+ var dataAttr = this.attr;
237
+ var isDataBound = function(element)
238
+ {
239
+ if(element)
240
+ {
241
+ var value = base.data(element, dataAttr);
242
+ if(value)
243
+ {
244
+ var parts = value.split(":");
245
+ if(parts.length)
246
+ {
247
+ return {
248
+ id: parts[0],
249
+ value: parts[1],
250
+ bindId: base.data(element, dataAttr + '-id')
251
+ };
252
+ }
253
+ }
254
+ }
255
+ return false;
256
+ };
257
+
258
+ /* this will create a closure scope to the object
259
+ by using a local call back function. */
260
+ var self = this, pubSub = this.pubSub;
261
+ this.changeHandler = function(evt)
262
+ {
263
+ if(evt.type === 'keyup')
264
+ {
265
+ var blockedKeys = [
266
+ 17, //ctrl
267
+ 9, //tab
268
+ 16, //shift
269
+ 18, //alt
270
+ 20, //caps lock
271
+ 37, //arrows
272
+ 38,
273
+ 39,
274
+ 40
275
+ ];
276
+ /* this will check to block ctrl, shift or alt +
277
+ buttons */
278
+ if(evt.ctrlKey !== false || evt.shiftKey !== false || evt.altKey !== false || base.inArray(blockedKeys, evt.keyCode) !== -1)
279
+ {
280
+ return true;
281
+ }
282
+ }
283
+
284
+ var target = evt.target || evt.srcElement;
285
+ var settings = isDataBound(target);
286
+ if(settings)
287
+ {
288
+ var prop = settings.value;
289
+ if(prop && prop !== "")
290
+ {
291
+ var value = self.get(target);
292
+ /* this will publish to the ui and to the
293
+ model that subscribes to the element */
294
+ pubSub.publish(settings.bindId, prop, value, target);
295
+ pubSub.publish(settings.id + ':change', prop, value, target);
296
+ }
297
+ }
298
+ evt.stopPropagation();
299
+ };
300
+
301
+ this.addEvents();
302
+ },
303
+
304
+ /* this will add the binder events */
305
+ addEvents: function()
306
+ {
307
+ base.on(["change", "keyup"], document, this.changeHandler, false);
308
+ },
309
+
310
+ /* this will remove the binder events */
311
+ removeEvents: function()
312
+ {
313
+ base.off(["change", "keyup"], document, this.changeHandler, false);
314
+ }
315
+ };
316
+
317
+ /*
318
+ DataPubSub
319
+
320
+ this will create a pub sub object
321
+ to allow messages to be subscribed to and
322
+ publish changes that will be pushed to the
323
+ subscribers.
324
+ */
325
+ var DataPubSub = function()
326
+ {
327
+ this.callBacks = {};
328
+ };
329
+
330
+ DataPubSub.prototype =
331
+ {
332
+ constructor: DataPubSub,
333
+
334
+ /* this will get the subscriber array for the
335
+ message or create a new subscriber array if none
336
+ is setup already.
337
+ @param (string) msg
338
+ @return (array) subscriber array */
339
+ get: function(msg)
340
+ {
341
+ var callBacks = this.callBacks;
342
+ return (callBacks[msg] = callBacks[msg] || []);
343
+ },
344
+
345
+ reset: function()
346
+ {
347
+ this.callBacks = [];
348
+ },
349
+
350
+ on: function(msg, callBack)
351
+ {
352
+ var list = this.get(msg);
353
+ list.push(callBack);
354
+ },
355
+
356
+ off: function(msg, callBack)
357
+ {
358
+ var list = this.get(msg);
359
+ var index = base.inArray(list, callBack);
360
+ if(index > -1)
361
+ {
362
+ list.splice(index, 1);
363
+ }
364
+ },
365
+
366
+ remove: function(msg)
367
+ {
368
+ var callBacks = this.callBacks;
369
+ if(callBacks[msg])
370
+ {
371
+ delete callBacks[msg];
372
+ }
373
+ },
374
+
375
+ callBack: null,
376
+
377
+ publish: function(msg)
378
+ {
379
+ var i, length,
380
+ list = this.callBacks[msg] || false;
381
+ if(list !== false)
382
+ {
383
+ length = list.length;
384
+ for (i = 0; i < length; i++ )
385
+ {
386
+ list[i].apply(this, arguments);
387
+ }
388
+ }
389
+
390
+ if(typeof this.callBack === 'function')
391
+ {
392
+ /* this will setujp the params array by pushing
393
+ the publish args to the params array */
394
+ var params = [];
395
+ length = arguments.length;
396
+ for(i = 0; i < length; i++)
397
+ {
398
+ params[i] = arguments[i];
399
+ }
400
+ this.callBack.apply(null, params);
401
+ }
402
+ }
403
+ };
404
+
405
+ base.extend.DataPubSub = DataPubSub;
406
+ base.extend.DataBinder = new DataBinder();
407
+ })();