[619] | 1 | /* |
---|
| 2 | * Ext JS Library 2.2.1 |
---|
| 3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
| 4 | * licensing@extjs.com |
---|
| 5 | * |
---|
| 6 | * http://extjs.com/license |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | if(typeof YAHOO == "undefined"){ |
---|
| 10 | throw "Unable to load Ext, core YUI utilities (yahoo, dom, event) not found."; |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | (function(){ |
---|
| 14 | var E = YAHOO.util.Event; |
---|
| 15 | var D = YAHOO.util.Dom; |
---|
| 16 | var CN = YAHOO.util.Connect; |
---|
| 17 | |
---|
| 18 | var ES = YAHOO.util.Easing; |
---|
| 19 | var A = YAHOO.util.Anim; |
---|
| 20 | var libFlyweight; |
---|
| 21 | |
---|
| 22 | Ext.lib.Dom = { |
---|
| 23 | getViewWidth : function(full){ |
---|
| 24 | return full ? D.getDocumentWidth() : D.getViewportWidth(); |
---|
| 25 | }, |
---|
| 26 | |
---|
| 27 | getViewHeight : function(full){ |
---|
| 28 | return full ? D.getDocumentHeight() : D.getViewportHeight(); |
---|
| 29 | }, |
---|
| 30 | |
---|
| 31 | isAncestor : function(haystack, needle){ |
---|
| 32 | return D.isAncestor(haystack, needle); |
---|
| 33 | }, |
---|
| 34 | |
---|
| 35 | getRegion : function(el){ |
---|
| 36 | return D.getRegion(el); |
---|
| 37 | }, |
---|
| 38 | |
---|
| 39 | getY : function(el){ |
---|
| 40 | return this.getXY(el)[1]; |
---|
| 41 | }, |
---|
| 42 | |
---|
| 43 | getX : function(el){ |
---|
| 44 | return this.getXY(el)[0]; |
---|
| 45 | }, |
---|
| 46 | |
---|
| 47 | // original version based on YahooUI getXY |
---|
| 48 | // this version fixes several issues in Safari and FF |
---|
| 49 | // and boosts performance by removing the batch overhead, repetitive dom lookups and array index calls |
---|
| 50 | getXY : function(el){ |
---|
| 51 | var p, pe, b, scroll, bd = (document.body || document.documentElement); |
---|
| 52 | el = Ext.getDom(el); |
---|
| 53 | |
---|
| 54 | if(el == bd){ |
---|
| 55 | return [0, 0]; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | if (el.getBoundingClientRect) { |
---|
| 59 | b = el.getBoundingClientRect(); |
---|
| 60 | scroll = fly(document).getScroll(); |
---|
| 61 | return [b.left + scroll.left, b.top + scroll.top]; |
---|
| 62 | } |
---|
| 63 | var x = 0, y = 0; |
---|
| 64 | |
---|
| 65 | p = el; |
---|
| 66 | |
---|
| 67 | var hasAbsolute = fly(el).getStyle("position") == "absolute"; |
---|
| 68 | |
---|
| 69 | while (p) { |
---|
| 70 | |
---|
| 71 | x += p.offsetLeft; |
---|
| 72 | y += p.offsetTop; |
---|
| 73 | |
---|
| 74 | if (!hasAbsolute && fly(p).getStyle("position") == "absolute") { |
---|
| 75 | hasAbsolute = true; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | if (Ext.isGecko) { |
---|
| 79 | pe = fly(p); |
---|
| 80 | |
---|
| 81 | var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0; |
---|
| 82 | var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0; |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | x += bl; |
---|
| 86 | y += bt; |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | if (p != el && pe.getStyle('overflow') != 'visible') { |
---|
| 90 | x += bl; |
---|
| 91 | y += bt; |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | p = p.offsetParent; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | if (Ext.isSafari && hasAbsolute) { |
---|
| 98 | x -= bd.offsetLeft; |
---|
| 99 | y -= bd.offsetTop; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | if (Ext.isGecko && !hasAbsolute) { |
---|
| 103 | var dbd = fly(bd); |
---|
| 104 | x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0; |
---|
| 105 | y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | p = el.parentNode; |
---|
| 109 | while (p && p != bd) { |
---|
| 110 | if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) { |
---|
| 111 | x -= p.scrollLeft; |
---|
| 112 | y -= p.scrollTop; |
---|
| 113 | } |
---|
| 114 | p = p.parentNode; |
---|
| 115 | } |
---|
| 116 | return [x, y]; |
---|
| 117 | }, |
---|
| 118 | |
---|
| 119 | setXY : function(el, xy){ |
---|
| 120 | el = Ext.fly(el, '_setXY'); |
---|
| 121 | el.position(); |
---|
| 122 | var pts = el.translatePoints(xy); |
---|
| 123 | if(xy[0] !== false){ |
---|
| 124 | el.dom.style.left = pts.left + "px"; |
---|
| 125 | } |
---|
| 126 | if(xy[1] !== false){ |
---|
| 127 | el.dom.style.top = pts.top + "px"; |
---|
| 128 | } |
---|
| 129 | }, |
---|
| 130 | |
---|
| 131 | setX : function(el, x){ |
---|
| 132 | this.setXY(el, [x, false]); |
---|
| 133 | }, |
---|
| 134 | |
---|
| 135 | setY : function(el, y){ |
---|
| 136 | this.setXY(el, [false, y]); |
---|
| 137 | } |
---|
| 138 | }; |
---|
| 139 | |
---|
| 140 | Ext.lib.Event = { |
---|
| 141 | getPageX : function(e){ |
---|
| 142 | return E.getPageX(e.browserEvent || e); |
---|
| 143 | }, |
---|
| 144 | |
---|
| 145 | getPageY : function(e){ |
---|
| 146 | return E.getPageY(e.browserEvent || e); |
---|
| 147 | }, |
---|
| 148 | |
---|
| 149 | getXY : function(e){ |
---|
| 150 | return E.getXY(e.browserEvent || e); |
---|
| 151 | }, |
---|
| 152 | |
---|
| 153 | getTarget : function(e){ |
---|
| 154 | return E.getTarget(e.browserEvent || e); |
---|
| 155 | }, |
---|
| 156 | |
---|
| 157 | getRelatedTarget : function(e){ |
---|
| 158 | return E.getRelatedTarget(e.browserEvent || e); |
---|
| 159 | }, |
---|
| 160 | |
---|
| 161 | on : function(el, eventName, fn, scope, override){ |
---|
| 162 | E.on(el, eventName, fn, scope, override); |
---|
| 163 | }, |
---|
| 164 | |
---|
| 165 | un : function(el, eventName, fn){ |
---|
| 166 | E.removeListener(el, eventName, fn); |
---|
| 167 | }, |
---|
| 168 | |
---|
| 169 | purgeElement : function(el){ |
---|
| 170 | E.purgeElement(el); |
---|
| 171 | }, |
---|
| 172 | |
---|
| 173 | preventDefault : function(e){ |
---|
| 174 | E.preventDefault(e.browserEvent || e); |
---|
| 175 | }, |
---|
| 176 | |
---|
| 177 | stopPropagation : function(e){ |
---|
| 178 | E.stopPropagation(e.browserEvent || e); |
---|
| 179 | }, |
---|
| 180 | |
---|
| 181 | stopEvent : function(e){ |
---|
| 182 | E.stopEvent(e.browserEvent || e); |
---|
| 183 | }, |
---|
| 184 | |
---|
| 185 | onAvailable : function(el, fn, scope, override){ |
---|
| 186 | return E.onAvailable(el, fn, scope, override); |
---|
| 187 | } |
---|
| 188 | }; |
---|
| 189 | |
---|
| 190 | Ext.lib.Ajax = { |
---|
| 191 | request : function(method, uri, cb, data, options){ |
---|
| 192 | if(options){ |
---|
| 193 | var hs = options.headers; |
---|
| 194 | if(hs){ |
---|
| 195 | for(var h in hs){ |
---|
| 196 | if(hs.hasOwnProperty(h)){ |
---|
| 197 | CN.initHeader(h, hs[h], false); |
---|
| 198 | } |
---|
| 199 | } |
---|
| 200 | } |
---|
| 201 | if(options.xmlData){ |
---|
| 202 | if (!hs || !hs['Content-Type']){ |
---|
| 203 | CN.initHeader('Content-Type', 'text/xml', false); |
---|
| 204 | } |
---|
| 205 | method = (method ? method : (options.method ? options.method : 'POST')); |
---|
| 206 | data = options.xmlData; |
---|
| 207 | }else if(options.jsonData){ |
---|
| 208 | if (!hs || !hs['Content-Type']){ |
---|
| 209 | CN.initHeader('Content-Type', 'application/json', false); |
---|
| 210 | } |
---|
| 211 | method = (method ? method : (options.method ? options.method : 'POST')); |
---|
| 212 | data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData; |
---|
| 213 | } |
---|
| 214 | } |
---|
| 215 | return CN.asyncRequest(method, uri, cb, data); |
---|
| 216 | }, |
---|
| 217 | |
---|
| 218 | formRequest : function(form, uri, cb, data, isUpload, sslUri){ |
---|
| 219 | CN.setForm(form, isUpload, sslUri); |
---|
| 220 | return CN.asyncRequest(Ext.getDom(form).method ||'POST', uri, cb, data); |
---|
| 221 | }, |
---|
| 222 | |
---|
| 223 | isCallInProgress : function(trans){ |
---|
| 224 | return CN.isCallInProgress(trans); |
---|
| 225 | }, |
---|
| 226 | |
---|
| 227 | abort : function(trans){ |
---|
| 228 | return CN.abort(trans); |
---|
| 229 | }, |
---|
| 230 | |
---|
| 231 | serializeForm : function(form){ |
---|
| 232 | var d = CN.setForm(form.dom || form); |
---|
| 233 | CN.resetFormState(); |
---|
| 234 | return d; |
---|
| 235 | } |
---|
| 236 | }; |
---|
| 237 | |
---|
| 238 | Ext.lib.Region = YAHOO.util.Region; |
---|
| 239 | Ext.lib.Point = YAHOO.util.Point; |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | Ext.lib.Anim = { |
---|
| 243 | scroll : function(el, args, duration, easing, cb, scope){ |
---|
| 244 | this.run(el, args, duration, easing, cb, scope, YAHOO.util.Scroll); |
---|
| 245 | }, |
---|
| 246 | |
---|
| 247 | motion : function(el, args, duration, easing, cb, scope){ |
---|
| 248 | this.run(el, args, duration, easing, cb, scope, YAHOO.util.Motion); |
---|
| 249 | }, |
---|
| 250 | |
---|
| 251 | color : function(el, args, duration, easing, cb, scope){ |
---|
| 252 | this.run(el, args, duration, easing, cb, scope, YAHOO.util.ColorAnim); |
---|
| 253 | }, |
---|
| 254 | |
---|
| 255 | run : function(el, args, duration, easing, cb, scope, type){ |
---|
| 256 | type = type || YAHOO.util.Anim; |
---|
| 257 | if(typeof easing == "string"){ |
---|
| 258 | easing = YAHOO.util.Easing[easing]; |
---|
| 259 | } |
---|
| 260 | var anim = new type(el, args, duration, easing); |
---|
| 261 | anim.animateX(function(){ |
---|
| 262 | Ext.callback(cb, scope); |
---|
| 263 | }); |
---|
| 264 | return anim; |
---|
| 265 | } |
---|
| 266 | }; |
---|
| 267 | |
---|
| 268 | // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights |
---|
| 269 | function fly(el){ |
---|
| 270 | if(!libFlyweight){ |
---|
| 271 | libFlyweight = new Ext.Element.Flyweight(); |
---|
| 272 | } |
---|
| 273 | libFlyweight.dom = el; |
---|
| 274 | return libFlyweight; |
---|
| 275 | } |
---|
| 276 | |
---|
| 277 | // prevent IE leaks |
---|
| 278 | if(Ext.isIE) { |
---|
| 279 | function fnCleanUp() { |
---|
| 280 | var p = Function.prototype; |
---|
| 281 | delete p.createSequence; |
---|
| 282 | delete p.defer; |
---|
| 283 | delete p.createDelegate; |
---|
| 284 | delete p.createCallback; |
---|
| 285 | delete p.createInterceptor; |
---|
| 286 | |
---|
| 287 | window.detachEvent("onunload", fnCleanUp); |
---|
| 288 | } |
---|
| 289 | window.attachEvent("onunload", fnCleanUp); |
---|
| 290 | } |
---|
| 291 | // various overrides |
---|
| 292 | |
---|
| 293 | // add ability for callbacks with animations |
---|
| 294 | if(YAHOO.util.Anim){ |
---|
| 295 | YAHOO.util.Anim.prototype.animateX = function(callback, scope){ |
---|
| 296 | var f = function(){ |
---|
| 297 | this.onComplete.unsubscribe(f); |
---|
| 298 | if(typeof callback == "function"){ |
---|
| 299 | callback.call(scope || this, this); |
---|
| 300 | } |
---|
| 301 | }; |
---|
| 302 | this.onComplete.subscribe(f, this, true); |
---|
| 303 | this.animate(); |
---|
| 304 | }; |
---|
| 305 | } |
---|
| 306 | |
---|
| 307 | if(YAHOO.util.DragDrop && Ext.dd.DragDrop){ |
---|
| 308 | YAHOO.util.DragDrop.defaultPadding = Ext.dd.DragDrop.defaultPadding; |
---|
| 309 | YAHOO.util.DragDrop.constrainTo = Ext.dd.DragDrop.constrainTo; |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | YAHOO.util.Dom.getXY = function(el) { |
---|
| 313 | var f = function(el) { |
---|
| 314 | return Ext.lib.Dom.getXY(el); |
---|
| 315 | }; |
---|
| 316 | return YAHOO.util.Dom.batch(el, f, YAHOO.util.Dom, true); |
---|
| 317 | }; |
---|
| 318 | |
---|
| 319 | |
---|
| 320 | // workaround for Safari anim duration speed problems |
---|
| 321 | if(YAHOO.util.AnimMgr){ |
---|
| 322 | YAHOO.util.AnimMgr.fps = 1000; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | YAHOO.util.Region.prototype.adjust = function(t, l, b, r){ |
---|
| 326 | this.top += t; |
---|
| 327 | this.left += l; |
---|
| 328 | this.right += r; |
---|
| 329 | this.bottom += b; |
---|
| 330 | return this; |
---|
| 331 | }; |
---|
| 332 | |
---|
| 333 | YAHOO.util.Region.prototype.constrainTo = function(r) { |
---|
| 334 | this.top = this.top.constrain(r.top, r.bottom); |
---|
| 335 | this.bottom = this.bottom.constrain(r.top, r.bottom); |
---|
| 336 | this.left = this.left.constrain(r.left, r.right); |
---|
| 337 | this.right = this.right.constrain(r.left, r.right); |
---|
| 338 | return this; |
---|
| 339 | }; |
---|
| 340 | |
---|
| 341 | |
---|
| 342 | })(); |
---|