<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
*{margin:0;padding:0;border:0;word-break: break-all;}
.tishiBox,.tishiBox span{ position:absolute;display:inline-block; background:url(images/tishiBg.png)}
.tishiBox{height:36px; position: absolute; white-space:nowrap;background-position:center 0;}
.tishiBox span{ position:absolute;display:inline-block; background:url(images/tishiBg.png);}
.tishiBox span.spanL,.tishiBox span.spanR{width:10px;height:36px;top:0;}
.tishiBox span.spanL{ background-position:0 0;left:-10px;}
.tishiBox span.spanR{ background-position:right 0;right:-10px;}
.tishiBox p{padding:0 10px;line-height:30px;color:#e70909; font-size:12px;}
</style>
</head>
<body>
<div style="margin:100px">
<input type="button" style="height:30px; width:190px" id="test" class="fanfan"/>
<input type="button" style="height:30px; width:190px" id="test1" class="fanfan"/>
</div>
</body>
</html>
<script type="text/javascript" src="js/jquery.min.js"></script>//公共的jquery库
<script type="text/javascript" src="js/k-min-debug.js"></script>
<script type="text/javascript" src="js/Tip.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var bttip=new Editor.tool.Tip();
var tipfn={
'test':{
tip:'检查试题是否完整性!'
},
'test1':{
tip:'对当前编辑的试题进行预览!'
}
};
$.each(tipfn,function(key,val){
$('#'+key).mouseover(function(){
bttip.setContent(val.tip);
bttip.show(this);
}).mouseout(function(){
bttip.hide();
});
});
})
</script>
k-min-debug.js:
var Kyf=(function(){
var nameSpace=function(){
var args=Kyf.toArray(arguments),_arg=arguments;
if(args.length>1){
Kyf.each(args,function(index,arg){
_arg.callee.apply(window,arg);
});
return;
}
var NSList=args[0].split('.'),parent=window;
Kyf.each(NSList,function(index,ns){
parent[ns]=(Kyf.isUndefined(parent[ns])?{}:parent[ns]);
parent=parent[ns];
});
},
seed=1,
toString=Object.prototype.toString;
var IsArray=function(param){
return toString.call(param)=='[object Array]';
};
var each=function(list,fn,scope){
if(IsArray(list)){
var i=0,item=null;
while(i<list.length){
item=list[i];
if(fn.call(scope,i,item,list)===false)break;
i++;
}
}else{
for(var key in list){
var val=list[key];
if(fn.call(scope,key,val,list)===false)
break;
}
}
};
var apply=function(dest,src,isOverRide){
each(src,function(key,val){
if(!dest[key]||!!isOverRide)
dest[key]=val;
});
return dest;
};
var browser=(function(){
var matchReg={
isIE:/msie/i,
isIE6:/msie 6.0/i,
isIE7:/msie 7.0/i,
isIE8:/msie 8.0/i,
isIE9:/msie 9.0/i,
isFF:/firefox/i,
isChrome:/chrome/i
},
v=new Object(),
userAgent=window.navigator.userAgent.toString();
each(matchReg,function(key,val){
v[key]=val.test(userAgent);
});
return v;
})();
var methods={
version:'1.0.1',
id:function(name){return (name?name:'kyf')+(seed++);},
apply:function(dest,src){
return apply(dest,src,true);
},
applyIf:function(dest,src){
return apply(dest,src);
},
browser:browser,
nameSpace:nameSpace,
NS:nameSpace,
emptyFn:function(){},
define:function(path,option){
var p=path.split('.');
if(p.length>1){
this.NS(p.slice(0,p.length-1).join('.'));
}
var clazz=function(){
if(!this.initialize)this.initialize=Kyf.emptyFn;
this.self=arguments.callee;
this.initialize.apply(this,arguments);
};
clazz.superclass=null;
clazz.subclass=[];
var implement=function(interface,_clazz){
var args=arguments;
if(Kyf.isArray(interface)){
each(interface,function(index,item){
args.callee(item,_clazz);
});
return;
}
if(Kyf.isString(interface))interface=(new Function('return '+interface)).call();
var pro=new interface();
each(pro,function(name,val){
if(Kyf.isFunction(val)){
_clazz.prototype[name]=val;
}
});
};
if(option){
if(option['statics']&&
Kyf.isUndefined(option['extend'])&&
Kyf.isUndefined(option['implement'])&&
Kyf.isUndefined(option['members'])
){
eval(path+'=option.statics;');
return;
}else{
if(option.implement){
implement(option.implement,clazz);
}
if(option.extend){
var constructor=clazz.prototype.constructor,emptyFn=Kyf.emptyFn;
emptyFn.prototype=option.extend.prototype;
clazz.prototype=new emptyFn();
clazz.prototype.constructor=constructor;
clazz.superclass=option.extend.prototype;
clazz.prototype.base=clazz.superclass;
}
if(option.members){
apply(clazz.prototype,option.members,true);
if(option.members.hasOwnProperty('toString')){
clazz.prototype.toString=option.members.toString;
}
}
if(option.statics){
apply(clazz,option.statics);
}
}
if(option['initialize']){
clazz.prototype.initialize=option['initialize'];
}
}
eval(path+'=clazz;');
},
isFunction:function(param){
return toString.call(param)=='[object Function]';
},
isArray:IsArray,
isNumber:function(param){
var reg=new RegExp('^(([\\d][\\d\\.]*[\\d])|([\\d]+))$');
return reg.test(param);
},
isBoolean:function(param){
return toString.call(param)=='[object Boolean]';
},
isObject:function(param){
return toString.call(param)=='[object Object]';
},
isUndefined:function(param){
return typeof param=='undefined';
},
isNull:function(param){
return param==null;
},
isString:function(param){
return toString.call(param)=='[object String]';
},
each:each,
toArray:function(params){
return Array.prototype.slice.call(params);
},
createDelegate:function(){
var args=Kyf.toArray(arguments);
return function(){
args[0].apply(args[1],args.slice(2).concat(Kyf.toArray(arguments)));
};
},
createCallback:function(){
var args=Kyf.toArray(arguments);
return function(){
args[0].apply(window,args.slice(1).concat(Kyf.toArray(arguments)));
};
},
now:function(){
return Date.now();
},
live:function(selector,action,fn){//import jquery
var args=arguments;
var indexOf=function(selector,target){
var index=-1;
$(selector).each(function(i){
if(this===target){
index=i;
return false;
}
});
return index;
};
$(document).bind(action,function(e){
if(indexOf(selector,e.target)!=-1)fn.apply(window,Array.prototype.slice.call(args,3));
});
},
getEvent:function(){
if(Kyf.browser.isIE)return window.event;
var arg=arguments.callee.caller;
while(arg.arguments[0].toString().toLowerCase().indexOf('event')==-1){
arg=arg.arguments.callee.caller;
}
return arg.arguments[0];
},
getTarget:function(e){
return Kyf.browser.isIE?e.srcElement:e.target;
},
getRoot:function(){
if(Kyf.browser.isChrome){
return document.body;
}else{
return document.documentElement;
}
},
max:function(ArrayList){
var val=ArrayList.getAt(0);
ArrayList.each(function(i,v){
if(i>0){
val=Math.max(val,v);
}
});
return val;
}
};
return methods;
})();
Kyf.define('Kyf.util.Event',{
initialize:function(obj,name){
this.obj=obj;
this.name=name;
if(!this.listeners)this.listeners=[];
},
members:{
toString:function(){
return '[class Kyf.util.Event]';
},
isListening:false,
fire:function(){
this.isListening=true;
var handlers=this.listeners,args=arguments;
Kyf.each(handlers,function(i,handler){
handler.fn.apply(handler.scope,args);
});
this.isListening=false;
},
addListener:function(fn,scope){
scope=scope||window;
if(!this.findListener(fn,scope)){
this.listeners.push({fn:fn,scope:scope});
return true;
}
return false;
},
removeListener:function(fn,scope){
scope=scope||window;
var index=this.getIndex(fn,scope);
if(index!=-1){
if(this.isListening){
this.listeners=this.listeners.slice(0);
}
this.listeners.splice(index,1);
return true;
}
return false;
},
clearListener:function(){
if(this.isListening){
this.listeners=this.listeners.slice(0);
}
this.listeners=[];
},
getIndex:function(fn,scope){
scope=scope||window;
var index=-1;
Kyf.each(this.listeners,function(i,listener){
if(listener.fn==fn&&listener.scope==scope){
index=i;
}
});
return index;
},
findListener:function(fn,scope){
var listener=null;
var index=this.getIndex(fn,scope);
if(index!=-1)listener=this.listeners[index];
return listener;
}
}
});
Kyf.define('Kyf.util.Observable',{
initialize:function(){
if(this.listeners){
this.on(this.listeners);
delete this.listeners;
}
},
members:{
toString:function(){
return '[class Kyf.util.Observable]';
},
addEvents:function(){
if(!this.events)this.events={};
var args=Kyf.toArray(arguments),self=this;
if(Kyf.isObject(args[0])){
Kyf.apply(this.events,args[0]);
return;
}
Kyf.each(args,Kyf.createDelegate(function(index,name){
this.events[name]=this.events[name]||true;
},this));
},
removeEvents:function(name){
var e=this.events[name];
if(this.hasEvent(name)){
if(Kyf.isObject(e)){
e.clearListener();
}
delete this.events[name];
return true;
}
return false;
},
addListener:function(name,fn,scope){
var args=Kyf.toArray(arguments),
_arg=arguments,
self=this;
if(Kyf.isObject(args[0])){
Kyf.each(args[0],function(key,val,item){
if(key!='scope')
_arg.callee.call(self,key,val.fn||val,val.scope||item.scope||window);
});
return;
}
if(Kyf.isBoolean(this.events[name])){
this.events[name]=new Kyf.util.Event(self,name);
}
this.events[name].addListener(fn,scope);
},
removeListener:function(name,fn,scope){
var args=Kyf.toArray(arguments),
_arg=arguments,
self=this;
if(Kyf.isObject(args[0])){
Kyf.each(args[0],function(key,val,self,item){
if(key!='scope')
_arg.callee.call(this,key,val.fn||val,val.scope||item.scope);
});
return;
}
var e=this.events[name];
if(e){
if(Kyf.isBoolean(e)){
delete this.events[name];
}else{
e.removeListener(fn,scope);
}
return true;
}
return false;
},
suspendEvent:function(forceClear){
this.isSuspend=true;
if(forceClear&&!this.eventQueue){
this.eventQueue=[];
}
},
resumeEvent:function(){
this.isSuspend=false;
var l=this.eventQueue||[];
Kyf.each(l,Kyf.createDelegate(function(i,name){
this.fireEvent.apply(this,name);
},this));
delete this.eventQueue;
},
hasEvent:function(name){
return this.events[name]?true:false;
},
fireEvent:function(name){
var e=this.events[name],args=Kyf.toArray(arguments).slice(1);
if(this.isSuspend===false){
var q=this.eventQueue;
q=q||[];
q.push(name);
}else if(Kyf.isObject(e)){
e.fire.apply(e,args);
}
}
}
});
(function(){
var pro=Kyf.util.Observable.prototype;
Kyf.apply(pro,{
on:pro.addListener,
un:pro.removeListener
});
})();
Kyf.define('Kyf.data.ICollection',{
members:{
toString:function(){return '[class Kyf.data.ICollection]';},
insert:function(index,item){},
append:function(item){},
getAt:function(index){},
getIndex:function(item){},
remove:function(index){},
removeAll:function(){},
clone:function(){},
each:function(){}
}
});
Kyf.define('Kyf.data.Hash',{
implement:Kyf.data.ICollection,
extend:Kyf.util.Observable,
initialize:function(item){
this.list=item||new Object();
this.addEvents('insert','append','remove');
this.base.initialize.call(this);
},
members:{
toString:function(){
return '[class Kyf.data.Hash]';
},
insert:function(index,item){
this.list[index]=item;
this.fireEvent('insert',index,item);
return item;
},
getAt:function(index){
return this.list[index]||null;
},
getIndex:function(item){
var index=-1;
this.each(function(i,it,list){
if(it==item){
index=i;
return false;
}
});
return index;
},
remove:function(index){
this.fireEvent('remove',index);
var item = this.list[index];
delete this.list[index];
return item;
},
removeAll:function(){
this.list={};
},
clone:function(){
return Kyf.apply({},this.list);
},
each:function(fn,scope){
Kyf.each(this.list,fn,scope||this);
}
}
});
Kyf.define('Kyf.data.ArrayList',{
implement:Kyf.data.ICollection,
extend:Kyf.util.Observable,
initialize:function(item){
this.list=item||new Array();
this.addEvents('insert','append','remove');
this.base.initialize.call(this);
},
members:{
toString:function(){
return '[class Kyf.data.ArrayList]';
},
size:function(){
return this.list.length;
},
insert:function(index,item){
index=index||0;
var l=this.list,
temp=l.slice(0,index-1);
temp.push(item);
l=temp.concat(l.slice(index));
this.fireEvent('insert',index,item);
return item;
},
append:function(item){
this.fireEvent('append',item);
return this.list.push(item);
},
getAt:function(index){
return this.list[index]||null;
},
getIndex:function(item){
var index=-1;
this.each(function(i,it,list){
if(it==item){
index=i;
return false;
}
});
return index;
},
remove:function(index,number){
number=number||1;
this.fireEvent('remove',index,number);
return this.list.splice(index,number);
},
removeAll:function(){
this.list=[];
},
clone:function(){
return this.list.slice();
},
each:function(fn,scope){
Kyf.each(this.list,fn,scope||this);
},
shift:function(){
return this.list.shift();
},
pop:function(){
return this.list.pop();
},
slice:function(index,number){
number=number||1;
return this.list.slice(index,number);
},
join:function(char){
char=Kyf.isUndefined(char)?',':char;
return this.list.join(char);
}
}
});
Kyf.define('Kyf.util.String',{
statics:{
trim:function(param){
return this.lTrim(param)+this.rTrim(param);
},
ellipsis:function(param,number){
var Builder=new Array(),counter=0;
this.each(param,function(index,char){
var charCode=char.charCodeAt();
counter+=charCode>=256?2:1;
if(counter>number){
return false;
}else{
Builder.push();
}
});
return Builder.join();
},
each:function(param,fn){
var arr=this.toArray(param);
Kyf.each(arr,function(index,char){
return fn.call(this,index,char);
},this);
},
lTrim:function(param){
var reg=new RegExp('^\s+');
return param.replace(reg,'');
},
rTrim:function(param){
var reg=new RegExp('\s+$');
return param.replace(reg,'');
},
textPad:function(param,action,len,flag){
if(Kyf.isNumber(action)){
len=action;
action='l';
}
if(Kyf.isUndefined(flag))flag='0';
var fn=null;
switch(action){
case 'l':
case 'left':
fn=function(index){
param=flag+param;
};
break;
case 'r':
case 'right':
fn=function(){
param+=flag;
};
break;
}
Kyf.each(new Array(len-param.length),fn);
return param;
},
format:function(param){
var reg=new RegExp('{([\\d]+)}','g'),args=Kyf.toArray(arguments).slice(1);
return param.replace(reg,function(main,group){
return args[group]||'';
});
},
filterCss:function(param){
var reg=new RegExp('<[^>]+>','g');
return param.replace(reg,'');
},
toArray:function(param){
return param.split('');
},
toJson:function(param){
try{
return eval(this.format('({0})',param));
}catch(e){}
}
}
});
Kyf.define('Kyf.util.StringBuilder',{
initialize:function(str){
this.str=new String(str?str:'');
this.apply();
},
members:{
toString:function(){
return '[class Kyf.util.StringBuilder]';
},
apply:function(src){
var me=this;
Kyf.each(src||Kyf.util.String,function(name,fn){
me.constructor.prototype[name]=function(){
fn.apply(me,this.str,arguments);
};
});
},
value:function(){
return this.str;
},
append:function(){
var list=null,args=Kyf.toArray(arguments);
if(Kyf.browser.isIE){
list=new Array();
Kyf.each(args,function(i,s){
list.push(s);
});
return this.str+=list.join('');
}else{
list=new String();
Kyf.each(args,function(i,s){
list+=s;
});
return this.str+=list;
}
}
}
});
Kyf.define('Kyf.core.Template',{
initialize:function(html){
if(Kyf.isArray(html))html=html.join('');
var me=this,args=Kyf.toArray(arguments),buf=[];
if(args.length>1){
Kyf.each(args,function(i,v){
buf.push(v);
});
html=buf.join('');
}
me.html=html||'';
if(me.html!='')this.compile();
},
members:{
html:'',
re:new RegExp('\\{([\\w-]+)\\}','g'),
compiledFn:null,
toString:function(){
return '[class Kyf.core.Template]';
},
compile:function(){
var STRING=Kyf.util.String,
builder='',
fn=function(main,group){
var str='\'+(data["{0}"]||"")+\'';
return STRING.format(str,group);
};
if(!this.html)this.html='';
builder=STRING.format('this.compiledFn=function(data){if(!data)return null;return \'{0}\';}',this.html.replace(/\\/g,'\\\\').replace(/"/g,'\\\"').replace(/'/g,'\\\'').replace(/(\r\n|\n)/g,'\\n').replace(this.re,fn));
try{
eval(builder);
}catch(e){}
},
apply:function(data){
return this.compiledFn?this.compiledFn(data):
this.html.replace(this.re,function(main,group){
return data[group]||'';
});
}
}
});
Kyf.define('Kyf.xml.Element',{
initialize:function(nodes){
this.nodes=nodes||[];
},
members:{
get:function(index){
return this.nodes[index];
},
attr:function(name){
var attrList=[];
this.each(function(i,node){
attrList.push(node.getAttribute(name));
});
if(attrList.length==0)attrList='';
if(attrList.length==1)attrList=attrList[0];
return attrList;
},
val:function(){
var valList=[];
this.each(function(i,node){
var val=Kyf.browser.isIE?node.text:node.textContent;
valList.push(val);
});
if(valList.length==0)valList='';
if(valList.length==1)valList=valList[0];
return valList;
},
size:function(){
return this.nodes.length;
},
each:function(fn,nodes){
$.each(nodes||this.nodes,$.proxy(fn,this));
},
find:function(selector){
var nodeList=[],tempList=[],matches=null;
if(matches=((new RegExp('(\\w+)\\[([\\w+\\d\\-_]+)\\=(["\\w+\\d\\-_]+)\\]','i')).exec(selector))){
this.each(function(i,node){
$.each(node.getElementsByTagName(matches[1]),function(i,node){
tempList.push(node);
});
});
this.each(function(i,node){
if(node.getAttribute(matches[2])==matches[3]){
nodeList.push(node);
}
},tempList);
}else{
this.each(function(i,node){
if(node){
$.each(node.getElementsByTagName(selector),function(i,node){
nodeList.push(node);
});
}
});
}
return new Kyf.xml.Element(nodeList);
}
}
});
Kyf.define('Kyf.core.Element',{
initialize:function(selector){
if(!selector)selector=this.self.create();
this.el=$(selector);
this.copy();
},
statics:{
create:function(tag){
tag=tag||'div';
return $(document.createElement(tag));
}
},
members:{
copy:function(){
var me=this;
Kyf.each(this.el,function(k,v){
if(Kyf.isFunction(v))this[k]=function(){v.apply(me.el,arguments);};
this[k]=v;
},this);
}
}
});
Kyf.define('Kyf.dd.DD',{
extend:Kyf.util.Observable,
initialize:function(ops){
Kyf.apply(this,ops);
this.addEvents('beforeMouseDown','afterMouseDown','mouseMove','beforeMouseUp','afterMouseUp');
Kyf.dd.DD.superclass.initialize.call(this,ops);
this.initComponent();
},
members:{
handler:null,
el:null,
initComponent:function(){
this.handler=this.handler||this.el;
if(!this.handler)return;
this.el.css({'position':'absolute'});
this.handler.css({'cursor':'move'});
this.handler.bind('mousedown',Kyf.createDelegate(this.mouseDown,this));
},
mouseDown:function(e){
if(e.button>1)return;
this.fireEvent('beforeMouseDown',e);
this.handler.bind('mousemove',Kyf.createDelegate(this.mouseMove,this));
this.handler.bind('mouseup',Kyf.createDelegate(this.mouseUp,this));
this.setCapture();
this.currentXY=[parseInt(e.clientX),parseInt(e.clientY)];
this.fireEvent('afterMouseDown',e);
},
setCapture:function(){
var dom=this.handler.get(0);
if(dom.setCapture)
dom.setCapture();
else
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
},
releaseCapture:function(){
var dom=this.handler.get(0);
if(dom.releaseCapture)
dom.releaseCapture();
else
window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
},
mouseMove:function(e){
var XY=[parseInt(e.clientX),parseInt(e.clientY)],
compare=[XY[0]-this.currentXY[0],XY[1]-this.currentXY[1]],
offset=this.el.offset(),
p=[parseInt(offset.left),parseInt(offset.top)];
this.currentXY=XY;
this.el.css({
'left':p[0]+compare[0]+'px',
'top':p[1]+compare[1]+'px'
});
this.fireEvent('mouseMove',e);
},
mouseUp:function(e){
this.fireEvent('beforeMouseUp',e);
this.handler.unbind('mousemove');
this.handler.unbind('mouseup');
this.releaseCapture();
this.fireEvent('afterMouseUp',e);
}
}
});
Kyf.define('Kyf.dd.Sortable',{
extend:Kyf.dd.DD,
members:{
module:null,
columns:null,
siblings:new Kyf.data.ArrayList(),
initComponent:function(){
this.handler=this.handler||this.el;
if(!this.handler)return;
this.module=this.el;
this.handler.css({'cursor':'move'});
this.handler.unbind('mousedown').bind('mousedown',Kyf.createDelegate(this.mouseDown,this));
},
mouseDown:function(e){
if(e.button>1)return;
this.fireEvent('beforeMouseDown',e);
this.tempModule=this.createModule();
this.el=this.createTemp();
this.el.bind('mousemove',Kyf.createDelegate(this.mouseMove,this));
this.el.bind('mouseup',Kyf.createDelegate(this.mouseUp,this));
this.setCapture();
this.currentXY=[parseInt(e.clientX),parseInt(e.clientY)];
this.fireEvent('afterMouseDown',e);
},
mouseMove:function(e){
Kyf.dd.Sortable.superclass.mouseMove.call(this,e);
var result=this.getActiveModule(e);
if(result.current){
var width=result.current.width();
this.tempModule.css({'width':width});
switch(result.action){
case 'top':
result.current.before(this.tempModule);
break;
default:
result.current.after(this.tempModule);
}
}else if(!result.isActive){
var column=this.getActiveColumn(e);
if(column){
this.tempModule.css({'width':column.width()-2});
column.append(this.tempModule);
}
}
},
mouseUp:function(e){
this.fireEvent('beforeMouseUp',e);
this.el.unbind('mousemove');
this.el.unbind('mouseup');
this.tempModule.after(this.module);
this.releaseCapture();
this.remove();
this.fireEvent('afterMouseUp',e);
},
createTemp:function(){
var temp=new Kyf.core.Element(),
offset=this.module.offset(),
BODY=new Kyf.core.Element(document.body);
temp.css({
'position':'absolute',
'top':offset.top,
'left':offset.left,
'width':this.module.width(),
'opacity':.5
}).appendTo(BODY).append(this.module);
return temp;
},
remove:function(){
this.el.remove();
this.el=null;
this.tempModule.remove();
this.tempModule=null;
},
createModule:function(){
var module=new Kyf.core.Element();
module.css({
'width':this.module.width(),
'height':this.module.height(),
'border':'1px dashed red'
});
this.module.after(module);
return module;
},
getActiveModule:function(e){
var me=this,
current=null,
action=null,
isActive=false,
module=this.module,
offset=module.offset(),
region=[offset.left,offset.top,module.width()+offset.left,module.height()+offset.top];
e.clientY+=this.getScrollTop();
this.siblings.each(function(index,el){
if(el&&el.get(0)&&el.get(0)!=module.get(0)){
var _offset=el.offset(),
_region=[_offset.left,_offset.top,el.width()+_offset.left,el.height()+_offset.top],
maxBox=[module.width()+el.width(),module.height()+el.height()],
width1=Math.abs(_region[0]-region[2]),
height1=Math.abs(_region[1]-region[3]),
width2=Math.abs(_region[2]-region[0]),
height2=Math.abs(_region[3]-region[1]),
width3=Math.abs(_region[2]-region[0]),
height3=Math.abs(_region[1]-region[3]),
width4=Math.abs(_region[0]-region[2]),
height4=Math.abs(_region[3]-region[1]);
var width=Kyf.max(new Kyf.data.ArrayList([width1,width2,width3,width4])),
height=Kyf.max(new Kyf.data.ArrayList([height1,height2,height3,height4]));
var result=me.compare(e,_region,el,maxBox,width,height);
action=result.action;
current=result.current;
if(maxBox[0]>width&&maxBox[1]>height){
isActive=true;
}
return result.status;
}
});
return {current:current,action:action,isActive:isActive};
},
compare:function(e,_region,el,maxBox,width,height){
var action=null,current=null,status=true;
if(e.clientX<_region[2]&&e.clientX>_region[0]&&e.clientY>_region[1]&&e.clientY<_region[3]){
current=el;
if(e.clientY<(_region[1]+el.height()/2))
action='top';
else
action='bottom';
status=false;
}
return {action:action,current:current,status:status};
},
getScrollTop:function(){
var root=Kyf.getRoot();
return root.scrollTop;
},
getActiveColumn:function(e){
if(!this.columns)return;
var currentColumn=null;
this.columns.each(function(){
var el=new Kyf.core.Element(this),
offset=el.offset(),
region=[offset.left,offset.top,offset.left+el.width(),offset.top+el.height()];
if(e.clientX>region[0]&&e.clientX<region[2]&&e.clientY>region[1]&&e.clientY<region[3]){
currentColumn=el;
return false;
}
});
return currentColumn;
}
}
});
Kyf.define('Kyf.dd.SortFrame',{
extend:Kyf.dd.Sortable,
members:{
compare:function(e,_region,el,maxBox,width,height){
var action=null,current=null,status=true;
if(maxBox[0]>width&&maxBox[1]>height){
current=el;
if(e.clientY<(maxBox[1]/4*3))
action='top';
else
action='bottom';
status=false;
}
return {action:action,current:current,status:status};
}
}
});
Tip.js:
Kyf.define('Editor.tool.Tip',{
initialize:function(content){
this.el=$(document.createElement('div'));
this.content=$(document.createElement('div'));
this.el.css({'position':'absolute','display':'none','zIndex':'1000'});
var html=[
'<span class="spanL"></span>',
'<span class="spanR"></span>',
' <p></p>',
]
this.content.addClass("tishiBox");
this.content.html(html.join(''));
this.content.appendTo(this.el);
if(content)this.setContent(content);
},
members:{
show:function(control){
if(!this.display){
this.el.appendTo($(document.body));
}
this.el.show();
var p=$(control).offset(),
size=[this.el.width(),this.el.height()];
if($(control).width()>=50&&$(control).width()!==85){
this.el.css({
left:p.left+30,
top:p.top-size[1]-35
});
}else if($(control).width()<50){
this.el.css({
left:p.left-this.content.width()/2+$(control).width()/2+17,
top:p.top-size[1]-35
});
}else{
this.el.css({
left:p.left-this.content.width()/2+$(control).width()/2,
top:(p.top-$(control).height())-size[1]-11
});
}
},
hide:function(){
this.el.hide();
},
setContent:function(content){
this.content.find("p").html(content);
}
}
});
图片: