CSS样式:
.zeng_msgbox_layer、
.zeng_msgbox_layer .gtl_ico_succ、
.zeng_msgbox_layer .gtl_ico_fail、
.zeng_msgbox_layer .gtl_ico_hits、
.zeng_msgbox_layer .gtl_ico_clear、
.zeng_msgbox_layer .gtl_end{表示:インライン-ブロック;高さ:54px;行の高さ:54px;フォントの太さ:太字;フォントサイズ:14px;色:#606060;背景画像:url("gb_tip_layer.png");_背景画像:url("gb_tip_layer_ie6 .png");background-repeat:no-repeat;}
.zeng_msgbox_layer_wrap{width:100%;position:fixed;_position:absolute;top:46%;left:0;text-align:center;z- Index:65533;}
.zeng_msgbox_layer{background-position:0 -161px;background-repeat:repeat-x;padding:0 18px 0 9px;margin:0 auto;position:relative;}
.zeng_msgbox_layer 。 gtl_ico_succ{背景位置:-6px 0;左:-45px;上:0;幅:45px;位置:絶対;}
.zeng_msgbox_layer .gtl_end{背景位置:0 0;位置:絶対;右:- 6px;top:0;width:6px;}
.zeng_msgbox_layer .gtl_ico_fail{background-position:-6px -108px;position:absolute;left:-45px;top:0;width:45px;}
。 zeng_msgbox_layer .gtl_ico_hits{背景位置:-6px -54px;位置:絶対;左:-45px;上:0;幅:45px;}
.zeng_msgbox_layer .gtl_ico_clear{背景位置:-6px 0;左:- 5px;width:5px;position:absolute;top:0;}
.zeng_msgbox_layer img{float:left;margin:19px 10px 0 5px ;}
JAVASCRIPT:
window.ZENG=window.ZENG || {};
ZENG.dom = {getById: function(id) {
return document.getElementById(id);
},get: function(e) {
return (typeof (e) == "string") ? document.getElementById(e) : e;
},createElementIn: function(tagName, elem, insertFirst, attrs) {
var _e = (elem = ZENG.dom.get(elem) || document.body).ownerDocument.createElement(tagName || " div")、k;
if (typeof (attrs) == 'object') {
for (k in attrs) {
if (k == "class") {
_e.className = attrs[k] ;
} else if (k == "style") {
_e.style.cssText = attrs[k];
} else {
_e[k] = attrs[k];
}
}
}
insertFirst ? elem.insertBefore(_e, elem.firstChild) : elem.appendChild(_e);
return _e;
},getStyle: function(el, property) {
el = ZENG.dom.get(el);
if (!el || el.nodeType == 9) {
return null;
}
var w3cMode = document.defaultView && document.defaultView.getComputedStyle, computed = !w3cMode ? null : document.defaultView.getComputedStyle(el, '')、値 = "";
switch (property) {
case "float":
property = w3cMode ? "cssFloat" : "styleFloat";
休憩;
ケース "不透明度":
if (!w3cMode) {
var val = 100;
try {
val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
} catch (e) {
try {
val = el.filters('alpha').opacity;
} catch (e) {
}
}
return val / 100;
} else {
return parseFloat((computed || el.style)[property]);
}
休憩;
case "backgroundPositionX":
if (w3cMode) {
property = "backgroundPosition";
return ((computed || el.style)[property]).split(" ")[0];
}
休憩;
case "backgroundPositionY":
if (w3cMode) {
property = "backgroundPosition";
return ((computed || el.style)[property]).split(" ")[1];
}
休憩;
}
if (w3cMode) {
return (computed || el.style)[property];
} else {
return (el.currentStyle[property] || el.style[property]);
}
},setStyle: function(el,properties, value) {
if (!(el = ZENG.dom.get(el)) || el.nodeType != 1) {
false を返します。
}
var tmp, bRtn = true, w3cMode = (tmp = document.defaultView) && tmp.getComputedStyle, rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/私;
if (typeof (properties) == 'string') {
tmp = プロパティ;
プロパティ = {};
プロパティ[tmp] = 値;
}
for (プロパティの var prop) {
値 = プロパティ[prop];
if (prop == 'float') {
prop = w3cMode ? "cssFloat" : "styleFloat";
} else if (prop == 'opacity') {
if (!w3cMode) {
prop = 'filter';
値 = 値 >= 1 ? '' : ('alpha(opacity=' Math.round(value * 100) ')');
}
} else if (prop == 'backgroundPositionX' || prop == 'backgroundPositionY') {
tmp = prop.slice(-1) == 'X' ? 'Y' : 'X';
if (w3cMode) {
var v = ZENG.dom.getStyle(el, "backgroundPosition" tmp);
prop = '背景位置';
typeof (値) == '数値' && (値 = 値 'px');
値 = tmp == 'Y' ? (値 " " (v || "上")) : ((v || '左') " " 値);
}
}
if (typeof el.style[prop] != "未定義") {
el.style[prop] = value (typeof value === "number" && !reexclude) .test(prop) ? 'px' : '');
bRtn = bRtn && true;
} else {
bRtn = bRtn && false;
}
}
return bRtn;
},getScrollTop: function(doc) {
var _doc = doc ||書類;
return Math.max(_doc.documentElement.scrollTop, _doc.body.scrollTop);
},getClientHeight: function(doc) {
var _doc = doc ||書類;
return _doc.compatMode == "CSS1Compat" ? _doc.documentElement.clientHeight : _doc.body.clientHeight;
}
};
ZENG.string = {RegExps: {trim: /^s |s $/g,ltrim: /^s /,rtrim: /s $/,nl2br: /n/g,s2nb: /[x20]{ 2}/g,URIencode: /[x09x0Ax0Dx20x21-x29x2Bx2Cx2Fx3A-x3Fx5B-x5Ex60x7B-x7E]/g,escHTML: {re_amp: /&/g,re_lt: //g,re_apos: /x27/g,re_quot: /x22/g},escString: {bsls: /\/g,sls: ///g,nl: /n/g,rt: /r/g,tab: /t/g },restXHTML: {re_amp: /&/g,re_lt: //g,re_apos: /&(?:apos|#0?39);/g,re_quot: /" /g},write: /{(d{1,2})(?::([xodQqb]))?}/g,isURL: /^(?:ht|f)tp(?:s)?: //(?:[w-.] ).w /i,cut: /[x00-xFF]/,getRealLen: {r0: /[^x00-xFF]/g,r1: /[x00-xFF]/ g},format: /{([dw.] )}/g},commonReplace: function(s, p, r) {
return s.replace(p, r);
},format: function (str) {
var args = Array.prototype.slice.call(arguments), v;
str = String(args.shift());
if (args.length == 1 && typeof) (args[0]) == 'object') {
args = args[0];
ZENG.string.RegExps.format.lastIndex = 0; ZENG.string.RegExps.format, function(m, n) {
v = ZENG.object.route(args, n);
return v === 未定義 ? m:v;
});
}};
ZENG.object = {
routeRE: /([dw_] )/g,
route: function(obj, path) {
obj = obj || {};
パス = 文字列(パス);
var r = ZENG.object.routeRE, m;
r.lastIndex = 0;
while ((m = r.exec(path)) !== null) {
obj = obj[m[0]];
if (obj === 未定義 || obj === null) {
break;
}
}
オブジェクトを返します。
}};
var ua = ZENG.userAgent = {}、エージェント = navigator.userAgent;
ua.ie = 9 - ((agent.indexOf('Trident/5.0') > -1) ? 0 : 1) - (window.XDomainRequest ? 0 : 1) - (window.XMLHttpRequest ? 0 : 1) );
if (typeof (ZENG.msgbox) == '未定義') {
ZENG.msgbox = {};
}
ZENG.msgbox._timer = null;
ZENG.msgbox.loadingAnimationPath = ZENG.msgbox.loadingAnimationPath || ("loading.gif");
ZENG.msgbox.show = function(msgHtml, type, timeout, opts) {
if (typeof (opts) == 'number') {
opts = {topPosition: opts};
}
opts = オプト || {};
var _s = ZENG.msgbox,
template = '{loadIcon}{msgHtml}'、typeClass = [0, 0, 0, 0, "succ", "失敗"、"クリア"]、mBox、ヒント;
_s._loadCss && _s._loadCss(opts.cssPath);
mBox = ZENG.dom.get("q_Msgbox") || ZENG.dom.createElementIn("div", document.body, false, {className: "zeng_msgbox_layer_wrap"});
mBox.id = "q_Msgbox";
mBox.style.display = "";
mBox.innerHTML = ZENG.string.format(template, {type: typeClass[type] || "hits",msgHtml: msgHtml || "",loadIcon: type == 6 ?読み込み中: ""});
_s._setPosition(mBox, タイムアウト, opts.topPosition);
};
ZENG.msgbox._setPosition = function(tips, timeout, topPosition) {
timeout = タイムアウト || 5000;
var _s = ZENG.msgbox, bt = ZENG.dom.getScrollTop(), ch = ZENG.dom.getClientHeight(), t = Math.floor(ch / 2) - 40;
ZENG.dom.setStyle(tips, "top", ((document.compatMode == "BackCompat" || ZENG.userAgent.ie < 7) ? bt : 0) ((typeof (topPosition) == "数値") ? topPosition : t) "px");
clearTimeout(_s._timer);
tips.firstChild.style.display = "";
タイムアウト && (_s._timer = setTimeout(_s.hide, timeout));
};
ZENG.msgbox.hide = function(timeout) {
var _s = ZENG.msgbox;
if (タイムアウト) {
clearTimeout(_s._timer);
_s._timer = setTimeout(_s._hide, タイムアウト);
} else {
_s._hide();
}
};
ZENG.msgbox._hide = function() {
var _mBox = ZENG.dom.get("q_Msgbox"), _s = ZENG.msgbox;
clearTimeout(_s._timer);
if (_mBox) {
var _tips = _mBox.firstChild;
ZENG.dom.setStyle(_mBox, "表示", "なし");
}
};
调用:
ZENG .msgbox.show("设置成功!", 4, 2000);
ZENG.msgbox.show("サーバーが混雑しています、受信後に再確認します。", 1, 2000);
ZENG.msgbox.show("データ拉取失败", 5, 2000);
ZENG.msgbox.show(" 正在加下中,请稍後...", 6,8000);
演示およびダウンロード体验:
腾讯UED-漂亮の提案信息