mbui.define([], function (exports) {
var doc = document, query = 'querySelectorAll', claname = 'getElementsByClassName', S = function (s) {
return doc[query](s);
};
var template = {
warning: function (text) {
//警告提示
return `
${text}
`;
},
error: function (text) {
//失败提示
return `
${text}
`;
},
toast: function (text) {
//轻提示
return `
${text}
`;
},
loading: function (text) {
//轻提示
return `
${text}
`;
},
success: function (text) {
//轻提示
return `
${text}
`;
}
}
//默认配置
var config = {
type: 1,
shade: true,
shadeClose: false,
fixed: true
};
var ready = {
extend: function (obj) {
var newobj = JSON.parse(JSON.stringify(config));
for (var i in obj) {
newobj[i] = obj[i];
}
return newobj;
},
timer: {}, end: {}
};
//点触事件
ready.touch = function (elem, fn) {
elem.addEventListener('click', function (e) {
fn.call(this, e);
}, false);
};
var index = 0, classs = ['mbui-layer'], Layer = function (options) {
var that = this;
that.config = ready.extend(options);
that.view();
};
Layer.prototype.view = function () {
var that = this, config = that.config, layerbox = doc.createElement('div');
that.id = layerbox.id = classs[0] + index;
layerbox.setAttribute('class', classs[0] + ' ' + classs[0] + (config.type || 0));
layerbox.setAttribute('index', index);
//标题区域
var title = (function () {
var titype = typeof config.title === 'object';
return config.title
? '