📄 prototype-bridge.js
字号:
Ext.lib.Ajax = function(){ var createSuccess = function(cb){ return cb.success ? function(xhr){ cb.success.call(cb.scope||window, { responseText: xhr.responseText, responseXML : xhr.responseXML, argument: cb.argument }); } : Ext.emptyFn; }; var createFailure = function(cb){ return cb.failure ? function(xhr){ cb.failure.call(cb.scope||window, { responseText: xhr.responseText, responseXML : xhr.responseXML, argument: cb.argument }); } : Ext.emptyFn; }; return { request : function(method, uri, cb, data, options){ var o = { method: method, parameters: data || '', timeout: cb.timeout, onSuccess: createSuccess(cb), onFailure: createFailure(cb) }; if(options){ if(options.headers){ o.requestHeaders = options.headers; } if(options.xmlData){ method = 'POST'; o.contentType = 'text/xml'; o.postBody = options.xmlData; delete o.parameters; } if(options.jsonData){ method = 'POST'; o.contentType = 'text/javascript'; o.postBody = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData; delete o.parameters; } } new Ajax.Request(uri, o); }, formRequest : function(form, uri, cb, data, isUpload, sslUri){ new Ajax.Request(uri, { method: Ext.getDom(form).method ||'POST', parameters: Form.serialize(form)+(data?'&'+data:''), timeout: cb.timeout, onSuccess: createSuccess(cb), onFailure: createFailure(cb) }); }, isCallInProgress : function(trans){ return false; }, abort : function(trans){ return false; }, serializeForm : function(form){ return Form.serialize(form.dom||form); } };}();Ext.lib.Anim = function(){ var easings = { easeOut: function(pos) { return 1-Math.pow(1-pos,2); }, easeIn: function(pos) { return 1-Math.pow(1-pos,2); } }; var createAnim = function(cb, scope){ return { stop : function(skipToLast){ this.effect.cancel(); }, isAnimated : function(){ return this.effect.state == 'running'; }, proxyCallback : function(){ Ext.callback(cb, scope); } }; }; return { scroll : function(el, args, duration, easing, cb, scope){ // not supported so scroll immediately? var anim = createAnim(cb, scope); el = Ext.getDom(el); if(typeof args.scroll.to[0] == 'number'){ el.scrollLeft = args.scroll.to[0]; } if(typeof args.scroll.to[1] == 'number'){ el.scrollTop = args.scroll.to[1]; } anim.proxyCallback(); return anim; }, motion : function(el, args, duration, easing, cb, scope){ return this.run(el, args, duration, easing, cb, scope); }, color : function(el, args, duration, easing, cb, scope){ return this.run(el, args, duration, easing, cb, scope); }, run : function(el, args, duration, easing, cb, scope, type){ var o = {}; for(var k in args){ switch(k){ // scriptaculous doesn't support, so convert these case 'points': var by, pts, e = Ext.fly(el, '_animrun'); e.position(); if(by = args.points.by){ var xy = e.getXY(); pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]); }else{ pts = e.translatePoints(args.points.to); } o.left = pts.left+'px'; o.top = pts.top+'px'; break; case 'width': o.width = args.width.to+'px'; break; case 'height': o.height = args.height.to+'px'; break; case 'opacity': o.opacity = String(args.opacity.to); break; default: o[k] = String(args[k].to); break; } } var anim = createAnim(cb, scope); anim.effect = new Effect.Morph(Ext.id(el), { duration: duration, afterFinish: anim.proxyCallback, transition: easings[easing] || Effect.Transitions.linear, style: o }); return anim; } };}();// all lib flyweight calls use their own flyweight to prevent collisions with developer flyweightsfunction fly(el){ if(!libFlyweight){ libFlyweight = new Ext.Element.Flyweight(); } libFlyweight.dom = el; return libFlyweight;} Ext.lib.Region = function(t, r, b, l) { this.top = t; this[1] = t; this.right = r; this.bottom = b; this.left = l; this[0] = l;};Ext.lib.Region.prototype = { contains : function(region) { return ( region.left >= this.left && region.right <= this.right && region.top >= this.top && region.bottom <= this.bottom ); }, getArea : function() { return ( (this.bottom - this.top) * (this.right - this.left) ); }, intersect : function(region) { var t = Math.max( this.top, region.top ); var r = Math.min( this.right, region.right ); var b = Math.min( this.bottom, region.bottom ); var l = Math.max( this.left, region.left ); if (b >= t && r >= l) { return new Ext.lib.Region(t, r, b, l); } else { return null; } }, union : function(region) { var t = Math.min( this.top, region.top ); var r = Math.max( this.right, region.right ); var b = Math.max( this.bottom, region.bottom ); var l = Math.min( this.left, region.left ); return new Ext.lib.Region(t, r, b, l); }, constrainTo : function(r) { this.top = this.top.constrain(r.top, r.bottom); this.bottom = this.bottom.constrain(r.top, r.bottom); this.left = this.left.constrain(r.left, r.right); this.right = this.right.constrain(r.left, r.right); return this; }, adjust : function(t, l, b, r){ this.top += t; this.left += l; this.right += r; this.bottom += b; return this; }};Ext.lib.Region.getRegion = function(el) { var p = Ext.lib.Dom.getXY(el); var t = p[1]; var r = p[0] + el.offsetWidth; var b = p[1] + el.offsetHeight; var l = p[0]; return new Ext.lib.Region(t, r, b, l);};Ext.lib.Point = function(x, y) { if (x instanceof Array) { y = x[1]; x = x[0]; } this.x = this.right = this.left = this[0] = x; this.y = this.top = this.bottom = this[1] = y;};Ext.lib.Point.prototype = new Ext.lib.Region();// prevent IE leaksif(Ext.isIE) { function fnCleanUp() { var p = Function.prototype; delete p.createSequence; delete p.defer; delete p.createDelegate; delete p.createCallback; delete p.createInterceptor; window.detachEvent("onunload", fnCleanUp); } window.attachEvent("onunload", fnCleanUp);}})();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -