Repository: sentsin/layui
File: src/modules/layer.js (JavaScript)

Code before:
};

// 记录宽高坐标，用于还原
ready.record = function(layero){
  if(!layero[0]) return window.console && console.error('index error');
  var type = layero.attr('type');
  var contentElem = layero.find('.layui-layer-content');
  var contentRecordHeightElem = type === ready.type[2] ? contentElem.children('iframe') : contentElem;
  var area = [
    layero[0].style.width || ready.getStyle(layero[0], 'width'),
    layero[0].style.height || ready.getStyle(layero[0], 'height'),
    layero.position().top, 
    layero.position().left + parseFloat(layero.css('margin-left'))
  ];
  layero.find('.layui-layer-max').addClass('layui-layer-maxmin');
  layero.attr({area: area});
  contentElem.data(RECORD_HEIGHT_KEY, ready.getStyle(contentRecordHeightElem[0], 'height'));
};

// 设置页面滚动条
ready.setScrollbar = function(index){
  doms.html.css('overflow', 'hidden');
};

// 恢复页面滚动条
ready.restScrollbar = function(index, isZoom){
  // 关闭和大小化, layer-full 处理
  var targetEl = $('.'+ doms[0]).filter(function(){ 
    var layero = $(this);
    return layero.data('config').scrollbar === false 
      && layero.data('maxminStatus') !== 'min'
      && layero.attr('times') !== String(index);
  });
  if(targetEl.length === 0){
    doms.html.css('overflow', '');
  }
};

// 类似 Promise.resolve
ready.promiseLikeResolve = function(value){
  var deferred = $.Deferred();

  if(value && typeof value.then === 'function'){
    value.then(deferred.resolve, deferred.reject);
  }else{
    deferred.resolve(value);
  }
  return deferred.promise();
}

/** 内置成员 */

Review comment (suggestion):
```suggestion
ready.restScrollbar = function(index) {
```

Code after:
};

// 记录宽高坐标，用于还原
ready.record = function(layero){
  if(!layero[0]) return window.console && console.error('index error');
  var type = layero.attr('type');
  var contentElem = layero.find('.layui-layer-content');
  var contentRecordHeightElem = type === ready.type[2] ? contentElem.children('iframe') : contentElem;
  var area = [
    layero[0].style.width || ready.getStyle(layero[0], 'width'),
    layero[0].style.height || ready.getStyle(layero[0], 'height'),
    layero.position().top, 
    layero.position().left + parseFloat(layero.css('margin-left'))
  ];
  layero.find('.layui-layer-max').addClass('layui-layer-maxmin');
  layero.attr({area: area});
  contentElem.data(RECORD_HEIGHT_KEY, ready.getStyle(contentRecordHeightElem[0], 'height'));
};

// 设置页面滚动条
ready.setScrollbar = function(index){
  doms.html.css('overflow', 'hidden');
};

// 恢复页面滚动条
ready.restScrollbar = function(index) {
  // 关闭和大小化, layer-full 处理
  var targetEl = $('.'+ doms[0]).filter(function(){ 
    var layero = $(this);
    return layero.data('config').scrollbar === false 
      && layero.data('maxminStatus') !== 'min'
      && layero.attr('times') !== String(index);
  });
  if(targetEl.length === 0){
    doms.html.css('overflow', '');
  }
};

// 类似 Promise.resolve
ready.promiseLikeResolve = function(value){
  var deferred = $.Deferred();

  if(value && typeof value.then === 'function'){
    value.then(deferred.resolve, deferred.reject);
  }else{
    deferred.resolve(value);
  }
  return deferred.promise();
}

/** 内置成员 */