Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/webroot/rsrc/externals/javelin/ext/view/ViewInterpreter.js
12242 views
1
/**
2
* Experimental interpreter for nice views.
3
* This is CoffeeScript:
4
*
5
* d = declare
6
* selectable: false
7
* boxOrientation: Orientation.HORIZONTAL
8
* additionalClasses: ['some-css-class']
9
* MultiAvatar ref: 'avatars'
10
* div
11
* flex: 1
12
* div(
13
* span className: 'some-css-class', ref: 'actorTargetLine'
14
* span className: 'message-css', ref: 'message'
15
* )
16
*
17
* div
18
* boxOrientation: Orientation.HORIZONTAL
19
* className: 'attachment-css-class'
20
* div
21
* className: 'attachment-image-css-class'
22
* ref: 'attachmentImageContainer'
23
* boxOrientation: Orientation.HORIZONTAL
24
* div className: 'inline attachment-text', ref: 'attachmentText',
25
* div
26
* className: 'attachment-title'
27
* ref: 'attachmentTitle'
28
* flex: 1
29
* div
30
* className: 'attachment-subtitle'
31
* ref: 'attachmentSubtitle'
32
* flex: 1
33
* div className: 'clear'
34
* MiniUfi ref: 'miniUfi'
35
* FeedbackFlyout ref: 'feedbackFlyout'
36
*
37
* It renders to nested function calls of the form:
38
* view({....options...}, child1, child2, ...);
39
*
40
* This view interpreter is meant to make it work.
41
*
42
* @provides javelin-view-interpreter
43
* @requires javelin-view
44
* javelin-install
45
* javelin-dom
46
*/
47
48
JX.install('ViewInterpreter', {
49
members : {
50
register : function(name, view_cls) {
51
this[name] = function(/* [properties, ]children... */) {
52
var properties = arguments[0] || {};
53
var children = Array.prototype.slice.call(arguments, 1);
54
55
// Passing properties is optional
56
if (properties instanceof JX.View ||
57
properties instanceof JX.HTML ||
58
properties.nodeType ||
59
typeof properties === 'string') {
60
children.unshift(properties);
61
properties = {};
62
}
63
64
var result = new view_cls(properties).setName(name);
65
result.addChildren(children);
66
67
return result;
68
};
69
}
70
}
71
});
72
73