(function($){ke.rect=function(){this.left=arguments[0];this.top=arguments[1];this.width=arguments[2];this.height=arguments[3];if(arguments.length>4){this.horizontal=arguments[4];this.vertical=arguments[5]}return this};ke.rect.prototype.getPos=function(){return{left:this.left,top:this.top}};ke.rect.prototype.setPos=function(left,top){this.left=left;this.top=top};ke.rect.prototype.getRight=function(){return this.left+this.width};ke.rect.prototype.getBottom=function(){return this.top+this.height};ke.rect.prototype.diff=function(e){var r=0;if(e.width>this.width)r+=e.width-this.width;if(e.height>this.height)r+=e.height-this.height;return r};ke.rect.prototype.getSplitRects=function(maxWidth,maxHeight){var r=[];var left=this.left,top=this.top,h=this.height,w=this.width;var bottom=top+h,right=left+w;return[new ke.rect(left,bottom,maxWidth-left,maxHeight-bottom,"ll","tb"),new ke.rect(0,bottom,right,maxHeight-bottom,"rr","tb"),new ke.rect(left,0,maxWidth-left,top,"ll","bt"),new ke.rect(0,0,right,top,"rr","bt"),new ke.rect(right,top,maxWidth-right,maxHeight-top,"lr","tt"),new ke.rect(right,0,maxWidth-right,bottom,"lr","bb"),new ke.rect(0,top,left,maxHeight-top,"rl","tt"),new ke.rect(0,0,left,bottom,"rl","bb")]};ke.createObject=function(id,preFix){var info={};var cons=ke.ui.findControls(id,"input");for(var i=0;i0){var items=el.children;var store=new ke.table;store.addColumn("num");store.addColumn("name");store.addColumn("title");store.addColumn("html");for(var i=0;i0)css.width=Math.round(w);if(h>0)css.height=Math.round(h);if(left!=null)css.left=left;if(top!=null)css.top=top;this.css(css);return css}};$.fn._containsXY=function(x,y){var x0=this.offset().left;var y0=this.offset().top;var w=this._width();var h=this._height();if(xx0+w)return false;if(yy0+h)return false;return true};$.fn._width=function(){return this.length?Math.round(this.outerWidth(true)):0};$.fn._height=function(){return this.length?Math.round(this.outerHeight(true)):0};$.fn._extend=function(sup,args){sup.apply(this,args);$.extend(this,args.callee.methods);this.skin.parse(args.callee.defaults);return this};function createUI(){var ui=$(window);ui.registerAsGlobal=true;ui.winWidth=ui.width();ui.winHeight=ui.height();ui.controls=[];ui.controlsCount=0;ui.lang=function(wd){return wd};ui.render=function($el,_parent,_global){var exists=true;while(exists){exists=false;var tag="[class^='keui-']:first";var cons=!$el?$(tag):$el.find(tag);for(var i=0;i";con.after(htm);var dom=con[0].nextSibling;con.remove();con[0]=dom;con.autoSizeBox=skin.autoSizeBox||con.parent();con.initHandler();if(skin.data&&skin.data.tooltip)con.tooltip();if(con.documentClick){$(window).click(con,con.documentClick)}con.initSize(true);if(con.hasClass("draggable")&&$.drag){$.drag.bind(con.skin.dragEl||con,{el:con})}if(skin.hidden)con.hide();delete skin.htm;delete skin.css;delete skin.data;ui.createRelation(con,_parent);return con};ui.createRelation=function(con,_parent){if(ui.registerAsGlobal&&con.skin.id)window[con.skin.id]=con;_parent=_parent||ui;con._parent=_parent;_parent.controls.push(con)};ui.destroy=function(con){if(con){for(var i=0;i-1){parent.controls.splice(index,1);con.remove();delete con}}};ui.findControls=function(dom,cls){if(dom&&ke.isString(dom))dom=ke.get(dom);var result=[];$(dom||window.document.body).find("."+cls).each(function(i,d){var t=ui.find(d);if(t)result.push(t)});return result};ui.find=function(dom,parent){if(ke.isString(dom))dom=ke.get(dom);parent=parent||ke.ui;var r=null;for(var i=0;i0)return parseInt(val)*.01;else return parseInt(val)};this.className="";this.attributes="";this.style="";var data={};if(el){var opt=el.attributes["data-options"];if(opt){if(opt.value.indexOf(":")>0)opt.value="{"+opt.value+"}";data=$.extend(data,new Function("return "+opt.value+";")());opt.value=""}opt=el.attributes["data-union"];if(opt){data.union=new Function("return {"+opt.value+"};")();opt.value=""}opt=el.attributes["data-tooltip"];if(opt){data.tooltip=opt.value;opt.value=""}data.width=this.getSize("width",el,data.width);data.height=this.getSize("height",el,data.height);data.hidden=data.hidden||el.style.display=="none";el.style.display="";var attr=el.attributes;var keeps=["id","class","title","value","placeholder","disabled","readonly"];for(var i=0;i-1)data[name]=val;else if(name=="style")this.style=val;else if(val)this.attributes+=" "+name+'="'+val+'"'}var cls=el.className.split(" ");for(var i=0;i-1){htm+='
"}}return htm},layerHtml:function(wd){var htm="";if(ke.ui.mobile&&this.skin.isInput)htm+='
'+ke.ui.lang("取消")+'
'+this.skin.title+"
";if(this.store)htm=this.optionsHtml(this.store,wd,this.get());htm=htm||'";return htm},layerHide:function(){ke.ui.destroy(this.layerCompnent)},showLayer:function(wd){this.trigger("layerShowBefore");if(this.layerCompnent)ke.ui.destroy(this.layerCompnent);var htm=this.layerHtml(wd);htm=$.parseHTML('
'+this.layerHtml(wd)+"
");$(document.body).append(htm);this.layerCompnent=$(htm).layer(this.skin.layerOptions).render().removeClass("fll").trigger("layerShow").show();this.trigger("layerShowAfter");return this.layerCompnent}};$.fn.layout=function(){return this._extend($.fn.component,arguments)};$.fn.layout.defaults={scroller:true,url:"",urlParms:null};$.fn.layout.methods={initSkin:function(){this.skin.parse($.fn.layout.defaults)},initSize:function(first){if(first)ke.ui.render(this,this)},initHandler:function(){},getSize:function(){var w=this.skin.width;var h=this.skin.height;if(w<=1)w=this.autoSizeBox.width()*(w>0?w:1);if(!this.skin.autoHeight)if(h<=1)h=this.autoSizeBox.height()*(h>0?h:1);return[parseInt(w),parseInt(h)]}};$.fn.panel=function(){if(ke.ui.exists(this))return ke.ui.find(this[0]);return this._extend($.fn.layout,arguments)};$.fn.panel.defaults={collapsible:false,closable:false,maximizable:false,collapsed:false,minimizable:false,state:"",bodyCls:"",frameAutoHeight:false,onLoad:null,autoHeight:false};$.fn.panel.methods={initSkin:function(){$.fn.layout.methods.initSkin.call(this);this.skin.css+="panel";var htm="";if(this.skin.title){htm='
'+ke.ui.lang(this.skin.title)+'
';if(this.skin.collapsible)htm+='
';if(this.skin.minimizable)htm+='
';if(this.skin.maximizable)htm+='
';if(this.skin.closable)htm+='
';htm+="
"}htm+='
'+this.html()+"
"},initHandler:function(){var con=this;con.$header=con.find(".panel-header");con.$body=con.find(".panel-body");con.skin.dragEl=con.$header;con.bind("onShow",con,function(e){if(e.data.skin.url)e.data.loadUrl(e.data.skin.url)});this.pmb=this._getPMB();con.find(".static-icon-btn").click(function(e){if(ke.hasClass(e.target,"icon-collapse"))con.collapse();else if(ke.hasClass(e.target,"icon-minimize"))con.minimumSize();else if(ke.hasClass(e.target,"icon-maximize"))con.maximumSize();else if(ke.hasClass(e.target,"icon-close"))con.hide()})},initSize:function(first){var con=this;var wh=con.getSize();if(con.skin.state=="max"){wh[0]=con.autoSizeBox.width();wh[1]=con.autoSizeBox.height()}if(con.$header.length){con.$header._setSize(true,wh[0]);wh[1]-=con.$header._height()}con.$body._setSize(true,wh[0]-this.pmb[0],wh[1]-this.pmb[1]);if(first){con[0].style.width="";con[0].style.height="";if(!this.skin.hidden&&this.skin.url)this.loadUrl(this.skin.url);if(this.skin.onLoad)this.load(this.skin.onLoad);$.fn.layout.methods.initSize.call(this,first)}ke.ui.size(con)},collapse:function(v,callback){this.skin.collapsed=v||!this.skin.collapsed;this.$header.find(".icon-collapse").toggleClass("icon-collapsed",this.skin.collapsed);if(this.skin.collapsed)this.$body.hide();else this.$body.show()},maximumSize:function(){this.skin.state=this.skin.state!="max"?"max":"";this.$header.find(".icon-maximize").toggleClass("icon-maximized",this.skin.state=="max");this.initSize()},setTitle:function(v){this.$header.find(".fll").html(ke.ui.lang(v))},loadUrl:function(url,mustReload){this.skin.url=url;if(this.skin.urlParms)url=url+this.skin.urlParms();if(!this.skin.hidden||mustReload){if(this.currentUrl!=url||mustReload){var fm=this.$body.find("iframe");this.currentUrl=url;if(!fm.length){this.$body.removeClass("scroller");this.$body.html('');if(this.skin.frameAutoHeight){this.$body.find("iframe").bind("load",this,function(e){e.data.skin.height=$(e.data.window().document.body).height();e.data.resize()})}}else fm.attr("src",url)}}return this},loadHtml:function(htm){this.$body.html(htm);return this},window:function(){var r=this.find("iframe");return r.length?r[0].contentWindow:null},center:function(){var x=(this.skin.autoSizeBox.width()-this._width())/2;var y=(this.skin.autoSizeBox.height()-this._height())/2;this.css({left:x,top:y});this.skin.x=x;this.skin.y=y;this.skin.horizontal="center";this.skin.vertical="center"}};$.fn.layer=function(){if(ke.ui.exists(this))return ke.ui.find(this[0]);if(this[0].tagName!="BODY"){var el=this[0];this.remove();document.body.appendChild(el);this[0]=el}return this._extend($.fn.panel,arguments)};$.fn.layer.defaults={modal:false,owner:null,syncOwnerWidth:false,syncOwnerHeight:false,horizontal:"",vertical:"",allowOverflow:true,allowCoverOwner:true,ownerArrow:true,clickHide:true,clickSelfHide:false,minWidth:0,minHeight:0,left:-1,top:-1};$.fn.layer.methods={initSkin:function(){$.fn.panel.methods.initSkin.call(this);this.skin.css+=" layer";this.skin.autoSizeBox=ke.ui;this.firstShow=true;if(this.skin.ownerArrow)this.skin.html='
'+this.skin.html},initHandler:function(){$.fn.panel.methods.initHandler.call(this);if(this.skin.modal){ke.mask(this.skin.id,true);this.bind("onShow",this,function(e){ke.mask(e.data.skin.id,true)});this.bind("destroy",this,function(e){ke.unMask(e.data.skin.id)});this.bind("onHide",this,function(e){ke.unMask(e.data.skin.id)})}if(this.skin.minimizable){this.$header.bind("dblclick",this,function(e){e.data.minimumSize()})}if(this.skin.width<=0){this.skin.width=this._width()}if(this.skin.height<=0)this.skin.height=this._height();if(this.skin.ownerArrow)this.arrow=$(".triangle")},initSize:function(first){$.fn.panel.methods.initSize.call(this,first);var sk=this.skin;var dr=new ke.rect(sk.left,sk.top,sk.width,sk.height);var or=null;if(sk.owner){or=sk.owner._getRect();if(sk.syncOwnerWidth)dr.width=or.width;if(sk.syncOwnerHeight)dr.height=or.height;if(!sk.allowCoverOwner&&or){var _bottom=ke.ui.winHeight-or.top-or.height;if(dr.height>or.top&&dr.height>_bottom){dr.height=or.top>_bottom?or.top:_bottom}}}if(dr.widthke.ui.winWidth)dr.width=ke.ui.winWidth-10;if(dr.height>ke.ui.winHeight)dr.height=ke.ui.winHeight-10}this.$header._setSize(true,dr.width-this.pmb[0]);var h=dr.height-this.$header._height()-this.pmb[1];var w=dr.width-this.pmb[0];this.$body._setSize(true,w>1?w:null,h>1?h:null);dr.height=this._height();dr.width=this._width();this.initPos(dr,or,sk);sk.left=dr.left;sk.top=dr.top;this.css(dr.getPos());ke.ui.size(this)},initPos:function(dr,or,sk){if(sk.state=="max")dr.left=dr.top=0;if(sk.state=="min"){dr.left=ke.ui.winWidth-dr.width;dr.top=ke.ui.winHeight-dr.height}else{var fr=null;if(or){var rects=or.getSplitRects(ke.ui.winWidth,ke.ui.winHeight);var diff=-1;rects.forEach(function(d){var temp=d.diff(dr);if(diff<0||temp0)dr.left-=dif;dr.top=dr.top<0?0:dr.top;dif=dr.top+dr.height-ke.ui.winHeight;if(dif>0)dr.top-=dif}this.initArrowPos(dir,dr,or,sk)}},calPosLeft:function(dr,or,sk,fr){var max=ke.ui.winWidth;var align=sk.horizontal||fr&&fr.horizontal;var s=0,e=max,val=dr.width;if(or){s=or.left;e=or.left+or.width}var r=dr.left;if(align=="auto"){align="ll";if(s+val>max&&s+val-max>val-e)align="rr"}if(align=="center"){var dif=(e-s-val)/2;r=s+dif}else if(align=="ll")r=s;else if(align=="lr")r=e;else if(align=="rl")r=s-val;else if(align=="rr")r=e-val;return r},calPosTop:function(dr,or,sk,fr){var max=ke.ui.winHeight;var align=this.skin.vertical||fr&&fr.vertical;var s=0,e=max,val=dr.height;if(or){s=or.top;e=or.top+or.height}s=s||0;var r=dr.top;if(align=="auto"){align="tb";if(e+val>max&&s+val-max>val-e)align="bt"}if(align=="center"){var dif=(e-s-val)/2;r=s+dif}else if(align=="tt")r=s;else if(align=="tb")r=e;else if(align=="bt")r=s-val;else if(align=="bb")r=e-val;return r},initArrowDirect:function(dr,or,sk){if(or&&sk.ownerArrow){if(!(dr.left>=or.getRight()||dr.getRight()<=or.left)){if(or.top>=dr.top+dr.height&&dr.top>=6){dr.top-=8;return"bottom"}else if(dr.top+dr.height>=or.top+or.height){dr.top+=8;return"top"}}else if(!(dr.top>=or.getBottom()||dr.getBottom()<=or.top)){if(or.left>=dr.getRight()&&dr.left>=6){dr.left-=8;return"right"}else if(dr.left>=or.getRight()){dr.left+=8;return"left"}}}return""},initArrowPos:function(dir,dr,or,sk){if(dir){var r=this.arrow._getRect();var cls="";if(dir=="bottom"||dir=="top"){r.left=or.left+(or.width-16)/2-dr.left;r.left=r.left<5?5:r.left;r.top=dir=="top"?-8:dr.height-1}else if(dir=="left"||dir=="right"){r.top=or.top+(or.height-16)/2-dr.top;r.top=r.top<5?5:r.top;r.left=dir=="left"?-8:dr.width-2}this.arrow.css(r.getPos()).removeClass().addClass("triangle triangle-"+dir).show()}else if(this.arrow)this.arrow.hide()},documentClick:function(e){var con=e.data;if(!con._showEvent||con._showEvent!=event){if(con.skin.clickHide){if(!con.skin.hidden){var ele=e.target;while(ele&&!con.skin.clickSelfHide){if(ele==con[0]||con.skin.owner&&con.skin.owner[0]==ele){return}ele=ele.parentNode}con.hide()}}}},minimumSize:function(){this.skin.state=this.skin.state!="min"?"min":"";if(this.skin.state=="min"){this.collapse(true);this.initSize()}else{this.collapse(false);this.center()}},show:function(){this._showEvent=event;$.fn.component.methods.show.call(this);return this},showAt:function(){if(arguments.length>1){this.skin.left=arguments[0];this.skin.top=arguments[1]}else this.skin.owner=arguments[0];this.show()}};$.fn.input=function(){this._extend($.fn.component,arguments);this.$text=null;this.$value=null;this.selectedRow=null;return this};$.fn.input.defaults={type:"string",inline:false,nullable:true,disabled:false,readonly:false,textField:"name",valueField:"num",autoCreateStore:true,onChange:null,value:"",placeholder:"",reg:"",iconCls:"",iconClsPosition:"left",store:null,multiple:false,separator:",",clickShowLayer:true,valueInStore:false,union:null};$.fn.input.methods={initSkin:function(){var sk=this.skin;var sklayer=sk.layerOptions;sk.css+=" input";sk.formatContent=true;sk.outputAttr=false;sk.isInput=true;sk.legal=true;sk.css+=sk.inline?" inline-block":"";sk.attributes+=sk.placeholder?' placeholder="'+sk.placeholder+'"':"";sk.attributes+=sk.readonly?' readonly="readonly"':"";sklayer.syncOwnerWidth=true;sklayer.allowCoverOwner=sk.layerOptions.allowCoverOwner||false;sklayer.allowOverflow=sk.layerOptions.allowOverflow||false;sklayer.ownerArrow=false;sklayer.minWidth=sklayer.minWidth||120;sklayer.bodyCls="input-layer";if(sk.store)this.store=sk.data.store;else if(sk.autoCreateStore)this.store=ke.createStore(this[0]);if(sk.data.tooltip)this.skin.hasTooltip=true},initHandler:function(){var con=this;if(!con.$value){con.$value=con.find("input[type='text']");con.$text=con.find("input[type='text']")}con.$text.bind("blur",con,function(e){e.data.removeClass("focus");e.data.validate()});con.$text.bind("change",con,function(e){e.data.validate();e.data.change()});con.$text.bind("focus",con,function(e){e.data.addClass("focus")});con.bind("layerShowAfter",this,function(e){e.data.layerCompnent.find(".panel-body div").click(function(t){e.data.itemClick(t.target)});e.data.layerCompnent.find(".data-select-header .fll").click(function(){e.data.layerHide()})});con.setTitle(con.skin.title);con.setIconCls(con.skin.iconCls,true,con.skin.iconClsPosition)},initSize:function(first){var con=this;var w=con.skin.width;if(w<=1){if(!con.skin.inline)w=parseInt(con.autoSizeBox.width()*(w>0?w:1))}if(w>0){var css=con._setSize(true,w);w=con.width();var items=con.children();for(var i=0;i1){con._setSize(true,null,con.skin.height)}if(first){if(this.store)this.bindStore(this.store);if(this.skin.onChange)this.change(this.skin.onChange);this.skin.layerOptions.owner=this.find(".box");this.disable(this.skin.disabled);if(this.skin.value!=null&&this.skin.value!=="")this.set(this.skin.value)}},bindStore:function(store){this.store=store;if(!this.hasBindStoreClick&&store&&this.skin.clickShowLayer){this.hasBindStoreClick=true;this.find(".box").click(this,function(e){if(e.data.skin.disabled!==true)e.data.showLayer()})}this.set(this.get())},focus:function(){setTimeout(this.skin.id+".$text.focus();",100);return this},blur:function(data,fun){ke.bindOrTrriger(this.$text,"blur",arguments)},disable:function(v){this.skin.disabled=v;if(v){this.$text.attr("disabled",true);this.addClass("disabled")}else{this.$text.removeAttr("disabled");this.removeClass("disabled")}return this},readonly:function(v){this.skin.readonly=v;if(v)this.$text.attr("readonly","readonly");else this.$text.removeAttr("readonly")},change:function(){ke.bindOrTrriger(this,"keChange",arguments);if(arguments.length<1)ke.ui.trigger("inputChange",this)},val:function(){if(arguments.length==0)return this.$value.val();else this.set(arguments[0])},setTitle:function(val){this.skin.title=val;var el=this.children("label");if(val){val=ke.ui.lang(val);if(this.skin.hasTooltip)val+='';if(el.length)el.html(val);else this.prepend("")}else el.remove()},setIconCls:function(v,first,pos){if(v){if(pos=="left")this.find(".box").prepend('');else this.find(".box").append('')}else if(!first)this.find(".box").find("i").remove()},validate:function(){var val=this.get(ke.types.string);var r=this.skin.nullable||val!="";if(r&&val!=""&&this.skin.reg)r=val.match(this.skin.reg);this.find(".box").toggleClass("illegal",!r);this.skin.legal=r;return r},select:function(i){this.layerHide();this.set(this.store.rows[i].get(this.skin.valueField));this.change()},getText:function(v){return this.$text.val()},unionSet:function(){var data=this.selectedRows.length?this.selectedRows[0]:{};var u=this.skin.union;for(var f in u){if(u[f]!=null){u[f].set(data[f])}}},set:function(v){var con=this;con.selectedRows=[];if(con.store){var st=con.store;var vals=(v==null?"":v).toString().split(con.skin.separator);for(var i=0;i-1)this.selectedRows.push(d)}}if(con.skin.valueInStore){v=this.selectedRows.joinField(con.skin.valueField,this.skin.separator)}this.unionSet()}con.$value.val(v);con.validate();return this},setTriggerChange:function(v){this.set(v);this.change()},get:function(type){return ke.convert(this.$value.val(),type||this.skin.type)},itemClick:function(dom){var val=null;while(val==null&&dom&&dom.tagName!="BODY"){val=dom.getAttribute("data-value");dom=dom.parentNode}if(val){var con=this;if(!con.skin.multiple)con.setTriggerChange(val);else{var items=con.get().split(con.skin.separator);var index=items.indexOf(val);if(index>-1)items.splice(index,1);else items.push(val);con.setTriggerChange(items.join(con.skin.separator))}this.layerHide()}},selectedRows:[]};$.fn.button=function(){if(ke.ui.exists(this))return ke.ui.find(this[0]);return this._extend($.fn.component,arguments)};$.fn.button.defaults={disabled:false,layerHtml:"",iconCls:"",iconClsPosition:"left",onClick:null};$.fn.button.methods={initSkin:function(){this.skin.css+=" button inline-clear unselect";this.skin.html='
';if(!this.skin.layerHtml)this.skin.layerHtml=this.html().trim();this.skin.layerOptions.clickSelfHide=true},initHandler:function(){if(this.skin.onClick)this.click(this.skin.onClick);this.set(this.skin.title);this.setIconCls(this.skin.iconCls,true,this.skin.iconClsPosition)},setIconCls:function(v,first,pos){if(v){if(pos=="left")this.find(".box").prepend('');else this.find(".box").append('')}else if(!first)this.find(".box").find("i").remove()},initSize:function(first){var con=this;var w=con.skin.width;var h=con.skin.height;con._setSize(true,con.skin.width,con.skin.height);if(first){this.disable(this.skin.disabled);if(this.skin.layerHtml){this.skin.layerOptions.owner=this;this.layerHtml=function(){return this.skin.layerHtml};this.click(this,function(e){e.data.showLayer()})}}},disable:function(v){this.skin.disabled=v;this.toggleClass("disabled",v);return this},set:function(v){var box=this.find(".box div");if(v)v=ke.ui.lang(v);box.html(v);box.toggle(v!=null&&v!=="");return this},show:function(){this[0].style.display="inline-block";this.skin.hidden=false;this.initSize();this.trigger("onShow");return this},setMsg:function(i){var con=this.children(".button-msg");if(i){if(!con.length)this.append('
'+i+"
");else con.find("span").html(i)}else con.remove();return this}};$.fn.window=function(config){if(ke.ui.exists(this))return ke.ui.find(this[0]);var con=this.layer(config);con.skin.parse({closable:true,collapsible:true,minimizable:true,maximizable:true,draggable:true,clickHide:false,ownerArrow:false,horizontal:"center",vertical:"center"});con.skin.className+=" window";if(con.skin.draggable)con.skin.className+=" draggable";return con};$.fn.window.create=function(config,html){$(document.body).append("
"+html+"
");var con=$("#"+config.id).window(config).render();if(config.title&&!config.height)con.changeSize(null,con.skin.height);return con};$.fn.tooltip=function(){this.removeClass("keui-tooltip");this.mouseover(function(e){$.fn.tooltip.owner=$(this);setTimeout("$.fn.tooltip.show();",500)});this.click(function(e){$.fn.tooltip.hide()});this.mouseout(function(){$.fn.tooltip.hide()})};$.fn.tooltip.render=function($el){var tips=$el?$el.find(".keui-tooltip"):$(".keui-tooltip");tips.each(function(i,d){$(d).tooltip()})};$.fn.tooltip.show=function(){if($.fn.tooltip.owner){var config={id:"ke_tooltip",css:"tooltip ",horizontal:"center",vertical:"auto",ownerArrow:true,allowOverflow:false,clickSelfHide:true};ke.ui.destroy($.fn.tooltip.con);var tip=$.fn.tooltip.owner.attr("data-tooltip");var con=$.fn.window.create(config,tip);con.showAt($.fn.tooltip.owner);con.$body.css({height:"auto",width:"auto"});$.fn.tooltip.con=con}};$.fn.tooltip.hide=function(){if($.fn.tooltip.con)$.fn.tooltip.con.hide();$.fn.tooltip.owner=null};$.messager={alter:function(msg,callback,icon){this.show({msg:msg,btnNo:false,callback:callback,modal:true,icon:icon||"info"})},confirmMsg:function(msg,callback){this.show({title:"系统提示",msg:msg,callback:callback,modal:false,btnNo:false})},confirm:function(title,msg,callback,icon){this.show({title:title,msg:msg,callback:callback,modal:true,icon:icon||"question"})},prompt:function(title,msg,callback,inputSelectItems){this.show({title:title,msg:msg,showInput:true,btnNo:true,callback:callback,modal:true,icon:"",inputSelectItems:inputSelectItems,css:"prompt "})},notify:function(msg,sec,config){config=config||{};config=$.extend({id:"ke_messager_notify",msg:msg,btnNo:false,btnYes:false,btnClose:true,modal:false,callback:config.callback,center:false,css:"notify ",horizontal:config.horizontal||"center",vertical:config.vertical||"tt",animate:true},config);var con=this.show(config);if(config.animate){var w=con._width();var h=con._height();var from={left:w*-1,top:10};var to={left:10,top:10};var cls="left";if(con.skin.horizontal=="center"){from={top:h*-1};to={top:10};cls="top";if(con.skin.vertical=="bb"){cls="bottom";from={top:ke.ui.winHeight};to={top:ke.ui.winHeight-h-10}}else if(con.skin.vertical=="center"){cls="center";from={top:con.skin.y-h};to={top:con.skin.y}}}else if(con.skin.horizontal!="ll"){cls="right";from.left=ke.ui.winWidth;to.left=ke.ui.winWidth-w-10}con.skin.from=from;con.addClass("notify-"+cls).css(from);con.animate(to)}var evt=con.skin.id+"_evt";clearTimeout($.messager[evt]);$.messager[evt]=setTimeout("$.messager.notifyHide(ke.ui.find('"+con.skin.id+"'))",sec||5e3)},notifyHide:function(con){if(con){con.animate(con.skin.from,function(){ke.ui.destroy(con)})}},show:function(config){var opt=new ke.options(null,config);opt.parse($.messager.defaults);config.maximizable=false;config.minimizable=false;config.width=450;config.id=opt.id;ke.ui.destroy(ke.ui.find(opt.id));var cols=1;var htm='';if(opt.icon){htm+='';cols++}htm+='';if(opt.btnClose){htm+='';cols++}htm+="";if(opt.showInput){htm+='"}htm+="
{ke.ui.lang(d.msg)}
';if(opt.inputSelectItems)htm+=ke.formatForeach('',opt.inputSelectItems);htm+="
";var btns="";if(opt.btnYes)btns+='
{ke.ui.lang(d.btnYesText)}
';if(opt.btnNo)btns+='
{ke.ui.lang(d.btnNoText)}
';if(btns)btns='
'+btns+"
";htm+=btns+"
";config.css=" messager "+(config.css||"");var con=$.fn.window.create(config,new ke.template(htm).render(opt,0));con.opt=opt;this.initHandler(con);if(opt.showInput){con.controls[0].set(opt.defaultValue);con.controls[0].$text.focus()}return con},initHandler:function(con){con.find(".icon-cross").click(con,function(e){$.messager.notifyHide(con)});con.find(".btn").click(con,function(e){var obj=$(e.target);var txt=con.opt.showInput?con.controls[0].get():"";if(obj.hasClass("btn-yes")){con.hide();if(con.opt.callback)con.opt.callback(txt);ke.ui.destroy(con)}else if(obj.hasClass("btn-cancel")){if(con.opt.noCallback)con.opt.noCallback(txt);ke.ui.destroy(con)}})}};$.messager.defaults={title:"",msg:"",btnYes:true,btnNo:true,btnClose:false,showInput:false,btnYesText:"确认",btnNoText:"取消",defaultValue:"",id:"ke_messager",icon:"info",modal:false,center:true,callback:null,noCallback:null,inputOptions:null,inputSelectItems:null,height:null};ke.openWindow=function(title,url,w,h,config){var id="ke_open_window";ke.ui.destroy(ke.ui.find(id));$(document.body).append('
');config=config||{};config.title=title;config.url=url;config.width=w;config.height=h;var con=$("#"+id).window(config).render();return con}})(jQuery);