mask.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 %%" 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. _fill: function (){
  42. var el = this.getDom();
  43. var vpRect = uiUtils.getViewportRect();
  44. el.style.width = vpRect.width + 'px';
  45. el.style.height = vpRect.height + 'px';
  46. }
  47. };
  48. utils.inherits(Mask, UIBase);
  49. })();