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.

220 lines
7.6 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. /*
  16. * Internal drag zone implementation for the calendar day and week views.
  17. */
  18. Ext.calendar.DayViewDragZone = Ext.extend(Ext.calendar.DragZone, {
  19. ddGroup: 'DayViewDD',
  20. resizeSelector: '.ext-evt-rsz',
  21. getDragData: function(e) {
  22. var t = e.getTarget(this.resizeSelector, 2, true),
  23. p,
  24. rec;
  25. if (t) {
  26. p = t.parent(this.eventSelector);
  27. rec = this.view.getEventRecordFromEl(p);
  28. return {
  29. type: 'eventresize',
  30. ddel: p.dom,
  31. eventStart: rec.data[Ext.calendar.EventMappings.StartDate.name],
  32. eventEnd: rec.data[Ext.calendar.EventMappings.EndDate.name],
  33. proxy: this.proxy
  34. };
  35. }
  36. t = e.getTarget(this.eventSelector, 3);
  37. if (t) {
  38. rec = this.view.getEventRecordFromEl(t);
  39. return {
  40. type: 'eventdrag',
  41. ddel: t,
  42. eventStart: rec.data[Ext.calendar.EventMappings.StartDate.name],
  43. eventEnd: rec.data[Ext.calendar.EventMappings.EndDate.name],
  44. proxy: this.proxy
  45. };
  46. }
  47. // If not dragging/resizing an event then we are dragging on
  48. // the calendar to add a new event
  49. t = this.view.getDayAt(e.getPageX(), e.getPageY());
  50. if (t.el) {
  51. return {
  52. type: 'caldrag',
  53. dayInfo: t,
  54. proxy: this.proxy
  55. };
  56. }
  57. return null;
  58. }
  59. });
  60. /*
  61. * Internal drop zone implementation for the calendar day and week views.
  62. */
  63. Ext.calendar.DayViewDropZone = Ext.extend(Ext.calendar.DropZone, {
  64. ddGroup: 'DayViewDD',
  65. onNodeOver: function(n, dd, e, data) {
  66. var dt,
  67. box,
  68. endDt,
  69. text = this.createText,
  70. curr,
  71. start,
  72. end,
  73. evtEl,
  74. dayCol;
  75. if (data.type == 'caldrag') {
  76. if (!this.dragStartMarker) {
  77. // Since the container can scroll, this gets a little tricky.
  78. // There is no el in the DOM that we can measure by default since
  79. // the box is simply calculated from the original drag start (as opposed
  80. // to dragging or resizing the event where the orig event box is present).
  81. // To work around this we add a placeholder el into the DOM and give it
  82. // the original starting time's box so that we can grab its updated
  83. // box measurements as the underlying container scrolls up or down.
  84. // This placeholder is removed in onNodeDrop.
  85. this.dragStartMarker = n.el.parent().createChild({
  86. style: 'position:absolute;'
  87. });
  88. this.dragStartMarker.setBox(n.timeBox);
  89. this.dragCreateDt = n.date;
  90. }
  91. box = this.dragStartMarker.getBox();
  92. box.height = Math.ceil(Math.abs(e.xy[1] - box.y) / n.timeBox.height) * n.timeBox.height;
  93. if (e.xy[1] < box.y) {
  94. box.height += n.timeBox.height;
  95. box.y = box.y - box.height + n.timeBox.height;
  96. endDt = this.dragCreateDt.add(Date.MINUTE, 30);
  97. }
  98. else {
  99. n.date = n.date.add(Date.MINUTE, 30);
  100. }
  101. this.shim(this.dragCreateDt, box);
  102. curr = Ext.calendar.Date.copyTime(n.date, this.dragCreateDt);
  103. this.dragStartDate = Ext.calendar.Date.min(this.dragCreateDt, curr);
  104. this.dragEndDate = endDt || Ext.calendar.Date.max(this.dragCreateDt, curr);
  105. dt = this.dragStartDate.format('g:ia-') + this.dragEndDate.format('g:ia');
  106. }
  107. else {
  108. evtEl = Ext.get(data.ddel);
  109. dayCol = evtEl.parent().parent();
  110. box = evtEl.getBox();
  111. box.width = dayCol.getWidth();
  112. if (data.type == 'eventdrag') {
  113. if (this.dragOffset === undefined) {
  114. this.dragOffset = n.timeBox.y - box.y;
  115. box.y = n.timeBox.y - this.dragOffset;
  116. }
  117. else {
  118. box.y = n.timeBox.y;
  119. }
  120. dt = n.date.format('n/j g:ia');
  121. box.x = n.el.getLeft();
  122. this.shim(n.date, box);
  123. text = this.moveText;
  124. }
  125. if (data.type == 'eventresize') {
  126. if (!this.resizeDt) {
  127. this.resizeDt = n.date;
  128. }
  129. box.x = dayCol.getLeft();
  130. box.height = Math.ceil(Math.abs(e.xy[1] - box.y) / n.timeBox.height) * n.timeBox.height;
  131. if (e.xy[1] < box.y) {
  132. box.y -= box.height;
  133. }
  134. else {
  135. n.date = n.date.add(Date.MINUTE, 30);
  136. }
  137. this.shim(this.resizeDt, box);
  138. curr = Ext.calendar.Date.copyTime(n.date, this.resizeDt);
  139. start = Ext.calendar.Date.min(data.eventStart, curr);
  140. end = Ext.calendar.Date.max(data.eventStart, curr);
  141. data.resizeDates = {
  142. StartDate: start,
  143. EndDate: end
  144. };
  145. dt = start.format('g:ia-') + end.format('g:ia');
  146. text = this.resizeText;
  147. }
  148. }
  149. data.proxy.updateMsg(String.format(text, dt));
  150. return this.dropAllowed;
  151. },
  152. shim: function(dt, box) {
  153. Ext.each(this.shims,
  154. function(shim) {
  155. if (shim) {
  156. shim.isActive = false;
  157. shim.hide();
  158. }
  159. });
  160. var shim = this.shims[0];
  161. if (!shim) {
  162. shim = this.createShim();
  163. this.shims[0] = shim;
  164. }
  165. shim.isActive = true;
  166. shim.show();
  167. shim.setBox(box);
  168. },
  169. onNodeDrop: function(n, dd, e, data) {
  170. var rec;
  171. if (n && data) {
  172. if (data.type == 'eventdrag') {
  173. rec = this.view.getEventRecordFromEl(data.ddel);
  174. this.view.onEventDrop(rec, n.date);
  175. this.onCalendarDragComplete();
  176. delete this.dragOffset;
  177. return true;
  178. }
  179. if (data.type == 'eventresize') {
  180. rec = this.view.getEventRecordFromEl(data.ddel);
  181. this.view.onEventResize(rec, data.resizeDates);
  182. this.onCalendarDragComplete();
  183. delete this.resizeDt;
  184. return true;
  185. }
  186. if (data.type == 'caldrag') {
  187. Ext.destroy(this.dragStartMarker);
  188. delete this.dragStartMarker;
  189. delete this.dragCreateDt;
  190. this.view.onCalendarEndDrag(this.dragStartDate, this.dragEndDate,
  191. this.onCalendarDragComplete.createDelegate(this));
  192. //shims are NOT cleared here -- they stay visible until the handling
  193. //code calls the onCalendarDragComplete callback which hides them.
  194. return true;
  195. }
  196. }
  197. this.onCalendarDragComplete();
  198. return false;
  199. }
  200. });
  201. </pre>
  202. </body>
  203. </html>