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.

222 lines
7.6 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. var els = {};
  38. var dragEl = null;
  39. var proc = {};
  40. var onStop = function(e){
  41. dragEl = null;
  42. clearProc();
  43. };
  44. var triggerRefresh = function(){
  45. if(ddm.dragCurrent){
  46. ddm.refreshCache(ddm.dragCurrent.groups);
  47. }
  48. };
  49. var doScroll = function(){
  50. if(ddm.dragCurrent){
  51. var dds = Ext.dd.ScrollManager;
  52. var inc = proc.el.ddScrollConfig ?
  53. proc.el.ddScrollConfig.increment : dds.increment;
  54. if(!dds.animate){
  55. if(proc.el.scroll(proc.dir, inc)){
  56. triggerRefresh();
  57. }
  58. }else{
  59. proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
  60. }
  61. }
  62. };
  63. var clearProc = function(){
  64. if(proc.id){
  65. clearInterval(proc.id);
  66. }
  67. proc.id = 0;
  68. proc.el = null;
  69. proc.dir = "";
  70. };
  71. var startProc = function(el, dir){
  72. clearProc();
  73. proc.el = el;
  74. proc.dir = dir;
  75. var group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup : undefined,
  76. freq = (el.ddScrollConfig && el.ddScrollConfig.frequency)
  77. ? el.ddScrollConfig.frequency
  78. : Ext.dd.ScrollManager.frequency;
  79. if (group === undefined || ddm.dragCurrent.ddGroup == group) {
  80. proc.id = setInterval(doScroll, freq);
  81. }
  82. };
  83. var onFire = function(e, isDrop){
  84. if(isDrop || !ddm.dragCurrent){ return; }
  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. var pt = new Ext.lib.Point(xy[0], xy[1]);
  93. for(var id in els){
  94. var el = els[id], r = el._region;
  95. var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
  96. if(r && r.contains(pt) && el.isScrollable()){
  97. if(r.bottom - pt.y <= c.vthresh){
  98. if(proc.el != el){
  99. startProc(el, "down");
  100. }
  101. return;
  102. }else if(r.right - pt.x <= c.hthresh){
  103. if(proc.el != el){
  104. startProc(el, "left");
  105. }
  106. return;
  107. }else if(pt.y - r.top <= c.vthresh){
  108. if(proc.el != el){
  109. startProc(el, "up");
  110. }
  111. return;
  112. }else if(pt.x - r.left <= c.hthresh){
  113. if(proc.el != el){
  114. startProc(el, "right");
  115. }
  116. return;
  117. }
  118. }
  119. }
  120. clearProc();
  121. };
  122. ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
  123. ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
  124. return {
  125. <div id="method-Ext.dd.ScrollManager-register"></div>/**
  126. * Registers new overflow element(s) to auto scroll
  127. * @param {Mixed/Array} el The id of or the element to be scrolled or an array of either
  128. */
  129. register : function(el){
  130. if(Ext.isArray(el)){
  131. for(var i = 0, len = el.length; i < len; i++) {
  132. this.register(el[i]);
  133. }
  134. }else{
  135. el = Ext.get(el);
  136. els[el.id] = el;
  137. }
  138. },
  139. <div id="method-Ext.dd.ScrollManager-unregister"></div>/**
  140. * Unregisters overflow element(s) so they are no longer scrolled
  141. * @param {Mixed/Array} el The id of or the element to be removed or an array of either
  142. */
  143. unregister : function(el){
  144. if(Ext.isArray(el)){
  145. for(var i = 0, len = el.length; i < len; i++) {
  146. this.unregister(el[i]);
  147. }
  148. }else{
  149. el = Ext.get(el);
  150. delete els[el.id];
  151. }
  152. },
  153. <div id="prop-Ext.dd.ScrollManager-vthresh"></div>/**
  154. * The number of pixels from the top or bottom edge of a container the pointer needs to be to
  155. * trigger scrolling (defaults to 25)
  156. * @type Number
  157. */
  158. vthresh : 25,
  159. <div id="prop-Ext.dd.ScrollManager-hthresh"></div>/**
  160. * The number of pixels from the right or left edge of a container the pointer needs to be to
  161. * trigger scrolling (defaults to 25)
  162. * @type Number
  163. */
  164. hthresh : 25,
  165. <div id="prop-Ext.dd.ScrollManager-increment"></div>/**
  166. * The number of pixels to scroll in each scroll increment (defaults to 100)
  167. * @type Number
  168. */
  169. increment : 100,
  170. <div id="prop-Ext.dd.ScrollManager-frequency"></div>/**
  171. * The frequency of scrolls in milliseconds (defaults to 500)
  172. * @type Number
  173. */
  174. frequency : 500,
  175. <div id="prop-Ext.dd.ScrollManager-animate"></div>/**
  176. * True to animate the scroll (defaults to true)
  177. * @type Boolean
  178. */
  179. animate: true,
  180. <div id="prop-Ext.dd.ScrollManager-animDuration"></div>/**
  181. * The animation duration in seconds -
  182. * MUST BE less than Ext.dd.ScrollManager.frequency! (defaults to .4)
  183. * @type Number
  184. */
  185. animDuration: .4,
  186. <div id="prop-Ext.dd.ScrollManager-ddGroup"></div>/**
  187. * The named drag drop {@link Ext.dd.DragSource#ddGroup group} to which this container belongs (defaults to undefined).
  188. * If a ddGroup is specified, then container scrolling will only occur when a dragged object is in the same ddGroup.
  189. * @type String
  190. */
  191. ddGroup: undefined,
  192. <div id="method-Ext.dd.ScrollManager-refreshCache"></div>/**
  193. * Manually trigger a cache refresh.
  194. */
  195. refreshCache : function(){
  196. for(var id in els){
  197. if(typeof els[id] == 'object'){ // for people extending the object prototype
  198. els[id]._region = els[id].getRegion();
  199. }
  200. }
  201. }
  202. };
  203. }();</pre>
  204. </body>
  205. </html>