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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
enyo.kind({
name: "onyx.Scrim",
showing: false,
classes: "onyx-scrim enyo-fit",
floating: false,
//* @protected
create: function() {
this.inherited(arguments);
this.zStack = [];
if (this.floating) {
this.setParent(enyo.floatingLayer);
}
},
showingChanged: function() {
// auto render when shown.
if (this.floating && this.showing && !this.hasNode()) {
this.render();
}
this.inherited(arguments);
//this.addRemoveClass(this.showingClassName, this.showing);
},
//* @protected
addZIndex: function(inZIndex) {
if (enyo.indexOf(inZIndex, this.zStack) < 0) {
this.zStack.push(inZIndex);
}
},
removeZIndex: function(inControl) {
enyo.remove(inControl, this.zStack);
},
//* @public
//* Show Scrim at the specified ZIndex. Note: If you use showAtZIndex you
//* must call hideAtZIndex to properly unwind the zIndex stack
showAtZIndex: function(inZIndex) {
this.addZIndex(inZIndex);
if (inZIndex !== undefined) {
this.setZIndex(inZIndex);
}
this.show();
},
//* Hide Scrim at the specified ZIndex
hideAtZIndex: function(inZIndex) {
this.removeZIndex(inZIndex);
if (!this.zStack.length) {
this.hide();
} else {
var z = this.zStack[this.zStack.length-1];
this.setZIndex(z);
}
},
//* @protected
// Set scrim to show at `inZIndex`
setZIndex: function(inZIndex) {
this.zIndex = inZIndex;
this.applyStyle("z-index", inZIndex);
},
make: function() {
return this;
}
});
//* @protected
//
// Scrim singleton exposing a subset of Scrim API.
// is replaced with a proper enyo.Scrim instance.
//
enyo.kind({
name: "onyx.scrimSingleton",
kind: null,
constructor: function(inName, inProps) {
this.instanceName = inName;
enyo.setObject(this.instanceName, this);
this.props = inProps || {};
},
make: function() {
var s = new onyx.Scrim(this.props);
enyo.setObject(this.instanceName, s);
return s;
},
showAtZIndex: function(inZIndex) {
var s = this.make();
s.showAtZIndex(inZIndex);
},
// in case somebody does this out of order
hideAtZIndex: enyo.nop,
show: function() {
var s = this.make();
s.show();
}
});
new onyx.scrimSingleton("onyx.scrim", {floating: true, classes: "onyx-scrim-translucent"});
new onyx.scrimSingleton("onyx.scrimTransparent", {floating: true, classes: "onyx-scrim-transparent"});
|