Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1145 lines
38 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. /**
  8. * @class Ext.Tip
  9. * @extends Ext.Panel
  10. * @xtype tip
  11. * This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and
  12. * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
  13. * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
  14. * @constructor
  15. * Create a new Tip
  16. * @param {Object} config The configuration options
  17. */
  18. Ext.Tip = Ext.extend(Ext.Panel, {
  19. /**
  20. * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
  21. */
  22. /**
  23. * @cfg {Number} width
  24. * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
  25. * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
  26. */
  27. /**
  28. * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
  29. */
  30. minWidth : 40,
  31. /**
  32. * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
  33. */
  34. maxWidth : 300,
  35. /**
  36. * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"
  37. * for bottom-right shadow (defaults to "sides").
  38. */
  39. shadow : "sides",
  40. /**
  41. * @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value
  42. * for this tip relative to its element of origin (defaults to "tl-bl?").
  43. */
  44. defaultAlign : "tl-bl?",
  45. autoRender: true,
  46. quickShowInterval : 250,
  47. // private panel overrides
  48. frame:true,
  49. hidden:true,
  50. baseCls: 'x-tip',
  51. floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
  52. autoHeight:true,
  53. closeAction: 'hide',
  54. // private
  55. initComponent : function(){
  56. Ext.Tip.superclass.initComponent.call(this);
  57. if(this.closable && !this.title){
  58. this.elements += ',header';
  59. }
  60. },
  61. // private
  62. afterRender : function(){
  63. Ext.Tip.superclass.afterRender.call(this);
  64. if(this.closable){
  65. this.addTool({
  66. id: 'close',
  67. handler: this[this.closeAction],
  68. scope: this
  69. });
  70. }
  71. },
  72. /**
  73. * Shows this tip at the specified XY position. Example usage:
  74. * <pre><code>
  75. // Show the tip at x:50 and y:100
  76. tip.showAt([50,100]);
  77. </code></pre>
  78. * @param {Array} xy An array containing the x and y coordinates
  79. */
  80. showAt : function(xy){
  81. Ext.Tip.superclass.show.call(this);
  82. if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
  83. this.doAutoWidth();
  84. }
  85. if(this.constrainPosition){
  86. xy = this.el.adjustForConstraints(xy);
  87. }
  88. this.setPagePosition(xy[0], xy[1]);
  89. },
  90. // protected
  91. doAutoWidth : function(adjust){
  92. adjust = adjust || 0;
  93. var bw = this.body.getTextWidth();
  94. if(this.title){
  95. bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
  96. }
  97. bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr") + adjust;
  98. this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
  99. // IE7 repaint bug on initial show
  100. if(Ext.isIE7 && !this.repainted){
  101. this.el.repaint();
  102. this.repainted = true;
  103. }
  104. },
  105. /**
  106. * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
  107. * anchor position value. Example usage:
  108. * <pre><code>
  109. // Show the tip at the default position ('tl-br?')
  110. tip.showBy('my-el');
  111. // Show the tip's top-left corner anchored to the element's top-right corner
  112. tip.showBy('my-el', 'tl-tr');
  113. </code></pre>
  114. * @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
  115. * @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
  116. * {@link #defaultAlign} if specified).
  117. */
  118. showBy : function(el, pos){
  119. if(!this.rendered){
  120. this.render(Ext.getBody());
  121. }
  122. this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
  123. },
  124. initDraggable : function(){
  125. this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
  126. this.header.addClass('x-tip-draggable');
  127. }
  128. });
  129. Ext.reg('tip', Ext.Tip);
  130. // private - custom Tip DD implementation
  131. Ext.Tip.DD = function(tip, config){
  132. Ext.apply(this, config);
  133. this.tip = tip;
  134. Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
  135. this.setHandleElId(tip.header.id);
  136. this.scroll = false;
  137. };
  138. Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
  139. moveOnly:true,
  140. scroll:false,
  141. headerOffsets:[100, 25],
  142. startDrag : function(){
  143. this.tip.el.disableShadow();
  144. },
  145. endDrag : function(e){
  146. this.tip.el.enableShadow(true);
  147. }
  148. });/**
  149. * @class Ext.ToolTip
  150. * @extends Ext.Tip
  151. * A standard tooltip implementation for providing additional information when hovering over a target element.
  152. * @xtype tooltip
  153. * @constructor
  154. * Create a new Tooltip
  155. * @param {Object} config The configuration options
  156. */
  157. Ext.ToolTip = Ext.extend(Ext.Tip, {
  158. /**
  159. * When a Tooltip is configured with the <code>{@link #delegate}</code>
  160. * option to cause selected child elements of the <code>{@link #target}</code>
  161. * Element to each trigger a seperate show event, this property is set to
  162. * the DOM element which triggered the show.
  163. * @type DOMElement
  164. * @property triggerElement
  165. */
  166. /**
  167. * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to monitor
  168. * for mouseover events to trigger showing this ToolTip.
  169. */
  170. /**
  171. * @cfg {Boolean} autoHide True to automatically hide the tooltip after the
  172. * mouse exits the target element or after the <code>{@link #dismissDelay}</code>
  173. * has expired if set (defaults to true). If <code>{@link closable} = true</code>
  174. * a close tool button will be rendered into the tooltip header.
  175. */
  176. /**
  177. * @cfg {Number} showDelay Delay in milliseconds before the tooltip displays
  178. * after the mouse enters the target element (defaults to 500)
  179. */
  180. showDelay : 500,
  181. /**
  182. * @cfg {Number} hideDelay Delay in milliseconds after the mouse exits the
  183. * target element but before the tooltip actually hides (defaults to 200).
  184. * Set to 0 for the tooltip to hide immediately.
  185. */
  186. hideDelay : 200,
  187. /**
  188. * @cfg {Number} dismissDelay Delay in milliseconds before the tooltip
  189. * automatically hides (defaults to 5000). To disable automatic hiding, set
  190. * dismissDelay = 0.
  191. */
  192. dismissDelay : 5000,
  193. /**
  194. * @cfg {Array} mouseOffset An XY offset from the mouse position where the
  195. * tooltip should be shown (defaults to [15,18]).
  196. */
  197. /**
  198. * @cfg {Boolean} trackMouse True to have the tooltip follow the mouse as it
  199. * moves over the target element (defaults to false).
  200. */
  201. trackMouse : false,
  202. /**
  203. * @cfg {Boolean} anchorToTarget True to anchor the tooltip to the target
  204. * element, false to anchor it relative to the mouse coordinates (defaults
  205. * to true). When <code>anchorToTarget</code> is true, use
  206. * <code>{@link #defaultAlign}</code> to control tooltip alignment to the
  207. * target element. When <code>anchorToTarget</code> is false, use
  208. * <code>{@link #anchorPosition}</code> instead to control alignment.
  209. */
  210. anchorToTarget : true,
  211. /**
  212. * @cfg {Number} anchorOffset A numeric pixel value used to offset the
  213. * default position of the anchor arrow (defaults to 0). When the anchor
  214. * position is on the top or bottom of the tooltip, <code>anchorOffset</code>
  215. * will be used as a horizontal offset. Likewise, when the anchor position
  216. * is on the left or right side, <code>anchorOffset</code> will be used as
  217. * a vertical offset.
  218. */
  219. anchorOffset : 0,
  220. /**
  221. * @cfg {String} delegate <p>Optional. A {@link Ext.DomQuery DomQuery}
  222. * selector which allows selection of individual elements within the
  223. * <code>{@link #target}</code> element to trigger showing and hiding the
  224. * ToolTip as the mouse moves within the target.</p>
  225. * <p>When specified, the child element of the target which caused a show
  226. * event is placed into the <code>{@link #triggerElement}</code> property
  227. * before the ToolTip is shown.</p>
  228. * <p>This may be useful when a Component has regular, repeating elements
  229. * in it, each of which need a Tooltip which contains information specific
  230. * to that element. For example:</p><pre><code>
  231. var myGrid = new Ext.grid.gridPanel(gridConfig);
  232. myGrid.on('render', function(grid) {
  233. var store = grid.getStore(); // Capture the Store.
  234. var view = grid.getView(); // Capture the GridView.
  235. myGrid.tip = new Ext.ToolTip({
  236. target: view.mainBody, // The overall target element.
  237. delegate: '.x-grid3-row', // Each grid row causes its own seperate show and hide.
  238. trackMouse: true, // Moving within the row should not hide the tip.
  239. renderTo: document.body, // Render immediately so that tip.body can be
  240. // referenced prior to the first show.
  241. listeners: { // Change content dynamically depending on which element
  242. // triggered the show.
  243. beforeshow: function updateTipBody(tip) {
  244. var rowIndex = view.findRowIndex(tip.triggerElement);
  245. tip.body.dom.innerHTML = 'Over Record ID ' + store.getAt(rowIndex).id;
  246. }
  247. }
  248. });
  249. });
  250. *</code></pre>
  251. */
  252. // private
  253. targetCounter : 0,
  254. constrainPosition : false,
  255. // private
  256. initComponent : function(){
  257. Ext.ToolTip.superclass.initComponent.call(this);
  258. this.lastActive = new Date();
  259. this.initTarget(this.target);
  260. this.origAnchor = this.anchor;
  261. },
  262. // private
  263. onRender : function(ct, position){
  264. Ext.ToolTip.superclass.onRender.call(this, ct, position);
  265. this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();
  266. this.anchorEl = this.el.createChild({
  267. cls: 'x-tip-anchor ' + this.anchorCls
  268. });
  269. },
  270. // private
  271. afterRender : function(){
  272. Ext.ToolTip.superclass.afterRender.call(this);
  273. this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1).setVisibilityMode(Ext.Element.DISPLAY);
  274. },
  275. /**
  276. * Binds this ToolTip to the specified element. The tooltip will be displayed when the mouse moves over the element.
  277. * @param {Mixed} t The Element, HtmlElement, or ID of an element to bind to
  278. */
  279. initTarget : function(target){
  280. var t;
  281. if((t = Ext.get(target))){
  282. if(this.target){
  283. var tg = Ext.get(this.target);
  284. this.mun(tg, 'mouseover', this.onTargetOver, this);
  285. this.mun(tg, 'mouseout', this.onTargetOut, this);
  286. this.mun(tg, 'mousemove', this.onMouseMove, this);
  287. }
  288. this.mon(t, {
  289. mouseover: this.onTargetOver,
  290. mouseout: this.onTargetOut,
  291. mousemove: this.onMouseMove,
  292. scope: this
  293. });
  294. this.target = t;
  295. }
  296. if(this.anchor){
  297. this.anchorTarget = this.target;
  298. }
  299. },
  300. // private
  301. onMouseMove : function(e){
  302. var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;
  303. if (t) {
  304. this.targetXY = e.getXY();
  305. if (t === this.triggerElement) {
  306. if(!this.hidden && this.trackMouse){
  307. this.setPagePosition(this.getTargetXY());
  308. }
  309. } else {
  310. this.hide();
  311. this.lastActive = new Date(0);
  312. this.onTargetOver(e);
  313. }
  314. } else if (!this.closable && this.isVisible()) {
  315. this.hide();
  316. }
  317. },
  318. // private
  319. getTargetXY : function(){
  320. if(this.delegate){
  321. this.anchorTarget = this.triggerElement;
  322. }
  323. if(this.anchor){
  324. this.targetCounter++;
  325. var offsets = this.getOffsets(),
  326. xy = (this.anchorToTarget && !this.trackMouse) ? this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) : this.targetXY,
  327. dw = Ext.lib.Dom.getViewWidth() - 5,
  328. dh = Ext.lib.Dom.getViewHeight() - 5,
  329. de = document.documentElement,
  330. bd = document.body,
  331. scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5,
  332. scrollY = (de.scrollTop || bd.scrollTop || 0) + 5,
  333. axy = [xy[0] + offsets[0], xy[1] + offsets[1]],
  334. sz = this.getSize();
  335. this.anchorEl.removeClass(this.anchorCls);
  336. if(this.targetCounter < 2){
  337. if(axy[0] < scrollX){
  338. if(this.anchorToTarget){
  339. this.defaultAlign = 'l-r';
  340. if(this.mouseOffset){this.mouseOffset[0] *= -1;}
  341. }
  342. this.anchor = 'left';
  343. return this.getTargetXY();
  344. }
  345. if(axy[0]+sz.width > dw){
  346. if(this.anchorToTarget){
  347. this.defaultAlign = 'r-l';
  348. if(this.mouseOffset){this.mouseOffset[0] *= -1;}
  349. }
  350. this.anchor = 'right';
  351. return this.getTargetXY();
  352. }
  353. if(axy[1] < scrollY){
  354. if(this.anchorToTarget){
  355. this.defaultAlign = 't-b';
  356. if(this.mouseOffset){this.mouseOffset[1] *= -1;}
  357. }
  358. this.anchor = 'top';
  359. return this.getTargetXY();
  360. }
  361. if(axy[1]+sz.height > dh){
  362. if(this.anchorToTarget){
  363. this.defaultAlign = 'b-t';
  364. if(this.mouseOffset){this.mouseOffset[1] *= -1;}
  365. }
  366. this.anchor = 'bottom';
  367. return this.getTargetXY();
  368. }
  369. }
  370. this.anchorCls = 'x-tip-anchor-'+this.getAnchorPosition();
  371. this.anchorEl.addClass(this.anchorCls);
  372. this.targetCounter = 0;
  373. return axy;
  374. }else{
  375. var mouseOffset = this.getMouseOffset();
  376. return [this.targetXY[0]+mouseOffset[0], this.targetXY[1]+mouseOffset[1]];
  377. }
  378. },
  379. getMouseOffset : function(){
  380. var offset = this.anchor ? [0,0] : [15,18];
  381. if(this.mouseOffset){
  382. offset[0] += this.mouseOffset[0];
  383. offset[1] += this.mouseOffset[1];
  384. }
  385. return offset;
  386. },
  387. // private
  388. getAnchorPosition : function(){
  389. if(this.anchor){
  390. this.tipAnchor = this.anchor.charAt(0);
  391. }else{
  392. var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);
  393. if(!m){
  394. throw 'AnchorTip.defaultAlign is invalid';
  395. }
  396. this.tipAnchor = m[1].charAt(0);
  397. }
  398. switch(this.tipAnchor){
  399. case 't': return 'top';
  400. case 'b': return 'bottom';
  401. case 'r': return 'right';
  402. }
  403. return 'left';
  404. },
  405. // private
  406. getAnchorAlign : function(){
  407. switch(this.anchor){
  408. case 'top' : return 'tl-bl';
  409. case 'left' : return 'tl-tr';
  410. case 'right': return 'tr-tl';
  411. default : return 'bl-tl';
  412. }
  413. },
  414. // private
  415. getOffsets : function(){
  416. var offsets,
  417. ap = this.getAnchorPosition().charAt(0);
  418. if(this.anchorToTarget && !this.trackMouse){
  419. switch(ap){
  420. case 't':
  421. offsets = [0, 9];
  422. break;
  423. case 'b':
  424. offsets = [0, -13];
  425. break;
  426. case 'r':
  427. offsets = [-13, 0];
  428. break;
  429. default:
  430. offsets = [9, 0];
  431. break;
  432. }
  433. }else{
  434. switch(ap){
  435. case 't':
  436. offsets = [-15-this.anchorOffset, 30];
  437. break;
  438. case 'b':
  439. offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];
  440. break;
  441. case 'r':
  442. offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];
  443. break;
  444. default:
  445. offsets = [25, -13-this.anchorOffset];
  446. break;
  447. }
  448. }
  449. var mouseOffset = this.getMouseOffset();
  450. offsets[0] += mouseOffset[0];
  451. offsets[1] += mouseOffset[1];
  452. return offsets;
  453. },
  454. // private
  455. onTargetOver : function(e){
  456. if(this.disabled || e.within(this.target.dom, true)){
  457. return;
  458. }
  459. var t = e.getTarget(this.delegate);
  460. if (t) {
  461. this.triggerElement = t;
  462. this.clearTimer('hide');
  463. this.targetXY = e.getXY();
  464. this.delayShow();
  465. }
  466. },
  467. // private
  468. delayShow : function(){
  469. if(this.hidden && !this.showTimer){
  470. if(this.lastActive.getElapsed() < this.quickShowInterval){
  471. this.show();
  472. }else{
  473. this.showTimer = this.show.defer(this.showDelay, this);
  474. }
  475. }else if(!this.hidden && this.autoHide !== false){
  476. this.show();
  477. }
  478. },
  479. // private
  480. onTargetOut : function(e){
  481. if(this.disabled || e.within(this.target.dom, true)){
  482. return;
  483. }
  484. this.clearTimer('show');
  485. if(this.autoHide !== false){
  486. this.delayHide();
  487. }
  488. },
  489. // private
  490. delayHide : function(){
  491. if(!this.hidden && !this.hideTimer){
  492. this.hideTimer = this.hide.defer(this.hideDelay, this);
  493. }
  494. },
  495. /**
  496. * Hides this tooltip if visible.
  497. */
  498. hide: function(){
  499. this.clearTimer('dismiss');
  500. this.lastActive = new Date();
  501. if(this.anchorEl){
  502. this.anchorEl.hide();
  503. }
  504. Ext.ToolTip.superclass.hide.call(this);
  505. delete this.triggerElement;
  506. },
  507. /**
  508. * Shows this tooltip at the current event target XY position.
  509. */
  510. show : function(){
  511. if(this.anchor){
  512. // pre-show it off screen so that the el will have dimensions
  513. // for positioning calcs when getting xy next
  514. this.showAt([-1000,-1000]);
  515. this.origConstrainPosition = this.constrainPosition;
  516. this.constrainPosition = false;
  517. this.anchor = this.origAnchor;
  518. }
  519. this.showAt(this.getTargetXY());
  520. if(this.anchor){
  521. this.anchorEl.show();
  522. this.syncAnchor();
  523. this.constrainPosition = this.origConstrainPosition;
  524. }else{
  525. this.anchorEl.hide();
  526. }
  527. },
  528. // inherit docs
  529. showAt : function(xy){
  530. this.lastActive = new Date();
  531. this.clearTimers();
  532. Ext.ToolTip.superclass.showAt.call(this, xy);
  533. if(this.dismissDelay && this.autoHide !== false){
  534. this.dismissTimer = this.hide.defer(this.dismissDelay, this);
  535. }
  536. if(this.anchor && !this.anchorEl.isVisible()){
  537. this.syncAnchor();
  538. this.anchorEl.show();
  539. }else{
  540. this.anchorEl.hide();
  541. }
  542. },
  543. // private
  544. syncAnchor : function(){
  545. var anchorPos, targetPos, offset;
  546. switch(this.tipAnchor.charAt(0)){
  547. case 't':
  548. anchorPos = 'b';
  549. targetPos = 'tl';
  550. offset = [20+this.anchorOffset, 2];
  551. break;
  552. case 'r':
  553. anchorPos = 'l';
  554. targetPos = 'tr';
  555. offset = [-2, 11+this.anchorOffset];
  556. break;
  557. case 'b':
  558. anchorPos = 't';
  559. targetPos = 'bl';
  560. offset = [20+this.anchorOffset, -2];
  561. break;
  562. default:
  563. anchorPos = 'r';
  564. targetPos = 'tl';
  565. offset = [2, 11+this.anchorOffset];
  566. break;
  567. }
  568. this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);
  569. },
  570. // private
  571. setPagePosition : function(x, y){
  572. Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
  573. if(this.anchor){
  574. this.syncAnchor();
  575. }
  576. },
  577. // private
  578. clearTimer : function(name){
  579. name = name + 'Timer';
  580. clearTimeout(this[name]);
  581. delete this[name];
  582. },
  583. // private
  584. clearTimers : function(){
  585. this.clearTimer('show');
  586. this.clearTimer('dismiss');
  587. this.clearTimer('hide');
  588. },
  589. // private
  590. onShow : function(){
  591. Ext.ToolTip.superclass.onShow.call(this);
  592. Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
  593. },
  594. // private
  595. onHide : function(){
  596. Ext.ToolTip.superclass.onHide.call(this);
  597. Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
  598. },
  599. // private
  600. onDocMouseDown : function(e){
  601. if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){
  602. this.disable();
  603. this.doEnable.defer(100, this);
  604. }
  605. },
  606. // private
  607. doEnable : function(){
  608. if(!this.isDestroyed){
  609. this.enable();
  610. }
  611. },
  612. // private
  613. onDisable : function(){
  614. this.clearTimers();
  615. this.hide();
  616. },
  617. // private
  618. adjustPosition : function(x, y){
  619. if(this.contstrainPosition){
  620. var ay = this.targetXY[1], h = this.getSize().height;
  621. if(y <= ay && (y+h) >= ay){
  622. y = ay-h-5;
  623. }
  624. }
  625. return {x : x, y: y};
  626. },
  627. beforeDestroy : function(){
  628. this.clearTimers();
  629. Ext.destroy(this.anchorEl);
  630. delete this.anchorEl;
  631. delete this.target;
  632. delete this.anchorTarget;
  633. delete this.triggerElement;
  634. Ext.ToolTip.superclass.beforeDestroy.call(this);
  635. },
  636. // private
  637. onDestroy : function(){
  638. Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
  639. Ext.ToolTip.superclass.onDestroy.call(this);
  640. }
  641. });
  642. Ext.reg('tooltip', Ext.ToolTip);/**
  643. * @class Ext.QuickTip
  644. * @extends Ext.ToolTip
  645. * @xtype quicktip
  646. * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
  647. * {@link Ext.QuickTips} instance. See the QuickTips class header for additional usage details and examples.
  648. * @constructor
  649. * Create a new Tip
  650. * @param {Object} config The configuration options
  651. */
  652. Ext.QuickTip = Ext.extend(Ext.ToolTip, {
  653. /**
  654. * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this quicktip (defaults to the document).
  655. */
  656. /**
  657. * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
  658. */
  659. interceptTitles : false,
  660. // private
  661. tagConfig : {
  662. namespace : "ext",
  663. attribute : "qtip",
  664. width : "qwidth",
  665. target : "target",
  666. title : "qtitle",
  667. hide : "hide",
  668. cls : "qclass",
  669. align : "qalign",
  670. anchor : "anchor"
  671. },
  672. // private
  673. initComponent : function(){
  674. this.target = this.target || Ext.getDoc();
  675. this.targets = this.targets || {};
  676. Ext.QuickTip.superclass.initComponent.call(this);
  677. },
  678. /**
  679. * Configures a new quick tip instance and assigns it to a target element. The following config values are
  680. * supported (for example usage, see the {@link Ext.QuickTips} class header):
  681. * <div class="mdetail-params"><ul>
  682. * <li>autoHide</li>
  683. * <li>cls</li>
  684. * <li>dismissDelay (overrides the singleton value)</li>
  685. * <li>target (required)</li>
  686. * <li>text (required)</li>
  687. * <li>title</li>
  688. * <li>width</li></ul></div>
  689. * @param {Object} config The config object
  690. */
  691. register : function(config){
  692. var cs = Ext.isArray(config) ? config : arguments;
  693. for(var i = 0, len = cs.length; i < len; i++){
  694. var c = cs[i];
  695. var target = c.target;
  696. if(target){
  697. if(Ext.isArray(target)){
  698. for(var j = 0, jlen = target.length; j < jlen; j++){
  699. this.targets[Ext.id(target[j])] = c;
  700. }
  701. } else{
  702. this.targets[Ext.id(target)] = c;
  703. }
  704. }
  705. }
  706. },
  707. /**
  708. * Removes this quick tip from its element and destroys it.
  709. * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
  710. */
  711. unregister : function(el){
  712. delete this.targets[Ext.id(el)];
  713. },
  714. /**
  715. * Hides a visible tip or cancels an impending show for a particular element.
  716. * @param {String/HTMLElement/Element} el The element that is the target of the tip.
  717. */
  718. cancelShow: function(el){
  719. var at = this.activeTarget;
  720. el = Ext.get(el).dom;
  721. if(this.isVisible()){
  722. if(at && at.el == el){
  723. this.hide();
  724. }
  725. }else if(at && at.el == el){
  726. this.clearTimer('show');
  727. }
  728. },
  729. getTipCfg: function(e) {
  730. var t = e.getTarget(),
  731. ttp,
  732. cfg;
  733. if(this.interceptTitles && t.title && Ext.isString(t.title)){
  734. ttp = t.title;
  735. t.qtip = ttp;
  736. t.removeAttribute("title");
  737. e.preventDefault();
  738. }else{
  739. cfg = this.tagConfig;
  740. ttp = t.qtip || Ext.fly(t).getAttribute(cfg.attribute, cfg.namespace);
  741. }
  742. return ttp;
  743. },
  744. // private
  745. onTargetOver : function(e){
  746. if(this.disabled){
  747. return;
  748. }
  749. this.targetXY = e.getXY();
  750. var t = e.getTarget();
  751. if(!t || t.nodeType !== 1 || t == document || t == document.body){
  752. return;
  753. }
  754. if(this.activeTarget && ((t == this.activeTarget.el) || Ext.fly(this.activeTarget.el).contains(t))){
  755. this.clearTimer('hide');
  756. this.show();
  757. return;
  758. }
  759. if(t && this.targets[t.id]){
  760. this.activeTarget = this.targets[t.id];
  761. this.activeTarget.el = t;
  762. this.anchor = this.activeTarget.anchor;
  763. if(this.anchor){
  764. this.anchorTarget = t;
  765. }
  766. this.delayShow();
  767. return;
  768. }
  769. var ttp, et = Ext.fly(t), cfg = this.tagConfig, ns = cfg.namespace;
  770. if(ttp = this.getTipCfg(e)){
  771. var autoHide = et.getAttribute(cfg.hide, ns);
  772. this.activeTarget = {
  773. el: t,
  774. text: ttp,
  775. width: et.getAttribute(cfg.width, ns),
  776. autoHide: autoHide != "user" && autoHide !== 'false',
  777. title: et.getAttribute(cfg.title, ns),
  778. cls: et.getAttribute(cfg.cls, ns),
  779. align: et.getAttribute(cfg.align, ns)
  780. };
  781. this.anchor = et.getAttribute(cfg.anchor, ns);
  782. if(this.anchor){
  783. this.anchorTarget = t;
  784. }
  785. this.delayShow();
  786. }
  787. },
  788. // private
  789. onTargetOut : function(e){
  790. // If moving within the current target, and it does not have a new tip, ignore the mouseout
  791. if (this.activeTarget && e.within(this.activeTarget.el) && !this.getTipCfg(e)) {
  792. return;
  793. }
  794. this.clearTimer('show');
  795. if(this.autoHide !== false){
  796. this.delayHide();
  797. }
  798. },
  799. // inherit docs
  800. showAt : function(xy){
  801. var t = this.activeTarget;
  802. if(t){
  803. if(!this.rendered){
  804. this.render(Ext.getBody());
  805. this.activeTarget = t;
  806. }
  807. if(t.width){
  808. this.setWidth(t.width);
  809. this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
  810. this.measureWidth = false;
  811. } else{
  812. this.measureWidth = true;
  813. }
  814. this.setTitle(t.title || '');
  815. this.body.update(t.text);
  816. this.autoHide = t.autoHide;
  817. this.dismissDelay = t.dismissDelay || this.dismissDelay;
  818. if(this.lastCls){
  819. this.el.removeClass(this.lastCls);
  820. delete this.lastCls;
  821. }
  822. if(t.cls){
  823. this.el.addClass(t.cls);
  824. this.lastCls = t.cls;
  825. }
  826. if(this.anchor){
  827. this.constrainPosition = false;
  828. }else if(t.align){ // TODO: this doesn't seem to work consistently
  829. xy = this.el.getAlignToXY(t.el, t.align);
  830. this.constrainPosition = false;
  831. }else{
  832. this.constrainPosition = true;
  833. }
  834. }
  835. Ext.QuickTip.superclass.showAt.call(this, xy);
  836. },
  837. // inherit docs
  838. hide: function(){
  839. delete this.activeTarget;
  840. Ext.QuickTip.superclass.hide.call(this);
  841. }
  842. });
  843. Ext.reg('quicktip', Ext.QuickTip);/**
  844. * @class Ext.QuickTips
  845. * <p>Provides attractive and customizable tooltips for any element. The QuickTips
  846. * singleton is used to configure and manage tooltips globally for multiple elements
  847. * in a generic manner. To create individual tooltips with maximum customizability,
  848. * you should consider either {@link Ext.Tip} or {@link Ext.ToolTip}.</p>
  849. * <p>Quicktips can be configured via tag attributes directly in markup, or by
  850. * registering quick tips programmatically via the {@link #register} method.</p>
  851. * <p>The singleton's instance of {@link Ext.QuickTip} is available via
  852. * {@link #getQuickTip}, and supports all the methods, and all the all the
  853. * configuration properties of Ext.QuickTip. These settings will apply to all
  854. * tooltips shown by the singleton.</p>
  855. * <p>Below is the summary of the configuration properties which can be used.
  856. * For detailed descriptions see the config options for the {@link Ext.QuickTip QuickTip} class</p>
  857. * <p><b>QuickTips singleton configs (all are optional)</b></p>
  858. * <div class="mdetail-params"><ul><li>dismissDelay</li>
  859. * <li>hideDelay</li>
  860. * <li>maxWidth</li>
  861. * <li>minWidth</li>
  862. * <li>showDelay</li>
  863. * <li>trackMouse</li></ul></div>
  864. * <p><b>Target element configs (optional unless otherwise noted)</b></p>
  865. * <div class="mdetail-params"><ul><li>autoHide</li>
  866. * <li>cls</li>
  867. * <li>dismissDelay (overrides singleton value)</li>
  868. * <li>target (required)</li>
  869. * <li>text (required)</li>
  870. * <li>title</li>
  871. * <li>width</li></ul></div>
  872. * <p>Here is an example showing how some of these config options could be used:</p>
  873. * <pre><code>
  874. // Init the singleton. Any tag-based quick tips will start working.
  875. Ext.QuickTips.init();
  876. // Apply a set of config properties to the singleton
  877. Ext.apply(Ext.QuickTips.getQuickTip(), {
  878. maxWidth: 200,
  879. minWidth: 100,
  880. showDelay: 50, // Show 50ms after entering target
  881. trackMouse: true
  882. });
  883. // Manually register a quick tip for a specific element
  884. Ext.QuickTips.register({
  885. target: 'my-div',
  886. title: 'My Tooltip',
  887. text: 'This tooltip was added in code',
  888. width: 100,
  889. dismissDelay: 10000 // Hide after 10 seconds hover
  890. });
  891. </code></pre>
  892. * <p>To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with
  893. * the <b>ext:</b> namespace. The HTML element itself is automatically set as the quick tip target. Here is the summary
  894. * of supported attributes (optional unless otherwise noted):</p>
  895. * <ul><li><b>hide</b>: Specifying "user" is equivalent to setting autoHide = false. Any other value will be the
  896. * same as autoHide = true.</li>
  897. * <li><b>qclass</b>: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).</li>
  898. * <li><b>qtip (required)</b>: The quick tip text (equivalent to the 'text' target element config).</li>
  899. * <li><b>qtitle</b>: The quick tip title (equivalent to the 'title' target element config).</li>
  900. * <li><b>qwidth</b>: The quick tip width (equivalent to the 'width' target element config).</li></ul>
  901. * <p>Here is an example of configuring an HTML element to display a tooltip from markup:</p>
  902. * <pre><code>
  903. // Add a quick tip to an HTML button
  904. &lt;input type="button" value="OK" ext:qtitle="OK Button" ext:qwidth="100"
  905. ext:qtip="This is a quick tip from markup!">&lt;/input>
  906. </code></pre>
  907. * @singleton
  908. */
  909. Ext.QuickTips = function(){
  910. var tip,
  911. disabled = false;
  912. return {
  913. /**
  914. * Initialize the global QuickTips instance and prepare any quick tips.
  915. * @param {Boolean} autoRender True to render the QuickTips container immediately to preload images. (Defaults to true)
  916. */
  917. init : function(autoRender){
  918. if(!tip){
  919. if(!Ext.isReady){
  920. Ext.onReady(function(){
  921. Ext.QuickTips.init(autoRender);
  922. });
  923. return;
  924. }
  925. tip = new Ext.QuickTip({
  926. elements:'header,body',
  927. disabled: disabled
  928. });
  929. if(autoRender !== false){
  930. tip.render(Ext.getBody());
  931. }
  932. }
  933. },
  934. // Protected method called by the dd classes
  935. ddDisable : function(){
  936. // don't disable it if we don't need to
  937. if(tip && !disabled){
  938. tip.disable();
  939. }
  940. },
  941. // Protected method called by the dd classes
  942. ddEnable : function(){
  943. // only enable it if it hasn't been disabled
  944. if(tip && !disabled){
  945. tip.enable();
  946. }
  947. },
  948. /**
  949. * Enable quick tips globally.
  950. */
  951. enable : function(){
  952. if(tip){
  953. tip.enable();
  954. }
  955. disabled = false;
  956. },
  957. /**
  958. * Disable quick tips globally.
  959. */
  960. disable : function(){
  961. if(tip){
  962. tip.disable();
  963. }
  964. disabled = true;
  965. },
  966. /**
  967. * Returns true if quick tips are enabled, else false.
  968. * @return {Boolean}
  969. */
  970. isEnabled : function(){
  971. return tip !== undefined && !tip.disabled;
  972. },
  973. /**
  974. * Gets the single {@link Ext.QuickTip QuickTip} instance used to show tips from all registered elements.
  975. * @return {Ext.QuickTip}
  976. */
  977. getQuickTip : function(){
  978. return tip;
  979. },
  980. /**
  981. * Configures a new quick tip instance and assigns it to a target element. See
  982. * {@link Ext.QuickTip#register} for details.
  983. * @param {Object} config The config object
  984. */
  985. register : function(){
  986. tip.register.apply(tip, arguments);
  987. },
  988. /**
  989. * Removes any registered quick tip from the target element and destroys it.
  990. * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
  991. */
  992. unregister : function(){
  993. tip.unregister.apply(tip, arguments);
  994. },
  995. /**
  996. * Alias of {@link #register}.
  997. * @param {Object} config The config object
  998. */
  999. tips : function(){
  1000. tip.register.apply(tip, arguments);
  1001. }
  1002. };
  1003. }();/**
  1004. * @class Ext.slider.Tip
  1005. * @extends Ext.Tip
  1006. * Simple plugin for using an Ext.Tip with a slider to show the slider value. Example usage:
  1007. <pre>
  1008. new Ext.Slider({
  1009. width: 214,
  1010. minValue: 0,
  1011. maxValue: 100,
  1012. plugins: new Ext.slider.Tip()
  1013. });
  1014. </pre>
  1015. * Optionally provide your own tip text by overriding getText:
  1016. <pre>
  1017. new Ext.Slider({
  1018. width: 214,
  1019. minValue: 0,
  1020. maxValue: 100,
  1021. plugins: new Ext.slider.Tip({
  1022. getText: function(thumb){
  1023. return String.format('<b>{0}% complete</b>', thumb.value);
  1024. }
  1025. })
  1026. });
  1027. </pre>
  1028. */
  1029. Ext.slider.Tip = Ext.extend(Ext.Tip, {
  1030. minWidth: 10,
  1031. offsets : [0, -10],
  1032. init: function(slider) {
  1033. slider.on({
  1034. scope : this,
  1035. dragstart: this.onSlide,
  1036. drag : this.onSlide,
  1037. dragend : this.hide,
  1038. destroy : this.destroy
  1039. });
  1040. },
  1041. /**
  1042. * @private
  1043. * Called whenever a dragstart or drag event is received on the associated Thumb.
  1044. * Aligns the Tip with the Thumb's new position.
  1045. * @param {Ext.slider.MultiSlider} slider The slider
  1046. * @param {Ext.EventObject} e The Event object
  1047. * @param {Ext.slider.Thumb} thumb The thumb that the Tip is attached to
  1048. */
  1049. onSlide : function(slider, e, thumb) {
  1050. this.show();
  1051. this.body.update(this.getText(thumb));
  1052. this.doAutoWidth();
  1053. this.el.alignTo(thumb.el, 'b-t?', this.offsets);
  1054. },
  1055. /**
  1056. * Used to create the text that appears in the Tip's body. By default this just returns
  1057. * the value of the Slider Thumb that the Tip is attached to. Override to customize.
  1058. * @param {Ext.slider.Thumb} thumb The Thumb that the Tip is attached to
  1059. * @return {String} The text to display in the tip
  1060. */
  1061. getText : function(thumb) {
  1062. return String(thumb.value);
  1063. }
  1064. });
  1065. //backwards compatibility - SliderTip used to be a ux before 3.2
  1066. Ext.ux.SliderTip = Ext.slider.Tip;