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.

446 lines
15 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.SplitBar"></div>/**
  16. * @class Ext.SplitBar
  17. * @extends Ext.util.Observable
  18. * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
  19. * <br><br>
  20. * Usage:
  21. * <pre><code>
  22. var split = new Ext.SplitBar("elementToDrag", "elementToSize",
  23. Ext.SplitBar.HORIZONTAL, Ext.SplitBar.LEFT);
  24. split.setAdapter(new Ext.SplitBar.AbsoluteLayoutAdapter("container"));
  25. split.minSize = 100;
  26. split.maxSize = 600;
  27. split.animate = true;
  28. split.on('moved', splitterMoved);
  29. </code></pre>
  30. * @constructor
  31. * Create a new SplitBar
  32. * @param {Mixed} dragElement The element to be dragged and act as the SplitBar.
  33. * @param {Mixed} resizingElement The element to be resized based on where the SplitBar element is dragged
  34. * @param {Number} orientation (optional) Either Ext.SplitBar.HORIZONTAL or Ext.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
  35. * @param {Number} placement (optional) Either Ext.SplitBar.LEFT or Ext.SplitBar.RIGHT for horizontal or
  36. Ext.SplitBar.TOP or Ext.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
  37. position of the SplitBar).
  38. */
  39. Ext.SplitBar = function(dragElement, resizingElement, orientation, placement, existingProxy){
  40. /** @private */
  41. this.el = Ext.get(dragElement, true);
  42. this.el.dom.unselectable = "on";
  43. /** @private */
  44. this.resizingEl = Ext.get(resizingElement, true);
  45. /**
  46. * @private
  47. * The orientation of the split. Either Ext.SplitBar.HORIZONTAL or Ext.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
  48. * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
  49. * @type Number
  50. */
  51. this.orientation = orientation || Ext.SplitBar.HORIZONTAL;
  52. <div id="prop-Ext.SplitBar-tickSize"></div>/**
  53. * The increment, in pixels by which to move this SplitBar. When <i>undefined</i>, the SplitBar moves smoothly.
  54. * @type Number
  55. * @property tickSize
  56. */
  57. <div id="prop-Ext.SplitBar-minSize"></div>/**
  58. * The minimum size of the resizing element. (Defaults to 0)
  59. * @type Number
  60. */
  61. this.minSize = 0;
  62. <div id="prop-Ext.SplitBar-maxSize"></div>/**
  63. * The maximum size of the resizing element. (Defaults to 2000)
  64. * @type Number
  65. */
  66. this.maxSize = 2000;
  67. <div id="prop-Ext.SplitBar-animate"></div>/**
  68. * Whether to animate the transition to the new size
  69. * @type Boolean
  70. */
  71. this.animate = false;
  72. <div id="prop-Ext.SplitBar-useShim"></div>/**
  73. * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
  74. * @type Boolean
  75. */
  76. this.useShim = false;
  77. /** @private */
  78. this.shim = null;
  79. if(!existingProxy){
  80. /** @private */
  81. this.proxy = Ext.SplitBar.createProxy(this.orientation);
  82. }else{
  83. this.proxy = Ext.get(existingProxy).dom;
  84. }
  85. /** @private */
  86. this.dd = new Ext.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
  87. /** @private */
  88. this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
  89. /** @private */
  90. this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
  91. /** @private */
  92. this.dragSpecs = {};
  93. /**
  94. * @private The adapter to use to positon and resize elements
  95. */
  96. this.adapter = new Ext.SplitBar.BasicLayoutAdapter();
  97. this.adapter.init(this);
  98. if(this.orientation == Ext.SplitBar.HORIZONTAL){
  99. /** @private */
  100. this.placement = placement || (this.el.getX() > this.resizingEl.getX() ? Ext.SplitBar.LEFT : Ext.SplitBar.RIGHT);
  101. this.el.addClass("x-splitbar-h");
  102. }else{
  103. /** @private */
  104. this.placement = placement || (this.el.getY() > this.resizingEl.getY() ? Ext.SplitBar.TOP : Ext.SplitBar.BOTTOM);
  105. this.el.addClass("x-splitbar-v");
  106. }
  107. this.addEvents(
  108. <div id="event-Ext.SplitBar-resize"></div>/**
  109. * @event resize
  110. * Fires when the splitter is moved (alias for {@link #moved})
  111. * @param {Ext.SplitBar} this
  112. * @param {Number} newSize the new width or height
  113. */
  114. "resize",
  115. <div id="event-Ext.SplitBar-moved"></div>/**
  116. * @event moved
  117. * Fires when the splitter is moved
  118. * @param {Ext.SplitBar} this
  119. * @param {Number} newSize the new width or height
  120. */
  121. "moved",
  122. <div id="event-Ext.SplitBar-beforeresize"></div>/**
  123. * @event beforeresize
  124. * Fires before the splitter is dragged
  125. * @param {Ext.SplitBar} this
  126. */
  127. "beforeresize",
  128. "beforeapply"
  129. );
  130. Ext.SplitBar.superclass.constructor.call(this);
  131. };
  132. Ext.extend(Ext.SplitBar, Ext.util.Observable, {
  133. onStartProxyDrag : function(x, y){
  134. this.fireEvent("beforeresize", this);
  135. this.overlay = Ext.DomHelper.append(document.body, {cls: "x-drag-overlay", html: "&#160;"}, true);
  136. this.overlay.unselectable();
  137. this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
  138. this.overlay.show();
  139. Ext.get(this.proxy).setDisplayed("block");
  140. var size = this.adapter.getElementSize(this);
  141. this.activeMinSize = this.getMinimumSize();
  142. this.activeMaxSize = this.getMaximumSize();
  143. var c1 = size - this.activeMinSize;
  144. var c2 = Math.max(this.activeMaxSize - size, 0);
  145. if(this.orientation == Ext.SplitBar.HORIZONTAL){
  146. this.dd.resetConstraints();
  147. this.dd.setXConstraint(
  148. this.placement == Ext.SplitBar.LEFT ? c1 : c2,
  149. this.placement == Ext.SplitBar.LEFT ? c2 : c1,
  150. this.tickSize
  151. );
  152. this.dd.setYConstraint(0, 0);
  153. }else{
  154. this.dd.resetConstraints();
  155. this.dd.setXConstraint(0, 0);
  156. this.dd.setYConstraint(
  157. this.placement == Ext.SplitBar.TOP ? c1 : c2,
  158. this.placement == Ext.SplitBar.TOP ? c2 : c1,
  159. this.tickSize
  160. );
  161. }
  162. this.dragSpecs.startSize = size;
  163. this.dragSpecs.startPoint = [x, y];
  164. Ext.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
  165. },
  166. /**
  167. * @private Called after the drag operation by the DDProxy
  168. */
  169. onEndProxyDrag : function(e){
  170. Ext.get(this.proxy).setDisplayed(false);
  171. var endPoint = Ext.lib.Event.getXY(e);
  172. if(this.overlay){
  173. Ext.destroy(this.overlay);
  174. delete this.overlay;
  175. }
  176. var newSize;
  177. if(this.orientation == Ext.SplitBar.HORIZONTAL){
  178. newSize = this.dragSpecs.startSize +
  179. (this.placement == Ext.SplitBar.LEFT ?
  180. endPoint[0] - this.dragSpecs.startPoint[0] :
  181. this.dragSpecs.startPoint[0] - endPoint[0]
  182. );
  183. }else{
  184. newSize = this.dragSpecs.startSize +
  185. (this.placement == Ext.SplitBar.TOP ?
  186. endPoint[1] - this.dragSpecs.startPoint[1] :
  187. this.dragSpecs.startPoint[1] - endPoint[1]
  188. );
  189. }
  190. newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
  191. if(newSize != this.dragSpecs.startSize){
  192. if(this.fireEvent('beforeapply', this, newSize) !== false){
  193. this.adapter.setElementSize(this, newSize);
  194. this.fireEvent("moved", this, newSize);
  195. this.fireEvent("resize", this, newSize);
  196. }
  197. }
  198. },
  199. <div id="method-Ext.SplitBar-getAdapter"></div>/**
  200. * Get the adapter this SplitBar uses
  201. * @return The adapter object
  202. */
  203. getAdapter : function(){
  204. return this.adapter;
  205. },
  206. <div id="method-Ext.SplitBar-setAdapter"></div>/**
  207. * Set the adapter this SplitBar uses
  208. * @param {Object} adapter A SplitBar adapter object
  209. */
  210. setAdapter : function(adapter){
  211. this.adapter = adapter;
  212. this.adapter.init(this);
  213. },
  214. <div id="method-Ext.SplitBar-getMinimumSize"></div>/**
  215. * Gets the minimum size for the resizing element
  216. * @return {Number} The minimum size
  217. */
  218. getMinimumSize : function(){
  219. return this.minSize;
  220. },
  221. <div id="method-Ext.SplitBar-setMinimumSize"></div>/**
  222. * Sets the minimum size for the resizing element
  223. * @param {Number} minSize The minimum size
  224. */
  225. setMinimumSize : function(minSize){
  226. this.minSize = minSize;
  227. },
  228. <div id="method-Ext.SplitBar-getMaximumSize"></div>/**
  229. * Gets the maximum size for the resizing element
  230. * @return {Number} The maximum size
  231. */
  232. getMaximumSize : function(){
  233. return this.maxSize;
  234. },
  235. <div id="method-Ext.SplitBar-setMaximumSize"></div>/**
  236. * Sets the maximum size for the resizing element
  237. * @param {Number} maxSize The maximum size
  238. */
  239. setMaximumSize : function(maxSize){
  240. this.maxSize = maxSize;
  241. },
  242. <div id="method-Ext.SplitBar-setCurrentSize"></div>/**
  243. * Sets the initialize size for the resizing element
  244. * @param {Number} size The initial size
  245. */
  246. setCurrentSize : function(size){
  247. var oldAnimate = this.animate;
  248. this.animate = false;
  249. this.adapter.setElementSize(this, size);
  250. this.animate = oldAnimate;
  251. },
  252. <div id="method-Ext.SplitBar-destroy"></div>/**
  253. * Destroy this splitbar.
  254. * @param {Boolean} removeEl True to remove the element
  255. */
  256. destroy : function(removeEl){
  257. Ext.destroy(this.shim, Ext.get(this.proxy));
  258. this.dd.unreg();
  259. if(removeEl){
  260. this.el.remove();
  261. }
  262. this.purgeListeners();
  263. }
  264. });
  265. /**
  266. * @private static Create our own proxy element element. So it will be the same same size on all browsers, we won't use borders. Instead we use a background color.
  267. */
  268. Ext.SplitBar.createProxy = function(dir){
  269. var proxy = new Ext.Element(document.createElement("div"));
  270. document.body.appendChild(proxy.dom);
  271. proxy.unselectable();
  272. var cls = 'x-splitbar-proxy';
  273. proxy.addClass(cls + ' ' + (dir == Ext.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
  274. return proxy.dom;
  275. };
  276. <div id="cls-Ext.SplitBar.BasicLayoutAdapter"></div>/**
  277. * @class Ext.SplitBar.BasicLayoutAdapter
  278. * Default Adapter. It assumes the splitter and resizing element are not positioned
  279. * elements and only gets/sets the width of the element. Generally used for table based layouts.
  280. */
  281. Ext.SplitBar.BasicLayoutAdapter = function(){
  282. };
  283. Ext.SplitBar.BasicLayoutAdapter.prototype = {
  284. // do nothing for now
  285. init : function(s){
  286. },
  287. <div id="method-Ext.SplitBar.BasicLayoutAdapter-getElementSize"></div>/**
  288. * Called before drag operations to get the current size of the resizing element.
  289. * @param {Ext.SplitBar} s The SplitBar using this adapter
  290. */
  291. getElementSize : function(s){
  292. if(s.orientation == Ext.SplitBar.HORIZONTAL){
  293. return s.resizingEl.getWidth();
  294. }else{
  295. return s.resizingEl.getHeight();
  296. }
  297. },
  298. <div id="method-Ext.SplitBar.BasicLayoutAdapter-setElementSize"></div>/**
  299. * Called after drag operations to set the size of the resizing element.
  300. * @param {Ext.SplitBar} s The SplitBar using this adapter
  301. * @param {Number} newSize The new size to set
  302. * @param {Function} onComplete A function to be invoked when resizing is complete
  303. */
  304. setElementSize : function(s, newSize, onComplete){
  305. if(s.orientation == Ext.SplitBar.HORIZONTAL){
  306. if(!s.animate){
  307. s.resizingEl.setWidth(newSize);
  308. if(onComplete){
  309. onComplete(s, newSize);
  310. }
  311. }else{
  312. s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
  313. }
  314. }else{
  315. if(!s.animate){
  316. s.resizingEl.setHeight(newSize);
  317. if(onComplete){
  318. onComplete(s, newSize);
  319. }
  320. }else{
  321. s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
  322. }
  323. }
  324. }
  325. };
  326. <div id="cls-Ext.SplitBar.AbsoluteLayoutAdapter"></div>/**
  327. *@class Ext.SplitBar.AbsoluteLayoutAdapter
  328. * @extends Ext.SplitBar.BasicLayoutAdapter
  329. * Adapter that moves the splitter element to align with the resized sizing element.
  330. * Used with an absolute positioned SplitBar.
  331. * @param {Mixed} container The container that wraps around the absolute positioned content. If it's
  332. * document.body, make sure you assign an id to the body element.
  333. */
  334. Ext.SplitBar.AbsoluteLayoutAdapter = function(container){
  335. this.basic = new Ext.SplitBar.BasicLayoutAdapter();
  336. this.container = Ext.get(container);
  337. };
  338. Ext.SplitBar.AbsoluteLayoutAdapter.prototype = {
  339. init : function(s){
  340. this.basic.init(s);
  341. },
  342. getElementSize : function(s){
  343. return this.basic.getElementSize(s);
  344. },
  345. setElementSize : function(s, newSize, onComplete){
  346. this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
  347. },
  348. moveSplitter : function(s){
  349. var yes = Ext.SplitBar;
  350. switch(s.placement){
  351. case yes.LEFT:
  352. s.el.setX(s.resizingEl.getRight());
  353. break;
  354. case yes.RIGHT:
  355. s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
  356. break;
  357. case yes.TOP:
  358. s.el.setY(s.resizingEl.getBottom());
  359. break;
  360. case yes.BOTTOM:
  361. s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
  362. break;
  363. }
  364. }
  365. };
  366. <div id="prop-Ext.SplitBar.AbsoluteLayoutAdapter-VERTICAL"></div>/**
  367. * Orientation constant - Create a vertical SplitBar
  368. * @static
  369. * @type Number
  370. */
  371. Ext.SplitBar.VERTICAL = 1;
  372. <div id="prop-Ext.SplitBar.AbsoluteLayoutAdapter-HORIZONTAL"></div>/**
  373. * Orientation constant - Create a horizontal SplitBar
  374. * @static
  375. * @type Number
  376. */
  377. Ext.SplitBar.HORIZONTAL = 2;
  378. <div id="prop-Ext.SplitBar.AbsoluteLayoutAdapter-LEFT"></div>/**
  379. * Placement constant - The resizing element is to the left of the splitter element
  380. * @static
  381. * @type Number
  382. */
  383. Ext.SplitBar.LEFT = 1;
  384. <div id="prop-Ext.SplitBar.AbsoluteLayoutAdapter-RIGHT"></div>/**
  385. * Placement constant - The resizing element is to the right of the splitter element
  386. * @static
  387. * @type Number
  388. */
  389. Ext.SplitBar.RIGHT = 2;
  390. <div id="prop-Ext.SplitBar.AbsoluteLayoutAdapter-TOP"></div>/**
  391. * Placement constant - The resizing element is positioned above the splitter element
  392. * @static
  393. * @type Number
  394. */
  395. Ext.SplitBar.TOP = 3;
  396. <div id="prop-Ext.SplitBar.AbsoluteLayoutAdapter-BOTTOM"></div>/**
  397. * Placement constant - The resizing element is positioned under splitter element
  398. * @static
  399. * @type Number
  400. */
  401. Ext.SplitBar.BOTTOM = 4;
  402. </pre>
  403. </body>
  404. </html>