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.

544 lines
21 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.calendar.CalendarPanel"></div>/**
  16. * @class Ext.calendar.CalendarPanel
  17. * @extends Ext.Panel
  18. * <p>This is the default container for Ext calendar views. It supports day, week and month views as well
  19. * as a built-in event edit form. The only requirement for displaying a calendar is passing in a valid
  20. * {@link #calendarStore} config containing records of type {@link Ext.calendar.EventRecord EventRecord}. In order
  21. * to make the calendar interactive (enable editing, drag/drop, etc.) you can handle any of the various
  22. * events fired by the underlying views and exposed through the CalendarPanel.</p>
  23. * {@link #layoutConfig} option if needed.</p>
  24. * @constructor
  25. * @param {Object} config The config object
  26. * @xtype calendarpanel
  27. */
  28. Ext.calendar.CalendarPanel = Ext.extend(Ext.Panel, {
  29. <div id="cfg-Ext.calendar.CalendarPanel-showDayView"></div>/**
  30. * @cfg {Boolean} showDayView
  31. * True to include the day view (and toolbar button), false to hide them (defaults to true).
  32. */
  33. showDayView: true,
  34. <div id="cfg-Ext.calendar.CalendarPanel-showWeekView"></div>/**
  35. * @cfg {Boolean} showWeekView
  36. * True to include the week view (and toolbar button), false to hide them (defaults to true).
  37. */
  38. showWeekView: true,
  39. <div id="cfg-Ext.calendar.CalendarPanel-showMonthView"></div>/**
  40. * @cfg {Boolean} showMonthView
  41. * True to include the month view (and toolbar button), false to hide them (defaults to true).
  42. * If the day and week views are both hidden, the month view will show by default even if
  43. * this config is false.
  44. */
  45. showMonthView: true,
  46. <div id="cfg-Ext.calendar.CalendarPanel-showNavBar"></div>/**
  47. * @cfg {Boolean} showNavBar
  48. * True to display the calendar navigation toolbar, false to hide it (defaults to true). Note that
  49. * if you hide the default navigation toolbar you'll have to provide an alternate means of navigating the calendar.
  50. */
  51. showNavBar: true,
  52. <div id="cfg-Ext.calendar.CalendarPanel-todayText"></div>/**
  53. * @cfg {String} todayText
  54. * Alternate text to use for the 'Today' nav bar button.
  55. */
  56. todayText: 'Today',
  57. <div id="cfg-Ext.calendar.CalendarPanel-showTodayText"></div>/**
  58. * @cfg {Boolean} showTodayText
  59. * True to show the value of {@link #todayText} instead of today's date in the calendar's current day box,
  60. * false to display the day number(defaults to true).
  61. */
  62. showTodayText: true,
  63. <div id="cfg-Ext.calendar.CalendarPanel-showTime"></div>/**
  64. * @cfg {Boolean} showTime
  65. * True to display the current time next to the date in the calendar's current day box, false to not show it
  66. * (defaults to true).
  67. */
  68. showTime: true,
  69. <div id="cfg-Ext.calendar.CalendarPanel-dayText"></div>/**
  70. * @cfg {String} dayText
  71. * Alternate text to use for the 'Day' nav bar button.
  72. */
  73. dayText: 'Day',
  74. <div id="cfg-Ext.calendar.CalendarPanel-weekText"></div>/**
  75. * @cfg {String} weekText
  76. * Alternate text to use for the 'Week' nav bar button.
  77. */
  78. weekText: 'Week',
  79. <div id="cfg-Ext.calendar.CalendarPanel-monthText"></div>/**
  80. * @cfg {String} monthText
  81. * Alternate text to use for the 'Month' nav bar button.
  82. */
  83. monthText: 'Month',
  84. // private
  85. layoutConfig: {
  86. layoutOnCardChange: true,
  87. deferredRender: true
  88. },
  89. // private property
  90. startDate: new Date(),
  91. // private
  92. initComponent: function() {
  93. this.tbar = {
  94. cls: 'ext-cal-toolbar',
  95. border: true,
  96. buttonAlign: 'center',
  97. items: [{
  98. id: this.id + '-tb-prev',
  99. handler: this.onPrevClick,
  100. scope: this,
  101. iconCls: 'x-tbar-page-prev'
  102. }]
  103. };
  104. this.viewCount = 0;
  105. if (this.showDayView) {
  106. this.tbar.items.push({
  107. id: this.id + '-tb-day',
  108. text: this.dayText,
  109. handler: this.onDayClick,
  110. scope: this,
  111. toggleGroup: 'tb-views'
  112. });
  113. this.viewCount++;
  114. }
  115. if (this.showWeekView) {
  116. this.tbar.items.push({
  117. id: this.id + '-tb-week',
  118. text: this.weekText,
  119. handler: this.onWeekClick,
  120. scope: this,
  121. toggleGroup: 'tb-views'
  122. });
  123. this.viewCount++;
  124. }
  125. if (this.showMonthView || this.viewCount == 0) {
  126. this.tbar.items.push({
  127. id: this.id + '-tb-month',
  128. text: this.monthText,
  129. handler: this.onMonthClick,
  130. scope: this,
  131. toggleGroup: 'tb-views'
  132. });
  133. this.viewCount++;
  134. this.showMonthView = true;
  135. }
  136. this.tbar.items.push({
  137. id: this.id + '-tb-next',
  138. handler: this.onNextClick,
  139. scope: this,
  140. iconCls: 'x-tbar-page-next'
  141. });
  142. this.tbar.items.push('->');
  143. var idx = this.viewCount - 1;
  144. this.activeItem = this.activeItem === undefined ? idx: (this.activeItem > idx ? idx: this.activeItem);
  145. if (this.showNavBar === false) {
  146. delete this.tbar;
  147. this.addClass('x-calendar-nonav');
  148. }
  149. Ext.calendar.CalendarPanel.superclass.initComponent.call(this);
  150. this.addEvents({
  151. <div id="event-Ext.calendar.CalendarPanel-eventadd"></div>/**
  152. * @event eventadd
  153. * Fires after a new event is added to the underlying store
  154. * @param {Ext.calendar.CalendarPanel} this
  155. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was added
  156. */
  157. eventadd: true,
  158. <div id="event-Ext.calendar.CalendarPanel-eventupdate"></div>/**
  159. * @event eventupdate
  160. * Fires after an existing event is updated
  161. * @param {Ext.calendar.CalendarPanel} this
  162. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was updated
  163. */
  164. eventupdate: true,
  165. <div id="event-Ext.calendar.CalendarPanel-eventdelete"></div>/**
  166. * @event eventdelete
  167. * Fires after an event is removed from the underlying store
  168. * @param {Ext.calendar.CalendarPanel} this
  169. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was removed
  170. */
  171. eventdelete: true,
  172. <div id="event-Ext.calendar.CalendarPanel-eventcancel"></div>/**
  173. * @event eventcancel
  174. * Fires after an event add/edit operation is canceled by the user and no store update took place
  175. * @param {Ext.calendar.CalendarPanel} this
  176. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was canceled
  177. */
  178. eventcancel: true,
  179. <div id="event-Ext.calendar.CalendarPanel-viewchange"></div>/**
  180. * @event viewchange
  181. * Fires after a different calendar view is activated (but not when the event edit form is activated)
  182. * @param {Ext.calendar.CalendarPanel} this
  183. * @param {Ext.CalendarView} view The view being activated (any valid {@link Ext.calendar.CalendarView CalendarView} subclass)
  184. * @param {Object} info Extra information about the newly activated view. This is a plain object
  185. * with following properties:<div class="mdetail-params"><ul>
  186. * <li><b><code>activeDate</code></b> : <div class="sub-desc">The currently-selected date</div></li>
  187. * <li><b><code>viewStart</code></b> : <div class="sub-desc">The first date in the new view range</div></li>
  188. * <li><b><code>viewEnd</code></b> : <div class="sub-desc">The last date in the new view range</div></li>
  189. * </ul></div>
  190. */
  191. viewchange: true
  192. //
  193. // NOTE: CalendarPanel also relays the following events from contained views as if they originated from this:
  194. //
  195. <div id="event-Ext.calendar.CalendarPanel-eventsrendered"></div>/**
  196. * @event eventsrendered
  197. * Fires after events are finished rendering in the view
  198. * @param {Ext.calendar.CalendarPanel} this
  199. */
  200. <div id="event-Ext.calendar.CalendarPanel-eventclick"></div>/**
  201. * @event eventclick
  202. * Fires after the user clicks on an event element
  203. * @param {Ext.calendar.CalendarPanel} this
  204. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was clicked on
  205. * @param {HTMLNode} el The DOM node that was clicked on
  206. */
  207. <div id="event-Ext.calendar.CalendarPanel-eventover"></div>/**
  208. * @event eventover
  209. * Fires anytime the mouse is over an event element
  210. * @param {Ext.calendar.CalendarPanel} this
  211. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that the cursor is over
  212. * @param {HTMLNode} el The DOM node that is being moused over
  213. */
  214. <div id="event-Ext.calendar.CalendarPanel-eventout"></div>/**
  215. * @event eventout
  216. * Fires anytime the mouse exits an event element
  217. * @param {Ext.calendar.CalendarPanel} this
  218. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that the cursor exited
  219. * @param {HTMLNode} el The DOM node that was exited
  220. */
  221. <div id="event-Ext.calendar.CalendarPanel-datechange"></div>/**
  222. * @event datechange
  223. * Fires after the start date of the view changes
  224. * @param {Ext.calendar.CalendarPanel} this
  225. * @param {Date} startDate The start date of the view (as explained in {@link #getStartDate}
  226. * @param {Date} viewStart The first displayed date in the view
  227. * @param {Date} viewEnd The last displayed date in the view
  228. */
  229. <div id="event-Ext.calendar.CalendarPanel-rangeselect"></div>/**
  230. * @event rangeselect
  231. * Fires after the user drags on the calendar to select a range of dates/times in which to create an event
  232. * @param {Ext.calendar.CalendarPanel} this
  233. * @param {Object} dates An object containing the start (StartDate property) and end (EndDate property) dates selected
  234. * @param {Function} callback A callback function that MUST be called after the event handling is complete so that
  235. * the view is properly cleaned up (shim elements are persisted in the view while the user is prompted to handle the
  236. * range selection). The callback is already created in the proper scope, so it simply needs to be executed as a standard
  237. * function call (e.g., callback()).
  238. */
  239. <div id="event-Ext.calendar.CalendarPanel-eventmove"></div>/**
  240. * @event eventmove
  241. * Fires after an event element is dragged by the user and dropped in a new position
  242. * @param {Ext.calendar.CalendarPanel} this
  243. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was moved with
  244. * updated start and end dates
  245. */
  246. <div id="event-Ext.calendar.CalendarPanel-initdrag"></div>/**
  247. * @event initdrag
  248. * Fires when a drag operation is initiated in the view
  249. * @param {Ext.calendar.CalendarPanel} this
  250. */
  251. <div id="event-Ext.calendar.CalendarPanel-eventresize"></div>/**
  252. * @event eventresize
  253. * Fires after the user drags the resize handle of an event to resize it
  254. * @param {Ext.calendar.CalendarPanel} this
  255. * @param {Ext.calendar.EventRecord} rec The {@link Ext.calendar.EventRecord record} for the event that was resized
  256. * containing the updated start and end dates
  257. */
  258. <div id="event-Ext.calendar.CalendarPanel-dayclick"></div>/**
  259. * @event dayclick
  260. * Fires after the user clicks within a day/week view container and not on an event element
  261. * @param {Ext.calendar.CalendarPanel} this
  262. * @param {Date} dt The date/time that was clicked on
  263. * @param {Boolean} allday True if the day clicked on represents an all-day box, else false.
  264. * @param {Ext.Element} el The Element that was clicked on
  265. */
  266. });
  267. this.layout = 'card';
  268. // do not allow override
  269. if (this.showDayView) {
  270. var day = Ext.apply({
  271. xtype: 'dayview',
  272. title: this.dayText,
  273. showToday: this.showToday,
  274. showTodayText: this.showTodayText,
  275. showTime: this.showTime
  276. },
  277. this.dayViewCfg);
  278. day.id = this.id + '-day';
  279. day.store = day.store || this.eventStore;
  280. this.initEventRelay(day);
  281. this.add(day);
  282. }
  283. if (this.showWeekView) {
  284. var wk = Ext.applyIf({
  285. xtype: 'weekview',
  286. title: this.weekText,
  287. showToday: this.showToday,
  288. showTodayText: this.showTodayText,
  289. showTime: this.showTime
  290. },
  291. this.weekViewCfg);
  292. wk.id = this.id + '-week';
  293. wk.store = wk.store || this.eventStore;
  294. this.initEventRelay(wk);
  295. this.add(wk);
  296. }
  297. if (this.showMonthView) {
  298. var month = Ext.applyIf({
  299. xtype: 'monthview',
  300. title: this.monthText,
  301. showToday: this.showToday,
  302. showTodayText: this.showTodayText,
  303. showTime: this.showTime,
  304. listeners: {
  305. 'weekclick': {
  306. fn: function(vw, dt) {
  307. this.showWeek(dt);
  308. },
  309. scope: this
  310. }
  311. }
  312. },
  313. this.monthViewCfg);
  314. month.id = this.id + '-month';
  315. month.store = month.store || this.eventStore;
  316. this.initEventRelay(month);
  317. this.add(month);
  318. }
  319. this.add(Ext.applyIf({
  320. xtype: 'eventeditform',
  321. id: this.id + '-edit',
  322. calendarStore: this.calendarStore,
  323. listeners: {
  324. 'eventadd': {
  325. scope: this,
  326. fn: this.onEventAdd
  327. },
  328. 'eventupdate': {
  329. scope: this,
  330. fn: this.onEventUpdate
  331. },
  332. 'eventdelete': {
  333. scope: this,
  334. fn: this.onEventDelete
  335. },
  336. 'eventcancel': {
  337. scope: this,
  338. fn: this.onEventCancel
  339. }
  340. }
  341. },
  342. this.editViewCfg));
  343. },
  344. // private
  345. initEventRelay: function(cfg) {
  346. cfg.listeners = cfg.listeners || {};
  347. cfg.listeners.afterrender = {
  348. fn: function(c) {
  349. // relay the view events so that app code only has to handle them in one place
  350. this.relayEvents(c, ['eventsrendered', 'eventclick', 'eventover', 'eventout', 'dayclick',
  351. 'eventmove', 'datechange', 'rangeselect', 'eventdelete', 'eventresize', 'initdrag']);
  352. },
  353. scope: this,
  354. single: true
  355. };
  356. },
  357. // private
  358. afterRender: function() {
  359. Ext.calendar.CalendarPanel.superclass.afterRender.call(this);
  360. this.fireViewChange();
  361. },
  362. // private
  363. onLayout: function() {
  364. Ext.calendar.CalendarPanel.superclass.onLayout.call(this);
  365. if (!this.navInitComplete) {
  366. this.updateNavState();
  367. this.navInitComplete = true;
  368. }
  369. },
  370. // private
  371. onEventAdd: function(form, rec) {
  372. rec.data[Ext.calendar.EventMappings.IsNew.name] = false;
  373. this.eventStore.add(rec);
  374. this.hideEditForm();
  375. this.fireEvent('eventadd', this, rec);
  376. },
  377. // private
  378. onEventUpdate: function(form, rec) {
  379. rec.commit();
  380. this.hideEditForm();
  381. this.fireEvent('eventupdate', this, rec);
  382. },
  383. // private
  384. onEventDelete: function(form, rec) {
  385. this.eventStore.remove(rec);
  386. this.hideEditForm();
  387. this.fireEvent('eventdelete', this, rec);
  388. },
  389. // private
  390. onEventCancel: function(form, rec) {
  391. this.hideEditForm();
  392. this.fireEvent('eventcancel', this, rec);
  393. },
  394. <div id="method-Ext.calendar.CalendarPanel-showEditForm"></div>/**
  395. * Shows the built-in event edit form for the passed in event record. This method automatically
  396. * hides the calendar views and navigation toolbar. To return to the calendar, call {@link #hideEditForm}.
  397. * @param {Ext.calendar.EventRecord} record The event record to edit
  398. * @return {Ext.calendar.CalendarPanel} this
  399. */
  400. showEditForm: function(rec) {
  401. this.preEditView = this.layout.activeItem.id;
  402. this.setActiveView(this.id + '-edit');
  403. this.layout.activeItem.loadRecord(rec);
  404. return this;
  405. },
  406. <div id="method-Ext.calendar.CalendarPanel-hideEditForm"></div>/**
  407. * Hides the built-in event edit form and returns to the previous calendar view. If the edit form is
  408. * not currently visible this method has no effect.
  409. * @return {Ext.calendar.CalendarPanel} this
  410. */
  411. hideEditForm: function() {
  412. if (this.preEditView) {
  413. this.setActiveView(this.preEditView);
  414. delete this.preEditView;
  415. }
  416. return this;
  417. },
  418. // private
  419. setActiveView: function(id) {
  420. var l = this.layout;
  421. l.setActiveItem(id);
  422. if (id == this.id + '-edit') {
  423. this.getTopToolbar().hide();
  424. this.doLayout();
  425. }
  426. else {
  427. l.activeItem.refresh();
  428. this.getTopToolbar().show();
  429. this.updateNavState();
  430. }
  431. this.activeView = l.activeItem;
  432. this.fireViewChange();
  433. },
  434. // private
  435. fireViewChange: function() {
  436. var info = null,
  437. view = this.layout.activeItem;
  438. if (view.getViewBounds) {
  439. vb = view.getViewBounds();
  440. info = {
  441. activeDate: view.getStartDate(),
  442. viewStart: vb.start,
  443. viewEnd: vb.end
  444. };
  445. };
  446. this.fireEvent('viewchange', this, view, info);
  447. },
  448. // private
  449. updateNavState: function() {
  450. if (this.showNavBar !== false) {
  451. var item = this.layout.activeItem,
  452. suffix = item.id.split(this.id + '-')[1];
  453. var btn = Ext.getCmp(this.id + '-tb-' + suffix);
  454. btn.toggle(true);
  455. }
  456. },
  457. <div id="method-Ext.calendar.CalendarPanel-setStartDate"></div>/**
  458. * Sets the start date for the currently-active calendar view.
  459. * @param {Date} dt
  460. */
  461. setStartDate: function(dt) {
  462. this.layout.activeItem.setStartDate(dt, true);
  463. this.updateNavState();
  464. this.fireViewChange();
  465. },
  466. // private
  467. showWeek: function(dt) {
  468. this.setActiveView(this.id + '-week');
  469. this.setStartDate(dt);
  470. },
  471. // private
  472. onPrevClick: function() {
  473. this.startDate = this.layout.activeItem.movePrev();
  474. this.updateNavState();
  475. this.fireViewChange();
  476. },
  477. // private
  478. onNextClick: function() {
  479. this.startDate = this.layout.activeItem.moveNext();
  480. this.updateNavState();
  481. this.fireViewChange();
  482. },
  483. // private
  484. onDayClick: function() {
  485. this.setActiveView(this.id + '-day');
  486. },
  487. // private
  488. onWeekClick: function() {
  489. this.setActiveView(this.id + '-week');
  490. },
  491. // private
  492. onMonthClick: function() {
  493. this.setActiveView(this.id + '-month');
  494. },
  495. <div id="method-Ext.calendar.CalendarPanel-getActiveView"></div>/**
  496. * Return the calendar view that is currently active, which will be a subclass of
  497. * {@link Ext.calendar.CalendarView CalendarView}.
  498. * @return {Ext.calendar.CalendarView} The active view
  499. */
  500. getActiveView: function() {
  501. return this.layout.activeItem;
  502. }
  503. });
  504. Ext.reg('calendarpanel', Ext.calendar.CalendarPanel);</pre>
  505. </body>
  506. </html>