295fdbcd1408f980c7feaa26eb5eda1b74d684fb.svn-base 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. (function() {
  7. var D = Ext.lib.Dom;
  8. var E = Ext.lib.Event;
  9. var A = Ext.lib.Anim;
  10. var propCache = {};
  11. var camelRe = /(-[a-z])/gi;
  12. var camelFn = function(m, a) {
  13. return a.charAt(1).toUpperCase()
  14. };
  15. var view = document.defaultView;
  16. Ext.Element = function(element, forceNew) {
  17. var dom = typeof element == "string"
  18. ? document.getElementById(element)
  19. : element;
  20. if (!dom) {
  21. return null
  22. }
  23. var id = dom.id;
  24. if (forceNew !== true && id && Ext.Element.cache[id]) {
  25. return Ext.Element.cache[id]
  26. }
  27. this.dom = dom;
  28. this.id = id || Ext.id(dom)
  29. };
  30. var El = Ext.Element;
  31. El.prototype = {
  32. originalDisplay : "",
  33. visibilityMode : 1,
  34. defaultUnit : "px",
  35. setVisibilityMode : function(visMode) {
  36. this.visibilityMode = visMode;
  37. return this
  38. },
  39. enableDisplayMode : function(display) {
  40. this.setVisibilityMode(El.DISPLAY);
  41. if (typeof display != "undefined") {
  42. this.originalDisplay = display
  43. }
  44. return this
  45. },
  46. findParent : function(simpleSelector, maxDepth, returnEl) {
  47. var p = this.dom, b = document.body, depth = 0, dq = Ext.DomQuery, stopEl;
  48. maxDepth = maxDepth || 50;
  49. if (typeof maxDepth != "number") {
  50. stopEl = Ext.getDom(maxDepth);
  51. maxDepth = 10
  52. }
  53. while (p && p.nodeType == 1 && depth < maxDepth && p != b
  54. && p != stopEl) {
  55. if (dq.is(p, simpleSelector)) {
  56. return returnEl ? Ext.get(p) : p
  57. }
  58. depth++;
  59. p = p.parentNode
  60. }
  61. return null
  62. },
  63. findParentNode : function(simpleSelector, maxDepth, returnEl) {
  64. var p = Ext.fly(this.dom.parentNode, "_internal");
  65. return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null
  66. },
  67. up : function(simpleSelector, maxDepth) {
  68. return this.findParentNode(simpleSelector, maxDepth, true)
  69. },
  70. is : function(simpleSelector) {
  71. return Ext.DomQuery.is(this.dom, simpleSelector)
  72. },
  73. animate : function(args, duration, onComplete, easing, animType) {
  74. this.anim(args, {
  75. duration : duration,
  76. callback : onComplete,
  77. easing : easing
  78. }, animType);
  79. return this
  80. },
  81. anim : function(args, opt, animType, defaultDur, defaultEase, cb) {
  82. animType = animType || "run";
  83. opt = opt || {};
  84. var anim = Ext.lib.Anim[animType](this.dom, args,
  85. (opt.duration || defaultDur) || 0.35,
  86. (opt.easing || defaultEase) || "easeOut", function() {
  87. Ext.callback(cb, this);
  88. Ext.callback(opt.callback, opt.scope || this, [this,
  89. opt])
  90. }, this);
  91. opt.anim = anim;
  92. return anim
  93. },
  94. preanim : function(a, i) {
  95. return !a[i] ? false : (typeof a[i] == "object" ? a[i] : {
  96. duration : a[i + 1],
  97. callback : a[i + 2],
  98. easing : a[i + 3]
  99. })
  100. },
  101. clean : function(forceReclean) {
  102. if (this.isCleaned && forceReclean !== true) {
  103. return this
  104. }
  105. var ns = /\S/;
  106. var d = this.dom, n = d.firstChild, ni = -1;
  107. while (n) {
  108. var nx = n.nextSibling;
  109. if (n.nodeType == 3 && !ns.test(n.nodeValue)) {
  110. d.removeChild(n)
  111. } else {
  112. n.nodeIndex = ++ni
  113. }
  114. n = nx
  115. }
  116. this.isCleaned = true;
  117. return this
  118. },
  119. scrollIntoView : function(container, hscroll) {
  120. var c = Ext.getDom(container) || Ext.getBody().dom;
  121. var el = this.dom;
  122. var o = this.getOffsetsTo(c), l = o[0] + c.scrollLeft, t = o[1]
  123. + c.scrollTop, b = t + el.offsetHeight, r = l
  124. + el.offsetWidth;
  125. var ch = c.clientHeight;
  126. var ct = parseInt(c.scrollTop, 10);
  127. var cl = parseInt(c.scrollLeft, 10);
  128. var cb = ct + ch;
  129. var cr = cl + c.clientWidth;
  130. if (el.offsetHeight > ch || t < ct) {
  131. c.scrollTop = t
  132. } else {
  133. if (b > cb) {
  134. c.scrollTop = b - ch
  135. }
  136. }
  137. c.scrollTop = c.scrollTop;
  138. if (hscroll !== false) {
  139. if (el.offsetWidth > c.clientWidth || l < cl) {
  140. c.scrollLeft = l
  141. } else {
  142. if (r > cr) {
  143. c.scrollLeft = r - c.clientWidth
  144. }
  145. }
  146. c.scrollLeft = c.scrollLeft
  147. }
  148. return this
  149. },
  150. scrollChildIntoView : function(child, hscroll) {
  151. Ext.fly(child, "_scrollChildIntoView")
  152. .scrollIntoView(this, hscroll)
  153. },
  154. autoHeight : function(animate, duration, onComplete, easing) {
  155. var oldHeight = this.getHeight();
  156. this.clip();
  157. this.setHeight(1);
  158. setTimeout(function() {
  159. var height = parseInt(this.dom.scrollHeight, 10);
  160. if (!animate) {
  161. this.setHeight(height);
  162. this.unclip();
  163. if (typeof onComplete == "function") {
  164. onComplete()
  165. }
  166. } else {
  167. this.setHeight(oldHeight);
  168. this.setHeight(height, animate, duration,
  169. function() {
  170. this.unclip();
  171. if (typeof onComplete == "function") {
  172. onComplete()
  173. }
  174. }.createDelegate(this), easing)
  175. }
  176. }.createDelegate(this), 0);
  177. return this
  178. },
  179. contains : function(el) {
  180. if (!el) {
  181. return false
  182. }
  183. return D.isAncestor(this.dom, el.dom ? el.dom : el)
  184. },
  185. isVisible : function(deep) {
  186. var vis = !(this.getStyle("visibility") == "hidden" || this
  187. .getStyle("display") == "none");
  188. if (deep !== true || !vis) {
  189. return vis
  190. }
  191. var p = this.dom.parentNode;
  192. while (p && p.tagName.toLowerCase() != "body") {
  193. if (!Ext.fly(p, "_isVisible").isVisible()) {
  194. return false
  195. }
  196. p = p.parentNode
  197. }
  198. return true
  199. },
  200. select : function(selector, unique) {
  201. return El.select(selector, unique, this.dom)
  202. },
  203. query : function(selector, unique) {
  204. return Ext.DomQuery.select(selector, this.dom)
  205. },
  206. child : function(selector, returnDom) {
  207. var n = Ext.DomQuery.selectNode(selector, this.dom);
  208. return returnDom ? n : Ext.get(n)
  209. },
  210. down : function(selector, returnDom) {
  211. var n = Ext.DomQuery.selectNode(" > " + selector, this.dom);
  212. return returnDom ? n : Ext.get(n)
  213. },
  214. initDD : function(group, config, overrides) {
  215. var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
  216. return Ext.apply(dd, overrides)
  217. },
  218. initDDProxy : function(group, config, overrides) {
  219. var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
  220. return Ext.apply(dd, overrides)
  221. },
  222. initDDTarget : function(group, config, overrides) {
  223. var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
  224. return Ext.apply(dd, overrides)
  225. },
  226. setVisible : function(visible, animate) {
  227. if (!animate || !A) {
  228. if (this.visibilityMode == El.DISPLAY) {
  229. this.setDisplayed(visible)
  230. } else {
  231. this.fixDisplay();
  232. this.dom.style.visibility = visible ? "visible" : "hidden"
  233. }
  234. } else {
  235. var dom = this.dom;
  236. var visMode = this.visibilityMode;
  237. if (visible) {
  238. this.setOpacity(0.01);
  239. this.setVisible(true)
  240. }
  241. this.anim({
  242. opacity : {
  243. to : (visible ? 1 : 0)
  244. }
  245. }, this.preanim(arguments, 1), null, 0.35, "easeIn",
  246. function() {
  247. if (!visible) {
  248. if (visMode == El.DISPLAY) {
  249. dom.style.display = "none"
  250. } else {
  251. dom.style.visibility = "hidden"
  252. }
  253. Ext.get(dom).setOpacity(1)
  254. }
  255. })
  256. }
  257. return this
  258. },
  259. isDisplayed : function() {
  260. return this.getStyle("display") != "none"
  261. },
  262. toggle : function(animate) {
  263. this.setVisible(!this.isVisible(), this.preanim(arguments, 0));
  264. return this
  265. },
  266. setDisplayed : function(value) {
  267. if (typeof value == "boolean") {
  268. value = value ? this.originalDisplay : "none"
  269. }
  270. this.setStyle("display", value);
  271. return this
  272. },
  273. focus : function() {
  274. try {
  275. this.dom.focus()
  276. } catch (e) {
  277. }
  278. return this
  279. },
  280. blur : function() {
  281. try {
  282. this.dom.blur()
  283. } catch (e) {
  284. }
  285. return this
  286. },
  287. addClass : function(className) {
  288. if (className instanceof Array) {
  289. for (var i = 0, len = className.length; i < len; i++) {
  290. this.addClass(className[i])
  291. }
  292. } else {
  293. if (className && !this.hasClass(className)) {
  294. this.dom.className = this.dom.className + " " + className
  295. }
  296. }
  297. return this
  298. },
  299. radioClass : function(className) {
  300. var siblings = this.dom.parentNode.childNodes;
  301. for (var i = 0; i < siblings.length; i++) {
  302. var s = siblings[i];
  303. if (s.nodeType == 1) {
  304. Ext.get(s).removeClass(className)
  305. }
  306. }
  307. this.addClass(className);
  308. return this
  309. },
  310. removeClass : function(className) {
  311. if (!className || !this.dom.className) {
  312. return this
  313. }
  314. if (className instanceof Array) {
  315. for (var i = 0, len = className.length; i < len; i++) {
  316. this.removeClass(className[i])
  317. }
  318. } else {
  319. if (this.hasClass(className)) {
  320. var re = this.classReCache[className];
  321. if (!re) {
  322. re = new RegExp(
  323. "(?:^|\\s+)" + className + "(?:\\s+|$)", "g");
  324. this.classReCache[className] = re
  325. }
  326. this.dom.className = this.dom.className.replace(re, " ")
  327. }
  328. }
  329. return this
  330. },
  331. classReCache : {},
  332. toggleClass : function(className) {
  333. if (this.hasClass(className)) {
  334. this.removeClass(className)
  335. } else {
  336. this.addClass(className)
  337. }
  338. return this
  339. },
  340. hasClass : function(className) {
  341. return className
  342. && (" " + this.dom.className + " ").indexOf(" " + className
  343. + " ") != -1
  344. },
  345. replaceClass : function(oldClassName, newClassName) {
  346. this.removeClass(oldClassName);
  347. this.addClass(newClassName);
  348. return this
  349. },
  350. getStyles : function() {
  351. var a = arguments, len = a.length, r = {};
  352. for (var i = 0; i < len; i++) {
  353. r[a[i]] = this.getStyle(a[i])
  354. }
  355. return r
  356. },
  357. getStyle : function() {
  358. return view && view.getComputedStyle ? function(prop) {
  359. var el = this.dom, v, cs, camel;
  360. if (prop == "float") {
  361. prop = "cssFloat"
  362. }
  363. if (v = el.style[prop]) {
  364. return v
  365. }
  366. if (cs = view.getComputedStyle(el, "")) {
  367. if (!(camel = propCache[prop])) {
  368. camel = propCache[prop] = prop
  369. .replace(camelRe, camelFn)
  370. }
  371. return cs[camel]
  372. }
  373. return null
  374. } : function(prop) {
  375. var el = this.dom, v, cs, camel;
  376. if (prop == "opacity") {
  377. if (typeof el.style.filter == "string") {
  378. var m = el.style.filter.match(/alpha\(opacity=(.*)\)/i);
  379. if (m) {
  380. var fv = parseFloat(m[1]);
  381. if (!isNaN(fv)) {
  382. return fv ? fv / 100 : 0
  383. }
  384. }
  385. }
  386. return 1
  387. } else {
  388. if (prop == "float") {
  389. prop = "styleFloat"
  390. }
  391. }
  392. if (!(camel = propCache[prop])) {
  393. camel = propCache[prop] = prop.replace(camelRe, camelFn)
  394. }
  395. if (v = el.style[camel]) {
  396. return v
  397. }
  398. if (cs = el.currentStyle) {
  399. return cs[camel]
  400. }
  401. return null
  402. }
  403. }(),
  404. setStyle : function(prop, value) {
  405. if (typeof prop == "string") {
  406. var camel;
  407. if (!(camel = propCache[prop])) {
  408. camel = propCache[prop] = prop.replace(camelRe, camelFn)
  409. }
  410. if (camel == "opacity") {
  411. this.setOpacity(value)
  412. } else {
  413. this.dom.style[camel] = value
  414. }
  415. } else {
  416. for (var style in prop) {
  417. if (typeof prop[style] != "function") {
  418. this.setStyle(style, prop[style])
  419. }
  420. }
  421. }
  422. return this
  423. },
  424. applyStyles : function(style) {
  425. Ext.DomHelper.applyStyles(this.dom, style);
  426. return this
  427. },
  428. getX : function() {
  429. return D.getX(this.dom)
  430. },
  431. getY : function() {
  432. return D.getY(this.dom)
  433. },
  434. getXY : function() {
  435. return D.getXY(this.dom)
  436. },
  437. getOffsetsTo : function(el) {
  438. var o = this.getXY();
  439. var e = Ext.fly(el, "_internal").getXY();
  440. return [o[0] - e[0], o[1] - e[1]]
  441. },
  442. setX : function(x, animate) {
  443. if (!animate || !A) {
  444. D.setX(this.dom, x)
  445. } else {
  446. this.setXY([x, this.getY()], this.preanim(arguments, 1))
  447. }
  448. return this
  449. },
  450. setY : function(y, animate) {
  451. if (!animate || !A) {
  452. D.setY(this.dom, y)
  453. } else {
  454. this.setXY([this.getX(), y], this.preanim(arguments, 1))
  455. }
  456. return this
  457. },
  458. setLeft : function(left) {
  459. this.setStyle("left", this.addUnits(left));
  460. return this
  461. },
  462. setTop : function(top) {
  463. this.setStyle("top", this.addUnits(top));
  464. return this
  465. },
  466. setRight : function(right) {
  467. this.setStyle("right", this.addUnits(right));
  468. return this
  469. },
  470. setBottom : function(bottom) {
  471. this.setStyle("bottom", this.addUnits(bottom));
  472. return this
  473. },
  474. setXY : function(pos, animate) {
  475. if (!animate || !A) {
  476. D.setXY(this.dom, pos)
  477. } else {
  478. this.anim({
  479. points : {
  480. to : pos
  481. }
  482. }, this.preanim(arguments, 1), "motion")
  483. }
  484. return this
  485. },
  486. setLocation : function(x, y, animate) {
  487. this.setXY([x, y], this.preanim(arguments, 2));
  488. return this
  489. },
  490. moveTo : function(x, y, animate) {
  491. this.setXY([x, y], this.preanim(arguments, 2));
  492. return this
  493. },
  494. getRegion : function() {
  495. return D.getRegion(this.dom)
  496. },
  497. getHeight : function(contentHeight) {
  498. var h = this.dom.offsetHeight || 0;
  499. h = contentHeight !== true ? h : h - this.getBorderWidth("tb")
  500. - this.getPadding("tb");
  501. return h < 0 ? 0 : h
  502. },
  503. getWidth : function(contentWidth) {
  504. var w = this.dom.offsetWidth || 0;
  505. w = contentWidth !== true ? w : w - this.getBorderWidth("lr")
  506. - this.getPadding("lr");
  507. return w < 0 ? 0 : w
  508. },
  509. getComputedHeight : function() {
  510. var h = Math.max(this.dom.offsetHeight, this.dom.clientHeight);
  511. if (!h) {
  512. h = parseInt(this.getStyle("height"), 10) || 0;
  513. if (!this.isBorderBox()) {
  514. h += this.getFrameWidth("tb")
  515. }
  516. }
  517. return h
  518. },
  519. getComputedWidth : function() {
  520. var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
  521. if (!w) {
  522. w = parseInt(this.getStyle("width"), 10) || 0;
  523. if (!this.isBorderBox()) {
  524. w += this.getFrameWidth("lr")
  525. }
  526. }
  527. return w
  528. },
  529. getSize : function(contentSize) {
  530. return {
  531. width : this.getWidth(contentSize),
  532. height : this.getHeight(contentSize)
  533. }
  534. },
  535. getStyleSize : function() {
  536. var w, h, d = this.dom, s = d.style;
  537. if (s.width && s.width != "auto") {
  538. w = parseInt(s.width, 10);
  539. if (Ext.isBorderBox) {
  540. w -= this.getFrameWidth("lr")
  541. }
  542. }
  543. if (s.height && s.height != "auto") {
  544. h = parseInt(s.height, 10);
  545. if (Ext.isBorderBox) {
  546. h -= this.getFrameWidth("tb")
  547. }
  548. }
  549. return {
  550. width : w || this.getWidth(true),
  551. height : h || this.getHeight(true)
  552. }
  553. },
  554. getViewSize : function() {
  555. var d = this.dom, doc = document, aw = 0, ah = 0;
  556. if (d == doc || d == doc.body) {
  557. return {
  558. width : D.getViewWidth(),
  559. height : D.getViewHeight()
  560. }
  561. } else {
  562. return {
  563. width : d.clientWidth,
  564. height : d.clientHeight
  565. }
  566. }
  567. },
  568. getValue : function(asNumber) {
  569. return asNumber ? parseInt(this.dom.value, 10) : this.dom.value
  570. },
  571. adjustWidth : function(width) {
  572. if (typeof width == "number") {
  573. if (this.autoBoxAdjust && !this.isBorderBox()) {
  574. width -= (this.getBorderWidth("lr") + this.getPadding("lr"))
  575. }
  576. if (width < 0) {
  577. width = 0
  578. }
  579. }
  580. return width
  581. },
  582. adjustHeight : function(height) {
  583. if (typeof height == "number") {
  584. if (this.autoBoxAdjust && !this.isBorderBox()) {
  585. height -= (this.getBorderWidth("tb") + this
  586. .getPadding("tb"))
  587. }
  588. if (height < 0) {
  589. height = 0
  590. }
  591. }
  592. return height
  593. },
  594. setWidth : function(width, animate) {
  595. width = this.adjustWidth(width);
  596. if (!animate || !A) {
  597. this.dom.style.width = this.addUnits(width)
  598. } else {
  599. this.anim({
  600. width : {
  601. to : width
  602. }
  603. }, this.preanim(arguments, 1))
  604. }
  605. return this
  606. },
  607. setHeight : function(height, animate) {
  608. height = this.adjustHeight(height);
  609. if (!animate || !A) {
  610. this.dom.style.height = this.addUnits(height)
  611. } else {
  612. this.anim({
  613. height : {
  614. to : height
  615. }
  616. }, this.preanim(arguments, 1))
  617. }
  618. return this
  619. },
  620. setSize : function(width, height, animate) {
  621. if (typeof width == "object") {
  622. height = width.height;
  623. width = width.width
  624. }
  625. width = this.adjustWidth(width);
  626. height = this.adjustHeight(height);
  627. if (!animate || !A) {
  628. this.dom.style.width = this.addUnits(width);
  629. this.dom.style.height = this.addUnits(height)
  630. } else {
  631. this.anim({
  632. width : {
  633. to : width
  634. },
  635. height : {
  636. to : height
  637. }
  638. }, this.preanim(arguments, 2))
  639. }
  640. return this
  641. },
  642. setBounds : function(x, y, width, height, animate) {
  643. if (!animate || !A) {
  644. this.setSize(width, height);
  645. this.setLocation(x, y)
  646. } else {
  647. width = this.adjustWidth(width);
  648. height = this.adjustHeight(height);
  649. this.anim({
  650. points : {
  651. to : [x, y]
  652. },
  653. width : {
  654. to : width
  655. },
  656. height : {
  657. to : height
  658. }
  659. }, this.preanim(arguments, 4), "motion")
  660. }
  661. return this
  662. },
  663. setRegion : function(region, animate) {
  664. this.setBounds(region.left, region.top, region.right - region.left,
  665. region.bottom - region.top, this.preanim(arguments, 1));
  666. return this
  667. },
  668. addListener : function(eventName, fn, scope, options) {
  669. Ext.EventManager
  670. .on(this.dom, eventName, fn, scope || this, options)
  671. },
  672. removeListener : function(eventName, fn) {
  673. Ext.EventManager.removeListener(this.dom, eventName, fn);
  674. return this
  675. },
  676. removeAllListeners : function() {
  677. E.purgeElement(this.dom);
  678. return this
  679. },
  680. relayEvent : function(eventName, observable) {
  681. this.on(eventName, function(e) {
  682. observable.fireEvent(eventName, e)
  683. })
  684. },
  685. setOpacity : function(opacity, animate) {
  686. if (!animate || !A) {
  687. var s = this.dom.style;
  688. if (Ext.isIE) {
  689. s.zoom = 1;
  690. s.filter = (s.filter || "")
  691. .replace(/alpha\([^\)]*\)/gi, "")
  692. + (opacity == 1 ? "" : " alpha(opacity=" + opacity
  693. * 100 + ")")
  694. } else {
  695. s.opacity = opacity
  696. }
  697. } else {
  698. this.anim({
  699. opacity : {
  700. to : opacity
  701. }
  702. }, this.preanim(arguments, 1), null, 0.35, "easeIn")
  703. }
  704. return this
  705. },
  706. getLeft : function(local) {
  707. if (!local) {
  708. return this.getX()
  709. } else {
  710. return parseInt(this.getStyle("left"), 10) || 0
  711. }
  712. },
  713. getRight : function(local) {
  714. if (!local) {
  715. return this.getX() + this.getWidth()
  716. } else {
  717. return (this.getLeft(true) + this.getWidth()) || 0
  718. }
  719. },
  720. getTop : function(local) {
  721. if (!local) {
  722. return this.getY()
  723. } else {
  724. return parseInt(this.getStyle("top"), 10) || 0
  725. }
  726. },
  727. getBottom : function(local) {
  728. if (!local) {
  729. return this.getY() + this.getHeight()
  730. } else {
  731. return (this.getTop(true) + this.getHeight()) || 0
  732. }
  733. },
  734. position : function(pos, zIndex, x, y) {
  735. if (!pos) {
  736. if (this.getStyle("position") == "static") {
  737. this.setStyle("position", "relative")
  738. }
  739. } else {
  740. this.setStyle("position", pos)
  741. }
  742. if (zIndex) {
  743. this.setStyle("z-index", zIndex)
  744. }
  745. if (x !== undefined && y !== undefined) {
  746. this.setXY([x, y])
  747. } else {
  748. if (x !== undefined) {
  749. this.setX(x)
  750. } else {
  751. if (y !== undefined) {
  752. this.setY(y)
  753. }
  754. }
  755. }
  756. },
  757. clearPositioning : function(value) {
  758. value = value || "";
  759. this.setStyle({
  760. "left" : value,
  761. "right" : value,
  762. "top" : value,
  763. "bottom" : value,
  764. "z-index" : "",
  765. "position" : "static"
  766. });
  767. return this
  768. },
  769. getPositioning : function() {
  770. var l = this.getStyle("left");
  771. var t = this.getStyle("top");
  772. return {
  773. "position" : this.getStyle("position"),
  774. "left" : l,
  775. "right" : l ? "" : this.getStyle("right"),
  776. "top" : t,
  777. "bottom" : t ? "" : this.getStyle("bottom"),
  778. "z-index" : this.getStyle("z-index")
  779. }
  780. },
  781. getBorderWidth : function(side) {
  782. return this.addStyles(side, El.borders)
  783. },
  784. getPadding : function(side) {
  785. return this.addStyles(side, El.paddings)
  786. },
  787. setPositioning : function(pc) {
  788. this.applyStyles(pc);
  789. if (pc.right == "auto") {
  790. this.dom.style.right = ""
  791. }
  792. if (pc.bottom == "auto") {
  793. this.dom.style.bottom = ""
  794. }
  795. return this
  796. },
  797. fixDisplay : function() {
  798. if (this.getStyle("display") == "none") {
  799. this.setStyle("visibility", "hidden");
  800. this.setStyle("display", this.originalDisplay);
  801. if (this.getStyle("display") == "none") {
  802. this.setStyle("display", "block")
  803. }
  804. }
  805. },
  806. setLeftTop : function(left, top) {
  807. this.dom.style.left = this.addUnits(left);
  808. this.dom.style.top = this.addUnits(top);
  809. return this
  810. },
  811. move : function(direction, distance, animate) {
  812. var xy = this.getXY();
  813. direction = direction.toLowerCase();
  814. switch (direction) {
  815. case "l" :
  816. case "left" :
  817. this.moveTo(xy[0] - distance, xy[1], this.preanim(
  818. arguments, 2));
  819. break;
  820. case "r" :
  821. case "right" :
  822. this.moveTo(xy[0] + distance, xy[1], this.preanim(
  823. arguments, 2));
  824. break;
  825. case "t" :
  826. case "top" :
  827. case "up" :
  828. this.moveTo(xy[0], xy[1] - distance, this.preanim(
  829. arguments, 2));
  830. break;
  831. case "b" :
  832. case "bottom" :
  833. case "down" :
  834. this.moveTo(xy[0], xy[1] + distance, this.preanim(
  835. arguments, 2));
  836. break
  837. }
  838. return this
  839. },
  840. clip : function() {
  841. if (!this.isClipped) {
  842. this.isClipped = true;
  843. this.originalClip = {
  844. "o" : this.getStyle("overflow"),
  845. "x" : this.getStyle("overflow-x"),
  846. "y" : this.getStyle("overflow-y")
  847. };
  848. this.setStyle("overflow", "hidden");
  849. this.setStyle("overflow-x", "hidden");
  850. this.setStyle("overflow-y", "hidden")
  851. }
  852. return this
  853. },
  854. unclip : function() {
  855. if (this.isClipped) {
  856. this.isClipped = false;
  857. var o = this.originalClip;
  858. if (o.o) {
  859. this.setStyle("overflow", o.o)
  860. }
  861. if (o.x) {
  862. this.setStyle("overflow-x", o.x)
  863. }
  864. if (o.y) {
  865. this.setStyle("overflow-y", o.y)
  866. }
  867. }
  868. return this
  869. },
  870. getAnchorXY : function(anchor, local, s) {
  871. var w, h, vp = false;
  872. if (!s) {
  873. var d = this.dom;
  874. if (d == document.body || d == document) {
  875. vp = true;
  876. w = D.getViewWidth();
  877. h = D.getViewHeight()
  878. } else {
  879. w = this.getWidth();
  880. h = this.getHeight()
  881. }
  882. } else {
  883. w = s.width;
  884. h = s.height
  885. }
  886. var x = 0, y = 0, r = Math.round;
  887. switch ((anchor || "tl").toLowerCase()) {
  888. case "c" :
  889. x = r(w * 0.5);
  890. y = r(h * 0.5);
  891. break;
  892. case "t" :
  893. x = r(w * 0.5);
  894. y = 0;
  895. break;
  896. case "l" :
  897. x = 0;
  898. y = r(h * 0.5);
  899. break;
  900. case "r" :
  901. x = w;
  902. y = r(h * 0.5);
  903. break;
  904. case "b" :
  905. x = r(w * 0.5);
  906. y = h;
  907. break;
  908. case "tl" :
  909. x = 0;
  910. y = 0;
  911. break;
  912. case "bl" :
  913. x = 0;
  914. y = h;
  915. break;
  916. case "br" :
  917. x = w;
  918. y = h;
  919. break;
  920. case "tr" :
  921. x = w;
  922. y = 0;
  923. break
  924. }
  925. if (local === true) {
  926. return [x, y]
  927. }
  928. if (vp) {
  929. var sc = this.getScroll();
  930. return [x + sc.left, y + sc.top]
  931. }
  932. var o = this.getXY();
  933. return [x + o[0], y + o[1]]
  934. },
  935. getAlignToXY : function(el, p, o) {
  936. el = Ext.get(el);
  937. if (!el || !el.dom) {
  938. throw "Element.alignToXY with an element that doesn't exist"
  939. }
  940. var d = this.dom;
  941. var c = false;
  942. var p1 = "", p2 = "";
  943. o = o || [0, 0];
  944. if (!p) {
  945. p = "tl-bl"
  946. } else {
  947. if (p == "?") {
  948. p = "tl-bl?"
  949. } else {
  950. if (p.indexOf("-") == -1) {
  951. p = "tl-" + p
  952. }
  953. }
  954. }
  955. p = p.toLowerCase();
  956. var m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
  957. if (!m) {
  958. throw "Element.alignTo with an invalid alignment " + p
  959. }
  960. p1 = m[1];
  961. p2 = m[2];
  962. c = !!m[3];
  963. var a1 = this.getAnchorXY(p1, true);
  964. var a2 = el.getAnchorXY(p2, false);
  965. var x = a2[0] - a1[0] + o[0];
  966. var y = a2[1] - a1[1] + o[1];
  967. if (c) {
  968. var w = this.getWidth(), h = this.getHeight(), r = el
  969. .getRegion();
  970. var dw = D.getViewWidth() - 5, dh = D.getViewHeight() - 5;
  971. var p1y = p1.charAt(0), p1x = p1.charAt(p1.length - 1);
  972. var p2y = p2.charAt(0), p2x = p2.charAt(p2.length - 1);
  973. var swapY = ((p1y == "t" && p2y == "b") || (p1y == "b" && p2y == "t"));
  974. var swapX = ((p1x == "r" && p2x == "l") || (p1x == "l" && p2x == "r"));
  975. var doc = document;
  976. var scrollX = (doc.documentElement.scrollLeft
  977. || doc.body.scrollLeft || 0)
  978. + 5;
  979. var scrollY = (doc.documentElement.scrollTop
  980. || doc.body.scrollTop || 0)
  981. + 5;
  982. if ((x + w) > dw + scrollX) {
  983. x = swapX ? r.left - w : dw + scrollX - w
  984. }
  985. if (x < scrollX) {
  986. x = swapX ? r.right : scrollX
  987. }
  988. if ((y + h) > dh + scrollY) {
  989. y = swapY ? r.top - h : dh + scrollY - h
  990. }
  991. if (y < scrollY) {
  992. y = swapY ? r.bottom : scrollY
  993. }
  994. }
  995. return [x, y]
  996. },
  997. getConstrainToXY : function() {
  998. var os = {
  999. top : 0,
  1000. left : 0,
  1001. bottom : 0,
  1002. right : 0
  1003. };
  1004. return function(el, local, offsets, proposedXY) {
  1005. el = Ext.get(el);
  1006. offsets = offsets ? Ext.applyIf(offsets, os) : os;
  1007. var vw, vh, vx = 0, vy = 0;
  1008. if (el.dom == document.body || el.dom == document) {
  1009. vw = Ext.lib.Dom.getViewWidth();
  1010. vh = Ext.lib.Dom.getViewHeight()
  1011. } else {
  1012. vw = el.dom.clientWidth;
  1013. vh = el.dom.clientHeight;
  1014. if (!local) {
  1015. var vxy = el.getXY();
  1016. vx = vxy[0];
  1017. vy = vxy[1]
  1018. }
  1019. }
  1020. var s = el.getScroll();
  1021. vx += offsets.left + s.left;
  1022. vy += offsets.top + s.top;
  1023. vw -= offsets.right;
  1024. vh -= offsets.bottom;
  1025. var vr = vx + vw;
  1026. var vb = vy + vh;
  1027. var xy = proposedXY
  1028. || (!local ? this.getXY() : [this.getLeft(true),
  1029. this.getTop(true)]);
  1030. var x = xy[0], y = xy[1];
  1031. var w = this.dom.offsetWidth, h = this.dom.offsetHeight;
  1032. var moved = false;
  1033. if ((x + w) > vr) {
  1034. x = vr - w;
  1035. moved = true
  1036. }
  1037. if ((y + h) > vb) {
  1038. y = vb - h;
  1039. moved = true
  1040. }
  1041. if (x < vx) {
  1042. x = vx;
  1043. moved = true
  1044. }
  1045. if (y < vy) {
  1046. y = vy;
  1047. moved = true
  1048. }
  1049. return moved ? [x, y] : false
  1050. }
  1051. }(),
  1052. adjustForConstraints : function(xy, parent, offsets) {
  1053. return this
  1054. .getConstrainToXY(parent || document, false, offsets, xy)
  1055. || xy
  1056. },
  1057. alignTo : function(element, position, offsets, animate) {
  1058. var xy = this.getAlignToXY(element, position, offsets);
  1059. this.setXY(xy, this.preanim(arguments, 3));
  1060. return this
  1061. },
  1062. anchorTo : function(el, alignment, offsets, animate, monitorScroll,
  1063. callback) {
  1064. var action = function() {
  1065. this.alignTo(el, alignment, offsets, animate);
  1066. Ext.callback(callback, this)
  1067. };
  1068. Ext.EventManager.onWindowResize(action, this);
  1069. var tm = typeof monitorScroll;
  1070. if (tm != "undefined") {
  1071. Ext.EventManager.on(window, "scroll", action, this, {
  1072. buffer : tm == "number" ? monitorScroll : 50
  1073. })
  1074. }
  1075. action.call(this);
  1076. return this
  1077. },
  1078. clearOpacity : function() {
  1079. if (window.ActiveXObject) {
  1080. if (typeof this.dom.style.filter == "string"
  1081. && (/alpha/i).test(this.dom.style.filter)) {
  1082. this.dom.style.filter = ""
  1083. }
  1084. } else {
  1085. this.dom.style.opacity = "";
  1086. this.dom.style["-moz-opacity"] = "";
  1087. this.dom.style["-khtml-opacity"] = ""
  1088. }
  1089. return this
  1090. },
  1091. hide : function(animate) {
  1092. this.setVisible(false, this.preanim(arguments, 0));
  1093. return this
  1094. },
  1095. show : function(animate) {
  1096. this.setVisible(true, this.preanim(arguments, 0));
  1097. return this
  1098. },
  1099. addUnits : function(size) {
  1100. return Ext.Element.addUnits(size, this.defaultUnit)
  1101. },
  1102. update : function(html, loadScripts, callback) {
  1103. if (typeof html == "undefined") {
  1104. html = ""
  1105. }
  1106. if (loadScripts !== true) {
  1107. this.dom.innerHTML = html;
  1108. if (typeof callback == "function") {
  1109. callback()
  1110. }
  1111. return this
  1112. }
  1113. var id = Ext.id();
  1114. var dom = this.dom;
  1115. html += "<span id=\"" + id + "\"></span>";
  1116. E.onAvailable(id, function() {
  1117. var hd = document.getElementsByTagName("head")[0];
  1118. var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
  1119. var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
  1120. var typeRe = /\stype=([\'\"])(.*?)\1/i;
  1121. var match;
  1122. while (match = re.exec(html)) {
  1123. var attrs = match[1];
  1124. var srcMatch = attrs ? attrs.match(srcRe) : false;
  1125. if (srcMatch && srcMatch[2]) {
  1126. var s = document.createElement("script");
  1127. s.src = srcMatch[2];
  1128. var typeMatch = attrs.match(typeRe);
  1129. if (typeMatch && typeMatch[2]) {
  1130. s.type = typeMatch[2]
  1131. }
  1132. hd.appendChild(s)
  1133. } else {
  1134. if (match[2] && match[2].length > 0) {
  1135. if (window.execScript) {
  1136. window.execScript(match[2])
  1137. } else {
  1138. window.eval(match[2])
  1139. }
  1140. }
  1141. }
  1142. }
  1143. var el = document.getElementById(id);
  1144. if (el) {
  1145. Ext.removeNode(el)
  1146. }
  1147. if (typeof callback == "function") {
  1148. callback()
  1149. }
  1150. });
  1151. dom.innerHTML = html.replace(
  1152. /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
  1153. return this
  1154. },
  1155. load : function() {
  1156. var um = this.getUpdater();
  1157. um.update.apply(um, arguments);
  1158. return this
  1159. },
  1160. getUpdater : function() {
  1161. if (!this.updateManager) {
  1162. this.updateManager = new Ext.Updater(this)
  1163. }
  1164. return this.updateManager
  1165. },
  1166. unselectable : function() {
  1167. this.dom.unselectable = "on";
  1168. this.swallowEvent("selectstart", true);
  1169. this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");
  1170. this.addClass("x-unselectable");
  1171. return this
  1172. },
  1173. getCenterXY : function() {
  1174. return this.getAlignToXY(document, "c-c")
  1175. },
  1176. center : function(centerIn) {
  1177. this.alignTo(centerIn || document, "c-c");
  1178. return this
  1179. },
  1180. isBorderBox : function() {
  1181. return noBoxAdjust[this.dom.tagName.toLowerCase()]
  1182. || Ext.isBorderBox
  1183. },
  1184. getBox : function(contentBox, local) {
  1185. var xy;
  1186. if (!local) {
  1187. xy = this.getXY()
  1188. } else {
  1189. var left = parseInt(this.getStyle("left"), 10) || 0;
  1190. var top = parseInt(this.getStyle("top"), 10) || 0;
  1191. xy = [left, top]
  1192. }
  1193. var el = this.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
  1194. if (!contentBox) {
  1195. bx = {
  1196. x : xy[0],
  1197. y : xy[1],
  1198. 0 : xy[0],
  1199. 1 : xy[1],
  1200. width : w,
  1201. height : h
  1202. }
  1203. } else {
  1204. var l = this.getBorderWidth("l") + this.getPadding("l");
  1205. var r = this.getBorderWidth("r") + this.getPadding("r");
  1206. var t = this.getBorderWidth("t") + this.getPadding("t");
  1207. var b = this.getBorderWidth("b") + this.getPadding("b");
  1208. bx = {
  1209. x : xy[0] + l,
  1210. y : xy[1] + t,
  1211. 0 : xy[0] + l,
  1212. 1 : xy[1] + t,
  1213. width : w - (l + r),
  1214. height : h - (t + b)
  1215. }
  1216. }
  1217. bx.right = bx.x + bx.width;
  1218. bx.bottom = bx.y + bx.height;
  1219. return bx
  1220. },
  1221. getFrameWidth : function(sides, onlyContentBox) {
  1222. return onlyContentBox && Ext.isBorderBox ? 0 : (this
  1223. .getPadding(sides) + this.getBorderWidth(sides))
  1224. },
  1225. setBox : function(box, adjust, animate) {
  1226. var w = box.width, h = box.height;
  1227. if ((adjust && !this.autoBoxAdjust) && !this.isBorderBox()) {
  1228. w -= (this.getBorderWidth("lr") + this.getPadding("lr"));
  1229. h -= (this.getBorderWidth("tb") + this.getPadding("tb"))
  1230. }
  1231. this.setBounds(box.x, box.y, w, h, this.preanim(arguments, 2));
  1232. return this
  1233. },
  1234. repaint : function() {
  1235. var dom = this.dom;
  1236. this.addClass("x-repaint");
  1237. setTimeout(function() {
  1238. Ext.get(dom).removeClass("x-repaint")
  1239. }, 1);
  1240. return this
  1241. },
  1242. getMargins : function(side) {
  1243. if (!side) {
  1244. return {
  1245. top : parseInt(this.getStyle("margin-top"), 10) || 0,
  1246. left : parseInt(this.getStyle("margin-left"), 10) || 0,
  1247. bottom : parseInt(this.getStyle("margin-bottom"), 10) || 0,
  1248. right : parseInt(this.getStyle("margin-right"), 10) || 0
  1249. }
  1250. } else {
  1251. return this.addStyles(side, El.margins)
  1252. }
  1253. },
  1254. addStyles : function(sides, styles) {
  1255. var val = 0, v, w;
  1256. for (var i = 0, len = sides.length; i < len; i++) {
  1257. v = this.getStyle(styles[sides.charAt(i)]);
  1258. if (v) {
  1259. w = parseInt(v, 10);
  1260. if (w) {
  1261. val += (w >= 0 ? w : -1 * w)
  1262. }
  1263. }
  1264. }
  1265. return val
  1266. },
  1267. createProxy : function(config, renderTo, matchBox) {
  1268. config = typeof config == "object" ? config : {
  1269. tag : "div",
  1270. cls : config
  1271. };
  1272. var proxy;
  1273. if (renderTo) {
  1274. proxy = Ext.DomHelper.append(renderTo, config, true)
  1275. } else {
  1276. proxy = Ext.DomHelper.insertBefore(this.dom, config, true)
  1277. }
  1278. if (matchBox) {
  1279. proxy.setBox(this.getBox())
  1280. }
  1281. return proxy
  1282. },
  1283. mask : function(msg, msgCls) {
  1284. if (this.getStyle("position") == "static") {
  1285. this.setStyle("position", "relative")
  1286. }
  1287. if (this._maskMsg) {
  1288. this._maskMsg.remove()
  1289. }
  1290. if (this._mask) {
  1291. this._mask.remove()
  1292. }
  1293. this._mask = Ext.DomHelper.append(this.dom, {
  1294. cls : "ext-el-mask"
  1295. }, true);
  1296. this.addClass("x-masked");
  1297. this._mask.setDisplayed(true);
  1298. if (typeof msg == "string") {
  1299. this._maskMsg = Ext.DomHelper.append(this.dom, {
  1300. cls : "ext-el-mask-msg",
  1301. cn : {
  1302. tag : "div"
  1303. }
  1304. }, true);
  1305. var mm = this._maskMsg;
  1306. mm.dom.className = msgCls
  1307. ? "ext-el-mask-msg " + msgCls
  1308. : "ext-el-mask-msg";
  1309. mm.dom.firstChild.innerHTML = msg;
  1310. mm.setDisplayed(true);
  1311. mm.center(this)
  1312. }
  1313. if (Ext.isIE && !(Ext.isIE7 && Ext.isStrict)
  1314. && this.getStyle("height") == "auto") {
  1315. this._mask.setSize(this.dom.clientWidth, this.getHeight())
  1316. }
  1317. return this._mask
  1318. },
  1319. unmask : function() {
  1320. if (this._mask) {
  1321. if (this._maskMsg) {
  1322. this._maskMsg.remove();
  1323. delete this._maskMsg
  1324. }
  1325. this._mask.remove();
  1326. delete this._mask
  1327. }
  1328. this.removeClass("x-masked")
  1329. },
  1330. isMasked : function() {
  1331. return this._mask && this._mask.isVisible()
  1332. },
  1333. createShim : function() {
  1334. var el = document.createElement("iframe");
  1335. el.frameBorder = "no";
  1336. el.className = "ext-shim";
  1337. if (Ext.isIE && Ext.isSecure) {
  1338. el.src = Ext.SSL_SECURE_URL
  1339. }
  1340. var shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
  1341. shim.autoBoxAdjust = false;
  1342. return shim
  1343. },
  1344. remove : function() {
  1345. Ext.removeNode(this.dom);
  1346. delete El.cache[this.dom.id]
  1347. },
  1348. hover : function(overFn, outFn, scope) {
  1349. var preOverFn = function(e) {
  1350. if (!e.within(this, true)) {
  1351. overFn.apply(scope || this, arguments)
  1352. }
  1353. };
  1354. var preOutFn = function(e) {
  1355. if (!e.within(this, true)) {
  1356. outFn.apply(scope || this, arguments)
  1357. }
  1358. };
  1359. this.on("mouseover", preOverFn, this.dom);
  1360. this.on("mouseout", preOutFn, this.dom);
  1361. return this
  1362. },
  1363. addClassOnOver : function(className, preventFlicker) {
  1364. this.hover(function() {
  1365. Ext.fly(this, "_internal").addClass(className)
  1366. }, function() {
  1367. Ext.fly(this, "_internal").removeClass(className)
  1368. });
  1369. return this
  1370. },
  1371. addClassOnFocus : function(className) {
  1372. this.on("focus", function() {
  1373. Ext.fly(this, "_internal").addClass(className)
  1374. }, this.dom);
  1375. this.on("blur", function() {
  1376. Ext.fly(this, "_internal").removeClass(className)
  1377. }, this.dom);
  1378. return this
  1379. },
  1380. addClassOnClick : function(className) {
  1381. var dom = this.dom;
  1382. this.on("mousedown", function() {
  1383. Ext.fly(dom, "_internal").addClass(className);
  1384. var d = Ext.getDoc();
  1385. var fn = function() {
  1386. Ext.fly(dom, "_internal").removeClass(className);
  1387. d.removeListener("mouseup", fn)
  1388. };
  1389. d.on("mouseup", fn)
  1390. });
  1391. return this
  1392. },
  1393. swallowEvent : function(eventName, preventDefault) {
  1394. var fn = function(e) {
  1395. e.stopPropagation();
  1396. if (preventDefault) {
  1397. e.preventDefault()
  1398. }
  1399. };
  1400. if (eventName instanceof Array) {
  1401. for (var i = 0, len = eventName.length; i < len; i++) {
  1402. this.on(eventName[i], fn)
  1403. }
  1404. return this
  1405. }
  1406. this.on(eventName, fn);
  1407. return this
  1408. },
  1409. parent : function(selector, returnDom) {
  1410. return this.matchNode("parentNode", "parentNode", selector,
  1411. returnDom)
  1412. },
  1413. next : function(selector, returnDom) {
  1414. return this.matchNode("nextSibling", "nextSibling", selector,
  1415. returnDom)
  1416. },
  1417. prev : function(selector, returnDom) {
  1418. return this.matchNode("previousSibling", "previousSibling",
  1419. selector, returnDom)
  1420. },
  1421. first : function(selector, returnDom) {
  1422. return this.matchNode("nextSibling", "firstChild", selector,
  1423. returnDom)
  1424. },
  1425. last : function(selector, returnDom) {
  1426. return this.matchNode("previousSibling", "lastChild", selector,
  1427. returnDom)
  1428. },
  1429. matchNode : function(dir, start, selector, returnDom) {
  1430. var n = this.dom[start];
  1431. while (n) {
  1432. if (n.nodeType == 1
  1433. && (!selector || Ext.DomQuery.is(n, selector))) {
  1434. return !returnDom ? Ext.get(n) : n
  1435. }
  1436. n = n[dir]
  1437. }
  1438. return null
  1439. },
  1440. appendChild : function(el) {
  1441. el = Ext.get(el);
  1442. el.appendTo(this);
  1443. return this
  1444. },
  1445. createChild : function(config, insertBefore, returnDom) {
  1446. config = config || {
  1447. tag : "div"
  1448. };
  1449. if (insertBefore) {
  1450. return Ext.DomHelper.insertBefore(insertBefore, config,
  1451. returnDom !== true)
  1452. }
  1453. return Ext.DomHelper[!this.dom.firstChild ? "overwrite" : "append"](
  1454. this.dom, config, returnDom !== true)
  1455. },
  1456. appendTo : function(el) {
  1457. el = Ext.getDom(el);
  1458. el.appendChild(this.dom);
  1459. return this
  1460. },
  1461. insertBefore : function(el) {
  1462. el = Ext.getDom(el);
  1463. el.parentNode.insertBefore(this.dom, el);
  1464. return this
  1465. },
  1466. insertAfter : function(el) {
  1467. el = Ext.getDom(el);
  1468. el.parentNode.insertBefore(this.dom, el.nextSibling);
  1469. return this
  1470. },
  1471. insertFirst : function(el, returnDom) {
  1472. el = el || {};
  1473. if (typeof el == "object" && !el.nodeType) {
  1474. return this.createChild(el, this.dom.firstChild, returnDom)
  1475. } else {
  1476. el = Ext.getDom(el);
  1477. this.dom.insertBefore(el, this.dom.firstChild);
  1478. return !returnDom ? Ext.get(el) : el
  1479. }
  1480. },
  1481. insertSibling : function(el, where, returnDom) {
  1482. var rt;
  1483. if (el instanceof Array) {
  1484. for (var i = 0, len = el.length; i < len; i++) {
  1485. rt = this.insertSibling(el[i], where, returnDom)
  1486. }
  1487. return rt
  1488. }
  1489. where = where ? where.toLowerCase() : "before";
  1490. el = el || {};
  1491. var refNode = where == "before" ? this.dom : this.dom.nextSibling;
  1492. if (typeof el == "object" && !el.nodeType) {
  1493. if (where == "after" && !this.dom.nextSibling) {
  1494. rt = Ext.DomHelper.append(this.dom.parentNode, el,
  1495. !returnDom)
  1496. } else {
  1497. rt = Ext.DomHelper[where == "after"
  1498. ? "insertAfter"
  1499. : "insertBefore"](this.dom, el, !returnDom)
  1500. }
  1501. } else {
  1502. rt = this.dom.parentNode.insertBefore(Ext.getDom(el), refNode);
  1503. if (!returnDom) {
  1504. rt = Ext.get(rt)
  1505. }
  1506. }
  1507. return rt
  1508. },
  1509. wrap : function(config, returnDom) {
  1510. if (!config) {
  1511. config = {
  1512. tag : "div"
  1513. }
  1514. }
  1515. var newEl = Ext.DomHelper
  1516. .insertBefore(this.dom, config, !returnDom);
  1517. newEl.dom ? newEl.dom.appendChild(this.dom) : newEl
  1518. .appendChild(this.dom);
  1519. return newEl
  1520. },
  1521. replace : function(el) {
  1522. el = Ext.get(el);
  1523. this.insertBefore(el);
  1524. el.remove();
  1525. return this
  1526. },
  1527. replaceWith : function(el) {
  1528. if (typeof el == "object" && !el.nodeType) {
  1529. el = this.insertSibling(el, "before")
  1530. } else {
  1531. el = Ext.getDom(el);
  1532. this.dom.parentNode.insertBefore(el, this.dom)
  1533. }
  1534. El.uncache(this.id);
  1535. this.dom.parentNode.removeChild(this.dom);
  1536. this.dom = el;
  1537. this.id = Ext.id(el);
  1538. El.cache[this.id] = this;
  1539. return this
  1540. },
  1541. insertHtml : function(where, html, returnEl) {
  1542. var el = Ext.DomHelper.insertHtml(where, this.dom, html);
  1543. return returnEl ? Ext.get(el) : el
  1544. },
  1545. set : function(o, useSet) {
  1546. var el = this.dom;
  1547. useSet = typeof useSet == "undefined" ? (el.setAttribute
  1548. ? true
  1549. : false) : useSet;
  1550. for (var attr in o) {
  1551. if (attr == "style" || typeof o[attr] == "function") {
  1552. continue
  1553. }
  1554. if (attr == "cls") {
  1555. el.className = o["cls"]
  1556. } else {
  1557. if (o.hasOwnProperty(attr)) {
  1558. if (useSet) {
  1559. el.setAttribute(attr, o[attr])
  1560. } else {
  1561. el[attr] = o[attr]
  1562. }
  1563. }
  1564. }
  1565. }
  1566. if (o.style) {
  1567. Ext.DomHelper.applyStyles(el, o.style)
  1568. }
  1569. return this
  1570. },
  1571. addKeyListener : function(key, fn, scope) {
  1572. var config;
  1573. if (typeof key != "object" || key instanceof Array) {
  1574. config = {
  1575. key : key,
  1576. fn : fn,
  1577. scope : scope
  1578. }
  1579. } else {
  1580. config = {
  1581. key : key.key,
  1582. shift : key.shift,
  1583. ctrl : key.ctrl,
  1584. alt : key.alt,
  1585. fn : fn,
  1586. scope : scope
  1587. }
  1588. }
  1589. return new Ext.KeyMap(this, config)
  1590. },
  1591. addKeyMap : function(config) {
  1592. return new Ext.KeyMap(this, config)
  1593. },
  1594. isScrollable : function() {
  1595. var dom = this.dom;
  1596. return dom.scrollHeight > dom.clientHeight
  1597. || dom.scrollWidth > dom.clientWidth
  1598. },
  1599. scrollTo : function(side, value, animate) {
  1600. var prop = side.toLowerCase() == "left"
  1601. ? "scrollLeft"
  1602. : "scrollTop";
  1603. if (!animate || !A) {
  1604. this.dom[prop] = value
  1605. } else {
  1606. var to = prop == "scrollLeft" ? [value, this.dom.scrollTop] : [
  1607. this.dom.scrollLeft, value];
  1608. this.anim({
  1609. scroll : {
  1610. "to" : to
  1611. }
  1612. }, this.preanim(arguments, 2), "scroll")
  1613. }
  1614. return this
  1615. },
  1616. scroll : function(direction, distance, animate) {
  1617. if (!this.isScrollable()) {
  1618. return
  1619. }
  1620. var el = this.dom;
  1621. var l = el.scrollLeft, t = el.scrollTop;
  1622. var w = el.scrollWidth, h = el.scrollHeight;
  1623. var cw = el.clientWidth, ch = el.clientHeight;
  1624. direction = direction.toLowerCase();
  1625. var scrolled = false;
  1626. var a = this.preanim(arguments, 2);
  1627. switch (direction) {
  1628. case "l" :
  1629. case "left" :
  1630. if (w - l > cw) {
  1631. var v = Math.min(l + distance, w - cw);
  1632. this.scrollTo("left", v, a);
  1633. scrolled = true
  1634. }
  1635. break;
  1636. case "r" :
  1637. case "right" :
  1638. if (l > 0) {
  1639. var v = Math.max(l - distance, 0);
  1640. this.scrollTo("left", v, a);
  1641. scrolled = true
  1642. }
  1643. break;
  1644. case "t" :
  1645. case "top" :
  1646. case "up" :
  1647. if (t > 0) {
  1648. var v = Math.max(t - distance, 0);
  1649. this.scrollTo("top", v, a);
  1650. scrolled = true
  1651. }
  1652. break;
  1653. case "b" :
  1654. case "bottom" :
  1655. case "down" :
  1656. if (h - t > ch) {
  1657. var v = Math.min(t + distance, h - ch);
  1658. this.scrollTo("top", v, a);
  1659. scrolled = true
  1660. }
  1661. break
  1662. }
  1663. return scrolled
  1664. },
  1665. translatePoints : function(x, y) {
  1666. if (typeof x == "object" || x instanceof Array) {
  1667. y = x[1];
  1668. x = x[0]
  1669. }
  1670. var p = this.getStyle("position");
  1671. var o = this.getXY();
  1672. var l = parseInt(this.getStyle("left"), 10);
  1673. var t = parseInt(this.getStyle("top"), 10);
  1674. if (isNaN(l)) {
  1675. l = (p == "relative") ? 0 : this.dom.offsetLeft
  1676. }
  1677. if (isNaN(t)) {
  1678. t = (p == "relative") ? 0 : this.dom.offsetTop
  1679. }
  1680. return {
  1681. left : (x - o[0] + l),
  1682. top : (y - o[1] + t)
  1683. }
  1684. },
  1685. getScroll : function() {
  1686. var d = this.dom, doc = document;
  1687. if (d == doc || d == doc.body) {
  1688. var l, t;
  1689. if (Ext.isIE && Ext.isStrict) {
  1690. l = doc.documentElement.scrollLeft
  1691. || (doc.body.scrollLeft || 0);
  1692. t = doc.documentElement.scrollTop
  1693. || (doc.body.scrollTop || 0)
  1694. } else {
  1695. l = window.pageXOffset || (doc.body.scrollLeft || 0);
  1696. t = window.pageYOffset || (doc.body.scrollTop || 0)
  1697. }
  1698. return {
  1699. left : l,
  1700. top : t
  1701. }
  1702. } else {
  1703. return {
  1704. left : d.scrollLeft,
  1705. top : d.scrollTop
  1706. }
  1707. }
  1708. },
  1709. getColor : function(attr, defaultValue, prefix) {
  1710. var v = this.getStyle(attr);
  1711. if (!v || v == "transparent" || v == "inherit") {
  1712. return defaultValue
  1713. }
  1714. var color = typeof prefix == "undefined" ? "#" : prefix;
  1715. if (v.substr(0, 4) == "rgb(") {
  1716. var rvs = v.slice(4, v.length - 1).split(",");
  1717. for (var i = 0; i < 3; i++) {
  1718. var h = parseInt(rvs[i]);
  1719. var s = h.toString(16);
  1720. if (h < 16) {
  1721. s = "0" + s
  1722. }
  1723. color += s
  1724. }
  1725. } else {
  1726. if (v.substr(0, 1) == "#") {
  1727. if (v.length == 4) {
  1728. for (var i = 1; i < 4; i++) {
  1729. var c = v.charAt(i);
  1730. color += c + c
  1731. }
  1732. } else {
  1733. if (v.length == 7) {
  1734. color += v.substr(1)
  1735. }
  1736. }
  1737. }
  1738. }
  1739. return (color.length > 5 ? color.toLowerCase() : defaultValue)
  1740. },
  1741. boxWrap : function(cls) {
  1742. cls = cls || "x-box";
  1743. var el = Ext.get(this.insertHtml("beforeBegin", String.format(
  1744. "<div class=\"{0}\">" + El.boxMarkup + "</div>",
  1745. cls)));
  1746. el.child("." + cls + "-mc").dom.appendChild(this.dom);
  1747. return el
  1748. },
  1749. getAttributeNS : Ext.isIE ? function(ns, name) {
  1750. var d = this.dom;
  1751. var type = typeof d[ns + ":" + name];
  1752. if (type != "undefined" && type != "unknown") {
  1753. return d[ns + ":" + name]
  1754. }
  1755. return d[name]
  1756. } : function(ns, name) {
  1757. var d = this.dom;
  1758. return d.getAttributeNS(ns, name)
  1759. || d.getAttribute(ns + ":" + name) || d.getAttribute(name)
  1760. || d[name]
  1761. },
  1762. getTextWidth : function(text, min, max) {
  1763. return (Ext.util.TextMetrics.measure(this.dom, Ext.value(text,
  1764. this.dom.innerHTML, true)).width).constrain(min
  1765. || 0, max || 1000000)
  1766. }
  1767. };
  1768. var ep = El.prototype;
  1769. ep.on = ep.addListener;
  1770. ep.mon = ep.addListener;
  1771. ep.getUpdateManager = ep.getUpdater;
  1772. ep.un = ep.removeListener;
  1773. ep.autoBoxAdjust = true;
  1774. El.unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;
  1775. El.addUnits = function(v, defaultUnit) {
  1776. if (v === "" || v == "auto") {
  1777. return v
  1778. }
  1779. if (v === undefined) {
  1780. return ""
  1781. }
  1782. if (typeof v == "number" || !El.unitPattern.test(v)) {
  1783. return v + (defaultUnit || "px")
  1784. }
  1785. return v
  1786. };
  1787. El.boxMarkup = "<div class=\"{0}-tl\"><div class=\"{0}-tr\"><div class=\"{0}-tc\"></div></div></div><div class=\"{0}-ml\"><div class=\"{0}-mr\"><div class=\"{0}-mc\"></div></div></div><div class=\"{0}-bl\"><div class=\"{0}-br\"><div class=\"{0}-bc\"></div></div></div>";
  1788. El.VISIBILITY = 1;
  1789. El.DISPLAY = 2;
  1790. El.borders = {
  1791. l : "border-left-width",
  1792. r : "border-right-width",
  1793. t : "border-top-width",
  1794. b : "border-bottom-width"
  1795. };
  1796. El.paddings = {
  1797. l : "padding-left",
  1798. r : "padding-right",
  1799. t : "padding-top",
  1800. b : "padding-bottom"
  1801. };
  1802. El.margins = {
  1803. l : "margin-left",
  1804. r : "margin-right",
  1805. t : "margin-top",
  1806. b : "margin-bottom"
  1807. };
  1808. El.cache = {};
  1809. var docEl;
  1810. El.get = function(el) {
  1811. var ex, elm, id;
  1812. if (!el) {
  1813. return null
  1814. }
  1815. if (typeof el == "string") {
  1816. if (!(elm = document.getElementById(el))) {
  1817. return null
  1818. }
  1819. if (ex = El.cache[el]) {
  1820. ex.dom = elm
  1821. } else {
  1822. ex = El.cache[el] = new El(elm)
  1823. }
  1824. return ex
  1825. } else {
  1826. if (el.tagName) {
  1827. if (!(id = el.id)) {
  1828. id = Ext.id(el)
  1829. }
  1830. if (ex = El.cache[id]) {
  1831. ex.dom = el
  1832. } else {
  1833. ex = El.cache[id] = new El(el)
  1834. }
  1835. return ex
  1836. } else {
  1837. if (el instanceof El) {
  1838. if (el != docEl) {
  1839. el.dom = document.getElementById(el.id) || el.dom;
  1840. El.cache[el.id] = el
  1841. }
  1842. return el
  1843. } else {
  1844. if (el.isComposite) {
  1845. return el
  1846. } else {
  1847. if (el instanceof Array) {
  1848. return El.select(el)
  1849. } else {
  1850. if (el == document) {
  1851. if (!docEl) {
  1852. var f = function() {
  1853. };
  1854. f.prototype = El.prototype;
  1855. docEl = new f();
  1856. docEl.dom = document
  1857. }
  1858. return docEl
  1859. }
  1860. }
  1861. }
  1862. }
  1863. }
  1864. }
  1865. return null
  1866. };
  1867. El.uncache = function(el) {
  1868. for (var i = 0, a = arguments, len = a.length; i < len; i++) {
  1869. if (a[i]) {
  1870. delete El.cache[a[i].id || a[i]]
  1871. }
  1872. }
  1873. };
  1874. El.garbageCollect = function() {
  1875. if (!Ext.enableGarbageCollector) {
  1876. clearInterval(El.collectorThread);
  1877. return
  1878. }
  1879. for (var eid in El.cache) {
  1880. var el = El.cache[eid], d = el.dom;
  1881. if (!d || !d.parentNode
  1882. || (!d.offsetParent && !document.getElementById(eid))) {
  1883. delete El.cache[eid];
  1884. if (d && Ext.enableListenerCollection) {
  1885. E.purgeElement(d)
  1886. }
  1887. }
  1888. }
  1889. };
  1890. El.collectorThreadId = setInterval(El.garbageCollect, 30000);
  1891. var flyFn = function() {
  1892. };
  1893. flyFn.prototype = El.prototype;
  1894. var _cls = new flyFn();
  1895. El.Flyweight = function(dom) {
  1896. this.dom = dom
  1897. };
  1898. El.Flyweight.prototype = _cls;
  1899. El.Flyweight.prototype.isFlyweight = true;
  1900. El._flyweights = {};
  1901. El.fly = function(el, named) {
  1902. named = named || "_global";
  1903. el = Ext.getDom(el);
  1904. if (!el) {
  1905. return null
  1906. }
  1907. if (!El._flyweights[named]) {
  1908. El._flyweights[named] = new El.Flyweight()
  1909. }
  1910. El._flyweights[named].dom = el;
  1911. return El._flyweights[named]
  1912. };
  1913. Ext.get = El.get;
  1914. Ext.fly = El.fly;
  1915. var noBoxAdjust = Ext.isStrict ? {
  1916. select : 1
  1917. } : {
  1918. input : 1,
  1919. select : 1,
  1920. textarea : 1
  1921. };
  1922. if (Ext.isIE || Ext.isGecko) {
  1923. noBoxAdjust["button"] = 1
  1924. }
  1925. Ext.EventManager.on(window, "unload", function() {
  1926. delete El.cache;
  1927. delete El._flyweights
  1928. })
  1929. })();