⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grid_format.js

📁 OA.....其他人不需帐号就可自由下载此源码其他人不需帐号就可自由下载此源码
💻 JS
📖 第 1 页 / 共 5 页
字号:
var target=obj;
for(i=1;i<parts.length;i++)
{
    target=target.getContent(parts[i])
}
if(window.HTMLElement)
{
    window.event=event
}
target[type].call(obj,event);
if(window.HTMLElement)
{
    window.event=null
}
return
};
var mouseover=function(element,name)
{
try
{
    element.className+=" "+name
}
catch(error)
{
}
};
var mouseout=function(element,name)
{
try
{
    element.className=element.className.replace(RegExp(" "+name,"g"),"")
}
catch(error)
{
}
};
Active.System.Template=Active.System.HTML.subclass();
Active.System.Template.create=function()
{
var obj=this.prototype;
var _super=this.superclass.prototype;
var _pattern=/^(\w+)\W(.+)$/;
var join=function()
{
    var i,s=arguments[0];
    for(i=1;i<arguments.length;i++)
    {
        s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1)
    }
    return s
};
obj.getProperty=function(name,a,b,c)
{
    if(name.match(_pattern))
    {
        var getProperty=join("get",RegExp.$1,"property");
        if(this[getProperty])
        {
            return this[getProperty](RegExp.$2,a,b,c)
        }
    }
};
obj.setProperty=function(name,value,a,b,c)
{
    if(name.match(_pattern))
    {
        var setProperty=join("set",RegExp.$1,"property");
        if(this[setProperty])
        {
            return this[setProperty](RegExp.$2,value,a,b,c)
        }
    }
};
obj.getModel=function(name)
{
    var getModel=join("get",name,"model");
    return this[getModel]()
};
obj.setModel=function(name,model)
{
    var setModel=join("set",name,"model");
    return this[setModel](model)
};
obj.defineTemplate=function(name,template)
{
    var ref="_"+name+"Template";
    var get=join("get",name,"template");
    var set=join("set",name,"template");
    var getDefault=join("default",name,"template");
    var name1="."+name;
    var name2="."+name+":";
    this[get]=this[getDefault]=function(index)
    {
        if(typeof(this[ref])=="function")
        {
            return this[ref].call(this,index)
        }
        if(this[ref].$owner !=this)
        {
            this[set](this[ref].clone())
        }
        if(typeof(index)=="undefined")
        {
            this[ref]._id=this._id+name1
        }
        else
        {
            this[ref]._id=this._id+name2+index
        }
        this[ref].$index=index;
        return this[ref]
    };
    obj[get]=function(a,b,c)
    {
        return this.$owner[get](a,b,c)
    };
    obj[set]=function(template)
    {
        this[ref]=template;
        if(template)
        {
            template.$owner=this
        }
    };
    this[set](template)
};
obj.getTemplate=function(name)
{
    if(name.match(_pattern))
    {
        var get=join("get",RegExp.$1,"template");
        arguments[0]=RegExp.$2;
        var template=this[get]();
        return template.getTemplate.apply(template,arguments)
    }
    else
    {
        get=join("get",name,"template");
        var i,args=[];
        for(i=1;i<arguments.length;i++)
        {
            args[i-1]=arguments[i]
        }
        return this[get].apply(this,args)
    }
};
obj.setTemplate=function(name,template,index)
{
    if(name.match(_pattern))
    {
        var get=join("get",RegExp.$1,"template");
        var n=RegExp.$2;
        this[get]().setTemplate(n,template,index)
    }
    else
    {
        var set=join("set",name,"template");
        this[set](template,index)
    }
};
obj.getAction=function(name)
{
    return this["_"+name+"Action"]
};
obj.setAction=function(name,value)
{
    this["_"+name+"Action"]=value
};
obj.action=function(name,source,a,b,c)
{
    if(typeof source=="undefined")
    {
        source=this
    }
    var action=this["_"+name+"Action"];
    if(typeof(action)=="function")
    {
        action.call(this,source,a,b,c)
    }
    else if(this.$owner)
    {
        this.$owner.action(name,source,a,b,c)
    }
}
};
Active.System.Template.create();
Active.System.Control=Active.System.Template.subclass();
Active.System.Control.create=function()
{
var obj=this.prototype;
var _super=this.superclass.prototype;
var _pattern=/^(\w+)\W(.+)$/;
var join=function()
{
    var i,s=arguments[0];
    for(i=1;i<arguments.length;i++)
    {
        s+=arguments[i].substr(0,1).toUpperCase()+arguments[i].substr(1)
    }
    return s
};
obj.setEvent("oncontextmenu","return false");
obj.setEvent("onselectstart","return false");
obj.defineModel=function(name)
{
    var external="_"+name+"Model";
    var defineProperty=join("define",name,"property");
    var definePropertyArray=join("define",name,"property","array");
    var getProperty=join("get",name,"property");
    var setProperty=join("set",name,"property");
    var get=
    {
    };
    var set=
    {
    };
    var getModel=join("get",name,"model");
    var setModel=join("set",name,"model");
    var updateModel=join("update",name,"model");
    this[defineProperty]=function(property,defaultValue)
    {
        var _getProperty=join("get",name,property);
        var _setProperty=join("set",name,property);
        var _property="_"+join(name,property);
        var getPropertyMethod=function()
        {
            return this[_property]
        };
        this[_getProperty]=getPropertyMethod;
        this[_setProperty]=function(value)
        {
            if(typeof value=="function")
            {
                this[_getProperty]=value
            }
            else
            {
                if(this[_getProperty] !==getPropertyMethod)
                {
                    this[_getProperty]=getPropertyMethod
                }
                this[_property]=value
            }
            this[updateModel](property)
        };
        this[_setProperty](defaultValue)
    };
    this[getProperty]=function(property,a,b,c)
    {
        try
        {
            if(this[external])
            {
                return this[external].getProperty(property,a,b,c)
            }
            if(!get[property])
            {
                get[property]=join("get",name,property)
            }
            return this[get[property]](a,b,c)
        }
        catch(error)
        {
            return this.handle(error)
        }
    };
    this[setProperty]=function(property,value,a,b,c)
    {
        try
        {
            if(this[external])
            {
                return this[external].setProperty(property,value,a,b,c)
            }
            if(!set[property])
            {
                set[property]=join("set",name,property)
            }
            return this[set[property]](value,a,b,c)
        }
        catch(error)
        {
            return this.handle(error)
        }
    };
    _super[getProperty]=function(property,a,b,c)
    {
        if(this[external])
        {
            return this[external].getProperty(property,a,b,c)
        }
        return this.$owner[getProperty](property,a,b,c)
    };
    _super[setProperty]=function(property,value,a,b,c)
    {
        if(this[external])
        {
            return this[external].setProperty(property,value,a,b,c)
        }
        return this.$owner[setProperty](property,value,a,b,c)
    };
    this[definePropertyArray]=function(property,defaultValue)
    {
        var _getProperty=join("get",name,property);
        var _setProperty=join("set",name,property);
        var _getArray=join("get",name,property+"s");
        var _setArray=join("set",name,property+"s");
        var _array="_"+join(name,property+"s");
        var _getCount=join("get",name,"count");
        var _setCount=join("set",name,"count");
        var getArrayElement=function(index)
        {
            return this[_array][index]
        };
        var getStaticElement=function()
        {
            return this[_array]
        };
        var getArray=function()
        {
            return this[_array].concat()
        };
        var getTempArray=function()
        {
            var i,a=[],max=this[_getCount]();
            for(i=0;i<max;i++)
            {
                a[i]=this[_getProperty](i)
            }
            return a
        };
        this[_setProperty]=function(value,index)
        {
            if(typeof value=="function")
            {
                this[_getProperty]=value;
                this[_getArray]=getTempArray
            }
            else if(arguments.length==1)
            {
                this[_array]=value;
                this[_getProperty]=getStaticElement;
                this[_getArray]=getTempArray
            }
            else
            {
                if(this[_getArray] !=getArray)
                {
                    this[_array]=this[_getArray]()
                }
                this[_array][index]=value;
                this[_getProperty]=getArrayElement;
                this[_getArray]=getArray
            }
            this[updateModel](property)
        };
        this[_setArray]=function(value)
        {
            if(typeof value=="function")
            {
                this[_getArray]=value
            }
            else
            {
                this[_array]=value.concat();
                this[_getProperty]=getArrayElement;
                this[_getArray]=getArray;
                this[_setCount](value.length)
            }
            this[updateModel](property)
        };
        this[_setProperty](defaultValue)
    };
    var proxyPrototype=new Active.System.Model;
    proxyPrototype.getProperty=function(property,a,b,c)
    {
        return this._target[getProperty](property,a,b,c)
    };
    proxyPrototype.setProperty=function(property,value,a,b,c)
    {
        return this._target[setProperty](property,value,a,b,c)
    };
    var proxy=join("_",name,"proxy");
    this[getModel]=function()
    {
        if(this[external])
        {
            return this[external]
        }
        if(!this[proxy])
        {
            this[proxy]=proxyPrototype.clone();
            this[proxy]._target=this;
            this[proxy].$owner=this.$owner
        }
        return this[proxy]
    };
    _super[setModel]=function(model)
    {
        this[external]=model;
        if(model && !model.$owner)
        {
            model.$owner=this
        }
    };
    _super[getModel]=function(a,b,c)
    {
        if(this[external])
        {
            return this[external]
        }
        return this.$owner[getModel](a,b,c)
    };
    this[updateModel]=function()
    {
    }
};
obj.defineProperty=function(name,defaultValue)
{
    if(name.match(_pattern))
    {
        var defineProperty=join("define",RegExp.$1,"property");
        if(this[defineProperty])
        {
            return this[defineProperty](RegExp.$2,defaultValue)
        }
    }
};
obj.definePropertyArray=function(name,defaultValue)
{
    if(name.match(_pattern))
    {
        var defineArray=join("define",RegExp.$1,"property","array");
        if(this[defineArray])
        {
            return this[defineArray](RegExp.$2,defaultValue)
        }
    }
}
};
Active.System.Control.create();
Active.Formats.String=Active.System.Format.subclass();
Active.Formats.String.create=function()
{
var obj=this.prototype;
obj.dataToValue=function(data)
{
    return data.toUpperCase()
};
obj.dataToText=function(data)
{
    return data
}
};
Active.Formats.String.create();
Active.Formats.Number=Active.System.Format.subclass();
Active.Formats.Number.create=function()
{
var obj=this.prototype;
obj.dataToValue=function(data)
{
    return Number(data)
};
var noFormat=function(value)
{
    return ""+value
};
var doFormat=function(value)
{
    var multiplier=this._multiplier;
    var abs=(value<0)?-value:value;
    var delta=(value<0)?-0.5:+0.5;
    var rounded=(Math.round(value * multiplier)+delta)/multiplier+"";
    if(abs<1000)
    {
        return rounded.replace(this.p1,this.r1)
    }
    if(abs<1000000)
    {
        return rounded.replace(this.p2,this.r2)
    }
    if(abs<1000000000)
    {
        return rounded.replace(this.p3,this.r3)
    }
    return rounded.replace(this.p4,this.r4)
};
obj.setTextFormat=function(format)
{
    var pattern=/^([^0#]*)([0#]*)([ .,]?)([0#]|[0#]{ 3 })([.,])([0#]*)([^0#]*)$/;
    var f=format.match(pattern);
    if(!f)
    {
        this.valueToText=noFormat;
        return
    }
    this.valueToText=doFormat;
    var rs=f[1];
    var rg=f[3];
    var rd=f[5];
    var re=f[7];
    var decimals=f[6].length;
    this._multiplier=Math.pow(10,decimals);
    var ps="^(-?\\d+)",pm="(\\d{3})",pe="\\.(\\d{"+decimals+"})\\d$";
    this.p1=new RegExp(ps+pe);
    this.p2=new RegExp(ps+pm+pe);
    this.p3=new RegExp(ps+pm+pm+pe);
    this.p4=new RegExp(ps+pm+pm+pm+pe);
    this.r1=rs+"$1"+rd+"$2"+re;
    this.r2=rs+"$1"+rg+"$2"+rd+"$3"+re;
    this.r3=rs+"$1"+rg+"$2"+rg+"$3"+rd+"$4"+re;
    this.r4=rs+"$1"+rg+"$2"+rg+"$3"+rg+"$4"+rd+"$5"+re
};
obj.setTextFormat("#.##")
};
Active.Formats.Number.create();
Active.Formats.Date=Active.System.Format.subclass();
Active.Formats.Date.create=function()
{
var obj=this.prototype;
obj.date=new Date();
obj.digits=[];
obj.shortMonths=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
obj.longMonths=["January","February","March","April","May","June","July","August","September","October","November","December"];
obj.shortWeekdays=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
obj.longWeekdays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
for(var i=0;i<100;i++)
{
    obj.digits[i]=i<10?"0"+i:""+i
}
var tokens=
{
    "hh":"this.digits[this.date.getUTCHours()]",":mm":"':'+this.digits[this.date.getUTCMinutes()]","mm:":"this.digits[this.date.getUTCMinutes()]+':'","ss":"this.digits[this.date.getUTCSeconds()]","dddd":"this.longWeekdays[this.date.getUTCDay()]","ddd":"this.shortWeekdays[this.date.getUTCDay()]","dd":"this.digits[this.date.getUTCDate()]","d":"this.date.getUTCDate()","mmmm":"this.longMonths[this.date.getUTCMonth()]","mmm":"this.shortMonths[this.date.getUTCMonth()]","mm":"this.digits[this.date.getUTCMonth()+1]","m":"(this.date.getUTCMonth()+1)","yyyy":"this.date.getUTCFullYear()","yy":"this.digits[this.date.getUTCFullYear()%100]"
};
var match="";
for(i in tokens)
{
    if(typeof(i)=="string")
    {
        match+="|"+i
    }
}
var re=new RegExp(match.replace("|","(")+")","gi");
obj.setTextFormat=function(format)
{
    format=format.replace(re,function(i)
    {
        return "'+"+tokens[i.toLowerCase()]+"+'"
    }
    );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -