not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.3 KiB

  1. enyo.kind({
  2. name: "onyx.Scrim",
  3. showing: false,
  4. classes: "onyx-scrim enyo-fit",
  5. floating: false,
  6. //* @protected
  7. create: function() {
  8. this.inherited(arguments);
  9. this.zStack = [];
  10. if (this.floating) {
  11. this.setParent(enyo.floatingLayer);
  12. }
  13. },
  14. showingChanged: function() {
  15. // auto render when shown.
  16. if (this.floating && this.showing && !this.hasNode()) {
  17. this.render();
  18. }
  19. this.inherited(arguments);
  20. //this.addRemoveClass(this.showingClassName, this.showing);
  21. },
  22. //* @protected
  23. addZIndex: function(inZIndex) {
  24. if (enyo.indexOf(inZIndex, this.zStack) < 0) {
  25. this.zStack.push(inZIndex);
  26. }
  27. },
  28. removeZIndex: function(inControl) {
  29. enyo.remove(inControl, this.zStack);
  30. },
  31. //* @public
  32. //* Show Scrim at the specified ZIndex. Note: If you use showAtZIndex you
  33. //* must call hideAtZIndex to properly unwind the zIndex stack
  34. showAtZIndex: function(inZIndex) {
  35. this.addZIndex(inZIndex);
  36. if (inZIndex !== undefined) {
  37. this.setZIndex(inZIndex);
  38. }
  39. this.show();
  40. },
  41. //* Hide Scrim at the specified ZIndex
  42. hideAtZIndex: function(inZIndex) {
  43. this.removeZIndex(inZIndex);
  44. if (!this.zStack.length) {
  45. this.hide();
  46. } else {
  47. var z = this.zStack[this.zStack.length-1];
  48. this.setZIndex(z);
  49. }
  50. },
  51. //* @protected
  52. // Set scrim to show at `inZIndex`
  53. setZIndex: function(inZIndex) {
  54. this.zIndex = inZIndex;
  55. this.applyStyle("z-index", inZIndex);
  56. },
  57. make: function() {
  58. return this;
  59. }
  60. });
  61. //* @protected
  62. //
  63. // Scrim singleton exposing a subset of Scrim API.
  64. // is replaced with a proper enyo.Scrim instance.
  65. //
  66. enyo.kind({
  67. name: "onyx.scrimSingleton",
  68. kind: null,
  69. constructor: function(inName, inProps) {
  70. this.instanceName = inName;
  71. enyo.setObject(this.instanceName, this);
  72. this.props = inProps || {};
  73. },
  74. make: function() {
  75. var s = new onyx.Scrim(this.props);
  76. enyo.setObject(this.instanceName, s);
  77. return s;
  78. },
  79. showAtZIndex: function(inZIndex) {
  80. var s = this.make();
  81. s.showAtZIndex(inZIndex);
  82. },
  83. // in case somebody does this out of order
  84. hideAtZIndex: enyo.nop,
  85. show: function() {
  86. var s = this.make();
  87. s.show();
  88. }
  89. });
  90. new onyx.scrimSingleton("onyx.scrim", {floating: true, classes: "onyx-scrim-translucent"});
  91. new onyx.scrimSingleton("onyx.scrimTransparent", {floating: true, classes: "onyx-scrim-transparent"});