1 /**
  2  * 遮盖层
  3  *
  4  * @author  CarlChen
  5  * @date    2012.10.9
  6  */
  7 define(["core"], function() {
  8 
  9     var mask_level = 0;
 10     /**
 11      * 遮盖层对象
 12      */
 13     $we.widget.reg("Mask", {
 14         interfaces:{
 15             /**
 16              * 显示
 17              */
 18             show:function ()
 19             {
 20                 var maskEle = $('#' + this.maskId);
 21                 if (maskEle.length == 0) {
 22                     var zIndex = this.config['zIndex'] || 100;
 23                     $(document.body).append("<div style='z-index:" + zIndex + ";' id='" + this.maskId + "' class='" +
 24                                             this.maskClass + "'></div>");
 25                     maskEle = $('#' + this.maskId);
 26                 }
 27                 maskEle.show();
 28             },
 29             /**
 30              * 隐藏
 31              */
 32             hide:function ()
 33             {
 34                 $('#' + this.maskId).hide();
 35             },
 36             /**
 37              * 销毁
 38              */
 39             remove:function(){
 40                 $('#' + this.maskId).remove();
 41             }
 42         },
 43         /**
 44          * Config
 45          * zIndex:mask的zindex
 46          * @param config
 47          */
 48         init:function (config)
 49         {
 50             this.config = config || {};
 51 
 52             mask_level++;
 53             this.maskClass = 'we_mask';
 54             this.maskId = 'mask_' + mask_level;
 55         },
 56         run:function ()
 57         {
 58         }
 59     });
 60 
 61     //单例对象
 62     $we.comp.mask = $we.widget.add('Mask');
 63     
 64     return $we.widget.amd("Mask");
 65 });