dothtml 5.2.1 → 5.2.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 (94) hide show
  1. package/lib/dothtml.js +1 -1
  2. package/package.json +2 -1
  3. package/.vscode/launch.json +0 -34
  4. package/.vscode/settings.json +0 -6
  5. package/azure-pipelines.yml +0 -14
  6. package/babel.config.js +0 -1
  7. package/jest.config.ts +0 -207
  8. package/lib/arg-callback-obj.d.ts +0 -29
  9. package/lib/built-in-components/nav-link.d.ts +0 -8
  10. package/lib/built-in-components/router.d.ts +0 -57
  11. package/lib/component.d.ts +0 -82
  12. package/lib/dot-util.d.ts +0 -26
  13. package/lib/dot.d.ts +0 -5
  14. package/lib/dothtml.d.ts +0 -25
  15. package/lib/dothtml.js.LICENSE.txt +0 -1
  16. package/lib/err.d.ts +0 -2
  17. package/lib/event-bus.d.ts +0 -10
  18. package/lib/i-dot.d.ts +0 -674
  19. package/lib/node-polyfill.d.ts +0 -2
  20. package/lib/observable-array.d.ts +0 -49
  21. package/lib/styling/css-types.ts/css-angle.d.ts +0 -7
  22. package/lib/styling/css-types.ts/css-color.d.ts +0 -9
  23. package/lib/styling/css-types.ts/css-complex.d.ts +0 -7
  24. package/lib/styling/css-types.ts/css-data-type.d.ts +0 -5
  25. package/lib/styling/css-types.ts/css-filter.d.ts +0 -22
  26. package/lib/styling/css-types.ts/css-length.d.ts +0 -7
  27. package/lib/styling/css-types.ts/css-number.d.ts +0 -6
  28. package/lib/styling/css-types.ts/css-percentage.d.ts +0 -5
  29. package/lib/styling/css-types.ts/css-transform.d.ts +0 -38
  30. package/lib/styling/css-types.ts/css-unknown.d.ts +0 -6
  31. package/lib/styling/css-types.ts/css-url.d.ts +0 -6
  32. package/lib/styling/i-dotcss.d.ts +0 -1069
  33. package/lib/styling/style-builder.d.ts +0 -24
  34. package/lib/styling/unit-function-tables.d.ts +0 -10
  35. package/out.md +0 -1340
  36. package/src/arg-callback-obj.ts +0 -76
  37. package/src/built-in-components/nav-link.ts +0 -21
  38. package/src/built-in-components/router.ts +0 -315
  39. package/src/component.ts +0 -415
  40. package/src/dot-util.ts +0 -69
  41. package/src/dot.ts +0 -1147
  42. package/src/dothtml.ts +0 -37
  43. package/src/err.ts +0 -22
  44. package/src/event-bus.ts +0 -39
  45. package/src/i-dot.ts +0 -787
  46. package/src/node-polyfill.ts +0 -11
  47. package/src/observable-array.ts +0 -289
  48. package/src/styling/css-types.ts/css-angle.ts +0 -18
  49. package/src/styling/css-types.ts/css-color.ts +0 -233
  50. package/src/styling/css-types.ts/css-complex.ts +0 -20
  51. package/src/styling/css-types.ts/css-data-type.ts +0 -9
  52. package/src/styling/css-types.ts/css-filter.ts +0 -134
  53. package/src/styling/css-types.ts/css-length.ts +0 -20
  54. package/src/styling/css-types.ts/css-number.ts +0 -12
  55. package/src/styling/css-types.ts/css-percentage.ts +0 -10
  56. package/src/styling/css-types.ts/css-transform.ts +0 -220
  57. package/src/styling/css-types.ts/css-unknown.ts +0 -13
  58. package/src/styling/css-types.ts/css-url.ts +0 -41
  59. package/src/styling/i-dotcss.ts +0 -1181
  60. package/src/styling/style-builder.ts +0 -966
  61. package/src/styling/unit-function-tables.ts +0 -24
  62. package/tsconfig.json +0 -99
  63. package/unittests/advanced-bindings.test.ts +0 -421
  64. package/unittests/array-evaluation.test.ts +0 -7
  65. package/unittests/basic-functionality.test.ts +0 -88
  66. package/unittests/calc.test.ts +0 -6
  67. package/unittests/class-binding.test.ts +0 -227
  68. package/unittests/components/component-decorator.-.ts +0 -14
  69. package/unittests/components/components-data.test.ts +0 -153
  70. package/unittests/components/components.test.ts +0 -258
  71. package/unittests/computed.test.ts +0 -35
  72. package/unittests/core.ts +0 -66
  73. package/unittests/element-and-attribute-coverage.test.ts +0 -472
  74. package/unittests/hooks.test.ts +0 -67
  75. package/unittests/immutable-if.test.ts +0 -19
  76. package/unittests/input-bindings.test.ts +0 -166
  77. package/unittests/integration.test.ts +0 -5
  78. package/unittests/iterations.test.ts +0 -18
  79. package/unittests/logic.test.ts +0 -18
  80. package/unittests/non-function-props-rerender.test.ts +0 -86
  81. package/unittests/refs.test.ts +0 -36
  82. package/unittests/routing.-.ts +0 -56
  83. package/unittests/scopes.test.ts +0 -22
  84. package/unittests/special-tags.test.ts +0 -39
  85. package/unittests/styles.test.ts +0 -9
  86. package/unittests/styling/animations.test.ts +0 -14
  87. package/unittests/styling/filters.test.ts +0 -23
  88. package/unittests/styling/inline-styling.test.ts +0 -18
  89. package/unittests/styling/pseudo-selectors.test.ts +0 -33
  90. package/unittests/styling/transformations.test.ts +0 -234
  91. package/unittests/styling/value-interpretation.test.ts +0 -3
  92. package/unittests/testpage.ts +0 -5
  93. package/unittests/wait.test.ts +0 -31
  94. package/webpack.config.js +0 -28
