Web UI for ARGUS server
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.

149 lines
6.3 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.BoxLayoutTemplate"></div>/**
  16. * @class Ext.calendar.BoxLayoutTemplate
  17. * @extends Ext.XTemplate
  18. * <p>This is the template used to render calendar views based on small day boxes within a non-scrolling container (currently
  19. * the {@link Ext.calendar.MonthView MonthView} and the all-day headers for {@link Ext.calendar.DayView DayView} and
  20. * {@link Ext.calendar.WeekView WeekView}. This template is automatically bound to the underlying event store by the
  21. * calendar components and expects records of type {@link Ext.calendar.EventRecord}.</p>
  22. * @constructor
  23. * @param {Object} config The config object
  24. */
  25. Ext.calendar.BoxLayoutTemplate = function(config){
  26. Ext.apply(this, config);
  27. var weekLinkTpl = this.showWeekLinks ? '<div id="{weekLinkId}" class="ext-cal-week-link">{weekNum}</div>' : '';
  28. Ext.calendar.BoxLayoutTemplate.superclass.constructor.call(this,
  29. '<tpl for="weeks">',
  30. '<div id="{[this.id]}-wk-{[xindex-1]}" class="ext-cal-wk-ct" style="top:{[this.getRowTop(xindex, xcount)]}%; height:{[this.getRowHeight(xcount)]}%;">',
  31. weekLinkTpl,
  32. '<table class="ext-cal-bg-tbl" cellpadding="0" cellspacing="0">',
  33. '<tbody>',
  34. '<tr>',
  35. '<tpl for=".">',
  36. '<td id="{[this.id]}-day-{date:date("Ymd")}" class="{cellCls}">&nbsp;</td>',
  37. '</tpl>',
  38. '</tr>',
  39. '</tbody>',
  40. '</table>',
  41. '<table class="ext-cal-evt-tbl" cellpadding="0" cellspacing="0">',
  42. '<tbody>',
  43. '<tr>',
  44. '<tpl for=".">',
  45. '<td id="{[this.id]}-ev-day-{date:date("Ymd")}" class="{titleCls}"><div>{title}</div></td>',
  46. '</tpl>',
  47. '</tr>',
  48. '</tbody>',
  49. '</table>',
  50. '</div>',
  51. '</tpl>', {
  52. getRowTop: function(i, ln){
  53. return ((i-1)*(100/ln));
  54. },
  55. getRowHeight: function(ln){
  56. return 100/ln;
  57. }
  58. }
  59. );
  60. };
  61. Ext.extend(Ext.calendar.BoxLayoutTemplate, Ext.XTemplate, {
  62. // private
  63. applyTemplate : function(o){
  64. Ext.apply(this, o);
  65. var w = 0, title = '', first = true, isToday = false, showMonth = false, prevMonth = false, nextMonth = false,
  66. weeks = [[]],
  67. today = new Date().clearTime(),
  68. dt = this.viewStart.clone(),
  69. thisMonth = this.startDate.getMonth();
  70. for(; w < this.weekCount || this.weekCount == -1; w++){
  71. if(dt > this.viewEnd){
  72. break;
  73. }
  74. weeks[w] = [];
  75. for(var d = 0; d < this.dayCount; d++){
  76. isToday = dt.getTime() === today.getTime();
  77. showMonth = first || (dt.getDate() == 1);
  78. prevMonth = (dt.getMonth() < thisMonth) && this.weekCount == -1;
  79. nextMonth = (dt.getMonth() > thisMonth) && this.weekCount == -1;
  80. if(dt.getDay() == 1){
  81. // The ISO week format 'W' is relative to a Monday week start. If we
  82. // make this check on Sunday the week number will be off.
  83. weeks[w].weekNum = this.showWeekNumbers ? dt.format('W') : '&nbsp;';
  84. weeks[w].weekLinkId = 'ext-cal-week-'+dt.format('Ymd');
  85. }
  86. if(showMonth){
  87. if(isToday){
  88. title = this.getTodayText();
  89. }
  90. else{
  91. title = dt.format(this.dayCount == 1 ? 'l, F j, Y' : (first ? 'M j, Y' : 'M j'));
  92. }
  93. }
  94. else{
  95. var dayFmt = (w == 0 && this.showHeader !== true) ? 'D j' : 'j';
  96. title = isToday ? this.getTodayText() : dt.format(dayFmt);
  97. }
  98. weeks[w].push({
  99. title: title,
  100. date: dt.clone(),
  101. titleCls: 'ext-cal-dtitle ' + (isToday ? ' ext-cal-dtitle-today' : '') +
  102. (w==0 ? ' ext-cal-dtitle-first' : '') +
  103. (prevMonth ? ' ext-cal-dtitle-prev' : '') +
  104. (nextMonth ? ' ext-cal-dtitle-next' : ''),
  105. cellCls: 'ext-cal-day ' + (isToday ? ' ext-cal-day-today' : '') +
  106. (d==0 ? ' ext-cal-day-first' : '') +
  107. (prevMonth ? ' ext-cal-day-prev' : '') +
  108. (nextMonth ? ' ext-cal-day-next' : '')
  109. });
  110. dt = dt.add(Date.DAY, 1);
  111. first = false;
  112. }
  113. }
  114. return Ext.calendar.BoxLayoutTemplate.superclass.applyTemplate.call(this, {
  115. weeks: weeks
  116. });
  117. },
  118. // private
  119. getTodayText : function(){
  120. var dt = new Date().format('l, F j, Y'),
  121. todayText = this.showTodayText !== false ? this.todayText : '',
  122. timeText = this.showTime !== false ? ' <span id="'+this.id+'-clock" class="ext-cal-dtitle-time">' +
  123. new Date().format('g:i a') + '</span>' : '',
  124. separator = todayText.length > 0 || timeText.length > 0 ? ' &mdash; ' : '';
  125. if(this.dayCount == 1){
  126. return dt + separator + todayText + timeText;
  127. }
  128. fmt = this.weekCount == 1 ? 'D j' : 'j';
  129. return todayText.length > 0 ? todayText + timeText : new Date().format(fmt) + timeText;
  130. }
  131. });
  132. Ext.calendar.BoxLayoutTemplate.prototype.apply = Ext.calendar.BoxLayoutTemplate.prototype.applyTemplate;
  133. </pre>
  134. </body>
  135. </html>