mask.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ///import core
  2. ///import uicore
  3. (function() {
  4. var utils = baidu.editor.utils,
  5. domUtils = baidu.editor.dom.domUtils,
  6. UIBase = baidu.editor.ui.UIBase,
  7. uiUtils = baidu.editor.ui.uiUtils;
  8. var Mask = (baidu.editor.ui.Mask = function(options) {
  9. this.initOptions(options);
  10. this.initUIBase();
  11. });
  12. Mask.prototype = {
  13. getHtmlTpl: function() {
  14. return '<div id="##" class="edui-mask %%" onclick="return $$._onClick(event, this);" onmousedown="return $$._onMouseDown(event, this);"></div>';
  15. },
  16. postRender: function() {
  17. var me = this;
  18. domUtils.on(window, "resize", function() {
  19. setTimeout(function() {
  20. if (!me.isHidden()) {
  21. me._fill();
  22. }
  23. });
  24. });
  25. },
  26. show: function(zIndex) {
  27. this._fill();
  28. this.getDom().style.display = "";
  29. this.getDom().style.zIndex = zIndex;
  30. },
  31. hide: function() {
  32. this.getDom().style.display = "none";
  33. this.getDom().style.zIndex = "";
  34. },
  35. isHidden: function() {
  36. return this.getDom().style.display == "none";
  37. },
  38. _onMouseDown: function() {
  39. return false;
  40. },
  41. _onClick: function(e, target) {
  42. this.fireEvent("click", e, target);
  43. },
  44. _fill: function() {
  45. var el = this.getDom();
  46. var vpRect = uiUtils.getViewportRect();
  47. el.style.width = vpRect.width + "px";
  48. el.style.height = vpRect.height + "px";
  49. }
  50. };
  51. utils.inherits(Mask, UIBase);
  52. })();