Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.82 KB | None | 0 0
  1. @{
  2. ViewData["Title"] = "Index";
  3. }
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset='utf-8' />
  8.  
  9. <link href='~/fcs/core/main.css' rel='stylesheet' />
  10. <link href='~/fcs/daygrid/main.css' rel='stylesheet' />
  11. <link href='~/fcs/timegrid/main.css' rel='stylesheet' />
  12. <link href='~/fcs/timeline/main.css' rel='stylesheet' />
  13. <link href='~/fcs/resource-timeline/main.css' rel='stylesheet' />
  14.  
  15. <script src='~/lib/jquery/dist/jquery.min.js'></script>
  16. <script src='~/fcs/core/main.js'></script>
  17. <script src='~/fcs/interaction/main.js'></script>
  18. <script src='~/fcs/daygrid/main.js'></script>
  19. <script src='~/fcs/timegrid/main.js'></script>
  20. <script src='~/fcs/timeline/main.js'></script>
  21. <script src='~/fcs/resource-common/main.js'></script>
  22. <script src='~/fcs/resource-timeline/main.js'></script>
  23. <script>
  24. var showContext = false;
  25. var contextEventId = null;
  26. document.addEventListener('DOMContentLoaded', function () {
  27. var Calendar = FullCalendar.Calendar;
  28. var Draggable = FullCalendarInteraction.Draggable;
  29.  
  30. /* initialize the external events
  31. -----------------------------------------------------------------*/
  32.  
  33. var containerEl = document.getElementById('external-events');
  34. new Draggable(containerEl, {
  35. itemSelector: '.fc-event',
  36. eventData: function (eventEl) {
  37. return {
  38. title: eventEl.innerText.trim(),
  39. id: '456'
  40. }
  41. }
  42. });
  43.  
  44.  
  45. /* initialize the calendar
  46. -----------------------------------------------------------------*/
  47.  
  48. var calendarEl = document.getElementById('calendar');
  49.  
  50. var calendar = new Calendar(calendarEl, {
  51. schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
  52. plugins: ['interaction', 'dayGrid', 'timeGrid', 'resourceTimeline'],
  53. now: '2019-07-04',
  54. editable: true, // enable draggable events
  55. droppable: true, // this allows things to be dropped onto the calendar
  56. aspectRatio: 2,
  57. scrollTime: '00:00', // undo default 6am scrollTime
  58. slotWidth: '100', // Added by DW
  59. businessHours: {
  60. daysOfWeek: [1, 2, 3, 4, 5],
  61. startTime: '08:00',
  62. endTime: '18:00'
  63. }, // Added by DW
  64. height: 900, // Added by DW
  65. resourceAreaWidth: "20%", // Added by DW
  66. header: {
  67. left: '',
  68. center: 'title',
  69. right: 'today prev,next'
  70. },
  71. defaultView: 'resourceTimelineThreeWeeks', //Changed by DW
  72. views: {
  73. resourceTimelineThreeWeeks: {
  74. type: 'resourceTimeline',
  75. duration: { weeks: 3 }, //Changed by DW
  76. buttonText: '3 weeks' //Changed by DW
  77. },
  78. resourceTimelineFourWeeks: {
  79. type: 'resourceTimeline',
  80. duration: { weeks: 4 }, //Changed by DW
  81. buttonText: '4 weeks' //Changed by DW
  82. }
  83. },
  84. resourceLabelText: 'People',
  85. resourceRender: function (arg) {
  86. arg.el.parentNode.style.backgroundColor = arg.resource.extendedProps.color;
  87. },
  88. resourceColumns: [
  89. {
  90. labelText: 'Location',
  91. field: 'location',
  92. width: '5%'
  93. },
  94. {
  95. labelText: 'Name',
  96. field: 'name',
  97. width: '14%'
  98. }
  99. ],
  100. resources: {
  101. url: '/data/resources_' + $('#TeamSelect').val() + '.json' //DW moved from a local array to external json
  102. },
  103. //refetchResourcesOnNavigate: false, // Added by DW
  104. refetchResourcesOnNavigate: true, // Added by DW
  105. // resources: function (fetchInfo, successCallback, failureCallback) {
  106. // $.getJSON({
  107. // url: '/data/resources_' + $('#TeamSelect').val() + '.json'
  108. // }, function (resources) {
  109. // successCallback(resources); //return resource data to the calendar via the provided callback function
  110. // });
  111. // },
  112. events: {
  113. url: '/data/events.json' //DW moved from a local array to external json
  114. },
  115. drop: function (arg) {
  116. console.log('drop date: ' + arg.dateStr)
  117.  
  118. if (arg.resource) {
  119. console.log('drop resource: ' + arg.resource.id)
  120. }
  121.  
  122. },
  123. eventReceive: function (arg) { // called when a proper external event is dropped
  124. console.log('eventReceive', arg.event);
  125. arg.event.id = '456';
  126.  
  127. },
  128. eventDrop: function (arg) { // called when an event (already on the calendar) is moved
  129. console.log('eventDrop', arg.event);
  130. },
  131. eventClick: function (info) {
  132. console.log('Event Clicked....' + info.event.id);
  133. if (contextEventId != info.event.id) {
  134. showContext = true;
  135. }
  136.  
  137. var contextMenu = document.getElementById('ContextMenu');
  138. var rect = info.el.getBoundingClientRect();
  139. contextMenu.style.left = rect.left + document.body.scrollLeft + 'px';
  140. contextMenu.style.top = 22 + rect.top + document.body.scrollTop + 'px';
  141. contextMenu.style.width = info.el.offsetWidth;
  142. contextMenu.style.display = showContext ? '' : 'none';
  143. showContext = !showContext;
  144. contextEventId = info.event.id;
  145. }
  146. });
  147. calendar.render();
  148.  
  149. document.getElementById('MoveEventBtn').addEventListener('click', function () {
  150. var event = calendar.getEventById('12');
  151. if (event) {
  152. event.setDates('2019-07-05', '2019-07-07', { allDay: true });
  153. event.setResources(['a']);
  154. }
  155.  
  156. //"start": "2019-07-02",
  157. //"end": "2019-07-03",
  158. });
  159.  
  160. $('#ContextMenu li:not(.no-op)').on('click', function () {
  161. var text = $(this).text();
  162. alert(text + ' clicked...');
  163. $('#ContextMenu').hide();
  164. contextEventId = '';
  165. });
  166.  
  167. $('#ContextMenu li.no-op .color-swab').on('click', function () {
  168. var event = calendar.getEventById(contextEventId);
  169. if (!event) return;
  170. //alert('Here 2');
  171. event.setProp($(this).parent().data('event-property'), $(this).css('background-color'));
  172. calendar.rerenderEvents();
  173. $('#ContextMenu').hide();
  174. //alert('Here 3');
  175. contextEventId = '';
  176. });
  177.  
  178. $('#TeamSelect').on('change', function () {
  179. $('#calendar').fullCalendar( 'refetchResources ');
  180. });
  181.  
  182. $('#changeResources').on('click', function () {
  183. alert('Here 3');
  184. $('#calendar').fullCalendar( 'refetchResources' );
  185. });
  186.  
  187. });</script>
  188.  
  189. <style>
  190.  
  191.  
  192. body {
  193. margin-top: 40px;
  194. font-size: 14px;
  195. font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  196. }
  197.  
  198. #wrap {
  199. width: 1900px;
  200. margin: 0 auto;
  201. }
  202.  
  203. #external-events {
  204. float: left;
  205. width: 150px;
  206. padding: 0 10px;
  207. border: 1px solid #ccc;
  208. background: #eee;
  209. text-align: left;
  210. }
  211.  
  212. #external-events h4 {
  213. font-size: 16px;
  214. margin-top: 0;
  215. padding-top: 1em;
  216. }
  217.  
  218. #external-events .fc-event {
  219. margin: 10px 0;
  220. cursor: pointer;
  221. }
  222.  
  223. #external-events p {
  224. margin: 1.5em 0;
  225. font-size: 11px;
  226. color: #666;
  227. }
  228.  
  229. #external-events p input {
  230. margin: 0;
  231. vertical-align: middle;
  232. }
  233.  
  234. #calendar {
  235. float: right;
  236. width: 1600px;
  237. }
  238.  
  239. #ContextMenu {
  240. width: 180px;
  241. }
  242.  
  243. #ContextMenu ul {
  244. list-style-type: none;
  245. padding: 0;
  246. margin: 1px;
  247. }
  248.  
  249. #ContextMenu ul li {
  250. line-height: 1.1em;
  251. padding: 3px;
  252. cursor: pointer;
  253. font-size: 0.8em;
  254. }
  255.  
  256. #ContextMenu ul li:hover {
  257. background-color: #DDDDDD;
  258. }
  259.  
  260. #ContextMenu ul li .color-swab {
  261. border: 1px solid #000;
  262. width: 10px;
  263. height: 10px;
  264. float: right;
  265. margin: 0px 0px 0px 4px;
  266. }
  267. </style>
  268. </head>
  269. <body>
  270. <div id='wrap'>
  271. <div id='external-events'>
  272. <h4>On-site</h4>
  273. <div class='fc-event'>J1234, Elevations, Job Short Name</div>
  274. <div class='fc-event'>J4323, Site Plan, Shell Garage Sale</div>
  275.  
  276. <h4>CAD</h4>
  277. <div class='fc-event'>J1234, Elevations, Job Short Name</div>
  278. <div class='fc-event'>J4323, Site Plan, Shell Garage Sale</div>
  279. <br />
  280. <div class='fc-event'>Annual Leave</div>
  281. <div class='fc-event'>Other</div>
  282.  
  283. <button type="button" id="MoveEventBtn">Move Event</button>
  284.  
  285. <button type="button" id="changeResources">Click to Change Resources</button>
  286.  
  287. <select name="TeamSelect" id="TeamSelect">
  288. <option>team1</option>
  289. <option>all</option>
  290. </select>
  291. </div>
  292.  
  293. <div id='calendar'>
  294. </div>
  295.  
  296. <div style='clear:both'></div>
  297.  
  298. <div id="ContextMenu" style="display: none; border: 1px solid #999999; background-color: #EEEEEE; position: absolute; top: 165.567px; left: 799.8px; z-index: 500;">
  299. <ul>
  300. <li>Extend</li>
  301. <li>Draft</li>
  302. <li>Access Required &amp; Arranged</li>
  303. <li>Access Required NOT Arranged</li>
  304. <li>Chargeable</li>
  305. <li>Do not move</li>
  306. <li>Day Rate</li>
  307. <li class="no-op" data-event-property="textColor">
  308. Text
  309. <div class="color-swab" style="background-color: #000000;"></div>
  310. <div class="color-swab" style="background-color: #D0CECE;"></div>
  311. <div class="color-swab" style="background-color: #FFFFFF;"></div>
  312. <div class="color-swab" style="background-color: #FF0201;"></div>
  313. <div class="color-swab" style="background-color: #00B050;"></div>
  314. <div class="color-swab" style="background-color: #0170C0;"></div>
  315. </li>
  316. <li class="no-op" data-event-property="backgroundColor">
  317. Background
  318. <div class="color-swab" style="background-color: #000000;"></div>
  319. <div class="color-swab" style="background-color: #D0CECE;"></div>
  320. <div class="color-swab" style="background-color: #FFFFFF;"></div>
  321. <div class="color-swab" style="background-color: #FCE4D6;"></div>
  322. <div class="color-swab" style="background-color: #E2EFDA;"></div>
  323. <div class="color-swab" style="background-color: #D9E1F2;"></div>
  324. </li>
  325. <li>Edit</li>
  326. <li>Delete</li>
  327. </ul>
  328. </div>
  329.  
  330. </div>
  331. </body>
  332. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement