forked from Aintaer/focss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (52 loc) · 1.49 KB
/
Copy pathindex.js
File metadata and controls
59 lines (52 loc) · 1.49 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
define(['nbd/Class', 'nbd/util/extend', './src/Engine'], function(Class, extend, Engine) {
'use strict';
var Focss = Class.extend({
init: function(root, extensions, scoped) {
scoped = scoped === undefined ? true : !!scoped;
this.engine = new Engine(root, scoped);
extend(this.engine.extensions, extensions);
},
/**
* Insert a focss rule
* @param selector {String} CSS selector/dynamic selector
* @param spec {Object} key/value map of CSS property to expression
* @returns Object Artifacts found while compiling the rule
*/
insert: function(selector, spec) {
if (typeof selector === "object") {
var artifacts = {};
for (var s in selector) {
if (selector.hasOwnProperty(s)) {
extend(artifacts, this.insert(s, selector[s]));
}
}
return artifacts;
}
var rule = this.engine.insert(selector, spec);
return rule.artifacts;
},
toggleSelector: function(key, isToggled) {
this.engine.toggleSelector(key, isToggled);
},
/**
* Run the current set of rules against state data
* Previous state data is overridden.
* @param data {Object} state data
*/
process: function(data) {
this.engine.process(data);
},
destroy: function() {
this.engine.destroy();
this.engine = null;
}
}, {
displayName: 'Focss'
})
.mixin({
get traces() {
return this.engine.traces;
}
});
return Focss;
});