/**
* Created by Kevin liu on 2015/12/2.
*/
//var tmp_json = {
// "title": [
// {"enName": "Brett", "cnName": "这是一个有趣的题目"}
// ]
//}
//
function Popup(tit, content, component, richText, btnInfo1, btnInfo2, methis, fn, popupWidth, classnamep) {
var isMask = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : true;
this.tit = tit;
this.content = content;
this.richText = richText;
this.component = component;
this.btnInfo1 = btnInfo1;
this.btnInfo2 = btnInfo2;
this.classnamep = classnamep;
this.isMask = isMask;
if (popupWidth) {
this.popupWidth = popupWidth;
} else {
this.popupWidth = 440;
}
this.methis = methis;
this.fn = function (selfBtn) {
if (typeof fn === 'function') {
fn(selfBtn);
}
};
}
Popup.prototype = {
organDom: function organDom() {
//组织 dom
var str = "",
me = this;
if (this.isMask) {
str += "
";
str += "
";
}
str += "";
return str;
},
showDom: function showDom() {
//显示dom && 关闭dom
var me = this;
$('body').append(me.organDom());
$('#popup-common-box').css('margin-top', -($('#popup-common-box').innerHeight() / 2));
if (this.isMask) {
$('html').addClass('confirm-body-fixed');
}
me.initEvent();
},
initEvent: function initEvent() {
var me = this;
// $('#popup-header-close,#btn_cancel').add($(".mask-layer")).on('click', me.callBack);
$('#popup-header-close,#btn_cancel').on('click', me.callBack);
$('#btn_yes').on('click', function (e) {
var selfBtn = $(this);
e.stopPropagation();
me.callBackFn(selfBtn);
me.callBack.call(selfBtn);
});
},
callBack: function callBack() {
var me = $(this);
var maskDom = me.parents('.popup-box').prev().find('.mask-layer');
if (maskDom.length) {
maskDom.remove()
}else {
$(".mask-layer").remove();
}
me.parents('.popup-box').remove();
// $(".popup-box").remove();
// if (this.isMask) {
$('html').removeClass('confirm-body-fixed');
// }
},
callBackFn: function callBackFn(selfBtn) {
var me = this;
me.fn(selfBtn);
}
};
function Tip(content) {
this.content = content;
}
Tip.prototype = {
organDom: function organDom() {
var str = "",
me = this;
str += "";
str += "
" + me.content + "
";
str += "
";
return str;
},
showDom: function showDom() {
var me = this;
$('body').append(me.organDom());
me.initEvent();
},
initEvent: function initEvent() {
var me = this;
setTimeout(function () {
me.callBack();
}, 2000);
},
callBack: function callBack() {
var me = this;
$('#tip').remove();
$('#maskLayer').remove();
}
};