forked from kriszyp/xstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.js
More file actions
35 lines (35 loc) · 928 Bytes
/
generate.js
File metadata and controls
35 lines (35 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
define([], function(){
function Generate(domNode){
return {
layout: function(layout, rule){
return function(domNode){
for(var i = 0; i < layout.length; i++){
var rule = layout[i];
var selector = rule.selector;
var target = document.createElement("div");
// create the appropriate additions to the elements based on the selectors
selector.replace(/\.([\w-]+)/, function(t, className){
target.className = className;
});
selector.replace(/#([\w-]+)/, function(t, id){
target.id = id;
});
rule.apply(target);
domNode.appendChild(target);
}
}
},
content: function(content, rule){
return function(domNode){
domNode.innerHTML = eval(content);
}
},
role: "layout"
};
}
var def = new Generate({});
Generate.layout = def.layout;
Generate.content = def.content;
Generate.role = def.role;
return Generate;
})