@@ -1,966 +0,0 @@
1
- "use strict";
2
-
3
- import {AllLengthUnits} from "./unit-function-tables";
4
- import CssAngle from "./css-types.ts/css-angle";
5
- import CssColor from "./css-types.ts/css-color";
6
- import CssComplex from "./css-types.ts/css-complex";
7
- import { CssDataTypeToken } from "./css-types.ts/css-data-type";
8
- import CssLength from "./css-types.ts/css-length";
9
- import CssNumber from "./css-types.ts/css-number";
10
- import CssTransform from "./css-types.ts/css-transform";
11
- import CssUnknown from "./css-types.ts/css-unknown";
12
- import CssUrl from "./css-types.ts/css-url";
13
- import IDotCss, { HideParams, LengthProp, NumericLength, ShowParams } from "./i-dotcss";
14
- import { AnimationType, floatRegex, numberStep } from "../dot-util";
15
- import CssFilter from "./css-types.ts/css-filter";
16
-
17
- //Latest Update.
18
- /*
19
- * - Wrapped code in anonymous function.
20
- * - Hid _Builder and _StyleProperty.
21
- * - Increased compatibility with IE 8, 9, and 10.
22
- * - Allowed 0-length animations.
23
- * 5.1
24
- * - Typified style builder.
25
- * - Fixed up transformations and redid transform builder.
26
- * - Removed some old junk.
27
- */
28
-
29
- const STATIC_SYLES_ATTR = "data-dot-static-styles";
30
-
31
- // Rename this to DotcssHelpers.
32
- // The name Dotcss2 comes from a time when this was a clone of dotcss with "private" members.
33
- class Dotcss2{
34
- //Inverse of framerate in ms/frame.
35
- // Used for old browsers that don't support requestAnimationFrameframe.
36
- fxInterval = 1000/60;
37
-
38
- lastBuilder: _Builder = null;
39
- scopeStack: Array<HTMLElement> = [];
40
-
41
- globalStyleElement: HTMLStyleElement = null;
42
-
43
- animateFull(
44
- element: HTMLElement,
45
- jsFriendlyProp: string,
46
- propType: string,
47
- startValue: any,
48
- targetValue: any,
49
- finalValue: any,
50
- currentTime: number,
51
- totalDuration: number,
52
- animationStyle: AnimationType,
53
- callback: Function,
54
- lastValue?: any){
55
- if(lastValue && element.style[jsFriendlyProp] != lastValue) return; //Animation can be cancelled any time by setting the value directly.
56
-
57
- if(totalDuration - currentTime > 0){
58
- switch(propType){
59
- case "color":
60
- var r = Math.round(numberStep(startValue.r, targetValue.r, currentTime, totalDuration, animationStyle));
61
- var g = Math.round(numberStep(startValue.g, targetValue.g, currentTime, totalDuration, animationStyle ));
62
- var b = Math.round(numberStep(startValue.b, targetValue.b, currentTime, totalDuration, animationStyle ));
63
- var a = dotcss.formatNumberValue(numberStep(startValue.a, targetValue.a, currentTime, totalDuration, animationStyle )); //TODO: make sure this doesn't need to be rounded or something.
64
- dotcss(element)[jsFriendlyProp](r, g, b, a);
65
- break;
66
- case "length":
67
- dotcss(element)[jsFriendlyProp](dotcss.formatNumberValue(numberStep(startValue.length, targetValue.length, currentTime, totalDuration, animationStyle), startValue.units) + startValue.units);
68
- break;
69
- case "transformation":
70
- var newTransform = "";
71
- //startValue and targetValue are guaranteed to have the same template.
72
- for(var i = 0; i < startValue.transformations.length; i++){
73
- var t1 = startValue.transformations[i];
74
- var t2 = targetValue.transformations[i];
75
- newTransform += t1.transformation + "(";
76
- for(var k = 0; k < t1.args.length; k++){
77
- var v1 = t1.args[k];
78
- var v2 = t2.args[k];
79
- var actualV1 = isNaN(v1) ? v1.length || v1.angle || v1.value || 0 : v1;
80
- var actualV2 = isNaN(v2) ? v2.length || v2.angle || v2.value || 0 : v2;
81
- var units = isNaN(v1) ? v1.units : "";
82
- newTransform += dotcss.formatNumberValue(numberStep(actualV1, actualV2, currentTime, totalDuration, animationStyle), units) + units + ",";
83
- }
84
- newTransform = newTransform.substring(0, newTransform.length - 1);
85
- newTransform += ") ";
86
- }
87
- dotcss(element)[jsFriendlyProp](newTransform);
88
- break;
89
- default:
90
- switch(startValue.type){
91
- case "number":
92
- dotcss(element)[jsFriendlyProp](dotcss.formatNumberValue(numberStep(startValue.value, targetValue.value, currentTime, totalDuration, animationStyle)));
93
- break;
94
- case "complex":
95
- var newVal = "";
96
- for(var i = 0; i < startValue.numbers.length; i++){
97
- newVal += startValue.parts[i];
98
- newVal += dotcss.formatNumberValue(numberStep(startValue.numbers[i], targetValue.numbers[i], currentTime, totalDuration, animationStyle))
99
- }
100
- newVal += startValue.parts[startValue.parts.length - 1];
101
-
102
- dotcss(element)[jsFriendlyProp](newVal);
103
- break;
104
- default:
105
- console.warn("Unexpected data type for animation.");
106
- }
107
- }
108
-
109
- var now = (window.performance && window.performance.now) ? window.performance.now() : null;
110
- //var reachedAnimFrame = false;
111
- //TODO: there could be a memory leak here. Need to investigate.
112
- //Because we're creating a lot of new functions. Are they being released?
113
- var last = element.style[jsFriendlyProp];
114
- var nextStep = function(timestamp){
115
- var change = (now ? (window.performance.now() - now) : dotcss2.fxInterval);
116
- dotcss2.animateFull(element, jsFriendlyProp, propType, startValue, targetValue, finalValue, currentTime + change, totalDuration, animationStyle, callback, last);
117
- }
118
- if(window.requestAnimationFrame) {
119
- window.requestAnimationFrame(nextStep);
120
- //setTimeout(function(){if(!reachedAnimFrame) console.log("ERROR");}, 100);
121
- }
122
- else window.setTimeout(nextStep, dotcss2.fxInterval);
123
- }
124
- else{
125
- //TODO: verify that decimal values are properly handled here.
126
- dotcss(element)[jsFriendlyProp](finalValue);
127
- if(callback) callback();
128
- }
129
- }
130
-
131
- //Takes the property and generates all the dotcss and builder functions.
132
- extendDothtml(prop, jsFriendlyProp, type){
133
- //Create the new function by extending the builder.
134
- let _b = _Builder.prototype;
135
- _b[jsFriendlyProp] = function(){
136
-
137
- if(arguments.length == 0) return this;
138
- var args = [];
139
- for(var i = 0; i < arguments.length; i++) args.push(arguments[i]);
140
-
141
- // TODO: Why can't I just pass arguments directly into this function?
142
- // Try it.
143
- var value = dotcss2.convertStyleIntoDotCssObject(args, type).toString();
144
-
145
-
146
- var newCss = prop + ":" + value + ";";
147
- this.currentCss += newCss;
148
- // console.log(`SETTING ${jsFriendlyProp}:`, this.toString());
149
- // this.toString()
150
-
151
- if(this.targets){
152
- for(var q = 0; q < this.targets.length; q++){
153
- //this.targets[q].style += newCss;
154
- var t = this.targets[q];
155
- if(t.tagName == "STYLE") t.innerHTML = t.innerHTML.substring(0, t.innerHTML.length - 1) + prop + ":" + value + ";}";
156
- else t.style[jsFriendlyProp] = value;
157
- }
158
- }
159
-
160
- return this;
161
- }
162
- //Add the new function to the dotcss object so that it can be accessed without doing dotcss().
163
- dotcss2.addPropFunctionToDotCssObject(jsFriendlyProp);
164
-
165
- //Each unit of length will also have its own version of this function (assuming this is a length property).
166
- if(type == "length"){
167
- for(var u = 0; u < AllLengthUnits.length; u++){
168
- var uu = AllLengthUnits[u];
169
- (function(uu){
170
- _b[jsFriendlyProp + (uu.jsName || uu.unit)] = function(){
171
- for(var i = 0; i < arguments.length; i++) arguments[i] = arguments[i] + uu.unit.toLowerCase();
172
- return _b[jsFriendlyProp].apply(this, arguments);
173
- }
174
- })(uu);
175
- dotcss2.addPropFunctionToDotCssObject(jsFriendlyProp + (uu.jsName || uu.unit));
176
- }
177
- }
178
-
179
- //_b[jsFriendlyProp].__proto__ = Object.create(_StyleProperty.prototype);
180
- _b[jsFriendlyProp].type = type;
181
- _b[jsFriendlyProp].jsFriendlyProp = jsFriendlyProp;
182
-
183
- // This is weird. It looks like I was trying to implement some form of multilpe inheritance.
184
- // This should really be upgraded.
185
- for (var k in _StyleProperty.prototype) {
186
- if(_b[jsFriendlyProp][k] === undefined) _b[jsFriendlyProp][k] = _StyleProperty.prototype[k];
187
- }
188
- }
189
-
190
- //Returns a JSON object representation of value specific to the cssDataType passed in.
191
- convertStyleIntoDotCssObject(value, cssDataType: CssDataTypeToken){
192
- //if(!value) return null;
193
- if(!(value instanceof Array)) value = [value];
194
- if(cssDataType == "color") return new CssColor(value);
195
- else if (cssDataType == "url") return new CssUrl(value);
196
- else if (cssDataType == "length" && (!isNaN(value[0]) || (value[0].indexOf(" ") == -1 && value[0].replace(floatRegex, "") != value[0]))) return new CssLength(value[0]);
197
- else if (cssDataType == "transformation") return (new CssTransform(value[0])).toString()
198
- else if (cssDataType == "filter") return (new CssFilter(value[0])).toString()
199
- else{
200
- if(value[0] === ""
201
- || (
202
- (isNaN(value[0]))
203
- && ("" + value[0]).replace(floatRegex, "") == value[0])
204
- ) return new CssUnknown(value[0]); //No numbers.
205
- if(isNaN(value[0])) return new CssComplex(value[0]); //Numbers
206
- else return new CssNumber(value[0]); //Just a number.
207
- }
208
-
209
- };
210
-
211
- //Ensures that two complex values match.
212
- compareComplexDataTypes(value1, value2){
213
- if(value1.type != "complex" || value2.type != "complex") return false;
214
- if(value1.numbers.length != value2.numbers.length) return false;
215
- if(value1.parts.length != value2.parts.length) return false;
216
- for(var i = 0; i < value1.parts.length; i++){
217
- if(value1.parts[i] != value2.parts[i]) return false;
218
- }
219
- return true;
220
- };
221
-
222
- //Adds a builder function directly to the dotcss object so that dotcss doesn't
223
- //have to be used as a function when a target doesn't need to be specified.
224
- addPropFunctionToDotCssObject(funcName){
225
- dotcss[funcName] = function(){
226
- var n = new _Builder();
227
- return n[funcName].apply(n, arguments);
228
- }
229
- };
230
-
231
- // Might remove this.
232
- // I think this doesn't work. Removing now. Not sure what it was supposed to do.
233
- // makeTransformFunction(fn){
234
- // dotcss[fn] = function(){
235
- // var n = new Transform();
236
- // return n[fn].apply(n, arguments);
237
- // };
238
- // }
239
-
240
- computedStyleOrActualStyle(element, property){
241
- return window.getComputedStyle(element)[property] || element.style[property];
242
- };
243
-
244
- modDeg(a){
245
- if(a < 0) a = 360 - ((-a) % 360);
246
- return a % 360;
247
- };
248
- }
249
- const dotcss2 = new Dotcss2();
250
-
251
-
252
- const dotcss = function(query:Array<HTMLElement>|HTMLElement|Array<string>|string){
253
- //this.currentCss = "";
254
- var target = null;
255
- if(query){
256
- // console.log(query, "?");
257
- if( typeof query == "string" ) {
258
- // Creating a style tag. Might not be supported forever.
259
- if(query.length > 2 && query.indexOf("{}") == query.length - 2){
260
- // TODO: this needs further testing, particularly when mulitple sytles are set on the same page.
261
- // Be sure to set up some tests.
262
- query = query.substring(0, query.length - 2);
263
-
264
- if(!dotcss2.globalStyleElement){
265
- dotcss2.globalStyleElement = document.createElement("style");
266
- document.head.appendChild(dotcss2.globalStyleElement);
267
- }
268
- target = [dotcss2.globalStyleElement];
269
- target[0].innerHTML += query + "{}\r\n";
270
- }
271
- else {
272
- // This is overly complicated, but here is the spiel.
273
- // If there's an element on the scopeStack, it should be used with the querySelectorAll.
274
- // BUT, querySelectorAll doesn't actually select the element it's currently on, which is a requirement for dothtml.
275
- // To make matters worse, if we do querySelectorAll on the element's parents, we may accidentally select its siblings!!
276
- // To fix this, we get a list from querySelectorAll on the element, then push the element itself to that list
277
- // iff it is in the list of elements queried from its parent.
278
- // In addition to all of that, we don't want scoped styles to be applied to child components.
279
- var s0 = dotcss2.scopeStack[0];
280
- // if(s0 instanceof Component){
281
- // s0 = s0.$el;
282
- // }
283
- // If we're doing scoped, and it's an element.
284
- if(s0 && s0.parentNode && s0.querySelectorAll){
285
- // console.log(s0);
286
- target = getScopedNodeList(query, s0);
287
- }
288
- else{
289
- target = document.querySelectorAll(query as string);
290
- }
291
- // target = referencePt.querySelectorAll(query);
292
- }
293
- }
294
-
295
- if((query instanceof NodeList) || (query instanceof Array)) target = query;
296
- if(query instanceof Node) target = [query]; //Doesn't need to be a NodeList. Just iterable.
297
- }
298
- dotcss2.lastBuilder = new _Builder(target);
299
- return dotcss2.lastBuilder;
300
- } as unknown as IDotCss; // We do this because many of the dotcss methods are generated at runtime. Greatly reduces build size.
301
-
302
-
303
- dotcss.version = "0.16.0";
304
-
305
- function getScopedNodeList(query: String, s0: Element): Array<HTMLElement>{
306
- // Get all of the matching child elements of the component. This will not include s0 itself, but it does include nested components.
307
- // So we will need to manipulate this collection.
308
- // querySelectorAll returns a NodeList, which we need to convert into an Array.
309
- var target = Array.from(s0.querySelectorAll(query as any));
310
- // console.log(query, s0.className);
311
-
312
- // Exclude nested components.
313
- for(var t = 0; t < target.length; t++){
314
- var T = target[t];
315
-
316
- // Is it a nested component??
317
- if(T["__dothtml_component"]){
318
- // It's a component. Remove it, and all of it's descendants.
319
- target.splice(t, 1);
320
- t--;
321
-
322
- var subTargets = T.querySelectorAll(query as any);
323
- for(var s = 0; s < subTargets.length; s++){
324
- let S = subTargets[s];
325
- target.splice(target.indexOf(S, t + 1), 1);
326
- }
327
- }
328
- }
329
-
330
- // Loop through all the sibling nodes until we find s0.
331
- var parentTargets = Array.from(s0.parentNode.querySelectorAll(query as any));
332
-
333
- var p = parentTargets.indexOf(s0);
334
- if(p != -1){
335
- target.unshift(parentTargets[p]);
336
- }
337
-
338
- return target;
339
- }
340
-
341
- /**
342
- * The dotcss builder gets extended with all of the css functions at runtime.
343
- */
344
- export class _Builder{
345
- currentCss: string;
346
- targets: Array<HTMLElement>;
347
- constructor(targets?: Array<HTMLElement>){
348
- this.currentCss = "";
349
- this.targets = targets ?? null;
350
- }
351
-
352
- toString(){
353
- // console.log("CALLED TOSTRING!", this.currentCss);
354
- return this.currentCss;
355
- }
356
-
357
- // These methods are a bit strange to have here.
358
- // They should probably be a part of the dotcss core object or something.
359
- // Also, they're the only items that are explicitly part of the builder rather than generated.
360
-
361
- //Usage:
362
- //hide()
363
- //hide(duration, complete)
364
- //hide(options)
365
- //Options
366
- // display: inline-block, block, etc.
367
- // duration: duration in ms.
368
- // complete: on-complete callback.
369
- // hideStyle: fade, shrink, or normal
370
- // animationStyle: linear or exponential
371
- hide(style?: {
372
- duration
373
- hideStyle
374
- complete
375
- }){
376
- if(this.targets){
377
- var arg0: HideParams|number = arguments[0] || {};
378
- var arg0N = arg0 as number;
379
- var arg0O = arg0 as HideParams;
380
- var ops: HideParams = {};
381
- ops.duration = arg0O.duration || (isNaN(arg0N) ? 0 : arg0N) || 0;
382
- //ops.display = arg0.display || "none";
383
- //ops.opacity = arg0.opacity || null;
384
- //ops.width = arg0.width || null;
385
- //ops.height = arg0.height || null;
386
- ops.complete = arg0O.complete || (typeof arguments[1] == "function" ? arguments[1] : (typeof arguments[2] == "function" ? arguments[2] : function(){}));
387
- ops.hideStyle = arg0O.hideStyle || "normal";
388
- ops.animationStyle = arg0O.animationStyle || (typeof arguments[1] == "string" ? arguments[1] as any : "ease");
389
-
390
- if(ops.duration > 0){
391
- let doneCnt = 0;
392
- let m = 0;
393
- let q = this.targets.length;
394
- for(let i = 0; i < this.targets.length; i++){
395
- let w = this.targets[i].style.width as NumericLength;
396
- let h = this.targets[i].style.height as NumericLength;
397
- let oStr = this.targets[i].style.opacity;
398
- let o: number;
399
- if(!oStr || oStr === "") o = 1;
400
- else o = Number(oStr);
401
- let ov = this.targets[i].style.overflow;
402
- if(ops.hideStyle != "fade"){
403
- this.targets[i].style.overflow = "hidden";
404
- m += 2;
405
- (function(that, t, w: NumericLength, h: NumericLength, ov){
406
- dotcss(t).width.animate(0, ops.duration, ops.animationStyle, function(){
407
- dotcss(t).display("none").width(w).overflow(ov); //Restore original overflow value. Only needs to be done once.
408
- doneCnt++; if(doneCnt >= m * q) ops.complete(that);
409
- });
410
- dotcss(t).height.animate(0, ops.duration, ops.animationStyle, function(){
411
- dotcss(t).display("none").height(h);
412
- doneCnt++; if(doneCnt >= m * q) ops.complete(that);
413
- });
414
- })(this, this.targets[i], w, h, ov);
415
- }
416
- if(ops.hideStyle != "shrink"){
417
- m++;
418
- (function(that, t, o){
419
- return dotcss(t).opacity.animate(0, ops.duration, ops.animationStyle, function(){
420
- dotcss(t).display("none").opacity(o);
421
- doneCnt++; if(doneCnt >= m * q) ops.complete(that);
422
- });
423
- })(this, this.targets[i], o);
424
- }
425
- }
426
- }
427
- else{
428
- dotcss(this.targets).display("none");
429
- ops.complete(this); //This sets the display to none.
430
- }
431
- }
432
- return this;
433
- }
434
-
435
- //Usage:
436
- //show()
437
- //show(duration, complete)
438
- //show(options)
439
- //Options
440
- // display: inline-block, block, etc.
441
- // opacity: final opacity.
442
- // width: final width.
443
- // height: final height.
444
- // duration: duration in ms.
445
- // complete: on-complete callback.
446
- // showStyle: fade, grow, or normal
447
- // animationStyle: linear or exponential
448
- show(style?: {
449
- duration
450
- showStyle
451
- complete
452
- }){
453
- if(this.targets){
454
- let arg0 = arguments[0] || {};
455
- let arg0N = arg0 as number;
456
- let arg0O = arg0 as ShowParams;
457
- let ops: ShowParams = {};
458
- ops.duration = arg0O.duration || (isNaN(arg0N) ? 0 : arg0N) || 0;
459
- ops.display = arg0O.display || "block";
460
- ops.opacity = arg0O.opacity;
461
- ops.width = arg0O.width || null;
462
- ops.height = arg0O.height || null;
463
- ops.complete = arg0O.complete || (typeof arguments[1] == "function" ? arguments[1] : (typeof arguments[2] == "function" ? arguments[2] : function(){}));
464
- ops.showStyle = arg0O.showStyle || "normal";
465
- ops.animationStyle = arg0O.animationStyle || (typeof arguments[1] == "string" ? arguments[1] as any : "ease");
466
-
467
- if(ops.duration > 0){
468
- let doneCnt = 0;
469
- let q = this.targets.length;
470
- let m = 0;
471
- for(let i = 0; i < this.targets.length; i++){
472
- let o = ops.opacity;
473
- if(ops.opacity === undefined){
474
- o = parseFloat(this.targets[i].style.opacity) || 1;
475
- }
476
- if(ops.showStyle != "fade"){
477
- m += 2;
478
- let w = ops.width || this.targets[i].style.width as NumericLength;
479
- let h = ops.height || this.targets[i].style.height as NumericLength;
480
-
481
- dotcss(this.targets[i]).width(0);
482
- dotcss(this.targets[i]).height(0);
483
- // console.log(doneCnt + " " + q*m);
484
- dotcss(this.targets[i]).width.animate(w, ops.duration, ops.animationStyle, function(){doneCnt++; if(doneCnt >= q * m) ops.complete();});
485
- dotcss(this.targets[i]).height.animate(h, ops.duration, ops.animationStyle, function(){doneCnt++; if(doneCnt >= q * m) ops.complete();});
486
- }
487
-
488
- //let o = this.targets[i].style.opacity; //Guess I should fade to 1?
489
- dotcss(this.targets[i]).opacity(0);
490
- dotcss(this.targets[i]).display(ops.display);
491
-
492
- if(ops.showStyle != "grow"){
493
- m++;
494
- dotcss(this.targets[i]).opacity.animate(o, ops.duration, ops.animationStyle, function(){doneCnt++; if(doneCnt == q * m) ops.complete();});
495
- }
496
- }
497
- }
498
- else{
499
- return dotcss(this.targets).display(ops.display);
500
- }
501
- }
502
- return this;
503
- }
504
-
505
- fadeOut(duration, complete){
506
- return this.hide({
507
- duration: isNaN(duration) ? 400 : Number(duration),
508
- hideStyle: "fade",
509
- complete: complete
510
- });
511
- };
512
-
513
- fadeIn(duration, complete){
514
- return this.show({
515
- duration: isNaN(duration) ? 400 : Number(duration),
516
- showStyle: "fade",
517
- complete: complete
518
- });
519
- };
520
- }
521
-
522
- // This could be better handeld. Consider putting it inside the dotcss class.
523
- dotcss.prototype.toString = _Builder.prototype.toString;
524
-
525
- // Why do we need this?
526
- class _StyleProperty{
527
- type: CssDataTypeToken;
528
- jsFriendlyProp: string;
529
- constructor(){
530
- this.type = null;
531
- this.jsFriendlyProp = null;
532
-
533
- }
534
- //toString override gets the value.
535
- toString(): string{
536
- if(dotcss2.lastBuilder.targets){
537
- // TODO: this doesn't make sense. Please figure it out.
538
- let ret = null;
539
- if(dotcss2.lastBuilder.targets.length > 1){
540
- ret = [];
541
- for(let i = 0; i < dotcss2.lastBuilder.targets.length; i++){
542
- ret.push(dotcss2.lastBuilder.targets[i].style[this.jsFriendlyProp]);
543
- }
544
- }
545
- else ret = dotcss2.lastBuilder.targets[0].style[this.jsFriendlyProp];
546
- return ret;
547
- }
548
- else return null;
549
- }
550
-
551
- //val is another special function that breaks the value into a special object.
552
- val(){
553
- if(dotcss2.lastBuilder.targets){
554
- let ret = null;
555
- // TODO: something wrong with this. Types don't check out.
556
- if(dotcss2.lastBuilder.targets.length > 1){
557
- ret = null;
558
- for(let i = 0; i < dotcss2.lastBuilder.targets.length; i++){
559
- if(dotcss2.lastBuilder.targets[0].style[this.jsFriendlyProp]){
560
- ret.push(dotcss2.convertStyleIntoDotCssObject(dotcss2.lastBuilder.targets[i].style[this.jsFriendlyProp], this.type));
561
- }
562
- else ret.push(null);
563
- }
564
- }
565
- else{
566
- if(dotcss2.lastBuilder.targets[0].style[this.jsFriendlyProp]){
567
- ret = dotcss2.convertStyleIntoDotCssObject(dotcss2.lastBuilder.targets[0].style[this.jsFriendlyProp], this.type)
568
- }
569
- else ret = null;
570
- }
571
- return ret;
572
- }
573
- else return null;
574
- }
575
-
576
- //Ability to animate just like jquery.
577
- //complete does not get called if the animation was cancelled.
578
- animate(value, duration, style, complete){
579
- duration = isNaN(duration) ? 400 : (duration || 0);
580
- if(dotcss2.lastBuilder && dotcss2.lastBuilder.targets){
581
- if(!complete && style && style.call && style.apply){ //Fix params.
582
- complete = style;
583
- style = undefined;
584
- }
585
- for(let i = 0; i < dotcss2.lastBuilder.targets.length; i++){
586
- let target = dotcss2.lastBuilder.targets[i];
587
- let oldValue = null;
588
- let newValue = null;
589
- let finalValue = null; //newValue might be in different units from the final value...
590
-
591
- //Get the old and new values.
592
- newValue = dotcss2.convertStyleIntoDotCssObject(value, this.type);
593
-
594
- //If it's a transformation, a little extra work is required.
595
- //Need to frame all the rotations properly, and combine both the new and the old transformations.
596
- if(this.type == "transformation"){
597
- //Special handling. We'd like to consider the transformation as a complex data type first, then if that's not possible, convert it into a matrix data type.
598
- //Reason being: linear transformations on matrices are inaccurate. Rotations end up scaling the target.
599
- //Don't want to get the computed value for transformations.
600
- oldValue = dotcss2.convertStyleIntoDotCssObject(target.style[this.jsFriendlyProp], this.type);
601
- }
602
- if(!oldValue){ //Standard. Happens when the type is not a transformation.
603
- oldValue = dotcss2.convertStyleIntoDotCssObject(dotcss2.computedStyleOrActualStyle(target, this.jsFriendlyProp), this.type);
604
- }
605
-
606
- finalValue = newValue.toString();
607
-
608
- //Do a little type/unit checking.
609
-
610
- if(this.type == "length"){
611
- if(oldValue.units != newValue.units){
612
- //Need to rectify this.
613
- //This can get messy. If one of the lengths is zero, it would minimize the likelihood of an error.
614
- if(oldValue.length == 0){
615
- oldValue.units = newValue.units;
616
- oldValue.length = 0;
617
- }
618
- else if(newValue.length == 0){
619
- newValue.units = oldValue.units;
620
- newValue.length = 0;
621
- }
622
- else{
623
- //Things are messy. Try to mitigate. Convert the old value into the new units, as best we can.
624
- let currentLengthPx = dotcss.lengthToPx(oldValue.toString(), this.jsFriendlyProp as LengthProp, target);
625
- let newLengthPx = dotcss.lengthToPx(newValue.toString(), this.jsFriendlyProp as LengthProp, target);
626
- oldValue.length = currentLengthPx;
627
- oldValue.units = "px";
628
- newValue.length = newLengthPx;
629
- newValue.units = "px";
630
-
631
- //Won't need this anymore.
632
- //console.warn("Couldn't animate " + this.jsFriendlyProp + ". Inconsistent units.");
633
- //return dotcss2._lastBuilder;
634
- }
635
- }
636
- }
637
- else if(this.type == "color"){} //OK
638
- else if(this.type == "transformation"){
639
- //Couple things to do here.
640
- //1. The old and new values must contain the exact same transformation template.
641
- //2. Angles in the old transformation should be reframed so that they are close to the new angles (or should they)
642
-
643
- let startTransform = "";
644
- let desiredTransform = "";
645
- let oldIndex = oldValue.transformations.length - 1;
646
- let newIndex = newValue.transformations.length - 1;
647
- while(oldIndex >= 0 || newIndex >= 0){
648
- let transformToAdd = "";
649
- let oldTransformValues = null;
650
- let newTransformValues = null;
651
- if(oldIndex >= 0 && newIndex >= 0 && oldValue.transformations[oldIndex].transformation == newValue.transformations[newIndex].transformation){
652
- let currentOldT = oldValue.transformations[oldIndex];
653
- let currentNewT = newValue.transformations[newIndex];
654
-
655
- transformToAdd = currentOldT.transformation;
656
- oldTransformValues = currentOldT.args;
657
- newTransformValues = currentNewT.args;
658
-
659
- oldIndex--;
660
- newIndex--;
661
- }
662
- else if(oldIndex >= newIndex){
663
- let currentOldT = oldValue.transformations[oldIndex];
664
- transformToAdd = currentOldT.transformation;
665
- oldTransformValues = currentOldT.args;
666
- if(transformToAdd == "matrix"){
667
- newTransformValues = [1,0, 0,1, 0,0];
668
- }
669
- else if(transformToAdd == "matrix3d"){
670
- newTransformValues = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1];
671
- }
672
- else {
673
- let filler = (transformToAdd.indexOf("scale") == -1) ? 0 : 1;
674
- newTransformValues = [];
675
- for(let j = 0; j < oldTransformValues.length; j++) newTransformValues.push(!isNaN(oldTransformValues[j]) ? filler : (
676
- !isNaN(oldTransformValues[j].angle) ? new CssAngle(0) : (
677
- !isNaN(oldTransformValues[j].length) ? new CssLength(0) : (0)
678
- )));
679
- }
680
- oldIndex--;
681
- }
682
- else{
683
- let currentNewT = newValue.transformations[newIndex];
684
- transformToAdd = currentNewT.transformation;
685
- newTransformValues = currentNewT.args;
686
- if(transformToAdd == "matrix"){
687
- oldTransformValues = [1,0, 0,1, 0,0];
688
- }
689
- else if(transformToAdd == "matrix3d"){
690
- oldTransformValues = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1];
691
- }
692
- else {
693
- let filler = (transformToAdd.indexOf("scale") == -1) ? 0 : 1;
694
- oldTransformValues = [];
695
- for(let j = 0; j < newTransformValues.length; j++) oldTransformValues.push(!isNaN(newTransformValues[j]) ? filler : (
696
- !isNaN(newTransformValues[j].angle) ? new CssAngle(0) : (
697
- !isNaN(newTransformValues[j].length) ? new CssLength(0) : (0)
698
- )));
699
- }
700
- newIndex--;
701
- }
702
-
703
- startTransform = ") " + startTransform;
704
- desiredTransform = ") " + desiredTransform;
705
- //Handle special values here.
706
- if(transformToAdd.indexOf("rotate") != -1){
707
- let oldAngle = oldTransformValues[oldTransformValues.length - 1].angle;
708
- let newAngle = newTransformValues[newTransformValues.length - 1].angle;
709
- let sep = dotcss.angleSubtract(newAngle, oldAngle);
710
- oldTransformValues[oldTransformValues.length - 1].angle = newAngle - sep;
711
- }
712
- for(let j = oldTransformValues.length - 1; j >= 0; j--){
713
- startTransform = "," + oldTransformValues[i] + startTransform;
714
- desiredTransform = "," + newTransformValues[i] + desiredTransform;
715
- }
716
- startTransform = transformToAdd + "(" + startTransform.substring(1);
717
- desiredTransform = transformToAdd + "(" + desiredTransform.substring(1);
718
- }
719
- oldValue = dotcss2.convertStyleIntoDotCssObject(startTransform, "transformation");
720
- newValue = dotcss2.convertStyleIntoDotCssObject(desiredTransform, "transformation");
721
-
722
- }
723
- else if(oldValue.type == "number" && newValue.type == "number"){} //OK
724
- else if(oldValue.type == "complex" && newValue.type == "complex"){
725
- if(!dotcss2.compareComplexDataTypes(oldValue, newValue)){
726
- console.warn("Couldn't animate " + this.jsFriendlyProp + ". Value mismatch.");
727
- continue;
728
- }
729
- }
730
- else{
731
- console.warn("Couldn't animate " + this.jsFriendlyProp + ". Not a recognizable length, color, or number.");
732
- continue;
733
- }
734
- dotcss2.animateFull(target, this.jsFriendlyProp, oldValue.type || this.type, oldValue, newValue, finalValue, dotcss2.fxInterval, duration, style || "ease", complete);
735
- }
736
- }
737
- return dotcss2.lastBuilder;
738
- }
739
-
740
- //Have to add these back since we're going to replace the __proto__ of a function with this new prototype.
741
- apply = Function.apply;
742
- call = Function.call;
743
- };
744
-
745
- dotcss.formatNumberValue = function(value, unit){
746
- switch(unit){
747
- case "px": return Math.round(value);
748
- default: return Math.round(value * 100) / 100;
749
- }
750
- };
751
-
752
- const _allProps = {
753
- color: "color|background-Color|border-Bottom-Color|border-Color|border-Left-Color|border-Right-Color|border-Top-Color|text-Decoration-Color|outline-Color|column-Rule-Color",
754
- length: "background-Size|block-Size|border-Bottom-Left-Radius|border-Bottom-Right-Radius|border-Bottom-Width|border-Image-Width|border-Left-Width|border-Radius|border-Right-Width|border-Top-Left-Radius|border-Top-Right-Radius|border-Top-Width|border-Width|bottom|gap|height|left|margin|margin-Bottom|margin-Left|margin-Right|margin-Top|max-Height|max-Width|min-Height|min-Width|padding|padding-Bottom|padding-Left|padding-Right|padding-Top|right|top|width|line-Height|flex-Basis|font-Size",
755
- url: "background-Image|border-Image|list-Style-Image|content|image-Orientation",
756
- transformation: "transform",
757
- filter: "filter|backdrop-Filter",
758
- misc: "appearance|aspect-Ratio|opacity|background|background-Attachment|background-Blend-Mode|background-Position|background-Repeat|background-Clip|background-Origin|border|border-Bottom|border-Bottom-Style|border-Image-Outset|border-Image-Repeat|border-Image-Slice|border-Image-Source|border-Left|border-Left-Style|border-Right|border-Right-Style|border-Style|border-Top|border-Top-Style|box-Decoration-Break|box-Shadow|clear|clip|display|float|overflow|box|overflow-X|overflow-Y|position|visibility|vertical-Align|z-Index|align-Content|align-Items|align-Self|flex|flex-Basis|flex-Direction|flex-Flow|flex-Grow|flex-Shrink|flex-Wrap|grid|grid-Area|grid-Auto-Columns|grid-auto-Rows|grid-Column|grid-Column-End|grid-Column-Gap|grid-Column-Start|grid-Gap|grid-Row|grid-Row-End|grid-Row-Gap|grid-Row-Start|grid-Template|grid-Template-Areas|grid-Template-Columns|grid-Template-Rows|justify-Content|order|hanging-Punctuation|hyphens|letter-Spacing|line-Break|overflow-Wrap|tab-Size|text-Align|text-Align-Last|text-Combine-Upright|text-Indent|text-Justify|text-Transform|white-Space|word-Break|word-Spacing|word-Wrap|text-Decoration|text-Decoration-Line|text-Decoration-Style|text-Shadow|text-Underline-Position|font|font-Family|font-Feature-Settings|font-Kerning|font-Language-Override|font-Size-Adjust|font-Stretch|font-Style|font-Synthesis|font-Variant|font-Variant-Alternates|font-Variant-Caps|font-Variant-East-Asian|font-Variant-Ligatures|font-Variant-Numeric|font-Variant-Position|font-Weight|direction|text-Orientation|text-Combine-Upright|unicode-Bidi|user-Select|writing-Mode|border-Collapse|border-Spacing|caption-Side|empty-Cells|table-Layout|counter-Increment|counter-Reset|list-Style|list-Style-Position|list-Style-Type|animation|animation-Delay|animation-Direction|animation-Duration|animation-Fill-Mode|animation-Iteration-Count|animation-Name|animation-Play-State|animation-Timing-Function|backface-Visibility|perspective2d|perspective-Origin|transform-Origin|transform-Style|transition|transition-Property|transition-Duration|transition-Timing-Function|transition-Delay|box-Sizing|cursor|ime-Mode|nav-Down|nav-Index|nav-Left|nav-Right|nav-Up|outline|outline-Offset|outline-Style|outline-Width|resize|text-Overflow|break-After|break-Before|break-Inside|column-Count|column-Fill|column-Gap|column-Rule|column-Rule-Style|column-Rule-Width|column-Span|column-Width|columns|widows|orphans|page-Break-After|page-Break-Before|page-Break-Inside|marks|quotes|image-Rendering|image-Resolution|object-Fit|object-Position|mask|mask-Type|mark|mark-After|mark-Before|phonemes|rest|rest-After|rest-Before|voice-Balance|voice-Duration|voice-Pitch|voice-Pitch-Range|voice-Rate|voice-Stress|voice-Volume|marquee-Direction|marquee-Play-Count|marquee-Speed|marquee-Style|pointer-Events"
759
- }
760
-
761
- // const _allTransforms = [
762
- // "matrix",
763
- // "matrix3d",
764
- // "translate",
765
- // "translate3d",
766
- // "translateX",
767
- // "translateY",
768
- // "translateZ",
769
- // "scale",
770
- // "scale3d",
771
- // "scaleX",
772
- // "scaleY",
773
- // "scaleZ",
774
- // "rotate",
775
- // "rotate3d",
776
- // "rotateX",
777
- // "rotateY",
778
- // "rotateZ",
779
- // "skew",
780
- // "skewX",
781
- // "skewY",
782
- // "perspective"
783
- // ]
784
-
785
- // TODO: this may have been intended to be private.
786
-
787
- dotcss.matrixMultiply3D = function(A: Array<number>, B: Array<number>){
788
- if(A.length != 16 || B.length != 16) throw "3D matrices must be arrays of 16 length.";
789
- var ret = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
790
- for(var y = 0; y < 4; y++)
791
- for(var x = 0; x < 4; x++)
792
- for(var i = 0; i < 4; i++)
793
- ret[y + x * 4] += Number(A[y + i * 4]) * Number(B[i + x * 4]);
794
- return ret;
795
- };
796
-
797
- //Public functions.
798
-
799
- // TODO: this doesn't really belong in here. This is like a math lib.
800
-
801
-
802
-
803
- // // TODO: I don't think these are really needed. The css types take care of these.
804
-
805
- // dotcss.angleSubtract = function(a: number, b: number):number{
806
- // if(a < 0) a = 360 - ((-a) % 360); else a = a % 360;
807
- // if(b < 0) b = 360 - ((-b) % 360); else b = b % 360;
808
- // var phi = Math.abs(b - a) % 360;
809
- // var d = phi > 180 ? 360 - phi : phi;
810
- // var sign = (a - b >= 0 && a - b <= 180) || (a - b <=-180 && a- b>= -360) ? 1 : -1;
811
- // return d * sign;
812
- // };
813
-
814
- // //Special handler for building urls.
815
- // dotcss.url = function(url: string): string{
816
- // return `url('${url}')`;
817
- // };
818
-
819
- // //Special handler for building rgb colors.
820
- // dotcss.rgb = function(r: number, g: number, b: number): string{
821
- // return `rgb(${r},${g},${b})`;
822
- // };
823
-
824
- // //Special handler for building rgba colors.
825
- // dotcss.rgba = function(r: number, g: number, b: number, a: number): string{
826
- // return `rgba(${r},${g},${b},${a})`;
827
- // };
828
-
829
- // We don't do this anymore.
830
- // dotcss.buildTransform = function(){
831
- // return new dotcss2._Transform();
832
- // };
833
-
834
- dotcss["cacheScopedStaticStyles"] = function(el: HTMLElement){
835
- let elements = getScopedNodeList("*", el);
836
- for(let element of elements){
837
- if(element.hasAttribute("style")){
838
- element.setAttribute(STATIC_SYLES_ATTR, element.getAttribute("style"));
839
- }
840
- }
841
- }
842
-
843
- dotcss["clearDynamicStyles"] = function(el: HTMLElement){
844
- let elements = getScopedNodeList("*", el);
845
- for(let element of elements){
846
- element.removeAttribute("style");
847
- if(element.hasAttribute(STATIC_SYLES_ATTR)){
848
- element.setAttribute("style", element.getAttribute(STATIC_SYLES_ATTR));
849
- }
850
- }
851
- }
852
-
853
- dotcss.scopeToEl = function(el: HTMLElement){
854
- dotcss2.scopeStack.unshift(el);
855
- return this;
856
- };
857
- dotcss.unscope = function(){
858
- dotcss2.scopeStack.shift();
859
- return this;
860
- };
861
-
862
- //Build dotcss.
863
- for(var k in _allProps) {
864
- let P = _allProps[k].split("|");
865
- for(var i in P){
866
- dotcss2.extendDothtml(P[i].toLowerCase(), P[i].replace(new RegExp("-", "g"), ""), k);
867
- }
868
- }
869
- // for(let i: number = 0; i < _allLengthUnits.length; i++) dotcss2.makeTransformFunction(_allLengthUnits[i]);
870
-
871
- //dotcss = new dotcss();
872
-
873
- // for (var k in _b) {
874
- // if(_Builder[k] === undefined) dotcss[k] = _p[k];
875
- // }
876
-
877
- export default dotcss;
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
- // Old stuff that might not be needed anymore?
886
- // angleToDeg: function(a: number|string){
887
- // if(!isNaN(a as number)) return Number(a); //If there are no units, assume deg.
888
- // a = (a as string).trim();
889
- // if(a.indexOf("deg") != -1) return dotcss.formatNumberValue(Number(a.split("deg")[0]));
890
- // else if(a.indexOf("grad") != -1) return dotcss.formatNumberValue(Number(a.split("grad")[0]) * 0.9);
891
- // else if(a.indexOf("rad") != -1) return dotcss.formatNumberValue(Number(a.split("rad")[0]) * 180 / Math.PI);
892
- // else if(a.indexOf("turn") != -1) return dotcss.formatNumberValue(Number(a.split("turn")[0]) * 360);
893
- // else throw a + " does not have valid units for an angle."
894
- // }, lengthToPx: function(l: string|number, prop?: LengthProp, element?: Element){
895
- // var R = Math.round;
896
- // var N = Number;
897
- // if(!isNaN(l as number)) return R(N(l)); //If there are no units, assume px.
898
- // l = (l as string).trim();
899
- // var S = l.split;
900
- // //Absolute:
901
- // if(l.indexOf("px") != -1) return R(N(l.split("px")[0]));
902
- // else if(l.indexOf("in") != -1) return R(N(l.split("in")[0]) * 96);
903
- // else if(l.indexOf("pt") != -1) return R(N(l.split("pt")[0]) * 96 / 72);
904
- // else if(l.indexOf("pc") != -1) return R(N(l.split("pc")[0]) * 16);
905
- // else if(l.indexOf("cm") != -1) return R(N(l.split("cm")[0]) * 96 / 2.54);
906
- // else if(l.indexOf("mm") != -1) return R(N(l.split("mm")[0]) * 96 / 25.4);
907
- // else if(l.indexOf("q") != -1) return R(N(l.split("q")[0]) * 96 / 101.6);
908
- // //Technically relative:
909
- // else if(l.indexOf("vw") != -1) return R(N(l.split("vw")[0]) * 0.01 * Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
910
- // else if(l.indexOf("vh") != -1) return R(N(l.split("vh")[0]) * 0.01 * Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
911
- // else if(l.indexOf("vmin") != -1) return Math.min(Util.lengthToPx(R(N(l.split("vmin")[0]+ "vw"))), R(N(l.split("vmin")[0]+ "vx"))); //I know this is slow, but it's compact, and it's not like this is a common unit.
912
- // else if(l.indexOf("vmax") != -1) return Math.max(Util.lengthToPx(R(N(l.split("vmin")[0]+ "vw"))), R(N(l.split("vmin")[0]+ "vx")));
913
- // else if(l.indexOf("rem") != -1) return R(N(l.split("rem")[0]) * Util.lengthToPx(dotcss2._computedStyleOrActualStyle(document.body, "fontSize"))); //Couldn't get a stack overflow if it's a computed value. Always in px.
914
-
915
- // //Absolutely relative:
916
- // else if (prop && element) {
917
- // //If we're setting things relative to font sizes, that's easy.
918
- // //Can't animate ex or ch. Sorry.
919
- // if(l.indexOf("em") != -1) return R(N(l.split("em")[0]) * Util.lengthToPx(dotcss2._computedStyleOrActualStyle(element, "fontSize")));
920
-
921
- // var ref = null;
922
- // switch(prop){
923
- // case "maxHeight":
924
- // case "minHeight":
925
- // case "top":
926
- // case "bottom":
927
- // case "height":
928
- // if(!element.parentNode) throw "Cannot convert " + l + " " + prop + " to px for an element that has no parent."
929
- // ref = Util.lengthToPx(dotcss2._computedStyleOrActualStyle(element.parentNode, "height"));
930
- // break;
931
- // case "maxHidth":
932
- // case "minWidth":
933
- // case "right":
934
- // case "left":
935
- // case "width":
936
- // case "margin": //Yes, all padding and margins are relative to width.
937
- // case "marginTop":
938
- // case "marginBottom":
939
- // case "marginLeft":
940
- // case "marginRight":
941
- // case "outlineOffset":
942
- // case "padding":
943
- // case "paddingTop":
944
- // case "paddingBottom":
945
- // case "paddingLeft":
946
- // case "paddingRight":
947
- // ref = Util.lengthToPx(dotcss2._computedStyleOrActualStyle(element.parentNode, "width"));
948
- // if(!element.parentNode) throw "Cannot convert " + l + " " + prop + " to px for an element that has no parent."
949
- // break;
950
- // case "lineHeight": //Always relative to font. Would actually be nice to be able to set this relative to container though
951
- // ref = Util.lengthToPx(dotcss2._computedStyleOrActualStyle(element, "fontSize"));
952
- // break;
953
- // case "fontSize": //Thought this is not strictly allowed in css, we'll assume it means relative to current element's height.
954
- // ref = Util.lengthToPx(dotcss2._computedStyleOrActualStyle(element, "height"));
955
- // break;
956
- // default:
957
- // throw "Unable to convert the value " + l + " to px for " + prop + ".";
958
- // }
959
-
960
- // if(isNaN(ref)) throw "Convert the value " + l + " to px for " + prop + " because the value it is relative to is not a number.";
961
-
962
- // if(l.indexOf("%") != -1) return R(N(l.split("%")[0]) * 0.01 * ref);
963
- // else throw "The units of " + l + " are not recognized by dotcss.";
964
- // }
965
- // else throw l + " does not have valid units for an absolute length.";
966
- // },