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.

210 lines
7.2 KiB

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