dothtml 4.8.5 → 5.0.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.
- package/{jest.config.js → jest.config.ts} +19 -16
- package/lib/arg-callback-obj.d.ts +29 -0
- package/lib/built-in-components/nav-link.d.ts +8 -0
- package/lib/built-in-components/router.d.ts +57 -0
- package/lib/component.d.ts +73 -0
- package/lib/dot-component-legacy.d.ts +0 -0
- package/lib/dot-document.d.ts +0 -0
- package/lib/dot-util.d.ts +13 -0
- package/lib/dot.d.ts +5 -0
- package/lib/dothtml.d.ts +21 -0
- package/lib/dothtml.js +2 -0
- package/lib/dothtml.js.LICENSE.txt +1 -0
- package/lib/err.d.ts +2 -0
- package/lib/event-bus.d.ts +10 -0
- package/lib/i-dot.d.ts +674 -0
- package/lib/i-dotcss.d.ts +827 -0
- package/lib/node-polyfill.d.ts +2 -0
- package/lib/observable-array.d.ts +49 -0
- package/lib/style-builder.d.ts +3 -0
- package/package.json +11 -5
- package/readme.md +3 -2
- package/src/{arg-callback-obj.js → arg-callback-obj.ts} +18 -6
- package/src/built-in-components/nav-link.ts +21 -0
- package/src/built-in-components/router.ts +315 -0
- package/src/component.ts +369 -0
- package/src/dot-component-legacy.ts +79 -0
- package/src/dot-document.ts +0 -0
- package/src/dot-util.ts +33 -0
- package/src/dot.ts +1147 -0
- package/src/dothtml.ts +33 -0
- package/src/err.ts +22 -0
- package/src/event-bus.ts +39 -0
- package/src/i-dot.ts +787 -0
- package/src/i-dotcss.ts +918 -0
- package/src/node-polyfill.ts +11 -0
- package/src/{observable-array.js → observable-array.ts} +10 -5
- package/src/{style-builder.js → style-builder.ts} +219 -183
- package/tsconfig.json +99 -0
- package/unittests/advanced-bindings.test.ts +421 -0
- package/unittests/{array-evaluation.test.js → array-evaluation.test.ts} +1 -1
- package/unittests/{basic-functionality.test.js → basic-functionality.test.ts} +14 -10
- package/unittests/class-binding.test.ts +227 -0
- package/unittests/component-decorator.-.ts +14 -0
- package/unittests/components-data.test.ts +153 -0
- package/unittests/components.test.ts +257 -0
- package/unittests/computed.test.ts +35 -0
- package/unittests/{core.js → core.ts} +5 -2
- package/unittests/element-and-attribute-coverage.test.ts +472 -0
- package/unittests/hooks.test.ts +67 -0
- package/unittests/immutable-if.test.ts +19 -0
- package/unittests/input-bindings.test.ts +166 -0
- package/unittests/integration.test.ts +5 -0
- package/unittests/{iterations.test.js → iterations.test.ts} +5 -5
- package/unittests/logic.test.ts +18 -0
- package/unittests/refs.test.ts +36 -0
- package/unittests/routing.-.ts +56 -0
- package/unittests/{scopes.test.js → scopes.test.ts} +5 -5
- package/unittests/special-tags.test.ts +39 -0
- package/unittests/styles.test.ts +9 -0
- package/unittests/{testpage.js → testpage.ts} +2 -0
- package/unittests/{wait.test.js → wait.test.ts} +8 -5
- package/webpack.config.js +13 -1
- package/lib/dothtml.min.js +0 -1
- package/src/component.js +0 -305
- package/src/err.js +0 -20
- package/src/event-bus.js +0 -40
- package/src/index.js +0 -1453
- package/src/util.js +0 -13
- package/unittests/advanced-bindings.test.js +0 -386
- package/unittests/class-binding.test.js +0 -53
- package/unittests/components-data.test.js +0 -97
- package/unittests/components.test.js +0 -151
- package/unittests/computed.test.js +0 -36
- package/unittests/hooks.test.js +0 -57
- package/unittests/immutable-if.test.js +0 -15
- package/unittests/input-bindings.test.js +0 -155
- package/unittests/integration.test.js +0 -6
- package/unittests/logic.test.js +0 -18
- package/unittests/routing.-.js +0 -56
- package/unittests/special-tags.test.js +0 -32
package/src/index.js
DELETED
|
@@ -1,1453 +0,0 @@
|
|
|
1
|
-
import dotcss from "./style-builder";
|
|
2
|
-
import eventBus from "./event-bus";
|
|
3
|
-
import { eachK, isF } from "./util";
|
|
4
|
-
import {addComponent, removeComponent, dotReady, _C} from "./component";
|
|
5
|
-
import ERR from "./err";
|
|
6
|
-
import ObservableArray from "./observable-array";
|
|
7
|
-
import { ArrayArgCallback, AttrArgCallback, ConditionalArgCallback, ContentArgCallback } from "./arg-callback-obj";
|
|
8
|
-
|
|
9
|
-
var version = "4.8.5";
|
|
10
|
-
|
|
11
|
-
/*! DOThtml (c) Joshua Sideris | dothtml.org/license */
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Changes:
|
|
15
|
-
*
|
|
16
|
-
* Updates
|
|
17
|
-
* - Integrated dotcss into the style function for components.
|
|
18
|
-
* - Styles from dotcss will be applied directly to the elements, not in a style tag.
|
|
19
|
-
* - Fixed a bug in dotcss where selectors of one character would trigger for "x".indexOf("{}") == "x".length - 2, causing styles to not attach to the element.
|
|
20
|
-
* - Removed jquery wrappers.
|
|
21
|
-
* - Event bus.
|
|
22
|
-
* - Added advanced binding to data.
|
|
23
|
-
* - Added advanced binding to Arrays.
|
|
24
|
-
* - Added advanced binding to attributes.
|
|
25
|
-
* - Styles will now be recomputed when a property causes the classname for a component to change.
|
|
26
|
-
* - Upgraded if statements to support property bindings.
|
|
27
|
-
* - Redesigned components.
|
|
28
|
-
* - Component will no longer return dot. It returns the component.
|
|
29
|
-
* - Ability to call methods and set props within the component directly.
|
|
30
|
-
* - Component events that can be raised.
|
|
31
|
-
* - Computed props.
|
|
32
|
-
* - Ability to pass data into and out of a component.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// Shortcuts:
|
|
37
|
-
var sT = setTimeout;
|
|
38
|
-
var str = function(s,v){return (s||"").toString(v)}
|
|
39
|
-
|
|
40
|
-
// Dot function.
|
|
41
|
-
|
|
42
|
-
/** @type {_D} */
|
|
43
|
-
var dot = function(targetSelector){
|
|
44
|
-
//console.log(targetSelector);
|
|
45
|
-
var targets = targetSelector ? (
|
|
46
|
-
typeof targetSelector == "string" ? document.querySelectorAll(targetSelector)
|
|
47
|
-
: (targetSelector instanceof Element || targetSelector instanceof Node ? [targetSelector]
|
|
48
|
-
: ((targetSelector instanceof NodeList || targetSelector.length != undefined && targetSelector[0] && (targetSelector[0] instanceof Element || targetSelector[0] instanceof Node)) ? targetSelector
|
|
49
|
-
: []
|
|
50
|
-
)))
|
|
51
|
-
: [];
|
|
52
|
-
//console.log(targets);
|
|
53
|
-
var newDot = new _D();
|
|
54
|
-
if(targets.length > 0){
|
|
55
|
-
newDot.__document = targets[0];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return newDot;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
dot.css = dotcss;
|
|
62
|
-
dot.bus = eventBus;
|
|
63
|
-
dot.__currentArgCallback = [];
|
|
64
|
-
|
|
65
|
-
// TOOLS:
|
|
66
|
-
|
|
67
|
-
function attachEvent(el, ev, val, a3){
|
|
68
|
-
if (el.addEventListener) el.addEventListener(ev, val, a3 || false);
|
|
69
|
-
else el.attachEvent("on" + ev, val); //compatibility with old browsers.
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _get(url, success, fail){
|
|
73
|
-
var xhttp = new XMLHttpRequest();
|
|
74
|
-
xhttp.onreadystatechange = function() {
|
|
75
|
-
if(this.readyState == 4){
|
|
76
|
-
if (this.status == 200) {
|
|
77
|
-
success && success(this);
|
|
78
|
-
}
|
|
79
|
-
else{
|
|
80
|
-
fail && fail(this);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
xhttp.open("GET", url, true);
|
|
85
|
-
xhttp.send();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function createElement(tag){
|
|
89
|
-
_p[tag] = _p[tag + "E"] = function(c){return this.el(tag, c);}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
function createAttribute(attribute){
|
|
93
|
-
_p[attribute] = _p[attribute + "A"] = function(value){return this.attr(attribute, value);}
|
|
94
|
-
};
|
|
95
|
-
function createEventAttribute(attribute){
|
|
96
|
-
createAttribute("on" + attribute);
|
|
97
|
-
createAttribute("on" + attribute.toLowerCase());
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// Compatibility:
|
|
101
|
-
var Node = window.Node;
|
|
102
|
-
if(!Node){
|
|
103
|
-
Node = function(){};
|
|
104
|
-
Node.prototype.ELEMENT_NODE = 1;
|
|
105
|
-
Node.prototype.ATTRIBUTE_NODE = 2;
|
|
106
|
-
Node.prototype.TEXT_NODE = 3;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
var DOCEL = "DOTHTML-DOCUMENT";
|
|
110
|
-
var DEFEL = "DOTHTML-DEFER";
|
|
111
|
-
|
|
112
|
-
// Dot document object.
|
|
113
|
-
function _D(document, classPrefix) {
|
|
114
|
-
var T = this;
|
|
115
|
-
T.__document = document;
|
|
116
|
-
T.__if = null;
|
|
117
|
-
T.__pendingCalls = []; //Allows you to set parent attributes from children.
|
|
118
|
-
T.__anonAttrFuncs = {}; //Only to be used by top-level dot object.
|
|
119
|
-
|
|
120
|
-
T.__lastNode = document ? document.lastChild : null;
|
|
121
|
-
|
|
122
|
-
T.__classPrefix = classPrefix || 0;
|
|
123
|
-
//T.__oldClassPrefix = [];
|
|
124
|
-
T.__classedElements = [];
|
|
125
|
-
}
|
|
126
|
-
// Prototype for the dot document object.
|
|
127
|
-
var _p = _D.prototype;
|
|
128
|
-
|
|
129
|
-
dotReady(dot, _p, _D);
|
|
130
|
-
|
|
131
|
-
_p.version = version;
|
|
132
|
-
|
|
133
|
-
_p._getNewDocument = function(){
|
|
134
|
-
return document.createElement(DOCEL);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
_p._getAnInstance = function(){
|
|
138
|
-
if(this.__document || this.__pendingCalls.length > 0) return this;
|
|
139
|
-
else {
|
|
140
|
-
var d = new _D(null, this.__classPrefix);
|
|
141
|
-
d.__if = this.__if;
|
|
142
|
-
return d;
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
_p._getLastChildOrNull = function(){
|
|
147
|
-
if(this.__document && this.__document.lastChild) return this.__document.lastChild;
|
|
148
|
-
return null;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
//I'm not sure if this is supported anymore.
|
|
152
|
-
_p.getLast = function(){
|
|
153
|
-
return this._getLastChildOrNull();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
_p.toString = function(){
|
|
157
|
-
if(this.__document) return this.__document.innerHTML;
|
|
158
|
-
else return "";
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
//before is passed in so that attributes can be associated with before's sibling, instead of inheritingParent, the default.
|
|
162
|
-
_p._evalContent = function(content, pendingCalls){
|
|
163
|
-
if(content == null || content == undefined) return null;
|
|
164
|
-
if(typeof content === "string" || typeof content === "number" || typeof content === "boolean") { //Raw data
|
|
165
|
-
var nDot = new _D(this._getNewDocument(), this.__classPrefix);
|
|
166
|
-
nDot.__document.innerHTML = content;
|
|
167
|
-
return nDot.__document.childNodes;
|
|
168
|
-
}
|
|
169
|
-
else if(content instanceof Node) return content;
|
|
170
|
-
else if(Object.prototype.toString.call( content ) === '[object Array]') { //Array
|
|
171
|
-
var nDot = new _D(this._getNewDocument(), this.__classPrefix);
|
|
172
|
-
for(var i = 0; i < content.length; i++){
|
|
173
|
-
nDot._appendOrCreateDocument(content[i]);
|
|
174
|
-
}
|
|
175
|
-
if(nDot.__document) return nDot.__document.childNodes;
|
|
176
|
-
}
|
|
177
|
-
else if(isF(content)) //Function to evaluate
|
|
178
|
-
{
|
|
179
|
-
return this._evalContent(content(), pendingCalls);
|
|
180
|
-
}
|
|
181
|
-
else if(content instanceof _C){
|
|
182
|
-
return this._evalContent(content.$el);
|
|
183
|
-
}
|
|
184
|
-
else if(content instanceof _D) { //DOT
|
|
185
|
-
for(var i = 0; i < content.__pendingCalls.length; i++){
|
|
186
|
-
pendingCalls.push(content.__pendingCalls[i]);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
var cp = this.__classPrefix;
|
|
190
|
-
for(var i in content.__classedElements){
|
|
191
|
-
var el = content.__classedElements[i];
|
|
192
|
-
if(!cp){
|
|
193
|
-
this.__classedElements.push(el);
|
|
194
|
-
}
|
|
195
|
-
else{
|
|
196
|
-
el.className = "dot-" + str(cp,16) + "-" + el.className;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
if(content.__document) return content.__document.childNodes; //Return all the nodes in here.
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return null;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
_p._appendOrCreateDocument = function(content, parentEl, beforeNode){
|
|
206
|
-
var T = this;
|
|
207
|
-
// Validation
|
|
208
|
-
;;; if(parentEl && beforeNode && isNaN(beforeNode) && beforeNode.parentNode != parentEl) throw "beforeNode is not in parentEl.";
|
|
209
|
-
|
|
210
|
-
// Find the parent, or create one.
|
|
211
|
-
//Note: the stuff with setting parentEl to beforeNode's parent is due to a very strange bug where this.__document gets set to some phantom document when the wait function is used inside a div like so: DOT.div(DOT.wait(100, "hello!")); Try it. )
|
|
212
|
-
parentEl = parentEl || (beforeNode && isNaN(beforeNode) ? beforeNode.parentNode : null) || T.__document || T._getNewDocument();
|
|
213
|
-
|
|
214
|
-
if(!isNaN(beforeNode)){
|
|
215
|
-
beforeNode = parentEl.childNodes[beforeNode];
|
|
216
|
-
//;;; if(!beforeNode) throw "beforeNode not found."; // TODO: reenable this and investigate why it breaks.
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// nd is a dot wrapper for parentEl (allows us to do dot ops on it).
|
|
220
|
-
var nd = T.__document === parentEl ? T : new _D(parentEl, T.__classPrefix);
|
|
221
|
-
nd.__if = T.__if;
|
|
222
|
-
var pendingCalls = []; //This will populate with pending calls.
|
|
223
|
-
|
|
224
|
-
// Evaluate the content. This does not add it to the DOM pet.
|
|
225
|
-
var eContent;
|
|
226
|
-
var cf = isF(content);
|
|
227
|
-
// If it's a function, we need to consider
|
|
228
|
-
//if(cf) dot.__currentArgCallback.push({f:content,e:parentEl})
|
|
229
|
-
if(cf) dot.__currentArgCallback.push(new ContentArgCallback(parentEl, content));
|
|
230
|
-
try{
|
|
231
|
-
eContent = nd._evalContent(content, /*parentEl, beforeNode,*/ pendingCalls);
|
|
232
|
-
}
|
|
233
|
-
finally{
|
|
234
|
-
if(cf) dot.__currentArgCallback.pop();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
// Pending calls are calls included in the dot element which didn't get consumed and must be propagated up.
|
|
239
|
-
// This usually includes attributes and waits.
|
|
240
|
-
for(var i = 0; i < pendingCalls.length; i++){
|
|
241
|
-
var call = pendingCalls[i];
|
|
242
|
-
//Three possibilities.
|
|
243
|
-
//1. Use the pending call against the last sibling element, if one exists.
|
|
244
|
-
//2. Otherwise, use it on the current parent, if it's ready.
|
|
245
|
-
//3. Otherwise, save it as a pending call right here. // Don't think this ever happens.
|
|
246
|
-
var pendingCallTarget = (beforeNode ? (beforeNode.previousSibling || parentEl /*Since lastChild will be a timeout*/) : null /*1*/) || parentEl.lastChild /*2*/ || parentEl;
|
|
247
|
-
if(pendingCallTarget && pendingCallTarget.tagName != "DOCUMENT"){
|
|
248
|
-
if (call.type == "attr") {
|
|
249
|
-
if (!isF(call.params[0])) {
|
|
250
|
-
pendingCallTarget.setAttribute(call.name, call.params[0]);
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
attachEvent(pendingCallTarget, call.name, call.params[0], call.arg3);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
else if(call.type == "wait"){
|
|
257
|
-
call.callback();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
else{
|
|
261
|
-
nd.__pendingCalls.push(call); /*3*/
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Append content to the current document.
|
|
266
|
-
if(eContent !== null && eContent !== undefined){
|
|
267
|
-
if( eContent instanceof NodeList ) {
|
|
268
|
-
//for(var i = 0; i < eContent.length; i++){
|
|
269
|
-
while(eContent.length > 0){
|
|
270
|
-
if(beforeNode) parentEl.insertBefore(eContent[0], beforeNode);
|
|
271
|
-
else parentEl.appendChild(eContent[0]);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
else{
|
|
275
|
-
if(beforeNode) parentEl.insertBefore(eContent, beforeNode);
|
|
276
|
-
else parentEl.appendChild(eContent);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return nd;
|
|
281
|
-
//return this;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
_p.el = function(tag, content){
|
|
285
|
-
var T = this;
|
|
286
|
-
var ne = document.createElement(tag);
|
|
287
|
-
var nDoc = T.__document || T._getNewDocument();
|
|
288
|
-
nDoc.appendChild(ne);
|
|
289
|
-
if(content) T._appendOrCreateDocument(content, ne);
|
|
290
|
-
var ret = T.__document === nDoc ? T : new _D(nDoc, T.__classPrefix);
|
|
291
|
-
if(content && content instanceof _D) for(var i in content.__classedElements) ret.__classedElements.push(content.__classedElements[i]);
|
|
292
|
-
return ret;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
_p.h = function(content){
|
|
296
|
-
var T = this;
|
|
297
|
-
var hDoc = T._getNewDocument();
|
|
298
|
-
var hDot = new _D(hDoc, T.__classPrefix);
|
|
299
|
-
//if(typeof content === "string" || typeof content === "number" || typeof content === "boolean") hDoc.innerHTML = content; //Raw data
|
|
300
|
-
hDot._appendOrCreateDocument(content)
|
|
301
|
-
|
|
302
|
-
var nDoc = T.__document || T._getNewDocument();
|
|
303
|
-
while(hDoc.childNodes.length > 0){
|
|
304
|
-
nDoc.appendChild(hDoc.childNodes[0]);
|
|
305
|
-
}
|
|
306
|
-
return T.__document === nDoc ? T : new _D(nDoc, T.__classPrefix);
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
_p.t = function(content){
|
|
310
|
-
var textNode = document.createTextNode(content);
|
|
311
|
-
var nDoc = this.__document || this._getNewDocument();
|
|
312
|
-
nDoc.appendChild(textNode);
|
|
313
|
-
return new _D(nDoc, this.__classPrefix);
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
_p.attr = function(attr, value, arg3){
|
|
317
|
-
var T = this;
|
|
318
|
-
if (isF(value)) { // events.
|
|
319
|
-
if (attr.indexOf("on") != 0) {//But only do this if it's an unrecognized event.
|
|
320
|
-
dot.__anonAttrFuncs[_anonFuncCounter] = (value);
|
|
321
|
-
value = "dot.__anonAttrFuncs[" + (_anonFuncCounter++) + "](arguments[0]);"
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
attr = attr.substring(2);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if(T.__document) {
|
|
329
|
-
var cn = T.__document.childNodes;
|
|
330
|
-
var last = cn[cn.length - 1];
|
|
331
|
-
if(last && last.setAttribute){
|
|
332
|
-
if (!isF(value)) {
|
|
333
|
-
|
|
334
|
-
// Objects (except for the css builder :/)
|
|
335
|
-
if(typeof value == "object" && !(value instanceof dot.css._Builder)){
|
|
336
|
-
var originalValue = value;
|
|
337
|
-
var valueSetter = function(){
|
|
338
|
-
var str = "";
|
|
339
|
-
eachK(originalValue, function(k,v){
|
|
340
|
-
v = isF(v) ? v() : v;
|
|
341
|
-
if(!v) return;
|
|
342
|
-
str += " " + k
|
|
343
|
-
});
|
|
344
|
-
return str.substring(1);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
//dot.__currentArgCallback.push({f:valueSetter,e:parentEl,a:attr})
|
|
348
|
-
dot.__currentArgCallback.push(new AttrArgCallback(last, attr, valueSetter));
|
|
349
|
-
value = valueSetter();
|
|
350
|
-
dot.__currentArgCallback.pop();
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
var eValue = last.getAttribute(attr); //Appends the new value to any existing value.
|
|
354
|
-
if (!eValue) eValue = ""; else eValue += " ";
|
|
355
|
-
last.setAttribute(attr, eValue + (value === undefined ? attr : value)); //||attr is for self-explaining attributes
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
attachEvent(last, attr, value, arg3);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
else{
|
|
363
|
-
// TODO: should probably remove pending calls. This has turned out to be an anti-pattern.
|
|
364
|
-
var pD = T._getAnInstance();
|
|
365
|
-
//if(!pD.__pendingCalls.length > 0) pD.__pendingCalls = [];
|
|
366
|
-
pD.__pendingCalls.push({ type: "attr", name: attr, params: [value], arg3: arg3 });
|
|
367
|
-
return pD;
|
|
368
|
-
}
|
|
369
|
-
return T;
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
_p._appendSetElement = function(targetId, appendMode){
|
|
373
|
-
var T = this;
|
|
374
|
-
if(!targetId) {ERR("A", [targetId]); return T;}
|
|
375
|
-
var destination = document.getElementById(targetId);
|
|
376
|
-
if(!destination) {ERR("F", [targetId]); return T;}
|
|
377
|
-
if(T.__document) {
|
|
378
|
-
if(!appendMode) destination.innerHTML = "";
|
|
379
|
-
while(T.__document.childNodes.length > 0) destination.appendChild(T.__document.childNodes[0]);
|
|
380
|
-
}
|
|
381
|
-
return T;
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
_p.iterate = function(iterations, callback, params){
|
|
385
|
-
var target = this;
|
|
386
|
-
var content = callback;
|
|
387
|
-
var copycontent = null;
|
|
388
|
-
if(content instanceof _D) copycontent = content.__document.cloneNode(true);
|
|
389
|
-
|
|
390
|
-
for(var i = 0; i < iterations; i++){
|
|
391
|
-
if(isF(callback)) content = callback(i, params);
|
|
392
|
-
if(copycontent) content.__document = copycontent.cloneNode(true);
|
|
393
|
-
target = target._appendOrCreateDocument(content);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return target;
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
_p.each = function(array, callback, forceNoDeferred){
|
|
400
|
-
var target = this;
|
|
401
|
-
|
|
402
|
-
if(isF(array)){
|
|
403
|
-
if(!forceNoDeferred){
|
|
404
|
-
return target.defer(function(v){
|
|
405
|
-
v.each(array, callback, true);
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
// console.log(this.__document);
|
|
409
|
-
var func = array;
|
|
410
|
-
//target = target._appendOrCreateDocument();
|
|
411
|
-
// dot.__currentArgCallback.push({f:callback,d:target});
|
|
412
|
-
dot.__currentArgCallback.push(new ArrayArgCallback(target, callback));
|
|
413
|
-
try{
|
|
414
|
-
array = func();
|
|
415
|
-
}
|
|
416
|
-
finally{
|
|
417
|
-
dot.__currentArgCallback.pop();
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if(array instanceof Array || array instanceof ObservableArray){
|
|
422
|
-
for(var i = 0; i < array.length; i++){
|
|
423
|
-
target = target._appendOrCreateDocument(callback(array[i], i));
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
else{
|
|
427
|
-
var keys = Object.keys(array);
|
|
428
|
-
for(var i = 0; i < keys.length; i++){
|
|
429
|
-
var k = keys[i];
|
|
430
|
-
target = target._appendOrCreateDocument(callback(array[k], k));
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
return target;
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
function _conditionalBlock(T, totalCondition, allConditions, contentCallback){
|
|
437
|
-
var startTextNode = document.createTextNode("");
|
|
438
|
-
var endTextNode = document.createTextNode("");
|
|
439
|
-
//var cb = {f:contentCallback,startNode:startTextNode, endNode:endTextNode,condition:totalCondition};
|
|
440
|
-
var cb = new ConditionalArgCallback(startTextNode, endTextNode, contentCallback, totalCondition);
|
|
441
|
-
dot.__currentArgCallback.push(cb);
|
|
442
|
-
|
|
443
|
-
var renderContent = totalCondition();
|
|
444
|
-
|
|
445
|
-
T = T._appendOrCreateDocument(startTextNode);
|
|
446
|
-
|
|
447
|
-
for(var i = 0; i < allConditions.length; i++) allConditions[i]();
|
|
448
|
-
cb.lastValue = renderContent;
|
|
449
|
-
if(renderContent) T = T._appendOrCreateDocument(contentCallback);
|
|
450
|
-
|
|
451
|
-
T = T._appendOrCreateDocument(endTextNode);
|
|
452
|
-
dot.__currentArgCallback.pop();
|
|
453
|
-
return T;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
_p.IF = _p["if"] = function(condition, contentCallback, ar){
|
|
457
|
-
var T = this._getAnInstance();
|
|
458
|
-
if(isF(condition)){
|
|
459
|
-
if(!ar) ar = T.__conditionalArray = [condition];
|
|
460
|
-
var l = ar.length - 1;
|
|
461
|
-
var totalCondition = function(){
|
|
462
|
-
for(var i = 0; i < l; i++){
|
|
463
|
-
if(!!ar[i]()) {
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
return !!condition();
|
|
468
|
-
}
|
|
469
|
-
T = _conditionalBlock(T, totalCondition, ar, contentCallback);
|
|
470
|
-
// ar.push(condition);
|
|
471
|
-
}
|
|
472
|
-
else{
|
|
473
|
-
// Old:
|
|
474
|
-
if(!!condition) {
|
|
475
|
-
T = T._appendOrCreateDocument(isF(contentCallback) ? contentCallback() : contentCallback);
|
|
476
|
-
T.__if = true;
|
|
477
|
-
}
|
|
478
|
-
else{
|
|
479
|
-
T.__if = false;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
return T;
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
_p.ELSEIF = _p.elseif = function(condition, callback){
|
|
486
|
-
if(isF(condition)){
|
|
487
|
-
var ar = this.__conditionalArray;
|
|
488
|
-
if(!ar) ERR("MC");
|
|
489
|
-
//var l = ar.length - 1;
|
|
490
|
-
// var newCondition = function(){
|
|
491
|
-
// for(var i = 0; i <= l; i++){
|
|
492
|
-
// if(ar[i]()) return false;
|
|
493
|
-
// }
|
|
494
|
-
// return !!condition();
|
|
495
|
-
// }
|
|
496
|
-
ar.push(condition);
|
|
497
|
-
return this["if"](condition, callback, ar);
|
|
498
|
-
}
|
|
499
|
-
else{
|
|
500
|
-
if(!this.__if){
|
|
501
|
-
return this["if"](condition, callback);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
return this;
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
_p.ELSE = _p["else"] = function(callback){
|
|
508
|
-
var ar = this.__conditionalArray;
|
|
509
|
-
if(ar){
|
|
510
|
-
//var l = ar.length - 1;
|
|
511
|
-
var newCondition = function(){
|
|
512
|
-
return true;
|
|
513
|
-
}
|
|
514
|
-
ar.push(newCondition);
|
|
515
|
-
return this["if"](newCondition, callback, ar);
|
|
516
|
-
}
|
|
517
|
-
else if(!this.__if){
|
|
518
|
-
this.__if = null;
|
|
519
|
-
return this._getAnInstance()._appendOrCreateDocument(callback);
|
|
520
|
-
}
|
|
521
|
-
return this;
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
_p.script = function(callback){
|
|
525
|
-
var last = this.getLast();
|
|
526
|
-
sT(function(){callback(last);}, 0);
|
|
527
|
-
return this;
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
_p.wait = function(timeout, callback){
|
|
531
|
-
var timeoutDot = this.el(DEFEL);
|
|
532
|
-
var timeoutNode = timeoutDot.__document.lastChild;
|
|
533
|
-
|
|
534
|
-
sT(function(){
|
|
535
|
-
timeoutDot._appendOrCreateDocument(callback, null, timeoutNode);
|
|
536
|
-
timeoutNode.parentElement.removeChild(timeoutNode);
|
|
537
|
-
}, timeout);
|
|
538
|
-
|
|
539
|
-
return timeoutDot;
|
|
540
|
-
// Ideally something like this:
|
|
541
|
-
//return this.defer(function(d){d.h(callback)}, timeout);
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
_p.defer = function(callback, timeout){
|
|
545
|
-
if(!isF(callback)) ERR("XF", "defer");
|
|
546
|
-
var deferDot = this.el(DEFEL);
|
|
547
|
-
var deferNode = deferDot.__document.lastChild;
|
|
548
|
-
|
|
549
|
-
sT(function(){
|
|
550
|
-
callback(dot(deferNode.parentElement));
|
|
551
|
-
deferNode.parentElement.removeChild(deferNode);
|
|
552
|
-
}, timeout || 0);
|
|
553
|
-
|
|
554
|
-
return deferDot;
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
// Deletes one element (and not its children).
|
|
558
|
-
// Used by _p.empty and _p.remove.
|
|
559
|
-
function deleteElement(element){
|
|
560
|
-
var deleted = null;
|
|
561
|
-
var dc = element.__dothtml_component;
|
|
562
|
-
if(dc){
|
|
563
|
-
var d = dc.__prms.deleting;
|
|
564
|
-
d && d.apply(dc);
|
|
565
|
-
dc.$el = null;
|
|
566
|
-
deleted = dc.__prms.deleted;
|
|
567
|
-
}
|
|
568
|
-
if(element.parentNode) element.parentNode.removeChild(element);
|
|
569
|
-
deleted && deleted.apply(dc);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
_p.empty = function(){
|
|
573
|
-
if(this.__document){
|
|
574
|
-
// Build a queue of items to remove.
|
|
575
|
-
var queue = [this.__document];
|
|
576
|
-
var firstQ = true;
|
|
577
|
-
var stack = [];
|
|
578
|
-
while(queue.length > 0)
|
|
579
|
-
{
|
|
580
|
-
var current = queue.shift();
|
|
581
|
-
if(current.childNodes.length > 0){
|
|
582
|
-
for(var i = 0; i < current.childNodes.length; i++){
|
|
583
|
-
queue.push(current.childNodes[i]);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
!firstQ && stack.push(current);
|
|
587
|
-
firstQ = false;
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
while(stack.length > 0){
|
|
591
|
-
deleteElement(stack.pop());
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
// Drop all the other nodes (like text)
|
|
595
|
-
// Text seems to get deleted even without this code :).
|
|
596
|
-
//while (this.__document.firstChild) {
|
|
597
|
-
// this.__document.removeChild(this.__document.firstChild);
|
|
598
|
-
//}
|
|
599
|
-
|
|
600
|
-
return this;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
_p.remove = function(){
|
|
604
|
-
this.empty();
|
|
605
|
-
deleteElement(this.__document);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
var classPrefix = 0x10000; _p.resetScopeClass = function(){classPrefix = 0x10000;}
|
|
609
|
-
_p.scopeClass = function(prefix, content){
|
|
610
|
-
if(arguments.length == 1){
|
|
611
|
-
content = prefix;
|
|
612
|
-
prefix = null;
|
|
613
|
-
}
|
|
614
|
-
var T = this;
|
|
615
|
-
|
|
616
|
-
//T.__classPrefix = prefix || classPrefix++;
|
|
617
|
-
//doc.__oldClassPrefix.push(prefix);
|
|
618
|
-
T.__classPrefix = prefix || classPrefix++;
|
|
619
|
-
var ret = T.h(content);
|
|
620
|
-
T.__classPrefix = 0;
|
|
621
|
-
//doc.__oldClassPrefix.pop();
|
|
622
|
-
//T.__classPrefix = oldCp;
|
|
623
|
-
return ret;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Binds the value of an element to a data field. Only works on inputs.
|
|
628
|
-
* @param {object} object
|
|
629
|
-
* @param {string} name
|
|
630
|
-
*/
|
|
631
|
-
_p.bindTo = function(object, name){
|
|
632
|
-
var last = this.getLast();
|
|
633
|
-
//var noListener = true;
|
|
634
|
-
var _value = object[name];
|
|
635
|
-
var ret = this.setVal(_value);
|
|
636
|
-
attachEvent(last, "change", function(e){_value = object[name] = dot(last).getVal();})
|
|
637
|
-
//binding.subscribe(last);
|
|
638
|
-
|
|
639
|
-
try{
|
|
640
|
-
Object.defineProperty(object, name, {
|
|
641
|
-
//value: value,
|
|
642
|
-
enumerable: true,
|
|
643
|
-
//writable: true,
|
|
644
|
-
get: function(){return _value;},
|
|
645
|
-
set: function(value){
|
|
646
|
-
_value = value;
|
|
647
|
-
dot(last).setVal(value);
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
catch(e){}
|
|
652
|
-
|
|
653
|
-
//var noListener = false;
|
|
654
|
-
return ret;
|
|
655
|
-
}
|
|
656
|
-
// _p.bindTo = function(binding){
|
|
657
|
-
// var last = this.getLast();
|
|
658
|
-
// //var noListener = true;
|
|
659
|
-
// var ret = this.setVal(binding.value);
|
|
660
|
-
// attachEvent(last, "change", function(e){binding.value = this.getVal();})
|
|
661
|
-
// binding.subscribe(last);
|
|
662
|
-
// //var noListener = false;
|
|
663
|
-
// return ret;
|
|
664
|
-
// }
|
|
665
|
-
|
|
666
|
-
dot.component = addComponent;
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
// TODO: might remove this in v4+
|
|
670
|
-
dot.removeComponent = removeComponent;
|
|
671
|
-
|
|
672
|
-
var allTags = [
|
|
673
|
-
"a",
|
|
674
|
-
"aside",
|
|
675
|
-
"abbr",
|
|
676
|
-
"address",
|
|
677
|
-
"area",
|
|
678
|
-
"article",
|
|
679
|
-
"audio",
|
|
680
|
-
"b",
|
|
681
|
-
"bdi",
|
|
682
|
-
"bdo",
|
|
683
|
-
"blockquote",
|
|
684
|
-
"br",
|
|
685
|
-
"button",
|
|
686
|
-
"canvas",
|
|
687
|
-
"caption",
|
|
688
|
-
"cite", //*
|
|
689
|
-
"code",
|
|
690
|
-
"col",
|
|
691
|
-
"colgroup",
|
|
692
|
-
"content",
|
|
693
|
-
"data", //*
|
|
694
|
-
"datalist",
|
|
695
|
-
"dd",
|
|
696
|
-
"del",
|
|
697
|
-
"details",
|
|
698
|
-
"dfn",
|
|
699
|
-
"dialog",
|
|
700
|
-
"div",
|
|
701
|
-
"dl",
|
|
702
|
-
"dt",
|
|
703
|
-
"em",
|
|
704
|
-
"embed",
|
|
705
|
-
"fieldset",
|
|
706
|
-
"figcaption",
|
|
707
|
-
"figure",
|
|
708
|
-
"footer",
|
|
709
|
-
"form", //*
|
|
710
|
-
"h1",
|
|
711
|
-
"h2",
|
|
712
|
-
"h3",
|
|
713
|
-
"h4",
|
|
714
|
-
"h5",
|
|
715
|
-
"h6",
|
|
716
|
-
"header",
|
|
717
|
-
"hr",
|
|
718
|
-
"i",
|
|
719
|
-
"iframe",
|
|
720
|
-
"img",
|
|
721
|
-
"input",
|
|
722
|
-
"ins",
|
|
723
|
-
"kbd",
|
|
724
|
-
"keygen",
|
|
725
|
-
"label", //*
|
|
726
|
-
"legend",
|
|
727
|
-
"li",
|
|
728
|
-
"main",
|
|
729
|
-
"map",
|
|
730
|
-
"mark",
|
|
731
|
-
"menu",
|
|
732
|
-
"menuitem",
|
|
733
|
-
"meter",
|
|
734
|
-
"nav",
|
|
735
|
-
"noscript",
|
|
736
|
-
"object",
|
|
737
|
-
"ol",
|
|
738
|
-
"optgroup",
|
|
739
|
-
"option",
|
|
740
|
-
"output",
|
|
741
|
-
"p",
|
|
742
|
-
"param",
|
|
743
|
-
"pre",
|
|
744
|
-
"progress",
|
|
745
|
-
"q",
|
|
746
|
-
"rp",
|
|
747
|
-
"rt",
|
|
748
|
-
"ruby",
|
|
749
|
-
"s",
|
|
750
|
-
"samp",
|
|
751
|
-
"section",
|
|
752
|
-
"select",
|
|
753
|
-
"small",
|
|
754
|
-
"source",
|
|
755
|
-
"span", //*
|
|
756
|
-
"strong",
|
|
757
|
-
"svg",
|
|
758
|
-
"sub",
|
|
759
|
-
"summary", //*
|
|
760
|
-
"sup",
|
|
761
|
-
"table",
|
|
762
|
-
"tbody",
|
|
763
|
-
"td",
|
|
764
|
-
"textarea",
|
|
765
|
-
"tfoot",
|
|
766
|
-
"th",
|
|
767
|
-
"thead",
|
|
768
|
-
"time",
|
|
769
|
-
"tr",
|
|
770
|
-
"track",
|
|
771
|
-
"u",
|
|
772
|
-
"ul",
|
|
773
|
-
"var",
|
|
774
|
-
"video",
|
|
775
|
-
"wbr"
|
|
776
|
-
];
|
|
777
|
-
|
|
778
|
-
var allAttributes = [
|
|
779
|
-
"accept",
|
|
780
|
-
"accesskey",
|
|
781
|
-
"action",
|
|
782
|
-
"align",
|
|
783
|
-
"alink",
|
|
784
|
-
"alt",
|
|
785
|
-
"archive",
|
|
786
|
-
"autocomplete",
|
|
787
|
-
"autofocus",
|
|
788
|
-
"autoplay",
|
|
789
|
-
"autosave",
|
|
790
|
-
"axis",
|
|
791
|
-
"background",
|
|
792
|
-
"bgcolor",
|
|
793
|
-
"border",
|
|
794
|
-
"buffered",
|
|
795
|
-
"cellpadding",
|
|
796
|
-
"cellspacing",
|
|
797
|
-
"challenge",
|
|
798
|
-
"char",
|
|
799
|
-
"charoff",
|
|
800
|
-
"checked",
|
|
801
|
-
"cite", //*
|
|
802
|
-
//"class",
|
|
803
|
-
"classid",
|
|
804
|
-
"clear",
|
|
805
|
-
"codebase",
|
|
806
|
-
"codetype",
|
|
807
|
-
"color",
|
|
808
|
-
"cols",
|
|
809
|
-
"colspan",
|
|
810
|
-
"compact",
|
|
811
|
-
"contenteditable",
|
|
812
|
-
"contextmenu",
|
|
813
|
-
"controls",
|
|
814
|
-
"coords",
|
|
815
|
-
"datetime",
|
|
816
|
-
"declare",
|
|
817
|
-
"default",
|
|
818
|
-
//"data", //*
|
|
819
|
-
"dir",
|
|
820
|
-
"dirname",
|
|
821
|
-
"disabled",
|
|
822
|
-
"download",
|
|
823
|
-
"draggable",
|
|
824
|
-
"dropzone",
|
|
825
|
-
"enctype",
|
|
826
|
-
"face",
|
|
827
|
-
"font",
|
|
828
|
-
"fontface",
|
|
829
|
-
"fontfaceformat",
|
|
830
|
-
"fontfacename",
|
|
831
|
-
"fontfacesrc",
|
|
832
|
-
"fontfaceuri",
|
|
833
|
-
"fontspecification",
|
|
834
|
-
"for",
|
|
835
|
-
"foreignobject",
|
|
836
|
-
"form", //*
|
|
837
|
-
"formaction",
|
|
838
|
-
"frame",
|
|
839
|
-
"frameborder",
|
|
840
|
-
"headers",
|
|
841
|
-
"height",
|
|
842
|
-
"hidden",
|
|
843
|
-
"high",
|
|
844
|
-
"href",
|
|
845
|
-
"hreflang",
|
|
846
|
-
"hspace",
|
|
847
|
-
"icon",
|
|
848
|
-
"id",
|
|
849
|
-
"images",
|
|
850
|
-
"ismap",
|
|
851
|
-
"itemprop",
|
|
852
|
-
"keytype",
|
|
853
|
-
"kind",
|
|
854
|
-
"label", //*
|
|
855
|
-
"lang",
|
|
856
|
-
"list",
|
|
857
|
-
"longdesc",
|
|
858
|
-
"loop",
|
|
859
|
-
"low",
|
|
860
|
-
"manifest",
|
|
861
|
-
"marginheight",
|
|
862
|
-
"marginwidth",
|
|
863
|
-
"max",
|
|
864
|
-
"maxlength",
|
|
865
|
-
"media",
|
|
866
|
-
"metadata",
|
|
867
|
-
"method",
|
|
868
|
-
"min",
|
|
869
|
-
"missingglyph",
|
|
870
|
-
"multiple",
|
|
871
|
-
"muted",
|
|
872
|
-
"name",
|
|
873
|
-
"nohref",
|
|
874
|
-
"noresize",
|
|
875
|
-
"noshade",
|
|
876
|
-
"novalidate",
|
|
877
|
-
"nowrap",
|
|
878
|
-
"open",
|
|
879
|
-
"optimum",
|
|
880
|
-
"pattern",
|
|
881
|
-
"ping",
|
|
882
|
-
"placeholder",
|
|
883
|
-
"poster",
|
|
884
|
-
"preload",
|
|
885
|
-
"prompt",
|
|
886
|
-
"radiogroup",
|
|
887
|
-
"readonly",
|
|
888
|
-
"rel",
|
|
889
|
-
"required",
|
|
890
|
-
"rev",
|
|
891
|
-
"reversed",
|
|
892
|
-
"rows",
|
|
893
|
-
"rowspan",
|
|
894
|
-
"rules",
|
|
895
|
-
"sandbox",
|
|
896
|
-
"scope",
|
|
897
|
-
"scrolling",
|
|
898
|
-
"seamless",
|
|
899
|
-
"selected",
|
|
900
|
-
"shape",
|
|
901
|
-
"size",
|
|
902
|
-
"sizes",
|
|
903
|
-
"span", //*
|
|
904
|
-
"spellcheck",
|
|
905
|
-
"src",
|
|
906
|
-
"srcdoc",
|
|
907
|
-
"srclang",
|
|
908
|
-
"srcset",
|
|
909
|
-
"standby",
|
|
910
|
-
"start",
|
|
911
|
-
"step",
|
|
912
|
-
"summary", //*
|
|
913
|
-
"style",
|
|
914
|
-
"tabindex",
|
|
915
|
-
"target",
|
|
916
|
-
"title",
|
|
917
|
-
"type",
|
|
918
|
-
"usemap",
|
|
919
|
-
"valign",
|
|
920
|
-
"value",
|
|
921
|
-
"valuetype",
|
|
922
|
-
"width",
|
|
923
|
-
"wrap"
|
|
924
|
-
//"dataA", //Special explicit
|
|
925
|
-
//"citeA",
|
|
926
|
-
//"formA",
|
|
927
|
-
//"labelA",
|
|
928
|
-
//"spanA",
|
|
929
|
-
//"summaryA"
|
|
930
|
-
];
|
|
931
|
-
|
|
932
|
-
var allEventAttr = [
|
|
933
|
-
"Blur",
|
|
934
|
-
"Change",
|
|
935
|
-
"Click",
|
|
936
|
-
"Dblclick",
|
|
937
|
-
"Focus",
|
|
938
|
-
"Keydown",
|
|
939
|
-
"Keypress",
|
|
940
|
-
"Keyup",
|
|
941
|
-
"Load",
|
|
942
|
-
"Mousedown",
|
|
943
|
-
"Mouseenter",
|
|
944
|
-
"Mousemove",
|
|
945
|
-
"Mouseout",
|
|
946
|
-
"Mouseover",
|
|
947
|
-
"Mouseup",
|
|
948
|
-
"Reset",
|
|
949
|
-
"Scroll",
|
|
950
|
-
"Select",
|
|
951
|
-
"Submit",
|
|
952
|
-
"Unload",
|
|
953
|
-
]
|
|
954
|
-
|
|
955
|
-
var i;
|
|
956
|
-
for(i in allTags) createElement(allTags[i]);
|
|
957
|
-
for(i in allAttributes) createAttribute(allAttributes[i]);
|
|
958
|
-
for(i in allEventAttr) createEventAttribute(allEventAttr[i]);
|
|
959
|
-
|
|
960
|
-
//Hyphenated Attributes.
|
|
961
|
-
_p["acceptCharset"] = _p["accept-charset"] = function(value){return this.attr("accept-charset", value);};
|
|
962
|
-
|
|
963
|
-
//SVG
|
|
964
|
-
//_p.svg = function(){ERR("S")};
|
|
965
|
-
|
|
966
|
-
//Data is a special attribute.
|
|
967
|
-
_p.dataA = dot.dataA = function(suffix, value){
|
|
968
|
-
if(arguments.length < 2){
|
|
969
|
-
value = suffix;
|
|
970
|
-
suffix = undefined;
|
|
971
|
-
return this.attr("data", value);
|
|
972
|
-
}
|
|
973
|
-
else{
|
|
974
|
-
return this.attr("data-" + suffix, value);
|
|
975
|
-
}
|
|
976
|
-
};
|
|
977
|
-
|
|
978
|
-
_p.data = dot.data = function(){
|
|
979
|
-
var T = this;
|
|
980
|
-
if(arguments.length > 1 || (arguments.length == 1 && (typeof arguments[0] !== "object") && T.__document && T.__document.lastChild && T.__document.lastChild.tagName == "OBJECT"))
|
|
981
|
-
return dot.dataA.apply(T, arguments);
|
|
982
|
-
return dot.dataE.apply(T, arguments);
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
//Special handling for names that exist as both elements and attributes.
|
|
986
|
-
//summary, span, label, form, cite
|
|
987
|
-
|
|
988
|
-
_p.cite = dot.cite = function(arg){
|
|
989
|
-
var T = this;
|
|
990
|
-
if(arg && (typeof arg !== "object") && T.__document && T.__document.lastChild){
|
|
991
|
-
var tagType = T.__document.lastChild.tagName;
|
|
992
|
-
if(tagType == "BLOCKQUOTE"
|
|
993
|
-
|| tagType == "DEL"
|
|
994
|
-
|| tagType == "INS"
|
|
995
|
-
|| tagType == "Q")
|
|
996
|
-
return T.attr("cite", arg);
|
|
997
|
-
}
|
|
998
|
-
return T.el("cite", arg);
|
|
999
|
-
};
|
|
1000
|
-
|
|
1001
|
-
_p.form = dot.form = function(arg){
|
|
1002
|
-
var T = this;
|
|
1003
|
-
if(arg && (typeof arg !== "object") && T.__document && T.__document.lastChild){
|
|
1004
|
-
var tagType = T.__document.lastChild.tagName;
|
|
1005
|
-
if(tagType == "BUTTON"
|
|
1006
|
-
|| tagType == "FIELDSET"
|
|
1007
|
-
|| tagType == "INPUT"
|
|
1008
|
-
|| tagType == "KEYGEN"
|
|
1009
|
-
|| tagType == "LABEL"
|
|
1010
|
-
|| tagType == "METER"
|
|
1011
|
-
|| tagType == "OBJECT"
|
|
1012
|
-
|| tagType == "OUTPUT"
|
|
1013
|
-
|| tagType == "PROGRESS"
|
|
1014
|
-
|| tagType == "SELECT"
|
|
1015
|
-
|| tagType == "TEXTAREA")
|
|
1016
|
-
return T.attr("form", arg);
|
|
1017
|
-
}
|
|
1018
|
-
return T.el("form", arg);
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
_p.class = _p.classA = function(value){
|
|
1022
|
-
var cp = this.__classPrefix;
|
|
1023
|
-
if(cp){
|
|
1024
|
-
var prefix = "dot-" + str(cp, 16) + "-";
|
|
1025
|
-
if(typeof value == "string") value = prefix + value;
|
|
1026
|
-
else if(typeof value == "object"){
|
|
1027
|
-
var v2 = {};
|
|
1028
|
-
eachK(value, function(k,v){
|
|
1029
|
-
v2[prefix + k] = v;
|
|
1030
|
-
});
|
|
1031
|
-
value = v2;
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
else{
|
|
1035
|
-
var el = this.getLast();
|
|
1036
|
-
el && this.__classedElements.push(el);
|
|
1037
|
-
}
|
|
1038
|
-
return this.attr("class", value);
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
_p.label = function(arg){
|
|
1042
|
-
var T = this;
|
|
1043
|
-
if(arg && (typeof arg !== "object") && T.__document && T.__document.lastChild){
|
|
1044
|
-
var tagType = T.__document.lastChild.tagName;
|
|
1045
|
-
if(tagType == "TRACK")
|
|
1046
|
-
return T.attr("label", arg);
|
|
1047
|
-
}
|
|
1048
|
-
return T.el("label", arg);
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
_p.span = function(arg){
|
|
1052
|
-
var T = this;
|
|
1053
|
-
if(arg && (typeof arg !== "object") && T.__document && T.__document.lastChild){
|
|
1054
|
-
var tagType = T.__document.lastChild.tagName;
|
|
1055
|
-
if(tagType == "COL"
|
|
1056
|
-
|| tagType == "COLGROUP")
|
|
1057
|
-
return T.attr("span", arg);
|
|
1058
|
-
}
|
|
1059
|
-
return T.el("span", arg);
|
|
1060
|
-
};
|
|
1061
|
-
|
|
1062
|
-
_p.summary = function(arg){
|
|
1063
|
-
var T = this;
|
|
1064
|
-
if(arg && (typeof arg !== "object") && T.__document && T.__document.lastChild){
|
|
1065
|
-
var tagType = T.__document.lastChild.tagName;
|
|
1066
|
-
if(tagType == "TABLE")
|
|
1067
|
-
return T.attr("summary", arg);
|
|
1068
|
-
}
|
|
1069
|
-
return T.el("summary", arg);
|
|
1070
|
-
};
|
|
1071
|
-
|
|
1072
|
-
/**
|
|
1073
|
-
* Sets the value of an input or texterea.
|
|
1074
|
-
* @param {string} value - The value to be set.
|
|
1075
|
-
*/
|
|
1076
|
-
_p.setVal = function(value){
|
|
1077
|
-
var last = this.getLast() || this.__document;
|
|
1078
|
-
if(!last) return this;
|
|
1079
|
-
if(last.parentNode && last.parentNode.tagName != DOCEL) last = last.parentNode;
|
|
1080
|
-
|
|
1081
|
-
//if ( typeof value === "number" ) val += "";
|
|
1082
|
-
if ( Array.isArray && Array.isArray( value ) || !Array.isArray && value.join ) {
|
|
1083
|
-
value = value.join("");
|
|
1084
|
-
}
|
|
1085
|
-
else if(value == null){
|
|
1086
|
-
value = "";
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
if ( last.type == "checkbox" ) {
|
|
1090
|
-
last.checked = value ? true : false;
|
|
1091
|
-
}
|
|
1092
|
-
else if ( last.type == "radio" ) {
|
|
1093
|
-
last.checked = value ? true : false;
|
|
1094
|
-
}
|
|
1095
|
-
else if ( last.tagName == "OPTION" ) {
|
|
1096
|
-
last.selected = value ? true : false;
|
|
1097
|
-
}
|
|
1098
|
-
else {
|
|
1099
|
-
last.value = value;
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
return this;
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
_p.getVal = function(){
|
|
1106
|
-
var element = this.__lastNode || this.__document;
|
|
1107
|
-
if(!element || element.nodeType !== 1) return undefined;
|
|
1108
|
-
|
|
1109
|
-
if ( element.type == "checkbox" ) {
|
|
1110
|
-
return element.checked ? true : false;
|
|
1111
|
-
}
|
|
1112
|
-
else if ( element.type == "radio" ) {
|
|
1113
|
-
return element.checked ? true : false;
|
|
1114
|
-
}
|
|
1115
|
-
else if ( element.tagName == "OPTION" ) {
|
|
1116
|
-
return element.selected ? true : false;
|
|
1117
|
-
}
|
|
1118
|
-
else {
|
|
1119
|
-
return element.value;
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
//Fill in all the other fields.
|
|
1124
|
-
//if(Object.create) dot.prototype = Object.create(_p);
|
|
1125
|
-
// dot.prototype.constructor = dot;
|
|
1126
|
-
dot.__document = null;
|
|
1127
|
-
dot.__if = null;
|
|
1128
|
-
dot.__pendingCalls = [];
|
|
1129
|
-
dot.__anonAttrFuncs = {};
|
|
1130
|
-
var _anonFuncCounter = 0;
|
|
1131
|
-
|
|
1132
|
-
// ROUTING:
|
|
1133
|
-
// TODO: Put this in the register hook for router.
|
|
1134
|
-
// TODO: Test to make sure allRouters get cleared when a nested router gets deleted.
|
|
1135
|
-
var routerEventSet = false;
|
|
1136
|
-
var allRouters = {};
|
|
1137
|
-
var routerId = 1;
|
|
1138
|
-
var mayRedirect = false;
|
|
1139
|
-
|
|
1140
|
-
function setupPopupFunction(){
|
|
1141
|
-
!routerEventSet && (routerEventSet = true) ? window.onpopstate = function(e){
|
|
1142
|
-
//console.log("Navigating", e.state);
|
|
1143
|
-
if(e.state){
|
|
1144
|
-
dot.navigate(e.state.path, true);
|
|
1145
|
-
document.title = e.state.pageTitle;
|
|
1146
|
-
}
|
|
1147
|
-
} : 0;
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
dot.component({
|
|
1151
|
-
name: "router",
|
|
1152
|
-
// constructor: function(){
|
|
1153
|
-
|
|
1154
|
-
// },
|
|
1155
|
-
/**
|
|
1156
|
-
* @param {Object} params - Parameters.
|
|
1157
|
-
* @param {Array.<{path: string, title: string, component: Object}>} params.routes - Array of routes.
|
|
1158
|
-
* @param {boolean} params.autoNavigate - Router will automatically navigate when outlet is created.
|
|
1159
|
-
* @param {Function} params.onNavigateInit - Occurs before any request is sent, and before the router outlet is emptied.
|
|
1160
|
-
* @param {Function} params.onError - Occurs in the event of an HTTP error.
|
|
1161
|
-
* @param {Function} params.onResponse - Occurs after a successful HTTP response, but before rendering.
|
|
1162
|
-
* @param {Function} params.onComplete - Occurs after an uncancelled route completes without an error.
|
|
1163
|
-
*/
|
|
1164
|
-
builder: function(params){
|
|
1165
|
-
var t = this;
|
|
1166
|
-
//t.navigate = function(p, nh, f){return routerNavigate.call(t, p, nh, f)};
|
|
1167
|
-
t.navId = 0;
|
|
1168
|
-
t.currentRoute = null;
|
|
1169
|
-
t.currentParams = null;
|
|
1170
|
-
|
|
1171
|
-
t.params = params;
|
|
1172
|
-
if(!params || !params.routes) {ERR("R"); return dot};
|
|
1173
|
-
for(var i = 0; i < t.params.routes.length; i++){
|
|
1174
|
-
var r = t.params.routes[i];
|
|
1175
|
-
if(r.path === null || r.path === undefined) {ERR("R"); return dot};
|
|
1176
|
-
r.segments = r.path.split("/");
|
|
1177
|
-
}
|
|
1178
|
-
if(params.autoNavigate === undefined) params.autoNavigate = true;
|
|
1179
|
-
var o = dot.el("dothtml-router");
|
|
1180
|
-
t.outlet = o.getLast();
|
|
1181
|
-
t.id = routerId++;
|
|
1182
|
-
allRouters[t.id] = t;
|
|
1183
|
-
t.outlet.dothtmlRouterId = t.id;
|
|
1184
|
-
return o;
|
|
1185
|
-
},
|
|
1186
|
-
ready: function(){
|
|
1187
|
-
var t = this;
|
|
1188
|
-
// If there is a route left inside the route queue
|
|
1189
|
-
setupPopupFunction();
|
|
1190
|
-
|
|
1191
|
-
if(t.params.autoNavigate){
|
|
1192
|
-
mayRedirect = true;
|
|
1193
|
-
var params = t.navigate(window.location.pathname + (window.location.hash || ""), true);
|
|
1194
|
-
mayRedirect = false;
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
if(history.pushState) history.replaceState({"pageTitle":params.title || document.title, "path": params.path}, params || document.title, params.path);
|
|
1198
|
-
else window.location.hash = params.path;
|
|
1199
|
-
},
|
|
1200
|
-
methods: {
|
|
1201
|
-
navigate: function(path, noHistory, force){
|
|
1202
|
-
var t = this;
|
|
1203
|
-
//console.log("NAVIGATING", path);
|
|
1204
|
-
// Step 1: parse the path into a route queue:
|
|
1205
|
-
path = path || "";
|
|
1206
|
-
if(typeof path != "string") path = path + "";
|
|
1207
|
-
var hashPath = path;
|
|
1208
|
-
if(path.indexOf("#") != -1) hashPath = path.split("#")[1];
|
|
1209
|
-
|
|
1210
|
-
var hashParts = path.split("#");
|
|
1211
|
-
var allQueues = [];
|
|
1212
|
-
|
|
1213
|
-
// Route navigating.
|
|
1214
|
-
var routeQueue = hashParts[0].split("?")[0].split("/");
|
|
1215
|
-
routeQueue[0] === "" ? routeQueue.shift() : 0;
|
|
1216
|
-
allQueues.push(routeQueue);
|
|
1217
|
-
|
|
1218
|
-
// Hash navigating.
|
|
1219
|
-
var tryHashQueue = hashParts.length > 1 ? hashParts[1].split("/") : null;
|
|
1220
|
-
tryHashQueue ? ((tryHashQueue[0] === "" ? tryHashQueue.shift() : 0)) : 0;
|
|
1221
|
-
tryHashQueue ? ((routeQueue.length > 1 ? allQueues.push(tryHashQueue) : allQueues.unshift(tryHashQueue))) : 0;
|
|
1222
|
-
|
|
1223
|
-
var cancel = false;
|
|
1224
|
-
navParams = {
|
|
1225
|
-
cancel: function(){cancel = true; navParams.wasCancelled = true;},
|
|
1226
|
-
element: t.element,
|
|
1227
|
-
httpResponse: null,
|
|
1228
|
-
isNew: true,
|
|
1229
|
-
params: {},
|
|
1230
|
-
path: path,
|
|
1231
|
-
title: null
|
|
1232
|
-
};
|
|
1233
|
-
|
|
1234
|
-
// Step 2: determine the last router that is correctly loaded.
|
|
1235
|
-
|
|
1236
|
-
// var deepestRouter = null;
|
|
1237
|
-
var bestRoute = null;
|
|
1238
|
-
// Loop through the router stack from start to finish to find the deepest router and the best route to take.
|
|
1239
|
-
// for(var i = 0; i < routerOutletStack.length; i++){
|
|
1240
|
-
|
|
1241
|
-
// var candidate = routerOutletStack[i];
|
|
1242
|
-
// Find the an available route that matches.
|
|
1243
|
-
// bestRoute = null;
|
|
1244
|
-
for(var q in allQueues){
|
|
1245
|
-
var Q = allQueues[q];
|
|
1246
|
-
var rFound = false;
|
|
1247
|
-
for(var r in t.params.routes){
|
|
1248
|
-
rFound = true;
|
|
1249
|
-
var nextRoute = t.params.routes[r];
|
|
1250
|
-
var prms = {};
|
|
1251
|
-
var rs = 0;
|
|
1252
|
-
var ps = 0;
|
|
1253
|
-
var lastRn = null;
|
|
1254
|
-
while(1){
|
|
1255
|
-
var rSn = nextRoute.segments[rs] || null;
|
|
1256
|
-
var pSn = Q[ps] || null;
|
|
1257
|
-
if(rSn === null && pSn === null) break;
|
|
1258
|
-
if(rSn === null && pSn !== null || rSn !== null && pSn === null) {
|
|
1259
|
-
rFound = false;
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
if(rSn === null && lastRn == "*") rSn = "*";
|
|
1263
|
-
|
|
1264
|
-
if(rSn == pSn || rSn == "+" || rSn == "*"){ // It's the route, or it's a wildcard.
|
|
1265
|
-
rs++;
|
|
1266
|
-
}
|
|
1267
|
-
else if(rSn.length > 2 && rSn.charAt(0) == "{" && rSn.charAt(rSn.length - 1) == "}"){ // It's a parameterized route.
|
|
1268
|
-
rs++;
|
|
1269
|
-
prms[rSn.substring(1, rSn.length - 1)] = pSn;
|
|
1270
|
-
}
|
|
1271
|
-
else if(lastRn != "*"){ // If the route doesn't match but the previous term was a super-wildcard, do nothing. Else, break.
|
|
1272
|
-
rFound = false;
|
|
1273
|
-
break;
|
|
1274
|
-
}
|
|
1275
|
-
ps++;
|
|
1276
|
-
lastRn = rSn;
|
|
1277
|
-
}
|
|
1278
|
-
if(rFound){
|
|
1279
|
-
bestRoute = nextRoute;
|
|
1280
|
-
navParams.params = prms;
|
|
1281
|
-
break;
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
if(rFound){
|
|
1285
|
-
if(Q == routeQueue) {
|
|
1286
|
-
if(!history.pushState && mayRedirect) {
|
|
1287
|
-
window.location.hash = path;
|
|
1288
|
-
window.location.pathname = "/";
|
|
1289
|
-
return;
|
|
1290
|
-
}
|
|
1291
|
-
break;
|
|
1292
|
-
};
|
|
1293
|
-
if(Q == tryHashQueue) {
|
|
1294
|
-
path = hashPath;
|
|
1295
|
-
navParams.path = path;
|
|
1296
|
-
if(history.pushState) {
|
|
1297
|
-
window.location.hash = "";
|
|
1298
|
-
history.replaceState({"pageTitle":document.title, "path": path}, document.title, path);
|
|
1299
|
-
}
|
|
1300
|
-
break;
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
navParams.isNew = !(!force && t.currentRoute == bestRoute && (!t.currentParams || t.currentParams == navParams.params || JSON.stringify(t.currentParams) === JSON.stringify(navParams.params)));
|
|
1306
|
-
|
|
1307
|
-
t.params.onNavigateInit && t.params.onNavigateInit(navParams);
|
|
1308
|
-
|
|
1309
|
-
if(!navParams.isNew || cancel) return navParams;
|
|
1310
|
-
t.currentRoute = bestRoute;
|
|
1311
|
-
t.currentParams = navParams.params;
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
var ro = t.outlet;
|
|
1315
|
-
dot(ro).empty();
|
|
1316
|
-
var navId = ++t.navId;
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
//if(deepestRouter == null) return this;
|
|
1320
|
-
if(routeQueue.length == 0) return navParams;
|
|
1321
|
-
if(bestRoute == null) return navParams;
|
|
1322
|
-
|
|
1323
|
-
navParams.title = bestRoute.title;
|
|
1324
|
-
|
|
1325
|
-
if(typeof bestRoute.component == "string"){
|
|
1326
|
-
_get(bestRoute.component, function(result){
|
|
1327
|
-
var text = result.responseText;
|
|
1328
|
-
navParams.httpResponse = result;
|
|
1329
|
-
if(navId != t.navId) return navParams;
|
|
1330
|
-
t.params.onResponse && t.params.onResponse(navParams);
|
|
1331
|
-
if(cancel) returnnavParams;
|
|
1332
|
-
if(bestRoute.component.split("?")[0].split("#")[0].toLowerCase().indexOf(".js") == bestRoute.component.length - 3){
|
|
1333
|
-
try{
|
|
1334
|
-
text = Function("var exports=null,module={},route=arguments[0];" + text + "\r\nreturn module.exports || exports;")(navParams);
|
|
1335
|
-
}
|
|
1336
|
-
catch(e){
|
|
1337
|
-
//e.fileName = bestRoute.component;
|
|
1338
|
-
console.error(e);
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
dot(ro).h(text);
|
|
1342
|
-
t.params.onComplete && t.params.onComplete(navParams);
|
|
1343
|
-
}, function(result){
|
|
1344
|
-
navParams.httpResponse = result;
|
|
1345
|
-
t.params.onError && t.params.onError(navParams);
|
|
1346
|
-
});
|
|
1347
|
-
}
|
|
1348
|
-
else{
|
|
1349
|
-
dot(ro).h(bestRoute.component.call(dot, navParams));
|
|
1350
|
-
t.params.onComplete && t.params.onComplete(navParams);
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
return navParams;
|
|
1354
|
-
}
|
|
1355
|
-
},
|
|
1356
|
-
deleting: function(){
|
|
1357
|
-
allRouters[this.id]
|
|
1358
|
-
}
|
|
1359
|
-
});
|
|
1360
|
-
|
|
1361
|
-
dot.navigate = function(path, noHistory, force){
|
|
1362
|
-
|
|
1363
|
-
setupPopupFunction();
|
|
1364
|
-
|
|
1365
|
-
var K = Object.keys(allRouters);
|
|
1366
|
-
var lastNavParams = {};
|
|
1367
|
-
var bestTitle = document.title;
|
|
1368
|
-
for(var k = 0; k < K.length; k++){
|
|
1369
|
-
var kk = K[k];
|
|
1370
|
-
var r = allRouters[kk];
|
|
1371
|
-
if(r) {
|
|
1372
|
-
var currentNavParams = r.navigate(path, noHistory, force);
|
|
1373
|
-
if(currentNavParams.isNew && !currentNavParams.wasCancelled){
|
|
1374
|
-
lastNavParams = currentNavParams;
|
|
1375
|
-
bestTitle = lastNavParams.title || bestTitle;
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
try{
|
|
1381
|
-
if(lastNavParams && !noHistory){
|
|
1382
|
-
//if(history.replaceState) history.replaceState({"pageTitle":title, "path": path}, title, path);
|
|
1383
|
-
if(history.pushState) history.pushState({"pageTitle":bestTitle, "path": lastNavParams.path}, bestTitle, lastNavParams.path);
|
|
1384
|
-
else window.location.hash = lastNavParams.path;
|
|
1385
|
-
}
|
|
1386
|
-
}catch(e){}
|
|
1387
|
-
|
|
1388
|
-
return this;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
dot.component({name: "navLink", builder: function(content, href){
|
|
1392
|
-
return dot.a(content).href(href).onclick(function(e){
|
|
1393
|
-
e.preventDefault();
|
|
1394
|
-
dot.navigate(href);
|
|
1395
|
-
});
|
|
1396
|
-
}});
|
|
1397
|
-
|
|
1398
|
-
// Make all the names available to the dot object.
|
|
1399
|
-
for (var k in _p) {
|
|
1400
|
-
if(dot[k] === undefined) dot[k] = _p[k];
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
// BINDINGS:
|
|
1406
|
-
// function _B(value){
|
|
1407
|
-
// var T = this;
|
|
1408
|
-
// T.value = T._value = value;
|
|
1409
|
-
// T.subscribers = [];
|
|
1410
|
-
// try{
|
|
1411
|
-
// T.property = Object.defineProperty(T, "value", {
|
|
1412
|
-
// //value: value,
|
|
1413
|
-
// enumerable: true,
|
|
1414
|
-
// //writable: true,
|
|
1415
|
-
// get: function(){return T._value;},
|
|
1416
|
-
// set: function(value){
|
|
1417
|
-
// T._value = value;
|
|
1418
|
-
// T.updateSubscribers();
|
|
1419
|
-
// }
|
|
1420
|
-
// });
|
|
1421
|
-
// }
|
|
1422
|
-
// catch(e){T.property = new Object()}
|
|
1423
|
-
// }
|
|
1424
|
-
|
|
1425
|
-
// var _Bp = _B.prototype;
|
|
1426
|
-
|
|
1427
|
-
// _Bp.subscribe = function(element){
|
|
1428
|
-
// this.subscribers.push(element);
|
|
1429
|
-
// }
|
|
1430
|
-
|
|
1431
|
-
// _Bp.unsubscribe = function(element){
|
|
1432
|
-
// for(var i = 0; i < S.length; i++){
|
|
1433
|
-
// if(S[i] == element){
|
|
1434
|
-
// S.splice(i, 1);
|
|
1435
|
-
// break;
|
|
1436
|
-
// }
|
|
1437
|
-
// }
|
|
1438
|
-
// }
|
|
1439
|
-
|
|
1440
|
-
// _Bp.updateSubscribers = function(){
|
|
1441
|
-
// var S = this.subscribers;
|
|
1442
|
-
// for(var i = 0; i < S.length; i++){
|
|
1443
|
-
// dot(S[i]).setVal(this._value);
|
|
1444
|
-
// }
|
|
1445
|
-
// }
|
|
1446
|
-
|
|
1447
|
-
// _Bp.setFrom = function(element){
|
|
1448
|
-
// this.value = dot(element).getVal();
|
|
1449
|
-
// }
|
|
1450
|
-
|
|
1451
|
-
// Done - return the object.
|
|
1452
|
-
|
|
1453
|
-
export default dot;
|