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.

224 lines
7.9 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.dd.ScrollManager"></div>/**
  16. * @class Ext.dd.ScrollManager
  17. * <p>Provides automatic scrolling of overflow regions in the page during drag operations.</p>
  18. * <p>The ScrollManager configs will be used as the defaults for any scroll container registered with it,
  19. * but you can also override most of the configs per scroll container by adding a
  20. * <tt>ddScrollConfig</tt> object to the target element that contains these properties: {@link #hthresh},
  21. * {@link #vthresh}, {@link #increment} and {@link #frequency}. Example usage:
  22. * <pre><code>
  23. var el = Ext.get('scroll-ct');
  24. el.ddScrollConfig = {
  25. vthresh: 50,
  26. hthresh: -1,
  27. frequency: 100,
  28. increment: 200
  29. };
  30. Ext.dd.ScrollManager.register(el);
  31. </code></pre>
  32. * <b>Note: This class uses "Point Mode" and is untested in "Intersect Mode".</b>
  33. * @singleton
  34. */
  35. Ext.dd.ScrollManager = function() {
  36. var ddm = Ext.dd.DragDropMgr,
  37. els = {},
  38. dragEl = null,
  39. proc = {},
  40. onStop = function(e) {
  41. dragEl = null;
  42. clearProc();
  43. },
  44. triggerRefresh = function() {
  45. if (ddm.dragCurrent) {
  46. ddm.refreshCache(ddm.dragCurrent.groups);
  47. }
  48. },
  49. doScroll = function() {
  50. if (ddm.dragCurrent) {
  51. var dds = Ext.dd.ScrollManager,
  52. inc = proc.el.ddScrollConfig ? proc.el.ddScrollConfig.increment: dds.increment;
  53. if (!dds.animate) {
  54. if (proc.el.scroll(proc.dir, inc)) {
  55. triggerRefresh();
  56. }
  57. } else {
  58. proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
  59. }
  60. }
  61. },
  62. clearProc = function() {
  63. if (proc.id) {
  64. clearInterval(proc.id);
  65. }
  66. proc.id = 0;
  67. proc.el = null;
  68. proc.dir = "";
  69. },
  70. startProc = function(el, dir) {
  71. clearProc();
  72. proc.el = el;
  73. proc.dir = dir;
  74. var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ?
  75. el.ddScrollConfig.frequency: Ext.dd.ScrollManager.frequency,
  76. group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup: undefined;
  77. if (group === undefined || ddm.dragCurrent.ddGroup == group) {
  78. proc.id = setInterval(doScroll, freq);
  79. }
  80. },
  81. onFire = function(e, isDrop) {
  82. if (isDrop || !ddm.dragCurrent) {
  83. return;
  84. }
  85. var dds = Ext.dd.ScrollManager;
  86. if (!dragEl || dragEl != ddm.dragCurrent) {
  87. dragEl = ddm.dragCurrent;
  88. // refresh regions on drag start
  89. dds.refreshCache();
  90. }
  91. var xy = Ext.lib.Event.getXY(e),
  92. pt = new Ext.lib.Point(xy[0], xy[1]),
  93. id,
  94. el,
  95. r,
  96. c;
  97. for (id in els) {
  98. if (els.hasOwnProperty(id)) {
  99. el = els[id];
  100. r = el._region;
  101. c = el.ddScrollConfig ? el.ddScrollConfig: dds;
  102. if (r && r.contains(pt) && el.isScrollable()) {
  103. if (r.bottom - pt.y <= c.vthresh) {
  104. if (proc.el != el) {
  105. startProc(el, "down");
  106. }
  107. return;
  108. } else if (r.right - pt.x <= c.hthresh) {
  109. if (proc.el != el) {
  110. startProc(el, "left");
  111. }
  112. return;
  113. } else if (pt.y - r.top <= c.vthresh) {
  114. if (proc.el != el) {
  115. startProc(el, "up");
  116. }
  117. return;
  118. } else if (pt.x - r.left <= c.hthresh) {
  119. if (proc.el != el) {
  120. startProc(el, "right");
  121. }
  122. return;
  123. }
  124. }
  125. }
  126. }
  127. clearProc();
  128. };
  129. ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
  130. ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
  131. return {
  132. <div id="method-Ext.dd.ScrollManager-register"></div>/**
  133. * Registers new overflow element(s) to auto scroll
  134. * @param {Mixed/Array} el The id of or the element to be scrolled or an array of either
  135. */
  136. register: function(el) {
  137. if (Ext.isArray(el)) {
  138. var i = 0,
  139. len = el.length;
  140. for (; i < len; i++) {
  141. this.register(el[i]);
  142. }
  143. } else {
  144. el = Ext.get(el);
  145. els[el.id] = el;
  146. }
  147. },
  148. <div id="method-Ext.dd.ScrollManager-unregister"></div>/**
  149. * Unregisters overflow element(s) so they are no longer scrolled
  150. * @param {Mixed/Array} el The id of or the element to be removed or an array of either
  151. */
  152. unregister: function(el) {
  153. if (Ext.isArray(el)) {
  154. var i = 0,
  155. len = el.length;
  156. for (; i < len; i++) {
  157. this.unregister(el[i]);
  158. }
  159. } else {
  160. el = Ext.get(el);
  161. delete els[el.id];
  162. }
  163. },
  164. <div id="prop-Ext.dd.ScrollManager-vthresh"></div>/**
  165. * The number of pixels from the top or bottom edge of a container the pointer needs to be to
  166. * trigger scrolling (defaults to 25)
  167. * @type Number
  168. */
  169. vthresh: 25,
  170. <div id="prop-Ext.dd.ScrollManager-hthresh"></div>/**
  171. * The number of pixels from the right or left edge of a container the pointer needs to be to
  172. * trigger scrolling (defaults to 25)
  173. * @type Number
  174. */
  175. hthresh: 25,
  176. <div id="prop-Ext.dd.ScrollManager-increment"></div>/**
  177. * The number of pixels to scroll in each scroll increment (defaults to 50)
  178. * @type Number
  179. */
  180. increment: 100,
  181. <div id="prop-Ext.dd.ScrollManager-frequency"></div>/**
  182. * The frequency of scrolls in milliseconds (defaults to 500)
  183. * @type Number
  184. */
  185. frequency: 500,
  186. <div id="prop-Ext.dd.ScrollManager-animate"></div>/**
  187. * True to animate the scroll (defaults to true)
  188. * @type Boolean
  189. */
  190. animate: true,
  191. <div id="prop-Ext.dd.ScrollManager-animDuration"></div>/**
  192. * The animation duration in seconds -
  193. * MUST BE less than Ext.dd.ScrollManager.frequency! (defaults to .4)
  194. * @type Number
  195. */
  196. animDuration: 0.4,
  197. <div id="method-Ext.dd.ScrollManager-refreshCache"></div>/**
  198. * Manually trigger a cache refresh.
  199. */
  200. refreshCache: function() {
  201. var id;
  202. for (id in els) {
  203. if (els.hasOwnProperty(id)) {
  204. if (typeof els[id] == 'object') {
  205. // for people extending the object prototype
  206. els[id]._region = els[id].getRegion();
  207. }
  208. }
  209. }
  210. }
  211. };
  212. }();</pre>
  213. </body>
  214. </html>