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.

379 lines
14 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.dd.DragSource"></div>/**
  16. * @class Ext.dd.DragSource
  17. * @extends Ext.dd.DDProxy
  18. * A simple class that provides the basic implementation needed to make any element draggable.
  19. * @constructor
  20. * @param {Mixed} el The container element
  21. * @param {Object} config
  22. */
  23. Ext.dd.DragSource = function(el, config){
  24. this.el = Ext.get(el);
  25. if(!this.dragData){
  26. this.dragData = {};
  27. }
  28. Ext.apply(this, config);
  29. if(!this.proxy){
  30. this.proxy = new Ext.dd.StatusProxy();
  31. }
  32. Ext.dd.DragSource.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
  33. {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true});
  34. this.dragging = false;
  35. };
  36. Ext.extend(Ext.dd.DragSource, Ext.dd.DDProxy, {
  37. <div id="cfg-Ext.dd.DragSource-ddGroup"></div>/**
  38. * @cfg {String} ddGroup
  39. * A named drag drop group to which this object belongs. If a group is specified, then this object will only
  40. * interact with other drag drop objects in the same group (defaults to undefined).
  41. */
  42. <div id="cfg-Ext.dd.DragSource-dropAllowed"></div>/**
  43. * @cfg {String} dropAllowed
  44. * The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok").
  45. */
  46. dropAllowed : "x-dd-drop-ok",
  47. <div id="cfg-Ext.dd.DragSource-dropNotAllowed"></div>/**
  48. * @cfg {String} dropNotAllowed
  49. * The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop").
  50. */
  51. dropNotAllowed : "x-dd-drop-nodrop",
  52. <div id="method-Ext.dd.DragSource-getDragData"></div>/**
  53. * Returns the data object associated with this drag source
  54. * @return {Object} data An object containing arbitrary data
  55. */
  56. getDragData : function(e){
  57. return this.dragData;
  58. },
  59. // private
  60. onDragEnter : function(e, id){
  61. var target = Ext.dd.DragDropMgr.getDDById(id);
  62. this.cachedTarget = target;
  63. if(this.beforeDragEnter(target, e, id) !== false){
  64. if(target.isNotifyTarget){
  65. var status = target.notifyEnter(this, e, this.dragData);
  66. this.proxy.setStatus(status);
  67. }else{
  68. this.proxy.setStatus(this.dropAllowed);
  69. }
  70. if(this.afterDragEnter){
  71. <div id="method-Ext.dd.DragSource-afterDragEnter"></div>/**
  72. * An empty function by default, but provided so that you can perform a custom action
  73. * when the dragged item enters the drop target by providing an implementation.
  74. * @param {Ext.dd.DragDrop} target The drop target
  75. * @param {Event} e The event object
  76. * @param {String} id The id of the dragged element
  77. * @method afterDragEnter
  78. */
  79. this.afterDragEnter(target, e, id);
  80. }
  81. }
  82. },
  83. <div id="method-Ext.dd.DragSource-beforeDragEnter"></div>/**
  84. * An empty function by default, but provided so that you can perform a custom action
  85. * before the dragged item enters the drop target and optionally cancel the onDragEnter.
  86. * @param {Ext.dd.DragDrop} target The drop target
  87. * @param {Event} e The event object
  88. * @param {String} id The id of the dragged element
  89. * @return {Boolean} isValid True if the drag event is valid, else false to cancel
  90. */
  91. beforeDragEnter : function(target, e, id){
  92. return true;
  93. },
  94. // private
  95. alignElWithMouse: function() {
  96. Ext.dd.DragSource.superclass.alignElWithMouse.apply(this, arguments);
  97. this.proxy.sync();
  98. },
  99. // private
  100. onDragOver : function(e, id){
  101. var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
  102. if(this.beforeDragOver(target, e, id) !== false){
  103. if(target.isNotifyTarget){
  104. var status = target.notifyOver(this, e, this.dragData);
  105. this.proxy.setStatus(status);
  106. }
  107. if(this.afterDragOver){
  108. <div id="method-Ext.dd.DragSource-afterDragOver"></div>/**
  109. * An empty function by default, but provided so that you can perform a custom action
  110. * while the dragged item is over the drop target by providing an implementation.
  111. * @param {Ext.dd.DragDrop} target The drop target
  112. * @param {Event} e The event object
  113. * @param {String} id The id of the dragged element
  114. * @method afterDragOver
  115. */
  116. this.afterDragOver(target, e, id);
  117. }
  118. }
  119. },
  120. <div id="method-Ext.dd.DragSource-beforeDragOver"></div>/**
  121. * An empty function by default, but provided so that you can perform a custom action
  122. * while the dragged item is over the drop target and optionally cancel the onDragOver.
  123. * @param {Ext.dd.DragDrop} target The drop target
  124. * @param {Event} e The event object
  125. * @param {String} id The id of the dragged element
  126. * @return {Boolean} isValid True if the drag event is valid, else false to cancel
  127. */
  128. beforeDragOver : function(target, e, id){
  129. return true;
  130. },
  131. // private
  132. onDragOut : function(e, id){
  133. var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
  134. if(this.beforeDragOut(target, e, id) !== false){
  135. if(target.isNotifyTarget){
  136. target.notifyOut(this, e, this.dragData);
  137. }
  138. this.proxy.reset();
  139. if(this.afterDragOut){
  140. <div id="method-Ext.dd.DragSource-afterDragOut"></div>/**
  141. * An empty function by default, but provided so that you can perform a custom action
  142. * after the dragged item is dragged out of the target without dropping.
  143. * @param {Ext.dd.DragDrop} target The drop target
  144. * @param {Event} e The event object
  145. * @param {String} id The id of the dragged element
  146. * @method afterDragOut
  147. */
  148. this.afterDragOut(target, e, id);
  149. }
  150. }
  151. this.cachedTarget = null;
  152. },
  153. <div id="method-Ext.dd.DragSource-beforeDragOut"></div>/**
  154. * An empty function by default, but provided so that you can perform a custom action before the dragged
  155. * item is dragged out of the target without dropping, and optionally cancel the onDragOut.
  156. * @param {Ext.dd.DragDrop} target The drop target
  157. * @param {Event} e The event object
  158. * @param {String} id The id of the dragged element
  159. * @return {Boolean} isValid True if the drag event is valid, else false to cancel
  160. */
  161. beforeDragOut : function(target, e, id){
  162. return true;
  163. },
  164. // private
  165. onDragDrop : function(e, id){
  166. var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
  167. if(this.beforeDragDrop(target, e, id) !== false){
  168. if(target.isNotifyTarget){
  169. if(target.notifyDrop(this, e, this.dragData)){ // valid drop?
  170. this.onValidDrop(target, e, id);
  171. }else{
  172. this.onInvalidDrop(target, e, id);
  173. }
  174. }else{
  175. this.onValidDrop(target, e, id);
  176. }
  177. if(this.afterDragDrop){
  178. <div id="method-Ext.dd.DragSource-afterDragDrop"></div>/**
  179. * An empty function by default, but provided so that you can perform a custom action
  180. * after a valid drag drop has occurred by providing an implementation.
  181. * @param {Ext.dd.DragDrop} target The drop target
  182. * @param {Event} e The event object
  183. * @param {String} id The id of the dropped element
  184. * @method afterDragDrop
  185. */
  186. this.afterDragDrop(target, e, id);
  187. }
  188. }
  189. delete this.cachedTarget;
  190. },
  191. <div id="method-Ext.dd.DragSource-beforeDragDrop"></div>/**
  192. * An empty function by default, but provided so that you can perform a custom action before the dragged
  193. * item is dropped onto the target and optionally cancel the onDragDrop.
  194. * @param {Ext.dd.DragDrop} target The drop target
  195. * @param {Event} e The event object
  196. * @param {String} id The id of the dragged element
  197. * @return {Boolean} isValid True if the drag drop event is valid, else false to cancel
  198. */
  199. beforeDragDrop : function(target, e, id){
  200. return true;
  201. },
  202. // private
  203. onValidDrop : function(target, e, id){
  204. this.hideProxy();
  205. if(this.afterValidDrop){
  206. /**
  207. * An empty function by default, but provided so that you can perform a custom action
  208. * after a valid drop has occurred by providing an implementation.
  209. * @param {Object} target The target DD
  210. * @param {Event} e The event object
  211. * @param {String} id The id of the dropped element
  212. * @method afterInvalidDrop
  213. */
  214. this.afterValidDrop(target, e, id);
  215. }
  216. },
  217. // private
  218. getRepairXY : function(e, data){
  219. return this.el.getXY();
  220. },
  221. // private
  222. onInvalidDrop : function(target, e, id){
  223. this.beforeInvalidDrop(target, e, id);
  224. if(this.cachedTarget){
  225. if(this.cachedTarget.isNotifyTarget){
  226. this.cachedTarget.notifyOut(this, e, this.dragData);
  227. }
  228. this.cacheTarget = null;
  229. }
  230. this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);
  231. if(this.afterInvalidDrop){
  232. <div id="method-Ext.dd.DragSource-afterInvalidDrop"></div>/**
  233. * An empty function by default, but provided so that you can perform a custom action
  234. * after an invalid drop has occurred by providing an implementation.
  235. * @param {Event} e The event object
  236. * @param {String} id The id of the dropped element
  237. * @method afterInvalidDrop
  238. */
  239. this.afterInvalidDrop(e, id);
  240. }
  241. },
  242. // private
  243. afterRepair : function(){
  244. if(Ext.enableFx){
  245. this.el.highlight(this.hlColor || "c3daf9");
  246. }
  247. this.dragging = false;
  248. },
  249. <div id="method-Ext.dd.DragSource-beforeInvalidDrop"></div>/**
  250. * An empty function by default, but provided so that you can perform a custom action after an invalid
  251. * drop has occurred.
  252. * @param {Ext.dd.DragDrop} target The drop target
  253. * @param {Event} e The event object
  254. * @param {String} id The id of the dragged element
  255. * @return {Boolean} isValid True if the invalid drop should proceed, else false to cancel
  256. */
  257. beforeInvalidDrop : function(target, e, id){
  258. return true;
  259. },
  260. // private
  261. handleMouseDown : function(e){
  262. if(this.dragging) {
  263. return;
  264. }
  265. var data = this.getDragData(e);
  266. if(data && this.onBeforeDrag(data, e) !== false){
  267. this.dragData = data;
  268. this.proxy.stop();
  269. Ext.dd.DragSource.superclass.handleMouseDown.apply(this, arguments);
  270. }
  271. },
  272. <div id="method-Ext.dd.DragSource-onBeforeDrag"></div>/**
  273. * An empty function by default, but provided so that you can perform a custom action before the initial
  274. * drag event begins and optionally cancel it.
  275. * @param {Object} data An object containing arbitrary data to be shared with drop targets
  276. * @param {Event} e The event object
  277. * @return {Boolean} isValid True if the drag event is valid, else false to cancel
  278. */
  279. onBeforeDrag : function(data, e){
  280. return true;
  281. },
  282. <div id="method-Ext.dd.DragSource-onStartDrag"></div>/**
  283. * An empty function by default, but provided so that you can perform a custom action once the initial
  284. * drag event has begun. The drag cannot be canceled from this function.
  285. * @param {Number} x The x position of the click on the dragged object
  286. * @param {Number} y The y position of the click on the dragged object
  287. */
  288. onStartDrag : Ext.emptyFn,
  289. // private override
  290. startDrag : function(x, y){
  291. this.proxy.reset();
  292. this.dragging = true;
  293. this.proxy.update("");
  294. this.onInitDrag(x, y);
  295. this.proxy.show();
  296. },
  297. // private
  298. onInitDrag : function(x, y){
  299. var clone = this.el.dom.cloneNode(true);
  300. clone.id = Ext.id(); // prevent duplicate ids
  301. this.proxy.update(clone);
  302. this.onStartDrag(x, y);
  303. return true;
  304. },
  305. <div id="method-Ext.dd.DragSource-getProxy"></div>/**
  306. * Returns the drag source's underlying {@link Ext.dd.StatusProxy}
  307. * @return {Ext.dd.StatusProxy} proxy The StatusProxy
  308. */
  309. getProxy : function(){
  310. return this.proxy;
  311. },
  312. <div id="method-Ext.dd.DragSource-hideProxy"></div>/**
  313. * Hides the drag source's {@link Ext.dd.StatusProxy}
  314. */
  315. hideProxy : function(){
  316. this.proxy.hide();
  317. this.proxy.reset(true);
  318. this.dragging = false;
  319. },
  320. // private
  321. triggerCacheRefresh : function(){
  322. Ext.dd.DDM.refreshCache(this.groups);
  323. },
  324. // private - override to prevent hiding
  325. b4EndDrag: function(e) {
  326. },
  327. // private - override to prevent moving
  328. endDrag : function(e){
  329. this.onEndDrag(this.dragData, e);
  330. },
  331. // private
  332. onEndDrag : function(data, e){
  333. },
  334. // private - pin to cursor
  335. autoOffset : function(x, y) {
  336. this.setDelta(-12, -20);
  337. },
  338. destroy: function(){
  339. Ext.dd.DragSource.superclass.destroy.call(this);
  340. Ext.destroy(this.proxy);
  341. }
  342. });</pre>
  343. </body>
  344. </html>