a",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="
';}
var Content='';
if (data.error){$.MsgBox({msg:"Error found:"+data.error+' concrete content:
'+data.msg+'
',autoclose:false});return false;}
if (o.msg){
if ($.isFunction(o.msg)){
Content=o.msg(data.msg,_this);
}else{
var tr='';
$(data.msg).each(function(i){
tr+=o.msg.c(data.msg[i]);
})
Content=o.msg.t+tr+o.msg.b
}
}else{
var tr='',th='';
$(data.msg).each(function(i){
var td='';
$.each(data.msg[i],function(n,v){
if (o.thname){
var name=o.thname[n];
if (name){
if (i==0){th+=$.isPlainObject(name)?'
'+name.name+'
':'
'+name+'
';}
//td+=$.isPlainObject(name)?'
'+$.ToColor(v,name.fun(v))+'
':'
'+v+'
';
if ($.isPlainObject(name)){
if(name.multiple){
var input_Id = "input_multiple";
if(name.multiple.input_Id)
input_Id = name.multiple.input_Id;
var input_col = data.msg[i][0];
if(name.multiple.input_col)
input_col = data.msg[i][name.multiple.input_col];
var input_width = "25px";
if(name.multiple.input_width)
input_width = name.multiple.input_width;
var arr_input_multiple = v.split(",");
var td_input = "";
$.each(arr_input_multiple, function(index, item){
td_input+= '';
});
td+='
'+td_input+'
'
}else{
if ($.isFunction(name.style)){
td+='
'+name.style(v,name.fun(v,data.msg[i]))+'
';
}else{
td+='
'+$.ToColor(v,name.fun(v,data.msg[i]))+'
';
}
}
}else{
td+='
'+v+'
';
}
}
}else{
if (i==0){
th+='
'+n+'
';
}
td+='
'+v+'
';
}
})
tr+='
'+td+'
';
})
Content='
'+th+'
'+tr+'
';
};
$(_this).removeData("msg").data("msg",data.msg); //把数据写到对象上,方便以后操作
var Search='';
if (o.search && !o.ispage){
var Form='';
$(o.search.form).each(function(i){
Form+='
'+o.search.form[i].input+'
';
})
if(Form!=''){
Form='
'+Form+'
';
}
var Button='';
$(o.search.button).each(function(i){
if (o.search.button[i].name!=""){
Button+=''+o.search.button[i].name+'';
}else{
Button+='';
}
})
Button='
'+Button+'
';
if(Form==''){
Search='
'+Button+'
';
}else{
Search='
'+Form+'
'+'
'+Button+'
';
}
}
var Page=''; //翻页
if (o.page){
var ThenPageNum=act.showpagenum; //当前页码
var PageNum=act.pagenum; //每页显示条数
var CountNum=data.count //得到总记录数
var CountPage=CountNum%PageNum==0?CountNum/PageNum:parseInt(CountNum/PageNum)+1; //计算总页码
var PageNumHtml='';
if (ThenPageNum>1 && ThenPageNum!==1){PageNumHtml+='home';}else{PageNumHtml+='home';};
if (ThenPageNum>1){PageNumHtml+='previous';}else{PageNumHtml+='previous';};
var showpagenum=9; //翻页个数 注意.该数字为奇数.
var curr=parseInt(showpagenum/2)+1; //计算选中
var ii=ThenPageNum-curr;
if (CountPage-showpagenum'+(i+1)+'';
}else{
PageNumHtml+=''+(i+1)+'';
};
if (x>=showpagenum){break;};
};
if (ThenPageNumnext';}else{PageNumHtml+='next';};
if (ThenPageNumLast';}else{PageNumHtml+='Last';};
Page='
'+ThenPageNum+'/'+CountPage+' each page'+PageNum+'strip Total'+CountNum+'strip
').click(function(){$(this).toggleClass("curr").find("td:first").toggleClass("curr");});
}
//翻页操作
if (o.page){
$(_this).find(".Bottom .Page .PageNum span").click(function(){
var page=$(this).attr("page");
if (page){
options.list.ispage=true; //防止再次创建搜索区
options.list.act.showpagenum=parseInt(page); //修改页码
$(_this).Content(options)
}
})
}
}else{
$(_this).find(".Content").html("
There is no data yet.
")
}
//复制
$(_this).find("[copy]").css({"position":"relative"}).zclip({
copy:function(){
return $(this).attr("copy");
},
path:"/Template/SkinR/Images/ZeroClipboard.swf",
afterCopy:function(){
//$(this).next().text("复制成功").css({"color":"red"});
}
});
if ($.isFunction(o.rfun)){
o.rfun({
o:options,
p:$(_this),
t:$(this),
d:data.msg
});
}
});
},
Content_Chart:function(options){
options.chart=$.extend(true,{},ContentDefaults.chart,options.chart);
var _this=$(this);
var o=options.chart;
var act =o.act
$.JA(o.url,act,function(data){ //先加载数据
var Title='';
if (o.title){Title='
'+o.title+'
'+o.more+'
';}
var Content='';
if (data.error){$.MsgBox({msg:"发现错误:"+data.error+' 具体内容:
'+data.msg+'
',autoclose:false});return false;}
if (o.msg){
var tr='';
$(data.msg).each(function(i){
tr+=o.msg.c(data.msg[i]);
})
Content=o.msg.t+tr+o.msg.b
}else{
var tr='',th='';
$(data.msg).each(function(i){
var td='';
var j=0;
$.each(data.msg[i],function(n,v){
var tdorth=j==0?"th":"td";
if (o.thname){
var name=o.thname[n];
if (name){
if (i==0){th+=$.isPlainObject(name)?'
'+name.name+'
':'
'+name+'
';}
td+=$.isPlainObject(name)?'<'+tdorth+'>'+name.fun(v)+' '+tdorth+'>':'<'+tdorth+'>'+v+' '+tdorth+'>';
}
}else{
if (i==0){th+='
';
};
$(_this).removeData("msg").data("msg",data.msg); //把数据写到对象上,方便以后操作
var Search='';
if (o.search && !o.ispage){
var Form='';
$(o.search.form).each(function(i){
Form+='
'+o.search.form[i].input+'
';
})
Form='
'+Form+'
';
var Button='';
$(o.search.button).each(function(i){
Button+=''+o.search.button[i].name+'';
})
Button='
'+Button+'
';
Search='
'+Form+Button+'
';
}
var Page=''; //翻页
if (o.page){
var ThenPageNum=act.showpagenum; //当前页码
var PageNum=act.pagenum; //每页显示条数
var CountNum=data.count //得到总记录数
var CountPage=CountNum%PageNum==0?CountNum/PageNum:parseInt(CountNum/PageNum)+1; //计算总页码
var PageNumHtml='';
if (ThenPageNum>1 && ThenPageNum!==1){PageNumHtml+='首页';}else{PageNumHtml+='首页';};
if (ThenPageNum>1){PageNumHtml+='上页';}else{PageNumHtml+='上页';};
var showpagenum=11; //翻页个数 注意.该数字为奇数.
var curr=parseInt(showpagenum/2)+1; //计算选中
var ii=ThenPageNum-curr;
if (CountPage-showpagenum'+(i+1)+'';
}else{
PageNumHtml+=''+(i+1)+'';
};
if (x>=showpagenum){break;};
};
if (ThenPageNum下页';}else{PageNumHtml+='下页';};
if (ThenPageNum末页';}else{PageNumHtml+='末页';};
Page='
').click(function(){$(this).toggleClass("curr").find("td:first").toggleClass("curr");});
}
//翻页操作
if (o.page){
$(_this).find(".Bottom .Page .PageNum span").click(function(){
var page=$(this).attr("page");
if (page){
options.chart.ispage=true; //防止再次创建搜索区
options.chart.act.showpagenum=parseInt(page); //修改页码
$(_this).Content(options)
}
})
}
}else{
$(_this).find(".Content").html("
There is no data yet.
")
}
if ($.isFunction(o.rfun)){o.rfun(_this);}
});
},
Content_Form:function(options){
options.form=$.extend(true,{},ContentDefaults.form,options.form);
var _this=$(this);
var Content='',Top='';
var o = options.form
if (o.title){Top='
'+o.title+'
'+o.more+'
';}
if (o.content){
$(o.content).each(function(i){
var Tit='',Box='',Tips='',Bottom='',li='';
if (o.content[i].tit){Tit='
'+o.content[i].tit+'
';}
if (o.content[i].box){
$(o.content[i].box).each(function(b){
if (o.content[i].box[b].hr){
li+='
'+o.content[i].box[b].tags+'
';
}else{
li+='
'+o.content[i].box[b].input+'
'+o.content[i].box[b].tips+'
';
}
})
Box='
'+li+'
';
}
if (o.content[i].tips){Tips='
'+o.content[i].tips+'
';}
if (o.content[i].button){
var Button='',span='';
$(o.content[i].button).each(function(b){
span+=''+o.content[i].button[b].name+'';
})
Button='
'+span+'
';
Bottom='
'+Button+'
'
}
if (i>0){Content+='';}
Content+='';
})
}
var FormBox='
'+Top+Content+'
'
if (o.isaddform){
$(_this).append(FormBox);
$(_this).find(".FormBox").css({"margin-top":"20px"});
}else{
$(_this).html(FormBox)
}
//美化SELECT
if (o.content){$(_this).find(".FormBox [select]").Select();}
//事件绑定
$(_this).find(".FormBox .Content").each(function(i){
var p=$(this);
$(this).find(".Bottom .Button span").each(function(b){
var fun=o.content[i].button[b].fun;
if ($.isFunction(fun)){
$(this).click(function(){
fun({o:options,t:$(this),p:p});//把参数传回.方便再次使用.
})
}
})
})
//初始化函数
if ($.isFunction(o.rfun)){o.rfun(_this);}
//复制
$(_this).find("[copy]").css({"position":"relative"}).zclip({
copy:function(){
return $(this).attr("copy");
},
path:"/Template/SkinR/Images/ZeroClipboard.swf",
afterCopy:function(){
//$(this).next().text("复制成功").css({"color":"red"});
}
});
//日期控件
$(_this).find("[hx_jq=date]").attr("readonly",true).each(function(){
var t=$(this)
$(t).DatePicker({
format:'Y-m-d',
date: $(t).val(),
current: $(t).val(),
starts: 1,
onBeforeShow: function(){
var myDate=$(t).val()
if (myDate==""){myDate = $.getNowFormatDate()}
$(t).DatePickerSetDate(myDate, true);
},
onChange: function(formated, dates){
if ($(t).val()!=formated){
$(t).DatePickerHide();
}
$(t).val(formated);
}
});
})
},
Select:function(callback,isExeCute){
return this.each(function(){
var _this=$(this);
if ($(_this).length==0 || $(_this).attr("int")=="false"){return false;}
var value=$(_this).hide().attr("select").split("|");
var Html='';
var DefaultValue='';
Html+='
';
$(_this).next(".Select").remove();//这里
$(_this).after(Html).next().css({height:$(_this).outerHeight()+"px",width:"100px"}).find(".Value").text(DefaultValue);
$(_this).next().find(".Value").click(function(event){
if (!$(_this).next().find("ul").is(":visible")){
var w_h=$(window).outerHeight();
var t_t=$(this).offset().top-$(document).scrollTop()+$(this).outerHeight();
var o_h=$(this).next("ul").outerHeight();
var top=o_h+t_t>w_h?0-o_h:$(this).outerHeight();
$(this).next("ul").css({top:top+"px"});
var z_index=0;
$(".Select").each(function(){var TempIndex=$(this).css("z-index");if (TempIndex>z_index){z_index=TempIndex;}})
$(this).parent().css({"z-index":parseInt(z_index)+1});
$(this).next("ul").stop(true,true).show();
$(_this).next(".Select").trigger("focus")
}
})
$(_this).next(".Select").blur(function(event){
var target = $(event.target);
//console.log("tagName:"+$(target).attr("class"));
if ($(_this).next().find("ul").is(":visible") && $(target).attr("class")=="Select"){
$(_this).next().find("ul").stop(true,true).hide();
}
})
$(_this).next().find("li").click(function(event){
$(this).parent().find("[class=curr]").removeClass("curr");
$(this).addClass("curr");
$(this).parent().parent().find(".Value").text($(this).text());
$(_this).val($(this).attr("val"));
$(_this).attr("text",$(this).text());
if ($.isFunction(callback)){callback(_this,$(this).attr("val"));} //绑定回调函数
$(_this).next().find("ul").stop(true,true).hide();
})
if (isExeCute){callback(_this,$(_this).val());}
})
},
CheckBox:function(callback,isExeCute){ //复选框
return this.each(function(){
var _this=$(this);
if ($(_this).length==0 || $(_this).attr("int")=="false"){return false;}
var value=$(_this).hide().attr("checkbox").split("|");
var Html='';
var DefaultValue='';
Html+='
';
Html+='';
Html+='
';
var valarr=$(_this).val()!=""?$(_this).val().split(","):new Array();
$(value).each(function(i){
if ($.inArray(value[i].split("=")[1],valarr)>=0){
Html+='
'+value[i].split("=")[0]+'
';
}else{
Html+='
'+value[i].split("=")[0]+'
';
}
})
Html+='
';
Html+='
';
$(_this).next(".Select").remove();
$(_this).after(Html).next().find(".Value").text($(_this).val());
$(_this).next().find(".Value").click(function(event){
if (!$(_this).next().find("ul").is(":visible")){
//console.log("打开");
var w_h=$(window).outerHeight();
var t_t=$(this).offset().top+$(this).outerHeight();
var o_h=$(this).next("ul").outerHeight();
var top=o_h+t_t>w_h?0-o_h:$(this).outerHeight();
$(this).next("ul").css({top:top+"px"});
var z_index=0;
$(".Select").each(function(){var TempIndex=$(this).css("z-index");if (TempIndex>z_index){z_index=TempIndex;}})
//$(this).find(".Value").addClass("curr");
$(this).parent().css({"z-index":z_index+1});
$(this).next("ul").stop(true,true).fadeIn();
}else{
var arr=new Array()
$(this).next("ul").find("li.curr").each(function(i){
arr.push($(this).attr("val"));
})
$(_this).val(arr.join(","));
if ($.isFunction(callback)){callback(_this,$(_this).val());} //绑定回调函数
$(this).parent().parent().find(".Value").text($(_this).val());
$(this).next("ul").stop(true,true).fadeOut();
}
})
$(_this).next().find("li").click(function(event){
$(this).toggleClass("curr");
})
if (isExeCute){callback(_this,$(_this).val());}
})
},
Center:function(callback){ //对象居中显示
var t_w=$(this).outerWidth(true);
var t_h=$(this).outerHeight(true);
var c_l=(w_w-t_w)/2;
var c_t=(w_h-t_h)/2;
if (c_t<5){c_t=5}
if(c_t>225 && t_w<600) c_t=225;
this.css({top:c_t+'px',left:c_l+'px'});
if ($.isFunction(callback)){
setTimeout(function(){
callback();
},150)
}
return $(this);
},
ZoomMsgBox:function(){
var _this=$(this);
var data=$(this).data();
if (data["show"]){
data["show"]=false;
if ($.IsCss3()){
$(_this).stop().css({"width":data["width"],"height":data["height"],"top":data["top"],"left":data["left"]}).find(".Title").css({"width":"auto"})
}else{
$(_this).stop().animate({"width":data["width"],"height":data["height"],"top":data["top"],"left":data["left"]},300)
}
$(_this).find(".Zoom").removeClass("MinZoom").addClass("MaxZoom");
}else{
data["show"]=true;
data["width"]=$(_this).outerWidth(true);;
data["height"]=$(_this).outerHeight(true);;
data["top"]=$(_this).css("top");
data["left"]=$(_this).css("left");
var title_height=$(_this).find(".Top").outerHeight(true);
var top=w_h-title_height-10;
if ($.IsCss3()){
$(_this).stop().css({"width":"200px","height":title_height+"px","top":top+"px","left":"10px"}).find(".Title").css({"width":"110px"})
}else{
$(_this).stop().animate({"width":"200px","height":title_height+"px","top":top+"px","left":"10px"},300)
}
$(_this).find(".Zoom").removeClass("MaxZoom").addClass("MinZoom");
}
$(_this).ScreenMask();
},
RemoveMsgBox:function(){
var _this=$(this);
if ($("#S_"+$(_this).attr("id")).length>0){$(_this).ScreenMask();}
if ($.IsCss3()){
$(_this).removeClass("hide").removeClass("show").addClass("remove");
setTimeout(function(){
$(_this).remove();
},300)
}else{
var top=w_h/2;
var left=w_w/2;
$(_this).find(".Top,.Content,.Bottom,.Line").hide();
$(_this).stop().animate({"width":"0px","height":"0px","top":top+"px","left":left+"px"},300,function(){
$(_this).remove();
})
}
},
ScreenMask:function(){
var _this=$(this);
var _this_id=$(_this).attr("id");
var _this_zindex=$(_this).css("z-index")-1;
if ($("#S_"+_this_id).length==0){
$("body").append('');
if (_this_id!=undefined){
$("#S_"+_this_id).fadeIn().css({"z-index":_this_zindex});
}else{
$("#S_"+_this_id).show().css({"z-index":_this_zindex});
}
$('embed, object, select').css({ 'visibility' : 'hidden' });
}else{
if (_this_id!=undefined){
$("#S_"+_this_id).fadeOut(function(){$(this).remove();})
}else{
$("#S_"+_this_id).remove();
}
$('embed, object, select').css({ 'visibility' : 'visible' });
}
},
ErrorTips:function(msg){ //错误提示
$(this).find(".Error").html(msg);
},
Move:function(){ //层移动
var _this=$(this);
var _margins=10
$(_this).bind("mousedown", function(e){
$("body").addClass("NotSelectText");
$(_this).parent().css({"transition":"0s",opacity:0.8}).addClass("NotSelectText").find(".Content,.Bottom,.Line").hide();
if (!e) e = window.event;
var posX = e.clientX - parseInt($(this).parent().css('left'));
var posY = e.clientY - parseInt($(this).parent().css('top'));
var t_w=$(this).parent().outerWidth()+_margins;
var t_h=$(this).parent().outerHeight()+_margins;
$(document).bind("mousemove", { x: posX, y: posY }, function(e) {
var pos = e.data;
if (!e) e = window.event;
var top= e.clientY - pos.y;
var left= e.clientX - pos.x;
var height=t_h+top+_margins;
var width=t_w+left+_margins;
if (height>w_h){top=w_h-t_h;};
if (width>w_w){left=w_w-t_w;};
if (top<=_margins){top=_margins;};
if (left<=_margins){left=_margins;};
$(_this).parent().css('top',top).css('left', left);
});
$(document).bind("mouseup", function() {
$(document).unbind("mousemove");
$(document).unbind("mouseup");
$("body").removeClass("NotSelectText");
$(_this).parent().css({opacity:1,"transition":"0.5s"}).removeClass("NotSelectText").find(".Content,.Bottom,.Line").show();
})
});
},
wheel:function(callback){ //鼠标滚轮
var ele = this;
var roll = function(){
var delta = 0,
e = arguments[0] || window.event;
delta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3;
callback.apply(ele[0][0],[delta]);//回调函数中的回调函数
if(e.preventDefault){
e.preventDefault();
}
e.returnValue = false;
return;
}
if(document.attachEvent){
ele[0][0].attachEvent("onmousewheel",roll);
}else{
ele[0][0].addEventListener("DOMMouseScroll", roll, false);
ele[0][0].onmousewheel = roll;
}
},
keyboard:function(downcallback,upCallback){ //多事件监听
var ele = this;
var keyboardObject = {};
var keyDownFn = function(e){
var e = e||window.event;
var code = e.charCode||e.keyCode;
if(keyboardObject[code]){
return false;
}
keyboardObject[code]=setInterval(function(){
downcallback.apply(ele[0][0],[keyboardObject]);
},10);
};
var keyUpFn = function(e){
var e = e||window.event;
var code = e.charCode||e.keyCode;
clearInterval(keyboardObject[code]);
delete keyboardObject[code];
upCallback.apply(ele[0][0],[keyboardObject]);
};
$(document).on("keydown",keyDownFn);
$(document).on("keyup",keyUpFn);
return ele;
},
MsgBoxInit:function(o){
var _this=$(this)
var autoclose=null;
$(_this).find("img,iframe").show();
var _width,_width_unit;
//alert(o.width);
if (o.width){ //如果是自定义宽度,计算宽度和单位.
if (!isNaN(o.width)){
_width_unit="px";
_width=o.width;
}else if (o.width.indexOf("%")!=-1){
_width_unit="%";
_width=w_w/o.width.split("%")[0]*100; //把百分比转换为PX
}else{
_width_unit="px";
_width=o.width.split("px")[0];
}
}else{ //否则自动取宽度
_width_unit="px";
_width=$(_this).find(".Content").outerWidth(true); //自动获取宽度
_width=_width<300?300:_width; //设置最小的宽度
}
_margins=10;
var _max_width=w_w-_margins;
var _max_height=w_h-_margins;
var other_height=$(_this).find(".Top").outerHeight(true)+$(_this).find(".Bottom").outerHeight(true)+$(_this).find(".Line").outerHeight(true)*$(_this).find(".Line").length;
_width=_width>_max_width?_max_width:_width;
var zindex=o.zindex+$(".MsgBox").length+2;
$(_this).css({"z-index":zindex,"width":_width+"px"}).ScreenMask();
//重新调整高度
var _height=$(_this).find(".Content").outerHeight(true)+other_height;
if (_height>_max_height){
$(_this).find(".Content img").css({"height":"100%","width":"100%"});
$(_this).find(".Content").css({"height":_max_height-other_height-_margins*2});
}else{
$(_this).css({"height":_height});
}
//显示对话框
if ($.IsCss3()){
//alert(_height);
//$(_this).css({"top":"100px"});
$(_this).addClass("hide");
$(_this).Center(function(){
$(_this).addClass("show").remove("hide");
})
}else{
$(_this).css({"width":"0px","height":"0px"}).hide().Center(function(){
$(_this).find(".Top,.Content,.Bottom,.Line").hide()
$(_this).show().stop().animate({"width":_width+"px","height":_height+"px","top":((_margins/2)+(_max_height-_height)/2)+"px","left":((_margins/2)+(_max_width-_width)/2)+"px"},300,function(){
$(this).find(".Top,.Content,.Bottom,.Line").fadeIn();
});
})
}
//美化SELECT
$(_this).find("[select]").Select();
$(_this).find("[checkbox]").CheckBox();
//美化滚动条.
//$(_this).find(".Content").mCustomScrollbar({});
//日期控件
$(_this).find("[hx_jq=date]").attr("readonly",true).each(function(){
var t=$(this)
$(t).DatePicker({
format:'Y-m-d',
date: $(t).val(),
current: $(t).val(),
starts: 1,
onBeforeShow: function(){
var myDate=$(t).val()
if (myDate==""){myDate = $.getNowFormatDate()}
$(t).DatePickerSetDate(myDate, true);
},
onChange: function(formated, dates){
if ($(t).val()!=formated){
$(t).DatePickerHide();
}
$(t).val(formated);
}
});
})
//移动
$(_this).find(".Top").Move();
//绑定按钮点击事件
//自动关闭
if (o.autoclose && o.close && !o.button && o.msg){
autoclose=window.setInterval(function(){
o.autoclose--;
if (o.autoclose<0){
clearInterval(autoclose);
$(_this).RemoveMsgBox();
}
$(_this).find(".autoclose font").html(o.autoclose)
},1000);
$(_this).find(".Bottom .Button").find("button").each(function(i){$(this).click(function(){$(_this).find(".autoclose").html("Auto shutdown stopped");clearInterval(autoclose);});});
}else{
$(_this).find(".Bottom .Button").find("button").each(function(i){$(this).click(function(){if($.isFunction(o.button[i].fun)){o.button[i].fun(_this,$(this));};});});
}
//监听ESC
if (o.escclose && o.close){$(_this).keyup(function(e) {if (e.keyCode==27){clearInterval(autoclose);$(_this).RemoveMsgBox();}});};
//对关闭按钮进行事件绑定
$(_this).find(".Close").click(function(){clearInterval(autoclose);$(_this).RemoveMsgBox();})
//放大和缩小事件绑定
$(_this).find(".Zoom").click(function(){$(_this).ZoomMsgBox();})
//禁止文本选择
$(_this).find(".Top").bind("contextmenu",function(){return false;});
$(_this).find(".Top").bind("selectstart",function(){return false;});
//取得焦点.
$(_this).focus();
//关闭加载提示
$.Loading(false,false);
//执行初始化函数
if ($.isFunction(o.rfun)){o.rfun(_this);}
},
Scroll:function(opt,callback){
if(!opt) var opt={}; //参数初始化
var _this=this.eq(0).find("ul:first");
var lineH=_this.find("li:first").height(), //获取行高
line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数,默认为一屏,即父容器高度
speed=opt.speed?parseInt(opt.speed,10):2000, //卷动速度,数值越大,速度越慢(毫秒)
timer=opt.timer?parseInt(opt.timer,10):8000; //滚动的时间间隔(毫秒)
if(line==0) line=1;
var upHeight=0-line*lineH;
scrollUp=function(){
lineH=_this.find("li:first").height();
upHeight=0-line*lineH; //滚动函数
_this.animate(
{
marginTop:upHeight
},speed,function(){
for(i=1;i<=line;i++){
_this.find("li:first").appendTo(_this);
}
_this.css({marginTop:0});
}
);
}
scrollUp();
_this.hover(function(){ //鼠标事件绑定clearTimeout
window.clearInterval(timerID);
},function(){
timerID=window.setInterval("scrollUp()",timer);
}).mouseout();
//alert(timerID);
return timerID;
}
});
jQuery.extend({
DeBug:function(obj){
console.log(obj);
},
IsArray:function ( needle, array ) { //判断是否为数组
for( var i in array ) {
if( array[ i ] == needle ) {
return true;
}
}
return false;
},
DateDiff:function(date1,date2,s){ //计算两个时间差
var stringToTime=function stringToTime(string) {
var f = string.split(' ', 2);
var d = (f[0] ? f[0] : '').split('-', 3);
var t = (f[1] ? f[1] : '').split(':', 3);
return (new Date(parseInt(d[0], 10) || null,(parseInt(d[1], 10) || 1) - 1,parseInt(d[2], 10) || null,parseInt(t[0], 10) || null,parseInt(t[1], 10) || null,parseInt(t[2], 10) || null)).getTime();
}
var type1 = typeof date1, type2 = typeof date2;
date1=type1 == 'string'?stringToTime(date1):date1.getTime();
date2=type2 == 'string'?stringToTime(date2):date2.getTime();
var times=null;
switch(s){
case "d":times = (date2 - date1) / (1000 * 60 * 60 * 24);break; //天
case "h":times = (date2 - date1) / (1000 * 60 * 60);break; //小时
case "n":times = (date2 - date1) / (1000 * 60);break; //分钟
case "s":times = (date2 - date1) / (1000);break; //秒
case "t":times = (date2 - date1);break; //毫秒
default :
times = (date2 - date1) / (1000);break; //秒
break;
}
return times;
},
GetDate:function(){ //获取当前时间格式为:xxx-xx-xx xx:xx:xx
var d = new Date()
var Y = d.getFullYear()
var M = d.getMonth() + 1
var D = d.getDate()
var h = d.getHours();
var m = d.getMinutes();
var se = d.getSeconds();
return Y+"-"+(M<10 ? "0" + M : M)+"-"+(D<10 ? "0"+ D : D)+" "+(h<10 ? "0"+ h : h)+":"+(m<10 ? "0" + m : m)+":"+(se<10 ? "0" +se : se);
},
IsDate:function(date){ //检查日期格式是否正确
var reg = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))(\s(([01]\d{1})|(2[0123])):([0-5]\d):([0-5]\d))?$/;
if (!reg.test(date)){return false;}else{return true;};
},
IsCss3:function() { //检查浏览器是否支持CSS3
var div = document.createElement('div'),
vendors = 'Test Css3'.split(' '),
len = vendors.length;
var prop;
if (!prop) prop='textShadow';
if ( prop in div.style ) return true;
if ('-ms-' + prop in div.style) return true;
prop = prop.replace(/^[a-z]/, function(val) {return val.toUpperCase();});
while(len--) {
if ( vendors[len] + prop in div.style ) {
return true;
}
}
return false;
},
Timer:{ //倒计时计时器 返回,天,时,分,秒 该方法,只支持一个计时器.
time:0,
endtime:new Date(),
timer:null,
callback:function(){},
init:function(){
var _this=this;
if (this.time>=0){
this.callback({
day:Math.floor((this.time / 3600) / 24),
hour:Math.floor((this.time / 3600) % 24),
minute:Math.floor((this.time / 60) % 60),
second:Math.floor(this.time % 60),
time:this.time
});
var date1=new Date();
this.time=(this.endtime.getTime()-date1.getTime())/1000;
this.time=Math.floor(this.time);
this.timer = setTimeout(function(){_this.init();}, 1000);
} else {
clearTimeout(this.timer);
this.stop(this);
}
},
start:function(callback){
if ($.isFunction(callback)){
this.callback=callback;
}
clearTimeout(this.timer);
this.init(callback);
},
stop:function(){},
exit:function(){clearTimeout(this.timer);}
},
getNowFormatDate:function(){
var day = new Date();
var Year = 0;
var Month = 0;
var Day = 0;
var CurrentDate = "";
Year= day.getFullYear();//ie火狐下都可以
Month= day.getMonth()+1;
Day = day.getDate();
CurrentDate += Year + "-";
if (Month >= 10 ){
CurrentDate += Month + "-";
}else{
CurrentDate += "0" + Month + "-";
}
if (Day >= 10 ){
CurrentDate += Day ;
}else{
CurrentDate += "0" + Day ;
}
return CurrentDate;
},
templete:function(obj,opt){ //模板替换
//
昵称:{name} 年龄:{age}
[desc]
{text}
[desc]
var str;
function fun(str){
for(var name in opt){
if(typeof opt[name]=="object"){
// 字符串截取出新字符串
var getStr = str.substring(str.indexOf("["+name+"]")+2+name.length,str.lastIndexOf("["+name+"]"));
var newStr = "";
for(var i=0;i'
if (_this.length==0){
$("body").append(LoadingHtml);
_this=$("[hx_jq=Loading]").hide();
$(_this).Center();
}else{
$("[hx_jq=Loading]").text(msg);
}
if (t){
$(_this).show().Center();
}else{
$(_this).hide();
}
},0)
},
Set_Chart:function(opt){ //创建图表
$(opt.p).find(".ListBox .Content").append('')
$(opt.p).find("#datatable").show()
var strat_date=opt.o.chart.act.strat_date;
var end_date=opt.o.chart.act.end_date;
var title='';
var str='';
if (strat_date){str+='当前统计 - 开始时间:'+strat_date;}
if (end_date){str+=' 结束时间:'+end_date;}
if (str!=''){
title=str;
}else{
title='当前为默认显示最近'+ opt.o.chart.act.pagenum +'条数据.';
}
if ($(opt.p).find("#datatable").length){
$(opt.p).find('#container').highcharts({
data: {
table:document.getElementById('datatable')
},
chart: {
type:opt.o.chart.type
},
title: {
text: title
},
yAxis: {
allowDecimals: false,
title: {
text: ''
}
},
tooltip: {
//formatter: function() {
// return ''+ this.series.name +':¥'+ this.y +' 元';
//}
valueSuffix: ' 元'
}
});
}
$(opt.p).find("#container").hide()
},
MsgBox:function(options){ //MsgBox;对话窗口
var o = $.extend(true,{}, MsgBoxDefaults, options);
//alert(JSON.stringify(o));
var MsgBoxHtml='';
MsgBoxHtml+='
';
MsgBoxHtml+='
';
MsgBoxHtml+='';
MsgBoxHtml+='
'+o.title+'
';
MsgBoxHtml+='
';
if (o.zoom){MsgBoxHtml+='';}
if (o.close){MsgBoxHtml+='';}
MsgBoxHtml+='
';
$("#"+o.id).remove();
$("body").append(MsgBoxHtml);
var _this=$("#"+o.id);
$(_this).css({"top":"-10000px"});
//如果要使用CSS3动画,就不能使用$.hide().否则,将失去动画效果,因此,这里将对话框移动到浏览器不可见处.
var _this_load=$(_this).find("img,iframe").hide();
//处理图片和框架载入问题.
if (_this_load.length>0){
$.Loading(true,false);
var _this_tempnum=0;
$(_this_load).error(function(e){
_this_tempnum++;
if (_this_tempnum==_this_load.length){
$(_this).MsgBoxInit(o);
console.log("Error loading"+_this_tempnum);
}
})
$(_this_load).load(function(e){
_this_tempnum++;
if (_this_tempnum==_this_load.length){
$(_this).MsgBoxInit(o);
//console.log("正常加载"+_this_tempnum);
}
})
//防止长久不加载.
//window.setTimeout(function(){
// if (_this_tempnum!=_this_load.length){
// $(_this).MsgBoxInit(o);
// _this_tempnum=_this_load.length+1;
// console.log("延时加载"+_this_tempnum);
// }
//},3000*_this_load.length)
}else{
$(_this).MsgBoxInit(o);
}
},
MsgTips:function (options){ //MsgTips插件的MsgTipsDefaults
var MsgBoxDefaults = {
id:"AlertTips_",
title:"System prompt",
autoclosetime:30
};
var o = $.extend(true,{}, MsgBoxDefaults, options);
var Id=o.id+($(".MsgTips").size()+1);
var Top='',Msg='',Button='',Music='';
Top=o.logo?'
':'
'+o.title+'
';
Button=''+o.autoclosetime+'Automatically shut down in seconds closestop';
if (o.button){
$(o.button).each(function(i){
Button+=''+o.button[i].name+'';
})
};
Msg='
'+o.msg+'
';
var MsgTips='
'+Top+Button+Msg+'
';
$("body").append(MsgTips);
if (o.music){$.playVoice(o.music,"music");}
var _this=$("#"+Id);
//事件绑定
if (o.button){
$(o.button).each(function(i){
if ($.isFunction(o.button[i].fun)){
$(_this).find("[hx_jq=MsgTips_button]:eq("+i+")").click(function(){
o.button[i].fun(_this);
})
}
})
};
$(_this).animate({"bottom":"0px"},600);
$(_this).find("#close").click(function(){
$(_this).animate({"bottom":"-200px"},600,function(){
$(_this).remove();
});
});
var Times=window.setInterval(function(){
o.autoclosetime--;
$(_this).find("#times").html(o.autoclosetime);
if (o.autoclosetime==0){
$(_this).find("#close").trigger("click");
clearInterval(Times);
};
},1000);
$(_this).find("#stop").click(function(){
clearInterval(Times);
$(this).remove();
$(_this).find("#timesmsg").remove();
});
},
ck:function(name, value, options) { //cookies
if (typeof value != 'undefined') {
options = options || {};
if (value === null) {value = '';options.expires = -1;};
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
};
expires = '; expires=' + date.toUTCString();
};
var path = options.path ? '; path=' + (options.path) : '; path=/',domain = options.domain ? '; domain=' + (options.domain) : '',secure = options.secure ? '; secure': '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
};
return cookieValue;
}
},
isEmail:function(str){ //检查是否为Email
if((str.indexOf("@")==-1)||(str.indexOf(".")==-1)){
return false;
}else{
return true;
}
},
e:function(str){ //简化编码
return escape(str);
},
request:function(act){ //获取地址参数
//act=act.toLowerCase();
var url=location.search;//.toLowerCase()
var str=false;
if (url.indexOf("?")!=-1){
var strq=url.substr(1);
var strs=strq.split("&");
for(var i=0;i"+callback+"",autoclose:false});
}
}
},
dataType:dataType,
type:type
}
return $.ajax($.extend(true,{}, AjaxDefaults, options));
},
PJ:function(url,data1,callback,dataType,loadingmsg){
//alert(1); //Post Json
if (!url){$.MsgBox({msg:"请求地址不能为空",autoclose:false});};
if (!dataType){dataType="json"};
var options={
url:url,
data:data1,
dataType:dataType,
beforeSend:function(){$.Loading(true,loadingmsg);},
complete:function(XHR, TS){$.Loading(false,loadingmsg);},
success:function(data){
//alert(data);
//调用一个AJAX全局处理函数.该函数在成功返回后触发.可做数据通用处理.例如:检查登陆状态.
if (!$.AjaxApp(data)){
return;
}
if (!data){
//alert(data1.Action);
$.MsgBox({msg:"未获取到任何可用信息!",autoclose:false})
}else{
if ($.isFunction(callback)){
//alert(3);
callback(data);
}else{
$.MsgBox({msg:"回调函数有误:"+callback+"",autoclose:false});
}
}
}
}
return $.ajax($.extend(true,{}, AjaxDefaults, options));
},
JQP:function(url,data,callback,dataType,loadingmsg){ //Post Json
if (!url){$.MsgBox({msg:"请求地址不能为空",autoclose:false});};
if (!dataType){dataType="jsonp"};
var options={
async:false,
url:url+"&callback=?",
type: "GET",
dataType:"jsonp",
jsonp: 'jsoncallback',
data:data,
timeout: 5000,
contentType: "application/jsonp; charset=utf-8",
beforeSend:function(){$.Loading(true,loadingmsg);},
complete:function(XHR, TS){$.Loading(false,loadingmsg);},
success:function(data){
//alert(1);
//调用一个AJAX全局处理函数.该函数在成功返回后触发.可做数据通用处理.例如:检查登陆状态.
if (!$.AjaxApp(data)){
return;
}
if (!data){
$.MsgBox({msg:"未获取到任何可用信息!",autoclose:false})
}else{
if ($.isFunction(callback)){
//alert(data);
callback(data);
}else{
$.MsgBox({msg:"回调函数有误:"+callback+"",autoclose:false});
}
}
}
}
return $.ajax($.extend(true,{}, AjaxDefaults, options));
},
Ajax:function(options){ //重新定义AJAX
$.ajax($.extend(true,{}, AjaxDefaults, options));
},
ToColor:function(options,str){
var color="";
switch(options){
case "0":color="#3a6dd8";break; //红色
case "1":color="#f87c25";break; //橘黄
case "2":color="#ff0000";break; //蓝色
case "3":color="#542fb0";break; //彩色
case "4":color="#5dd887";break; //绿色
case "5":color="#ffa60b";break; //橙色
case "6":color="#b459d4";break; //紫色
case "7":color="#a87242";break; //棕色
}
return color==""?str:""+str+"";
},
JsonToStr:function(json){
var JsonArr=new Array();
$(json).each(function(i){
var value=json[i]?json[i]:json;
var arrtemp=new Array();
$.each(value,function(n,v){
if (isNaN(v)){
arrtemp.push('\"'+n+'\":\['+v+'\]');
}else{
arrtemp.push('\"'+n+'\":'+v+'');
}
})
JsonArr.push('{'+arrtemp.join(',')+'}')
})
return '['+JsonArr.join(',')+']';
},
playVoice:function(src, domId){
var dom=$('#'+domId);
if(!$.support.leadingWhitespace){ //IE678使用这个
if (dom.length){
dom[0].src=src
}else{
$('',{src:src, id:domId}).appendTo('body');
}
}else{ //否则使用HTML5
if (dom.length){
dom[0].src=src;dom[0].play();
}else{
$('