Web UI for ARGUS server
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.

516 lines
17 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.layout.boxOverflow.Scroller"></div>/**
  16. * @class Ext.layout.boxOverflow.Scroller
  17. * @extends Ext.layout.boxOverflow.None
  18. * Description
  19. */
  20. Ext.layout.boxOverflow.Scroller = Ext.extend(Ext.layout.boxOverflow.None, {
  21. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  22. * @cfg animateScroll
  23. * @type Boolean
  24. * True to animate the scrolling of items within the layout (defaults to true, ignored if enableScroll is false)
  25. */
  26. animateScroll: true,
  27. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  28. * @cfg scrollIncrement
  29. * @type Number
  30. * The number of pixels to scroll by on scroller click (defaults to 100)
  31. */
  32. scrollIncrement: 100,
  33. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  34. * @cfg wheelIncrement
  35. * @type Number
  36. * The number of pixels to increment on mouse wheel scrolling (defaults to <tt>3</tt>).
  37. */
  38. wheelIncrement: 3,
  39. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  40. * @cfg scrollRepeatInterval
  41. * @type Number
  42. * Number of milliseconds between each scroll while a scroller button is held down (defaults to 400)
  43. */
  44. scrollRepeatInterval: 400,
  45. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  46. * @cfg scrollDuration
  47. * @type Number
  48. * Number of seconds that each scroll animation lasts (defaults to 0.4)
  49. */
  50. scrollDuration: 0.4,
  51. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  52. * @cfg beforeCls
  53. * @type String
  54. * CSS class added to the beforeCt element. This is the element that holds any special items such as scrollers,
  55. * which must always be present at the leftmost edge of the Container
  56. */
  57. beforeCls: 'x-strip-left',
  58. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  59. * @cfg afterCls
  60. * @type String
  61. * CSS class added to the afterCt element. This is the element that holds any special items such as scrollers,
  62. * which must always be present at the rightmost edge of the Container
  63. */
  64. afterCls: 'x-strip-right',
  65. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  66. * @cfg scrollerCls
  67. * @type String
  68. * CSS class added to both scroller elements if enableScroll is used
  69. */
  70. scrollerCls: 'x-strip-scroller',
  71. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  72. * @cfg beforeScrollerCls
  73. * @type String
  74. * CSS class added to the left scroller element if enableScroll is used
  75. */
  76. beforeScrollerCls: 'x-strip-scroller-left',
  77. <div id="cfg-Ext.layout.boxOverflow.Scroller-null"></div>/**
  78. * @cfg afterScrollerCls
  79. * @type String
  80. * CSS class added to the right scroller element if enableScroll is used
  81. */
  82. afterScrollerCls: 'x-strip-scroller-right',
  83. /**
  84. * @private
  85. * Sets up an listener to scroll on the layout's innerCt mousewheel event
  86. */
  87. createWheelListener: function() {
  88. this.layout.innerCt.on({
  89. scope : this,
  90. mousewheel: function(e) {
  91. e.stopEvent();
  92. this.scrollBy(e.getWheelDelta() * this.wheelIncrement * -1, false);
  93. }
  94. });
  95. },
  96. /**
  97. * @private
  98. * Most of the heavy lifting is done in the subclasses
  99. */
  100. handleOverflow: function(calculations, targetSize) {
  101. this.createInnerElements();
  102. this.showScrollers();
  103. },
  104. /**
  105. * @private
  106. */
  107. clearOverflow: function() {
  108. this.hideScrollers();
  109. },
  110. /**
  111. * @private
  112. * Shows the scroller elements in the beforeCt and afterCt. Creates the scrollers first if they are not already
  113. * present.
  114. */
  115. showScrollers: function() {
  116. this.createScrollers();
  117. this.beforeScroller.show();
  118. this.afterScroller.show();
  119. this.updateScrollButtons();
  120. },
  121. /**
  122. * @private
  123. * Hides the scroller elements in the beforeCt and afterCt
  124. */
  125. hideScrollers: function() {
  126. if (this.beforeScroller != undefined) {
  127. this.beforeScroller.hide();
  128. this.afterScroller.hide();
  129. }
  130. },
  131. /**
  132. * @private
  133. * Creates the clickable scroller elements and places them into the beforeCt and afterCt
  134. */
  135. createScrollers: function() {
  136. if (!this.beforeScroller && !this.afterScroller) {
  137. var before = this.beforeCt.createChild({
  138. cls: String.format("{0} {1} ", this.scrollerCls, this.beforeScrollerCls)
  139. });
  140. var after = this.afterCt.createChild({
  141. cls: String.format("{0} {1}", this.scrollerCls, this.afterScrollerCls)
  142. });
  143. before.addClassOnOver(this.beforeScrollerCls + '-hover');
  144. after.addClassOnOver(this.afterScrollerCls + '-hover');
  145. before.setVisibilityMode(Ext.Element.DISPLAY);
  146. after.setVisibilityMode(Ext.Element.DISPLAY);
  147. this.beforeRepeater = new Ext.util.ClickRepeater(before, {
  148. interval: this.scrollRepeatInterval,
  149. handler : this.scrollLeft,
  150. scope : this
  151. });
  152. this.afterRepeater = new Ext.util.ClickRepeater(after, {
  153. interval: this.scrollRepeatInterval,
  154. handler : this.scrollRight,
  155. scope : this
  156. });
  157. <div id="prop-Ext.layout.boxOverflow.Scroller-beforeScroller"></div>/**
  158. * @property beforeScroller
  159. * @type Ext.Element
  160. * The left scroller element. Only created when needed.
  161. */
  162. this.beforeScroller = before;
  163. <div id="prop-Ext.layout.boxOverflow.Scroller-afterScroller"></div>/**
  164. * @property afterScroller
  165. * @type Ext.Element
  166. * The left scroller element. Only created when needed.
  167. */
  168. this.afterScroller = after;
  169. }
  170. },
  171. /**
  172. * @private
  173. */
  174. destroy: function() {
  175. Ext.destroy(this.beforeScroller, this.afterScroller, this.beforeRepeater, this.afterRepeater, this.beforeCt, this.afterCt);
  176. },
  177. /**
  178. * @private
  179. * Scrolls left or right by the number of pixels specified
  180. * @param {Number} delta Number of pixels to scroll to the right by. Use a negative number to scroll left
  181. */
  182. scrollBy: function(delta, animate) {
  183. this.scrollTo(this.getScrollPosition() + delta, animate);
  184. },
  185. /**
  186. * @private
  187. * Normalizes an item reference, string id or numerical index into a reference to the item
  188. * @param {Ext.Component|String|Number} item The item reference, id or index
  189. * @return {Ext.Component} The item
  190. */
  191. getItem: function(item) {
  192. if (Ext.isString(item)) {
  193. item = Ext.getCmp(item);
  194. } else if (Ext.isNumber(item)) {
  195. item = this.items[item];
  196. }
  197. return item;
  198. },
  199. /**
  200. * @private
  201. * @return {Object} Object passed to scrollTo when scrolling
  202. */
  203. getScrollAnim: function() {
  204. return {
  205. duration: this.scrollDuration,
  206. callback: this.updateScrollButtons,
  207. scope : this
  208. };
  209. },
  210. /**
  211. * @private
  212. * Enables or disables each scroller button based on the current scroll position
  213. */
  214. updateScrollButtons: function() {
  215. if (this.beforeScroller == undefined || this.afterScroller == undefined) {
  216. return;
  217. }
  218. var beforeMeth = this.atExtremeBefore() ? 'addClass' : 'removeClass',
  219. afterMeth = this.atExtremeAfter() ? 'addClass' : 'removeClass',
  220. beforeCls = this.beforeScrollerCls + '-disabled',
  221. afterCls = this.afterScrollerCls + '-disabled';
  222. this.beforeScroller[beforeMeth](beforeCls);
  223. this.afterScroller[afterMeth](afterCls);
  224. this.scrolling = false;
  225. },
  226. /**
  227. * @private
  228. * Returns true if the innerCt scroll is already at its left-most point
  229. * @return {Boolean} True if already at furthest left point
  230. */
  231. atExtremeBefore: function() {
  232. return this.getScrollPosition() === 0;
  233. },
  234. /**
  235. * @private
  236. * Scrolls to the left by the configured amount
  237. */
  238. scrollLeft: function(animate) {
  239. this.scrollBy(-this.scrollIncrement, animate);
  240. },
  241. /**
  242. * @private
  243. * Scrolls to the right by the configured amount
  244. */
  245. scrollRight: function(animate) {
  246. this.scrollBy(this.scrollIncrement, animate);
  247. },
  248. <div id="method-Ext.layout.boxOverflow.Scroller-scrollToItem"></div>/**
  249. * Scrolls to the given component.
  250. * @param {String|Number|Ext.Component} item The item to scroll to. Can be a numerical index, component id
  251. * or a reference to the component itself.
  252. * @param {Boolean} animate True to animate the scrolling
  253. */
  254. scrollToItem: function(item, animate) {
  255. item = this.getItem(item);
  256. if (item != undefined) {
  257. var visibility = this.getItemVisibility(item);
  258. if (!visibility.fullyVisible) {
  259. var box = item.getBox(true, true),
  260. newX = box.x;
  261. if (visibility.hiddenRight) {
  262. newX -= (this.layout.innerCt.getWidth() - box.width);
  263. }
  264. this.scrollTo(newX, animate);
  265. }
  266. }
  267. },
  268. /**
  269. * @private
  270. * For a given item in the container, return an object with information on whether the item is visible
  271. * with the current innerCt scroll value.
  272. * @param {Ext.Component} item The item
  273. * @return {Object} Values for fullyVisible, hiddenLeft and hiddenRight
  274. */
  275. getItemVisibility: function(item) {
  276. var box = this.getItem(item).getBox(true, true),
  277. itemLeft = box.x,
  278. itemRight = box.x + box.width,
  279. scrollLeft = this.getScrollPosition(),
  280. scrollRight = this.layout.innerCt.getWidth() + scrollLeft;
  281. return {
  282. hiddenLeft : itemLeft < scrollLeft,
  283. hiddenRight : itemRight > scrollRight,
  284. fullyVisible: itemLeft > scrollLeft && itemRight < scrollRight
  285. };
  286. }
  287. });
  288. Ext.layout.boxOverflow.scroller = Ext.layout.boxOverflow.Scroller;
  289. <div id="cls-Ext.layout.boxOverflow.VerticalScroller"></div>/**
  290. * @class Ext.layout.boxOverflow.VerticalScroller
  291. * @extends Ext.layout.boxOverflow.Scroller
  292. * Description
  293. */
  294. Ext.layout.boxOverflow.VerticalScroller = Ext.extend(Ext.layout.boxOverflow.Scroller, {
  295. scrollIncrement: 75,
  296. wheelIncrement : 2,
  297. handleOverflow: function(calculations, targetSize) {
  298. Ext.layout.boxOverflow.VerticalScroller.superclass.handleOverflow.apply(this, arguments);
  299. return {
  300. targetSize: {
  301. height: targetSize.height - (this.beforeCt.getHeight() + this.afterCt.getHeight()),
  302. width : targetSize.width
  303. }
  304. };
  305. },
  306. /**
  307. * @private
  308. * Creates the beforeCt and afterCt elements if they have not already been created
  309. */
  310. createInnerElements: function() {
  311. var target = this.layout.innerCt;
  312. //normal items will be rendered to the innerCt. beforeCt and afterCt allow for fixed positioning of
  313. //special items such as scrollers or dropdown menu triggers
  314. if (!this.beforeCt) {
  315. this.beforeCt = target.insertSibling({cls: this.beforeCls}, 'before');
  316. this.afterCt = target.insertSibling({cls: this.afterCls}, 'after');
  317. this.createWheelListener();
  318. }
  319. },
  320. /**
  321. * @private
  322. * Scrolls to the given position. Performs bounds checking.
  323. * @param {Number} position The position to scroll to. This is constrained.
  324. * @param {Boolean} animate True to animate. If undefined, falls back to value of this.animateScroll
  325. */
  326. scrollTo: function(position, animate) {
  327. var oldPosition = this.getScrollPosition(),
  328. newPosition = position.constrain(0, this.getMaxScrollBottom());
  329. if (newPosition != oldPosition && !this.scrolling) {
  330. if (animate == undefined) {
  331. animate = this.animateScroll;
  332. }
  333. this.layout.innerCt.scrollTo('top', newPosition, animate ? this.getScrollAnim() : false);
  334. if (animate) {
  335. this.scrolling = true;
  336. } else {
  337. this.scrolling = false;
  338. this.updateScrollButtons();
  339. }
  340. }
  341. },
  342. <div id="method-Ext.layout.boxOverflow.VerticalScroller-getScrollPosition"></div>/**
  343. * Returns the current scroll position of the innerCt element
  344. * @return {Number} The current scroll position
  345. */
  346. getScrollPosition: function(){
  347. return parseInt(this.layout.innerCt.dom.scrollTop, 10) || 0;
  348. },
  349. /**
  350. * @private
  351. * Returns the maximum value we can scrollTo
  352. * @return {Number} The max scroll value
  353. */
  354. getMaxScrollBottom: function() {
  355. return this.layout.innerCt.dom.scrollHeight - this.layout.innerCt.getHeight();
  356. },
  357. /**
  358. * @private
  359. * Returns true if the innerCt scroll is already at its right-most point
  360. * @return {Boolean} True if already at furthest right point
  361. */
  362. atExtremeAfter: function() {
  363. return this.getScrollPosition() >= this.getMaxScrollBottom();
  364. }
  365. });
  366. Ext.layout.boxOverflow.scroller.vbox = Ext.layout.boxOverflow.VerticalScroller;
  367. <div id="cls-Ext.layout.boxOverflow.HorizontalScroller"></div>/**
  368. * @class Ext.layout.boxOverflow.HorizontalScroller
  369. * @extends Ext.layout.boxOverflow.Scroller
  370. * Description
  371. */
  372. Ext.layout.boxOverflow.HorizontalScroller = Ext.extend(Ext.layout.boxOverflow.Scroller, {
  373. handleOverflow: function(calculations, targetSize) {
  374. Ext.layout.boxOverflow.HorizontalScroller.superclass.handleOverflow.apply(this, arguments);
  375. return {
  376. targetSize: {
  377. height: targetSize.height,
  378. width : targetSize.width - (this.beforeCt.getWidth() + this.afterCt.getWidth())
  379. }
  380. };
  381. },
  382. /**
  383. * @private
  384. * Creates the beforeCt and afterCt elements if they have not already been created
  385. */
  386. createInnerElements: function() {
  387. var target = this.layout.innerCt;
  388. //normal items will be rendered to the innerCt. beforeCt and afterCt allow for fixed positioning of
  389. //special items such as scrollers or dropdown menu triggers
  390. if (!this.beforeCt) {
  391. this.afterCt = target.insertSibling({cls: this.afterCls}, 'before');
  392. this.beforeCt = target.insertSibling({cls: this.beforeCls}, 'before');
  393. this.createWheelListener();
  394. }
  395. },
  396. /**
  397. * @private
  398. * Scrolls to the given position. Performs bounds checking.
  399. * @param {Number} position The position to scroll to. This is constrained.
  400. * @param {Boolean} animate True to animate. If undefined, falls back to value of this.animateScroll
  401. */
  402. scrollTo: function(position, animate) {
  403. var oldPosition = this.getScrollPosition(),
  404. newPosition = position.constrain(0, this.getMaxScrollRight());
  405. if (newPosition != oldPosition && !this.scrolling) {
  406. if (animate == undefined) {
  407. animate = this.animateScroll;
  408. }
  409. this.layout.innerCt.scrollTo('left', newPosition, animate ? this.getScrollAnim() : false);
  410. if (animate) {
  411. this.scrolling = true;
  412. } else {
  413. this.scrolling = false;
  414. this.updateScrollButtons();
  415. }
  416. }
  417. },
  418. <div id="method-Ext.layout.boxOverflow.HorizontalScroller-getScrollPosition"></div>/**
  419. * Returns the current scroll position of the innerCt element
  420. * @return {Number} The current scroll position
  421. */
  422. getScrollPosition: function(){
  423. return parseInt(this.layout.innerCt.dom.scrollLeft, 10) || 0;
  424. },
  425. /**
  426. * @private
  427. * Returns the maximum value we can scrollTo
  428. * @return {Number} The max scroll value
  429. */
  430. getMaxScrollRight: function() {
  431. return this.layout.innerCt.dom.scrollWidth - this.layout.innerCt.getWidth();
  432. },
  433. /**
  434. * @private
  435. * Returns true if the innerCt scroll is already at its right-most point
  436. * @return {Boolean} True if already at furthest right point
  437. */
  438. atExtremeAfter: function() {
  439. return this.getScrollPosition() >= this.getMaxScrollRight();
  440. }
  441. });
  442. Ext.layout.boxOverflow.scroller.hbox = Ext.layout.boxOverflow.HorizontalScroller;</pre>
  443. </body>
  444. </html>